qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] target-arm: fix broken sync of sysregs between QEMU and KVM 32 bit
@ 2015-01-19 15:17 Peter Maydell
  2015-01-19 15:17 ` [Qemu-devel] [PATCH 1/2] target-arm: Split NO_MIGRATE into ALIAS and NO_RAW Peter Maydell
  2015-01-19 15:17 ` [Qemu-devel] [PATCH 2/2] target-arm: Add checks that cpreg raw accesses are handled Peter Maydell
  0 siblings, 2 replies; 14+ messages in thread
From: Peter Maydell @ 2015-01-19 15:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Bellows, Alex Bennée, patches

[This is a patchset I originally posted back in December and
then forgot about...]

This patchset fixes a regression in the synchronization of
system registers between QEMU and KVM for 32-bit ARM hosts.
The most obvious effect of the bug is that trying to access
memory via the gdbstub doesn't work, because gdbstub thinks the
MMU is off and doesn't get the virt-to-phys translation right.
(Migration would not be broken.)

The underlying cause of this is that we are using the cpreg
definition flag ARM_CP_NO_MIGRATE for two different purposes:
    1) register is an alias on to state that's also visible via
       some other register, and that other register is the one
       responsible for migrating the state
    2) register is not actually state at all (for instance the TLB
       or cache maintenance operation "registers") and it makes no
       sense to attempt to migrate it or otherwise access the raw state
    
This works fine for identifying which registers should be ignored
when performing migration, but we also use the same functions for
synchronizing system register state between QEMU and the kernel
when using KVM. In this case we don't want to try to sync state
into registers in category 2, but we do want to sync into registers
in category 1, because the kernel might have picked a different
one of the aliases as its choice for which one to expose for
migration. (In particular, on 32 bit hosts the kernel will
expose the state in the AArch32 version of the register, but
TCG's convention is to mark the AArch64 version as the version
to migrate, even if the CPU being emulated happens to be 32 bit,
so almost all system registers will hit this issue now that we've
added AArch64 system emulation.)
    
Fix this by splitting the NO_MIGRATE flag in two (ALIAS and NO_RAW)
corresponding to the two different reasons we might not want to
migrate a register. When setting up the TCG list of registers to
migrate we honour both flags; when populating the list from KVM,
only ignore registers which are NO_RAW.

Changes v1->v2:
 * change raw_accessors_valid() to raw_accessors_invalid() and
   beef up its comment, following confusion during review of v1

Peter Maydell (2):
  target-arm: Split NO_MIGRATE into ALIAS and NO_RAW
  target-arm: Add checks that cpreg raw accesses are handled

 target-arm/cpu.h    |  15 +++-
 target-arm/helper.c | 236 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 145 insertions(+), 106 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 0/2] target-arm: fix broken sync of sysregs between QEMU and KVM 32 bit
@ 2014-12-09 19:46 Peter Maydell
  2014-12-09 19:46 ` [Qemu-devel] [PATCH 1/2] target-arm: Split NO_MIGRATE into ALIAS and NO_RAW Peter Maydell
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2014-12-09 19:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Christoffer Dall, patches

This patchset fixes a regression in the synchronization of
system registers between QEMU and KVM for 32-bit ARM hosts.
The most obvious effect of the bug is that trying to access
memory via the gdbstub doesn't work, because gdbstub thinks the
MMU is off and doesn't get the virt-to-phys translation right.
(Migration would not be broken.)

The underlying cause of this is that we are using the cpreg
definition flag ARM_CP_NO_MIGRATE for two different purposes:
    1) register is an alias on to state that's also visible via
       some other register, and that other register is the one
       responsible for migrating the state
    2) register is not actually state at all (for instance the TLB
       or cache maintenance operation "registers") and it makes no
       sense to attempt to migrate it or otherwise access the raw state
    
This works fine for identifying which registers should be ignored
when performing migration, but we also use the same functions for
synchronizing system register state between QEMU and the kernel
when using KVM. In this case we don't want to try to sync state
into registers in category 2, but we do want to sync into registers
in category 1, because the kernel might have picked a different
one of the aliases as its choice for which one to expose for
migration. (In particular, on 32 bit hosts the kernel will
expose the state in the AArch32 version of the register, but
TCG's convention is to mark the AArch64 version as the version
to migrate, even if the CPU being emulated happens to be 32 bit,
so almost all system registers will hit this issue now that we've
added AArch64 system emulation.)
    
Fix this by splitting the NO_MIGRATE flag in two (ALIAS and NO_RAW)
corresponding to the two different reasons we might not want to
migrate a register. When setting up the TCG list of registers to
migrate we honour both flags; when populating the list from KVM,
only ignore registers which are NO_RAW.

These patches are based on my target-arm.next branch (they won't
apply to current master because I have all the TZ support patches
on target-arm.next).
    

Peter Maydell (2):
  target-arm: Split NO_MIGRATE into ALIAS and NO_RAW
  target-arm: Add checks that cpreg raw accesses are handled

 target-arm/cpu.h    |  15 +++-
 target-arm/helper.c | 228 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 137 insertions(+), 106 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-01-19 19:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-19 15:17 [Qemu-devel] [PATCH 0/2] target-arm: fix broken sync of sysregs between QEMU and KVM 32 bit Peter Maydell
2015-01-19 15:17 ` [Qemu-devel] [PATCH 1/2] target-arm: Split NO_MIGRATE into ALIAS and NO_RAW Peter Maydell
2015-01-19 17:19   ` Greg Bellows
2015-01-19 18:47     ` Peter Maydell
2015-01-19 15:17 ` [Qemu-devel] [PATCH 2/2] target-arm: Add checks that cpreg raw accesses are handled Peter Maydell
2015-01-19 18:05   ` Greg Bellows
2015-01-19 19:03     ` Peter Maydell
2015-01-19 19:05       ` Greg Bellows
2015-01-19 19:07         ` Peter Maydell
2015-01-19 19:09           ` Greg Bellows
  -- strict thread matches above, loose matches on Subject: below --
2014-12-09 19:46 [Qemu-devel] [PATCH 0/2] target-arm: fix broken sync of sysregs between QEMU and KVM 32 bit Peter Maydell
2014-12-09 19:46 ` [Qemu-devel] [PATCH 1/2] target-arm: Split NO_MIGRATE into ALIAS and NO_RAW Peter Maydell
2014-12-10 22:01   ` Greg Bellows
2014-12-10 22:46     ` Peter Maydell
2014-12-10 23:07       ` Greg Bellows

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).