Commit 4baa1d871c8c959084aa5367a9bf211f383941e5

Authored by Paul Mackerras
Committed by Alexander Graf
1 parent 5448050124

KVM: PPC: Book3S HV: Allow negative offsets to real-mode hcall handlers

The table of offsets to real-mode hcall handlers in book3s_hv_rmhandlers.S
can contain negative values, if some of the handlers end up before the
table in the vmlinux binary.  Thus we need to use a sign-extending load
to read the values in the table rather than a zero-extending load.
Without this, the host crashes when the guest does one of the hcalls
with negative offsets, due to jumping to a bogus address.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

arch/powerpc/kvm/book3s_hv_rmhandlers.S
... ... @@ -1381,7 +1381,7 @@
1381 1381 cmpldi r3,hcall_real_table_end - hcall_real_table
1382 1382 bge guest_exit_cont
1383 1383 LOAD_REG_ADDR(r4, hcall_real_table)
1384   - lwzx r3,r3,r4
  1384 + lwax r3,r3,r4
1385 1385 cmpwi r3,0
1386 1386 beq guest_exit_cont
1387 1387 add r3,r3,r4