All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] KVM: arm64: BUG FIX: Correctly handle zero register transfers
@ 2015-12-04 12:03 Pavel Fedin
  2015-12-04 12:03 ` [PATCH v4 1/4] KVM: arm64: Correctly handle zero register during MMIO Pavel Fedin
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Pavel Fedin @ 2015-12-04 12:03 UTC (permalink / raw)
  To: kvmarm, kvm; +Cc: Marc Zyngier

ARM64 CPU has zero register which is read-only, with a value of 0.
However, KVM currently incorrectly recognizes it being SP (because
Rt == 31, and in struct user_pt_regs 'regs' array is followed by SP),
resulting in invalid value being read, or even SP corruption on write.

The problem has been discovered by performing an operation

 *((volatile int *)reg) = 0;

which compiles as "str xzr, [xx]", and resulted in strange values being
written.

v3 => v4:
- Unwrapped assignment in patch 0003

v2 => v3:
- Brought back some const modifiers in unaffected functions

v1 => v2:
- Changed type of transfer value to u64 and store it directly in
  struct sys_reg_params instead of a pointer
- Use lower_32_bits()/upper_32_bits() where appropriate
- Fixed wrong usage of 'Rt' instead of 'Rt2' in kvm_handle_cp_64(),
  overlooked in v1
- Do not write value back when reading

Pavel Fedin (4):
  KVM: arm64: Correctly handle zero register during MMIO
  KVM: arm64: Remove const from struct sys_reg_params
  KVM: arm64: Correctly handle zero register in system register accesses
  KVM: arm64: Get rid of old vcpu_reg()

 arch/arm/include/asm/kvm_emulate.h   |  12 ++++
 arch/arm/kvm/mmio.c                  |   5 +-
 arch/arm/kvm/psci.c                  |  20 +++---
 arch/arm64/include/asm/kvm_emulate.h |  18 +++--
 arch/arm64/kvm/handle_exit.c         |   2 +-
 arch/arm64/kvm/sys_regs.c            | 123 +++++++++++++++++------------------
 arch/arm64/kvm/sys_regs.h            |   8 +--
 arch/arm64/kvm/sys_regs_generic_v8.c |   4 +-
 8 files changed, 105 insertions(+), 87 deletions(-)

-- 
2.4.4


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

end of thread, other threads:[~2015-12-08 14:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 12:03 [PATCH v4 0/4] KVM: arm64: BUG FIX: Correctly handle zero register transfers Pavel Fedin
2015-12-04 12:03 ` [PATCH v4 1/4] KVM: arm64: Correctly handle zero register during MMIO Pavel Fedin
2015-12-04 15:33   ` Marc Zyngier
2015-12-04 12:03 ` [PATCH v4 2/4] KVM: arm64: Remove const from struct sys_reg_params Pavel Fedin
2015-12-04 13:00   ` Marc Zyngier
2015-12-04 12:03 ` [PATCH v4 3/4] KVM: arm64: Correctly handle zero register in system register accesses Pavel Fedin
2015-12-04 12:03 ` [PATCH v4 4/4] KVM: arm64: Get rid of old vcpu_reg() Pavel Fedin
2015-12-05  0:33 ` [PATCH v4 0/4] KVM: arm64: BUG FIX: Correctly handle zero register transfers Andrew Jones
2015-12-07  8:36   ` Pavel Fedin
2015-12-07 22:36     ` Andrew Jones
2015-12-07 23:45       ` Andrew Jones
2015-12-08  6:57         ` Pavel Fedin
2015-12-08 14:48           ` Andrew Jones
2015-12-07  8:47   ` Pavel Fedin
2015-12-07 21:50     ` Andrew Jones
2015-12-07  9:48   ` Pavel Fedin
2015-12-07 21:58     ` Andrew Jones
2015-12-07 22:25       ` Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.