kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Raghavendra Rao Ananta <rananta@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Marc Zyngier <maz@kernel.org>,  Andrew Jones <drjones@redhat.com>,
	James Morse <james.morse@arm.com>,
	 Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	Peter Shier <pshier@google.com>,
	linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 00/18] KVM: arm64: selftests: Introduce arch_timer selftest
Date: Thu,  9 Sep 2021 01:38:00 +0000	[thread overview]
Message-ID: <20210909013818.1191270-1-rananta@google.com> (raw)

Hello,

The patch series adds a KVM selftest to validate the behavior of
ARM's generic timer (patch-15). The test programs the timer IRQs
periodically, and for each interrupt, it validates the behaviour
against the architecture specifications. The test further provides
a command-line interface to configure the number of vCPUs, the
period of the timer, and the number of iterations that the test
has to run for.

Patch-16 adds an option to randomly migrate the vCPUs to different
physical CPUs across the system. The bug for the fix provided by
Marc with commit 3134cc8beb69d0d ("KVM: arm64: vgic: Resample HW
pending state on deactivation") was discovered using arch_timer
test with vCPU migrations.

Since the test heavily depends on interrupts, patch-14 adds a host
library to setup ARM Generic Interrupt Controller v3 (GICv3). This
includes creating a vGIC device, setting up distributor and
redistributor attributes, and mapping the guest physical addresses.
Symmetrical to this, patch-11 adds a guest library to talk to the vGIC,
which includes initializing the controller, enabling/disabling the
interrupts, and so on.

The following patches are utility patches that the above ones make use
of:
Patch-1 adds readl/writel support for guests to access MMIO space.

Patch-2 imports arch/arm64/include/asm/sysreg.h into selftests to make
use of the register encodings and read/write definitions.

Patch-3 is not directly related to the test, but makes
aarch64/debug-exceptions.c use the read/write definitions from the
imported sysreg.h and remove the existing definitions of read_sysreg()
and write_sysreg().

Patch-4 introduces ARM64_SYS_KVM_REG, that helps convert the SYS_*
register encodings in sysreg.h to be acceptable by get_reg() and set_reg().

Patch-5 adds the support for cpu_relax().

Patch-6 adds basic arch_timer framework.

Patch-7 adds udelay() support for the guests to utilize.

Patch-8 adds local_irq_enable() and local_irq_disable() for the guests
to enable/disable interrupts.

Patch-9 adds the support to get the vcpuid for the guests. This allows
them to access any cpu-centric private data in the upcoming patches.

Patch-10 adds a light-weight support for spinlocks for the guests to
use.

Patch-12 and 13 adds helper routines to get the number of vCPUs and the
mode of the VM, respectively. These are further used by the vGIC host
routine (patch-14).

Patch-17 is unrelated to the test case, but it make a cleanup
for aarch64/vgic_init.c to use REDIST_REGION_ATTR_ADDR from vgic.h.

Patch-18 is also unrelated, where it replaces ARM64_SYS_REG with
ARM64_SYS_KVM_REG throughout the selftests. The definitions for the
system register encodings are further deleted in processor.h.

The patch series, specifically the library support, is derived from the
kvm-unit-tests and the kernel itself.

Regards,
Raghavendra

v3 -> v4:

Addressed the comments by Andrew, Oliver, and Ricardo (Thank you):
- Reimplemented get_vcpuid() by exporting a map of vcpuid:mpidr to the
  guest.
- Import sysreg.h from arch/arm64/include/asm/sysreg.h to get the system
  register encodings and its read/write support. As a result, delete the
  existing definitions in processor.h.
- Introduce ARM64_SYS_KVM_REG that converts SYS_* register definitions
  from sysreg.h into the encodings accepted by get_reg() and set_reg().
- Hence, remove the existing encodings of system registers (CPACR_EL1,
  TCR_EL1, and friends) and replace all the its consumers throughout
  the selftests with ARM64_SYS_KVM_REG.
- Keep track of number of vCPUs in 'struct kvm_vm'.
- Add a helper method to get the KVM VM's mode.
- Modify the vGIC host function vgic_v3_setup to make use of the above
  two helper methods, which prevents it from accepting nr_vcpus as
  an argument.
- Move the definition of REDIST_REGION_ATTR_ADDR from lib/aarch64/vgic.c
  to include/aarch64/vgic.h.
- Make the selftest, vgic_init.c, use the definition of REDIST_REGION_ATTR_ADDR
  from include/aarch64/vgic.h.
- Turn ON vCPU migration by default (-m 2).
- Add pr_debug() to log vCPU migrations. Helpful for diagnosis.
- Change TEST_ASSERT(false,...) to TEST_FAIL() in the base arch_timer
  test.
- Include linux/types.h for __force definitions.
- Change the type of 'val' to 'int' in spin_lock() to match the lock
  value type.
- Fix typos in code files and comments.

v2 -> v3:

- Addressed the comments from Ricardo regarding moving the vGIC host
  support for selftests to its own library.
- Added an option (-m) to migrate the guest vCPUs to physical CPUs
  in the system.

v1 -> v2:

Addressed comments from Zenghui in include/aarch64/arch_timer.h:
- Correct the header description
- Remove unnecessary inclusion of linux/sizes.h
- Re-arrange CTL_ defines in ascending order
- Remove inappropriate 'return' from timer_set_* functions, which
  returns 'void'.

v1: https://lore.kernel.org/kvmarm/20210813211211.2983293-1-rananta@google.com/
v2: https://lore.kernel.org/kvmarm/20210818184311.517295-1-rananta@google.com/
v3: https://lore.kernel.org/kvmarm/20210901211412.4171835-1-rananta@google.com/

Raghavendra Rao Ananta (18):
  KVM: arm64: selftests: Add MMIO readl/writel support
  KVM: arm64: selftests: Add sysreg.h
  KVM: arm64: selftests: Use read/write definitions from sysreg.h
  KVM: arm64: selftests: Introduce ARM64_SYS_KVM_REG
  KVM: arm64: selftests: Add support for cpu_relax
  KVM: arm64: selftests: Add basic support for arch_timers
  KVM: arm64: selftests: Add basic support to generate delays
  KVM: arm64: selftests: Add support to disable and enable local IRQs
  KVM: arm64: selftests: Add guest support to get the vcpuid
  KVM: arm64: selftests: Add light-weight spinlock support
  KVM: arm64: selftests: Add basic GICv3 support
  KVM: selftests: Keep track of the number of vCPUs for a VM
  KVM: selftests: Add support to get the VM's mode
  KVM: arm64: selftests: Add host support for vGIC
  KVM: arm64: selftests: Add arch_timer test
  KVM: arm64: selftests: arch_timer: Support vCPU migration
  KVM: arm64: selftests: Replace ARM64_SYS_REG with ARM64_SYS_KVM_REG
  KVM: selftests: vgic_init: Pull REDIST_REGION_ATTR_ADDR from vgic.h

 tools/testing/selftests/kvm/.gitignore        |    1 +
 tools/testing/selftests/kvm/Makefile          |    3 +-
 .../selftests/kvm/aarch64/arch_timer.c        |  462 ++++++
 .../selftests/kvm/aarch64/debug-exceptions.c  |   30 +-
 .../selftests/kvm/aarch64/psci_cpu_on_test.c  |    3 +-
 .../testing/selftests/kvm/aarch64/vgic_init.c |    3 +-
 .../kvm/include/aarch64/arch_timer.h          |  142 ++
 .../selftests/kvm/include/aarch64/delay.h     |   25 +
 .../selftests/kvm/include/aarch64/gic.h       |   21 +
 .../selftests/kvm/include/aarch64/processor.h |   93 +-
 .../selftests/kvm/include/aarch64/spinlock.h  |   13 +
 .../selftests/kvm/include/aarch64/sysreg.h    | 1278 +++++++++++++++++
 .../selftests/kvm/include/aarch64/vgic.h      |   20 +
 .../testing/selftests/kvm/include/kvm_util.h  |    2 +
 tools/testing/selftests/kvm/lib/aarch64/gic.c |   93 ++
 .../selftests/kvm/lib/aarch64/gic_private.h   |   21 +
 .../selftests/kvm/lib/aarch64/gic_v3.c        |  240 ++++
 .../selftests/kvm/lib/aarch64/gic_v3.h        |   70 +
 .../selftests/kvm/lib/aarch64/processor.c     |   62 +-
 .../selftests/kvm/lib/aarch64/spinlock.c      |   27 +
 .../testing/selftests/kvm/lib/aarch64/vgic.c  |   60 +
 tools/testing/selftests/kvm/lib/kvm_util.c    |   12 +
 .../selftests/kvm/lib/kvm_util_internal.h     |    1 +
 23 files changed, 2636 insertions(+), 46 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/arch_timer.c
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/arch_timer.h
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/delay.h
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/gic.h
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/spinlock.h
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/sysreg.h
 create mode 100644 tools/testing/selftests/kvm/include/aarch64/vgic.h
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/gic.c
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/gic_private.h
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/gic_v3.c
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/gic_v3.h
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/spinlock.c
 create mode 100644 tools/testing/selftests/kvm/lib/aarch64/vgic.c

-- 
2.33.0.153.gba50c8fa24-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

             reply	other threads:[~2021-09-09  1:38 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  1:38 Raghavendra Rao Ananta [this message]
2021-09-09  1:38 ` [PATCH v4 01/18] KVM: arm64: selftests: Add MMIO readl/writel support Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 02/18] KVM: arm64: selftests: Add sysreg.h Raghavendra Rao Ananta
2021-09-09  2:47   ` Oliver Upton
2021-09-09  6:53     ` Andrew Jones
2021-09-09 16:42       ` Raghavendra Rao Ananta
2021-09-09 17:17   ` Mark Brown
2021-09-09 20:06     ` Raghavendra Rao Ananta
2021-09-10  8:30       ` Mark Brown
2021-09-13 23:38         ` Raghavendra Rao Ananta
2021-09-14 10:39           ` Mark Brown
2021-09-09  1:38 ` [PATCH v4 03/18] KVM: arm64: selftests: Use read/write definitions from sysreg.h Raghavendra Rao Ananta
2021-09-09  2:55   ` Oliver Upton
2021-09-09  6:56   ` Andrew Jones
2021-09-09 16:43     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 04/18] KVM: arm64: selftests: Introduce ARM64_SYS_KVM_REG Raghavendra Rao Ananta
2021-09-09  3:02   ` Oliver Upton
2021-09-09 16:48     ` Raghavendra Rao Ananta
2021-09-09  7:04   ` Andrew Jones
2021-09-09 16:49     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 05/18] KVM: arm64: selftests: Add support for cpu_relax Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 06/18] KVM: arm64: selftests: Add basic support for arch_timers Raghavendra Rao Ananta
2021-09-09  7:07   ` Andrew Jones
2021-09-09  1:38 ` [PATCH v4 07/18] KVM: arm64: selftests: Add basic support to generate delays Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 08/18] KVM: arm64: selftests: Add support to disable and enable local IRQs Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 09/18] KVM: arm64: selftests: Add guest support to get the vcpuid Raghavendra Rao Ananta
2021-09-09  5:09   ` Oliver Upton
2021-09-09 16:59     ` Raghavendra Rao Ananta
2021-09-09 17:04       ` Oliver Upton
2021-09-09  7:56   ` Andrew Jones
2021-09-09 17:10     ` Raghavendra Rao Ananta
2021-09-10  8:10       ` Andrew Jones
2021-09-10 18:03         ` Raghavendra Rao Ananta
2021-09-13  7:25           ` Andrew Jones
2021-09-12  7:05   ` Reiji Watanabe
2021-09-13  7:35     ` Andrew Jones
2021-09-13 16:51       ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 10/18] KVM: arm64: selftests: Add light-weight spinlock support Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 11/18] KVM: arm64: selftests: Add basic GICv3 support Raghavendra Rao Ananta
2021-09-09  5:18   ` Oliver Upton
2021-09-09 16:38     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 12/18] KVM: selftests: Keep track of the number of vCPUs for a VM Raghavendra Rao Ananta
2021-09-09  5:22   ` Oliver Upton
2021-09-09 13:20   ` Andrew Jones
2021-09-09  1:38 ` [PATCH v4 13/18] KVM: selftests: Add support to get the VM's mode Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 14/18] KVM: arm64: selftests: Add host support for vGIC Raghavendra Rao Ananta
2021-09-09  5:32   ` Oliver Upton
2021-09-09 13:34     ` Andrew Jones
2021-09-09 17:25       ` Raghavendra Rao Ananta
2021-09-09 17:20     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 15/18] KVM: arm64: selftests: Add arch_timer test Raghavendra Rao Ananta
2021-09-09  5:51   ` Oliver Upton
2021-09-09 18:03     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 16/18] KVM: arm64: selftests: arch_timer: Support vCPU migration Raghavendra Rao Ananta
2021-09-09 13:45   ` Andrew Jones
2021-09-09 17:33     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 17/18] KVM: arm64: selftests: Replace ARM64_SYS_REG with ARM64_SYS_KVM_REG Raghavendra Rao Ananta
2021-09-09  5:34   ` Oliver Upton
2021-09-09 13:38   ` Andrew Jones
2021-09-09 17:29     ` Raghavendra Rao Ananta
2021-09-09  1:38 ` [PATCH v4 18/18] KVM: selftests: vgic_init: Pull REDIST_REGION_ATTR_ADDR from vgic.h Raghavendra Rao Ananta
2021-09-09  5:36   ` Oliver Upton
2021-09-09 16:41     ` Raghavendra Rao Ananta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909013818.1191270-1-rananta@google.com \
    --to=rananta@google.com \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=drjones@redhat.com \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).