From: Reiji Watanabe <reijiw@google.com>
To: Marc Zyngier <maz@kernel.org>, kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
James Morse <james.morse@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Andrew Jones <drjones@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Will Deacon <will@kernel.org>, Peter Shier <pshier@google.com>,
Ricardo Koller <ricarkol@google.com>,
Oliver Upton <oupton@google.com>,
Jing Zhang <jingzhangos@google.com>,
Raghavendra Rao Anata <rananta@google.com>,
Reiji Watanabe <reijiw@google.com>
Subject: [PATCH v5 0/2] KVM: arm64: mixed-width check should be skipped for uninitialized vCPUs
Date: Sun, 20 Mar 2022 22:08:02 -0700 [thread overview]
Message-ID: <20220321050804.2701035-1-reijiw@google.com> (raw)
KVM allows userspace to configure either all EL1 32bit or 64bit vCPUs
for a guest. At vCPU reset, vcpu_allowed_register_width() checks
if the vcpu's register width is consistent with all other vCPUs'.
Since the checking is done even against vCPUs that are not initialized
(KVM_ARM_VCPU_INIT has not been done) yet, the uninitialized vCPUs
are erroneously treated as 64bit vCPU, which causes the function to
incorrectly detect a mixed-width VM.
This series will fix this problem by introducing a new VM flag that
indicates the guest needs to be configured with all 32bit or 64bit
vCPUs and checking vcpu's register width against the new flag at
the vcpu's KVM_ARM_VCPU_INIT (instead of against other vCPUs'
register width).
Patch-1 introduces KVM_ARCH_FLAG_EL1_32BIT and
KVM_ARCH_FLAG_REG_WIDTH_CONFIGURED bits for kvm->arch.flags and
uses them to check vcpu's register width to fix the problem.
Patch-2 introduces a selftest that can test non-mixed-width vCPUs (all
64bit vCPUs or all 32bit vcPUs) can be configured, and mixed-width
vCPUs cannot be configured.
The series is based on kvmarm/next's at tag: kvmarm-5.18.
v5:
- Rebase to kvmarm/next (and drop the patch-1 "KVM: arm64: Generalise
VM features into a set of flags")
- Use kernel-doc style comments for kvm_set_vm_width() [Oliver]
- Change kvm_set_vm_width() to use if/else instead of a ternary
operator for KVM_ARCH_FLAG_EL1_32BIT check [Oliver]
v4: https://lore.kernel.org/all/20220314061959.3349716-1-reijiw@google.com/
- Use different implementation of vcpu_el1_is_32bit() depending on
the context. [Marc]
- Rename kvm_register_width_check_or_init() to kvm_set_vm_width(), and
call it from kvm_rest_vcpu() instead of from kvm_vcpu_set_target()
- Remove vcpu_allowed_register_width(), and does the same checking
in kvm_set_vm_width() instead.
v3: https://lore.kernel.org/all/20220303035408.3708241-1-reijiw@google.com/
- Introduced 'flags' to kvm_arch, and use bits of the flags for
a set of booleans for VM feature.
- Changed 'el1_reg_width' to two bits of 'flags' of kvm_arch.
v2: https://lore.kernel.org/all/20220118041923.3384602-1-reijiw@google.com/
- Introduced 'el1_reg_width' for kvm_arch and use it to check vcpu's
register width against the flag at the vcpu's KVM_ARM_VCPU_INIT.
v1: https://lore.kernel.org/all/20220110054042.1079932-1-reijiw@google.com/
[1] https://lore.kernel.org/all/20210715163159.1480168-2-maz@kernel.org/
Reiji Watanabe (2):
KVM: arm64: mixed-width check should be skipped for uninitialized
vCPUs
KVM: arm64: selftests: Introduce vcpu_width_config
arch/arm64/include/asm/kvm_emulate.h | 27 ++--
arch/arm64/include/asm/kvm_host.h | 10 ++
arch/arm64/kvm/reset.c | 65 ++++++---
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/aarch64/vcpu_width_config.c | 125 ++++++++++++++++++
6 files changed, 199 insertions(+), 30 deletions(-)
create mode 100644 tools/testing/selftests/kvm/aarch64/vcpu_width_config.c
--
2.35.1.894.gb6a874cedc-goog
next reply other threads:[~2022-03-21 5:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 5:08 Reiji Watanabe [this message]
2022-03-21 5:08 ` [PATCH v5 1/2] KVM: arm64: mixed-width check should be skipped for uninitialized vCPUs Reiji Watanabe
2022-03-21 5:08 ` [PATCH v5 2/2] KVM: arm64: selftests: Introduce vcpu_width_config Reiji Watanabe
2022-03-21 6:17 ` Oliver Upton
2022-03-21 8:28 ` Oliver Upton
2022-03-22 3:30 ` Reiji Watanabe
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=20220321050804.2701035-1-reijiw@google.com \
--to=reijiw@google.com \
--cc=alexandru.elisei@arm.com \
--cc=drjones@redhat.com \
--cc=james.morse@arm.com \
--cc=jingzhangos@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=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=pshier@google.com \
--cc=rananta@google.com \
--cc=ricarkol@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