mbox series

[v2,0/5] KVM: selftests: arm64 exception handling and debug test

Message ID 20210430232408.2707420-1-ricarkol@google.com (mailing list archive)
Headers show
Series KVM: selftests: arm64 exception handling and debug test | expand

Message

Ricardo Koller April 30, 2021, 11:24 p.m. UTC
Hi,

These patches add a debug exception test in aarch64 KVM selftests while
also adding basic exception handling support.

The structure of the exception handling is based on its x86 counterpart.
Tests use the same calls to initialize exception handling and both
architectures allow tests to override the handler for a particular
vector, or (vector, ec) for synchronous exceptions in the arm64 case.

The debug test is similar to x86_64/debug_regs, except that the x86 one
controls the debugging from outside the VM. This proposed arm64 test
controls and handles debug exceptions from the inside.

Thanks,
Ricardo

v1 -> v2:

Addressed comments from Andrew and Marc (thank you very much):
- rename vm_handle_exception in all tests.
- introduce UCALL_UNHANDLED in x86 first.
- move GUEST_ASSERT_EQ to common utils header.
- handle sync and other exceptions separately: use two tables (like
  kvm-unit-tests).
- add two separate functions for installing sync versus other exceptions
- changes in handlers.S: use the same layout as user_pt_regs, treat the
  EL1t vectors as invalid, refactor the vector table creation to not use
  manual numbering, add comments, remove LR from the stored registers.
- changes in debug-exceptions.c: remove unused headers, use the common
  GUEST_ASSERT_EQ, use vcpu_run instead of _vcpu_run.
- changes in processor.h: write_sysreg with support for xzr, replace EL1
  with current in macro names, define ESR_EC_MASK as ESR_EC_NUM-1.

Ricardo Koller (5):
  KVM: selftests: Rename vm_handle_exception
  KVM: selftests: Introduce UCALL_UNHANDLED for unhandled vector
    reporting
  KVM: selftests: Move GUEST_ASSERT_EQ to utils header
  KVM: selftests: Add exception handling support for aarch64
  KVM: selftests: Add aarch64/debug-exceptions test

 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   3 +-
 .../selftests/kvm/aarch64/debug-exceptions.c  | 244 ++++++++++++++++++
 .../selftests/kvm/include/aarch64/processor.h |  90 ++++++-
 .../testing/selftests/kvm/include/kvm_util.h  |  10 +
 .../selftests/kvm/include/x86_64/processor.h  |   4 +-
 .../selftests/kvm/lib/aarch64/handlers.S      | 130 ++++++++++
 .../selftests/kvm/lib/aarch64/processor.c     | 124 +++++++++
 .../selftests/kvm/lib/x86_64/processor.c      |  19 +-
 .../selftests/kvm/x86_64/kvm_pv_test.c        |   2 +-
 .../selftests/kvm/x86_64/tsc_msrs_test.c      |   9 -
 .../kvm/x86_64/userspace_msr_exit_test.c      |   8 +-
 .../selftests/kvm/x86_64/xapic_ipi_test.c     |   2 +-
 13 files changed, 611 insertions(+), 35 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/debug-exceptions.c
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/handlers.S

Comments

Paolo Bonzini May 24, 2021, 12:14 p.m. UTC | #1
On 01/05/21 01:24, Ricardo Koller wrote:
> Hi,
> 
> These patches add a debug exception test in aarch64 KVM selftests while
> also adding basic exception handling support.
> 
> The structure of the exception handling is based on its x86 counterpart.
> Tests use the same calls to initialize exception handling and both
> architectures allow tests to override the handler for a particular
> vector, or (vector, ec) for synchronous exceptions in the arm64 case.
> 
> The debug test is similar to x86_64/debug_regs, except that the x86 one
> controls the debugging from outside the VM. This proposed arm64 test
> controls and handles debug exceptions from the inside.
> 
> Thanks,
> Ricardo

Marc, are you going to queue this in your tree?

Thanks,

Paolo

> v1 -> v2:
> 
> Addressed comments from Andrew and Marc (thank you very much):
> - rename vm_handle_exception in all tests.
> - introduce UCALL_UNHANDLED in x86 first.
> - move GUEST_ASSERT_EQ to common utils header.
> - handle sync and other exceptions separately: use two tables (like
>    kvm-unit-tests).
> - add two separate functions for installing sync versus other exceptions
> - changes in handlers.S: use the same layout as user_pt_regs, treat the
>    EL1t vectors as invalid, refactor the vector table creation to not use
>    manual numbering, add comments, remove LR from the stored registers.
> - changes in debug-exceptions.c: remove unused headers, use the common
>    GUEST_ASSERT_EQ, use vcpu_run instead of _vcpu_run.
> - changes in processor.h: write_sysreg with support for xzr, replace EL1
>    with current in macro names, define ESR_EC_MASK as ESR_EC_NUM-1.
> 
> Ricardo Koller (5):
>    KVM: selftests: Rename vm_handle_exception
>    KVM: selftests: Introduce UCALL_UNHANDLED for unhandled vector
>      reporting
>    KVM: selftests: Move GUEST_ASSERT_EQ to utils header
>    KVM: selftests: Add exception handling support for aarch64
>    KVM: selftests: Add aarch64/debug-exceptions test
> 
>   tools/testing/selftests/kvm/.gitignore        |   1 +
>   tools/testing/selftests/kvm/Makefile          |   3 +-
>   .../selftests/kvm/aarch64/debug-exceptions.c  | 244 ++++++++++++++++++
>   .../selftests/kvm/include/aarch64/processor.h |  90 ++++++-
>   .../testing/selftests/kvm/include/kvm_util.h  |  10 +
>   .../selftests/kvm/include/x86_64/processor.h  |   4 +-
>   .../selftests/kvm/lib/aarch64/handlers.S      | 130 ++++++++++
>   .../selftests/kvm/lib/aarch64/processor.c     | 124 +++++++++
>   .../selftests/kvm/lib/x86_64/processor.c      |  19 +-
>   .../selftests/kvm/x86_64/kvm_pv_test.c        |   2 +-
>   .../selftests/kvm/x86_64/tsc_msrs_test.c      |   9 -
>   .../kvm/x86_64/userspace_msr_exit_test.c      |   8 +-
>   .../selftests/kvm/x86_64/xapic_ipi_test.c     |   2 +-
>   13 files changed, 611 insertions(+), 35 deletions(-)
>   create mode 100644 tools/testing/selftests/kvm/aarch64/debug-exceptions.c
>   create mode 100644 tools/testing/selftests/kvm/lib/aarch64/handlers.S
>
Marc Zyngier May 24, 2021, 12:59 p.m. UTC | #2
On Mon, 24 May 2021 13:14:52 +0100,
Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 01/05/21 01:24, Ricardo Koller wrote:
> > Hi,
> > 
> > These patches add a debug exception test in aarch64 KVM selftests while
> > also adding basic exception handling support.
> > 
> > The structure of the exception handling is based on its x86 counterpart.
> > Tests use the same calls to initialize exception handling and both
> > architectures allow tests to override the handler for a particular
> > vector, or (vector, ec) for synchronous exceptions in the arm64 case.
> > 
> > The debug test is similar to x86_64/debug_regs, except that the x86 one
> > controls the debugging from outside the VM. This proposed arm64 test
> > controls and handles debug exceptions from the inside.
> > 
> > Thanks,
> > Ricardo
> 
> Marc, are you going to queue this in your tree?

That is my plan. I'm waiting for the fixes branch to be merged in
Linus' tree to start queuing stuff on top.

Thanks,

	M.