From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.linux.dev
Cc: Marc Zyngier <maz@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Sebastian Ott <sebott@redhat.com>,
Oliver Upton <oliver.upton@linux.dev>,
Mark Brown <broonie@kernel.org>
Subject: [PATCH 2/3] KVM: arm64: Copy MIDR_EL1 into hyp VM when it is writable
Date: Wed, 5 Mar 2025 15:08:24 -0800 [thread overview]
Message-ID: <20250305230825.484091-3-oliver.upton@linux.dev> (raw)
In-Reply-To: <20250305230825.484091-1-oliver.upton@linux.dev>
KVM recently added a capability that allows userspace to override the
'implementation ID' registers presented to the VM. MIDR_EL1 is a special
example, where the hypervisor can directly set the value when read from
EL1 using VPIDR_EL2.
Copy the VM-wide value for MIDR_EL1 into the hyp VM for non-protected
guests when the capability is enabled so VPIDR_EL2 gets set up
correctly.
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/kvmarm/ac594b9c-4bbb-46c8-9391-e7a68ce4de5b@sirena.org.uk/
Fixes: 3adaee783061 ("KVM: arm64: Allow userspace to change the implementation ID registers")
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
arch/arm64/kvm/hyp/nvhe/pkvm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index 2e2975248cd3..afc1b5c403c9 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -376,6 +376,9 @@ static void init_pkvm_hyp_vm(struct kvm *host_kvm, struct pkvm_hyp_vm *hyp_vm,
hyp_vm->kvm.arch.flags = 0;
pkvm_init_features_from_host(hyp_vm, host_kvm);
hyp_vm->kvm.arch.ctr_el0 = host_kvm->arch.ctr_el0;
+
+ if (test_bit(KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS, &hyp_vm->kvm.arch.flags))
+ hyp_vm->kvm.arch.midr_el1 = host_kvm->arch.midr_el1;
}
static void pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *host_vcpu)
--
2.39.5
next prev parent reply other threads:[~2025-03-05 23:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 23:08 [PATCH 0/3] KVM: arm64: Fixes for 'writable' ID registers in protected mode Oliver Upton
2025-03-05 23:08 ` [PATCH 1/3] KVM: arm64: Copy guest CTR_EL0 into hyp VM Oliver Upton
2025-03-06 0:25 ` Marc Zyngier
2025-03-05 23:08 ` Oliver Upton [this message]
2025-03-06 10:52 ` [PATCH 2/3] KVM: arm64: Copy MIDR_EL1 into hyp VM when it is writable Sebastian Ott
2025-03-05 23:08 ` [PATCH 3/3] KVM: arm64: Fix documentation for KVM_CAP_ARM_WRITABLE_IMP_ID_REGS Oliver Upton
2025-03-06 0:26 ` [PATCH 0/3] KVM: arm64: Fixes for 'writable' ID registers in protected mode Marc Zyngier
2025-03-06 1:01 ` 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=20250305230825.484091-3-oliver.upton@linux.dev \
--to=oliver.upton@linux.dev \
--cc=broonie@kernel.org \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=sebott@redhat.com \
--cc=suzuki.poulose@arm.com \
/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