hv_vm: Mask off operand size for store emulation

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-15 17:42:03 +09:00
parent 496516ded0
commit 4acc3d7c7f

View file

@ -581,17 +581,19 @@ static bool emulate_store(u64 *regs, u32 insn, u64 *val, u64 *width)
regs[31] = 0; regs[31] = 0;
u64 mask = (1UL << (8 << *width)) - 1;
if ((insn & 0x3fe00400) == 0x38000400) { if ((insn & 0x3fe00400) == 0x38000400) {
// STRx (immediate) Pre/Post-index // STRx (immediate) Pre/Post-index
CHECK_RN; CHECK_RN;
regs[Rn] += imm9; regs[Rn] += imm9;
*val = regs[Rt]; *val = regs[Rt] & mask;
} else if ((insn & 0x3fc00000) == 0x39000000) { } else if ((insn & 0x3fc00000) == 0x39000000) {
// STRx (immediate) Unsigned offset // STRx (immediate) Unsigned offset
*val = regs[Rt]; *val = regs[Rt] & mask;
} else if ((insn & 0x3fe04c00) == 0x38204800) { } else if ((insn & 0x3fe04c00) == 0x38204800) {
// STRx (register) // STRx (register)
*val = regs[Rt]; *val = regs[Rt] & mask;
} else if ((insn & 0xffc00000) == 0xa9000000) { } else if ((insn & 0xffc00000) == 0xa9000000) {
// STP (Signed offset, 64-bit) // STP (Signed offset, 64-bit)
CHECK_RN; CHECK_RN;
@ -601,7 +603,7 @@ static bool emulate_store(u64 *regs, u32 insn, u64 *val, u64 *width)
*width = 4; *width = 4;
} else if ((insn & 0x3fe00c00) == 0x38000000) { } else if ((insn & 0x3fe00c00) == 0x38000000) {
// STURx (unscaled) // STURx (unscaled)
*val = regs[Rt]; *val = regs[Rt] & mask;
} else { } else {
return false; return false;
} }