qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] d96391: target-mips: Fix RDHWR exception host


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] d96391: target-mips: Fix RDHWR exception host PC
Date: Thu, 28 Apr 2016 04:30:02 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: d96391c1ffeb30a0afa695c86579517c69d9a889
      
https://github.com/qemu/qemu/commit/d96391c1ffeb30a0afa695c86579517c69d9a889
  Author: James Hogan <address@hidden>
  Date:   2016-04-28 (Thu, 28 Apr 2016)

  Changed paths:
    M target-mips/op_helper.c

  Log Message:
  -----------
  target-mips: Fix RDHWR exception host PC

Commit b00c72180c36 ("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: b00c72180c36 ("target-mips: add PC, XNP reg numbers to RDHWR")
Signed-off-by: James Hogan <address@hidden>
Cc: Leon Alrae <address@hidden>
Cc: Yongbok Kim <address@hidden>
Cc: Aurelien Jarno <address@hidden>
Reviewed-by: Aurelien Jarno <address@hidden>
Reviewed-by: Leon Alrae <address@hidden>
Signed-off-by: Leon Alrae <address@hidden>


  Commit: 8c4bf97580a7556e3e61b7bc41dedb5958f0b2f9
      
https://github.com/qemu/qemu/commit/8c4bf97580a7556e3e61b7bc41dedb5958f0b2f9
  Author: Peter Maydell <address@hidden>
  Date:   2016-04-28 (Thu, 28 Apr 2016)

  Changed paths:
    M target-mips/op_helper.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160428' into staging

MIPS patches 2016-04-28

Changes:
* fixed RDHWR exception host PC

# gpg: Signature made Thu 28 Apr 2016 10:11:18 BST using RSA key ID 0B29DA6B
# gpg: Good signature from "Leon Alrae <address@hidden>"

* remotes/lalrae/tags/mips-20160428:
  target-mips: Fix RDHWR exception host PC

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/736f85d5db70...8c4bf97580a7

reply via email to

[Prev in Thread] Current Thread [Next in Thread]