From: Oliver Upton <oupton@google.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Raghavendra Rao Anata <rananta@google.com>,
Peter Shier <pshier@google.com>,
Sean Christopherson <seanjc@google.com>,
David Matlack <dmatlack@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
linux-arm-kernel@lists.infradead.org,
Jim Mattson <jmattson@google.com>
Subject: [PATCH v7 0/7] KVM: arm64: Add idempotent controls to migrate guest counter
Date: Mon, 16 Aug 2021 00:12:10 +0000 [thread overview]
Message-ID: <20210816001217.3063400-1-oupton@google.com> (raw)
Currently, on KVM/arm64, we only allow a VMM to migrate the guest's
virtual counter by-value. Saving and restoring the counter by value is
problematic in the fact that the recorded state is not idempotent.
Furthermore, we obfuscate from userspace the fact that the architecture
actually provides offset-based controls.
Another issue is that KVM/arm64 doesn't provide userspace with the
controls of the physical counter-timer. This series aims to address both
issues by adding offset-based controls for the virtual and physical
counters.
Patches 1-2 are refactor changes required to provide offset controls to
userspace and putting in some generic plumbing to use for both physical
and virtual offsets.
Patch 3 exposes a vCPU's virtual offset through the KVM_*_ONE_REG
ioctls. When NV support is added to KVM, CNTVOFF_EL2 will be considered
a guest system register. So, it is safe to expose it now through that
ioctl.
Patch 4 adds a cpufeature bit to detect 'full' ECV implementations,
providing EL2 with the ability to offset the physical counter-timer.
Patch 5 exposes a vCPU's physical offset as a vCPU device attribute.
This is deliberate, as the attribute is not architectural; KVM uses this
attribute to track the host<->guest offset.
Patch 6 is a prepatory change for the sake of physical offset emulation,
as counter-timer traps must be configured separately for each vCPU.
Patch 7 allows non-ECV hosts to support the physical offset vCPU device
attribute, by trapping and emulating the physical counter registers.
This series was tested on an Ampere Mt. Jade system (non-ECV, VHE and
nVHE) as well as the ARM Base RevC FVP (ECV, VHE and nVHE). Patches
apply to kvmarm/next at the following commit:
ae280335cdb5 ("Merge branch kvm-arm64/mmu/el2-tracking into kvmarm-master/next")
Selftests for these changes are being mailed as a separate series, since
there exist dependencies betwen both x86 and arm64.
v6: https://lore.kernel.org/r/20210804085819.846610-1-oupton@google.com
v6 -> v7:
- Fixed typo in documentation (Marc)
- Clean up some unused variables (Drew)
- Added trap configuration for ECV+nVHE (Marc)
- Documented dependency on SCR_EL3.ECVEn (Marc)
- wrap up ptimer_emulation_required() for use in hyp and kernel code
(Drew)
- check static branch condition first (Drew)
- s/cpus_have_const_cap/cpus_have_final_cap/ (Marc)
- s/ARM64_ECV/ARM64_HAS_ECV2/
- Emulate CNTPCTSS_EL2 if ECV2 not present (Marc)
- Reordered the introduction of some functions to ensure that we don't
have unused functions in the middle of the series.
- Cleaned up the read side of CNTVOFF_EL2 (from userspace). Don't
open-code the answer based on the difference of hardware offsets,
just use the guest system register value we stashed on the write
side.
Oliver Upton (7):
KVM: arm64: Refactor update_vtimer_cntvoff()
KVM: arm64: Separate guest/host counter offset values
KVM: arm64: Allow userspace to configure a vCPU's virtual offset
arm64: cpufeature: Enumerate support for FEAT_ECV >= 0x2
KVM: arm64: Allow userspace to configure a guest's counter-timer
offset
KVM: arm64: Configure timer traps in vcpu_load() for VHE
KVM: arm64: Emulate physical counter offsetting on non-ECV systems
Documentation/arm64/booting.rst | 7 +
Documentation/virt/kvm/api.rst | 10 ++
Documentation/virt/kvm/devices/vcpu.rst | 28 ++++
arch/arm64/include/asm/kvm_asm.h | 2 +
arch/arm64/include/asm/sysreg.h | 5 +
arch/arm64/include/uapi/asm/kvm.h | 2 +
arch/arm64/kernel/cpufeature.c | 10 ++
arch/arm64/kvm/arch_timer.c | 196 +++++++++++++++++++++---
arch/arm64/kvm/arm.c | 4 +-
arch/arm64/kvm/guest.c | 6 +-
arch/arm64/kvm/hyp/include/hyp/switch.h | 32 ++++
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 +
arch/arm64/kvm/hyp/nvhe/timer-sr.c | 20 ++-
arch/arm64/kvm/hyp/vhe/timer-sr.c | 5 +
arch/arm64/tools/cpucaps | 1 +
include/clocksource/arm_arch_timer.h | 1 +
include/kvm/arm_arch_timer.h | 9 +-
17 files changed, 315 insertions(+), 29 deletions(-)
--
2.33.0.rc1.237.g0d66db33f3-goog
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next reply other threads:[~2021-08-16 0:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 0:12 Oliver Upton [this message]
2021-08-16 0:12 ` [PATCH v7 1/7] KVM: arm64: Refactor update_vtimer_cntvoff() Oliver Upton
2021-08-16 0:12 ` [PATCH v7 2/7] KVM: arm64: Separate guest/host counter offset values Oliver Upton
2021-08-16 0:12 ` [PATCH v7 3/7] KVM: arm64: Allow userspace to configure a vCPU's virtual offset Oliver Upton
2021-08-19 9:11 ` Marc Zyngier
2021-08-19 10:20 ` Andrew Jones
2021-08-29 2:35 ` Oliver Upton
2021-09-06 9:02 ` Marc Zyngier
2021-08-16 0:12 ` [PATCH v7 4/7] arm64: cpufeature: Enumerate support for FEAT_ECV >= 0x2 Oliver Upton
2021-08-16 0:12 ` [PATCH v7 5/7] KVM: arm64: Allow userspace to configure a guest's counter-timer offset Oliver Upton
2021-08-19 9:52 ` Marc Zyngier
2021-08-16 0:12 ` [PATCH v7 6/7] KVM: arm64: Configure timer traps in vcpu_load() for VHE Oliver Upton
2021-08-16 0:12 ` [PATCH v7 7/7] KVM: arm64: Emulate physical counter offsetting on non-ECV systems Oliver Upton
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=20210816001217.3063400-1-oupton@google.com \
--to=oupton@google.com \
--cc=catalin.marinas@arm.com \
--cc=dmatlack@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=pshier@google.com \
--cc=rananta@google.com \
--cc=seanjc@google.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