]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
KVM: PPC: Book3S HV: Fix endianness of instruction obtained from HEIR register
authorPaul Mackerras <paulus@samba.org>
Wed, 3 Dec 2014 02:30:39 +0000 (13:30 +1100)
committerAlexander Graf <agraf@suse.de>
Wed, 17 Dec 2014 12:50:39 +0000 (13:50 +0100)
commit4a157d61b48c7cdb8d751001442a14ebac80229f
treed9ad6c9e1809c8965a5af16c86b50707ad7decaa
parentc17b98cf6028704e1f953d6a25ed6140425ccfd0
KVM: PPC: Book3S HV: Fix endianness of instruction obtained from HEIR register

There are two ways in which a guest instruction can be obtained from
the guest in the guest exit code in book3s_hv_rmhandlers.S.  If the
exit was caused by a Hypervisor Emulation interrupt (i.e. an illegal
instruction), the offending instruction is in the HEIR register
(Hypervisor Emulation Instruction Register).  If the exit was caused
by a load or store to an emulated MMIO device, we load the instruction
from the guest by turning data relocation on and loading the instruction
with an lwz instruction.

Unfortunately, in the case where the guest has opposite endianness to
the host, these two methods give results of different endianness, but
both get put into vcpu->arch.last_inst.  The HEIR value has been loaded
using guest endianness, whereas the lwz will load the instruction using
host endianness.  The rest of the code that uses vcpu->arch.last_inst
assumes it was loaded using host endianness.

To fix this, we define a new vcpu field to store the HEIR value.  Then,
in kvmppc_handle_exit_hv(), we transfer the value from this new field to
vcpu->arch.last_inst, doing a byte-swap if the guest and host endianness
differ.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S