xemu/target-mips
James Hogan d96391c1ff target-mips: Fix RDHWR exception host PC
Commit b00c72180c ("target-mips: add PC, XNP reg numbers to RDHWR")
changed the rdhwr helpers to use check_hwrena() to check the register
being accessed is enabled in CP0_HWREna when used from user mode. If
that check fails an EXCP_RI exception is raised at the host PC
calculated with GETPC().

However check_hwrena() may not be fully inlined as the
do_raise_exception() part of it is common regardless of the arguments.
This causes GETPC() to calculate the address in the call in the helper
instead of the generated code calling the helper. No TB will be found
and the EPC reported with the resulting guest RI exception points to the
beginning of the TB instead of the RDHWR instruction.

We can't reliably force check_hwrena() to be inlined, and converting it
to a macro would be ugly, so instead pass the host PC in as an argument,
with each rdhwr helper passing GETPC(). This should avoid any dependence
on compiler behaviour, and in practice seems to ensure the full inlining
of check_hwrena() on x86_64.

This issue causes failures when running a MIPS KVM (trap & emulate)
guest in a MIPS QEMU TCG guest, as the inner guest kernel will do a
RDHWR of counter, which is disabled in the outer guest's CP0_HWREna by
KVM so it can emulate the inner guest's counter. The emulation fails and
the RI exception is passed to the inner guest.

Fixes: b00c72180c ("target-mips: add PC, XNP reg numbers to RDHWR")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-04-28 10:03:24 +01:00
..
cpu-qom.h target-mips: replace cpu_save/cpu_load with VMStateDescription 2015-03-11 14:13:57 +00:00
cpu.c include/qemu/osdep.h: Don't include qapi/error.h 2016-03-22 22:20:15 +01:00
cpu.h target-mips: add MAAR, MAARI register 2016-03-30 09:14:00 +01:00
dsp_helper.c mips: Clean up includes 2016-01-23 14:30:04 +00:00
gdbstub.c mips: Clean up includes 2016-01-23 14:30:04 +00:00
helper.c log: do not unnecessarily include qom/cpu.h 2016-02-03 09:19:10 +00:00
helper.h target-mips: add MAAR, MAARI register 2016-03-30 09:14:00 +01:00
kvm_mips.h
kvm.c mips/kvm: Support MSA in MIPS KVM guests 2016-02-26 08:59:17 +00:00
lmi_helper.c mips: Clean up includes 2016-01-23 14:30:04 +00:00
machine.c target-mips: add MAAR, MAARI register 2016-03-30 09:14:00 +01:00
Makefile.objs target-mips: add Unified Hosting Interface (UHI) support 2015-06-26 09:08:50 +01:00
mips-defs.h target-mips: fix MIPS64R6-generic configuration 2015-07-15 14:07:10 +01:00
mips-semi.c mips: Clean up includes 2016-01-23 14:30:04 +00:00
msa_helper.c mips: Clean up includes 2016-01-23 14:30:04 +00:00
op_helper.c target-mips: Fix RDHWR exception host PC 2016-04-28 10:03:24 +01:00
TODO
translate_init.c target-mips: add MAAR, MAARI register 2016-03-30 09:14:00 +01:00
translate.c target-mips: add MAAR, MAARI register 2016-03-30 09:14:00 +01:00