OSDN Git Service

KVM: arm64: selftests: Disable single-step without relying on ucall()
authorSean Christopherson <seanjc@google.com>
Thu, 17 Nov 2022 00:23:50 +0000 (00:23 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 17 Nov 2022 00:58:14 +0000 (16:58 -0800)
commitb3d937722de0e64eebe267451a0e3d5ed5107ef7
tree3cdbb3d248ebdbfdf8e624fb70e780bb8f5a7218
parent1cec8bbc1764964de24d19983fbf9fee6ce3c09d
KVM: arm64: selftests: Disable single-step without relying on ucall()

Automatically disable single-step when the guest reaches the end of the
verified section instead of using an explicit ucall() to ask userspace to
disable single-step.  An upcoming change to implement a pool-based scheme
for ucall() will add an atomic operation (bit test and set) in the guest
ucall code, and if the compiler generate "old school" atomics, e.g.

  40e57c:       c85f7c20        ldxr    x0, [x1]
  40e580:       aa100011        orr     x17, x0, x16
  40e584:       c80ffc31        stlxr   w15, x17, [x1]
  40e588:       35ffffaf        cbnz    w15, 40e57c <__aarch64_ldset8_sync+0x1c>

the guest will hang as the local exclusive monitor is reset by eret,
i.e. the stlxr will always fail due to the debug exception taken to EL2.

Link: https://lore.kernel.org/all/20221006003409.649993-8-seanjc@google.com
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20221117002350.2178351-3-seanjc@google.com
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
tools/testing/selftests/kvm/aarch64/debug-exceptions.c