Skip to content

Commit

Permalink
cmd/internal/obj/arm64: support MSR DIT
Browse files Browse the repository at this point in the history
Set the right instruction bits in asmout in order
to allow using MSR with DIT and an immediate
value. This allows us to avoid using an
intermediary register when we want to set DIT
(unsetting DIT already worked with the zero
register).

Ref: https://developer.arm.com/documentation/ddi0602/2024-06/Base-Instructions/MSR--immediate---Move-immediate-value-to-special-register-?lang=en
Change-Id: Id049a0b4e0feb534cea992553228f9b5e12ddcea
Reviewed-on: https://go-review.googlesource.com/c/go/+/597595
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
  • Loading branch information
rolandshoemaker committed Jul 24, 2024
1 parent c0eac35 commit b5c2b1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/asm/internal/asm/testdata/arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ next:
MSR R17, ZCR_EL1 // 111218d5
SYS $32768, R1 // 018008d5
SYS $32768 // 1f8008d5
MSR $1, DIT // 5f4103d5

// TLBI instruction
TLBI VMALLE1IS // 1f8308d5
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/internal/obj/arm64/asm7.go
Original file line number Diff line number Diff line change
Expand Up @@ -4229,6 +4229,9 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
// PSTATEfield can be special registers and special operands.
if p.To.Type == obj.TYPE_REG && p.To.Reg == REG_SPSel {
v = 0<<16 | 4<<12 | 5<<5
} else if p.To.Type == obj.TYPE_REG && p.To.Reg == REG_DIT {
// op1 = 011 (3) op2 = 010 (2)
v = 3<<16 | 2<<5
} else if p.To.Type == obj.TYPE_SPECIAL {
opd := SpecialOperand(p.To.Offset)
for _, pf := range pstatefield {
Expand Down

0 comments on commit b5c2b1e

Please sign in to comment.