From: Sebastian Ott <sebott@redhat.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Marc Zyngier <maz@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Cornelia Huck <cohuck@redhat.com>,
Eric Auger <eric.auger@redhat.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] KVM: arm64: Allow userspace to change MIDR_EL1
Date: Mon, 17 Feb 2025 16:06:16 +0100 (CET) [thread overview]
Message-ID: <afac82bb-2d7d-66d0-cdb8-d8e3471a2bed@redhat.com> (raw)
In-Reply-To: <Z7BoydkyT_h0gwOV@linux.dev>
Hello Oliver,
On Sat, 15 Feb 2025, Oliver Upton wrote:
> On Tue, Feb 11, 2025 at 03:39:07PM +0100, Sebastian Ott wrote:
>> +static int set_id_reg_non_ftr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
>> + u64 val)
>> +{
>> + u32 id = reg_to_encoding(rd);
>> + int ret;
>> +
>> + mutex_lock(&vcpu->kvm->arch.config_lock);
>
> There's quite a few early outs, guard() might be a better fit than
> explicitly dropping the lock.
Yea, I thought about that too but most of the other functions in that file
use the classic lock primitives. But you're right - it looks cleaner.
>
>> + /*
>> + * Since guest access to MIDR_EL1 is not trapped
>> + * set up VPIDR_EL2 to hold the MIDR_EL1 value.
>> + */
>> + if (id == SYS_MIDR_EL1)
>> + write_sysreg(val, vpidr_el2);
>
> This is problematic for a couple reasons:
>
> - If the kernel isn't running at EL2, VPIDR_EL2 is undefined
>
> - VPIDR_EL2 needs to be handled as part of the vCPU context, not
> written to without a running vCPU. What would happen if two vCPUs
> have different MIDR values?
Indeed. Sry, I hadn't thought about that. That makes much more sense now.
> Here's a new diff with some hacks thrown in to handle VPIDR_EL2
> correctly. Very lightly tested :)
Thank you very much! I've integrated that and currently run some tests
with it.
Sebastian
next prev parent reply other threads:[~2025-02-17 15:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 14:39 [PATCH v2 0/4] KVM: arm64: writable MIDR/REVIDR Sebastian Ott
2025-02-11 14:39 ` [PATCH v2 1/4] KVM: arm64: Allow userspace to change MIDR_EL1 Sebastian Ott
2025-02-15 10:13 ` Oliver Upton
2025-02-15 16:16 ` 罗勇刚(Yonggang Luo)
2025-02-15 16:41 ` Marc Zyngier
2025-02-15 19:04 ` 罗勇刚(Yonggang Luo)
2025-02-16 18:09 ` Marc Zyngier
2025-02-16 18:55 ` 罗勇刚(Yonggang Luo)
2025-02-16 19:06 ` Marc Zyngier
2025-02-17 6:40 ` 罗勇刚(Yonggang Luo)
2025-02-17 15:06 ` Sebastian Ott [this message]
2025-02-11 14:39 ` [PATCH v2 2/4] KVM: arm64: Allow userspace to change REVIDR_EL1 Sebastian Ott
2025-02-11 14:39 ` [PATCH v2 3/4] KVM: arm64: Allow userspace to change AIDR_EL1 Sebastian Ott
2025-02-11 14:39 ` [PATCH v2 4/4] KVM: selftests: arm64: Test writes to MIDR,REVIDR,AIDR Sebastian Ott
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=afac82bb-2d7d-66d0-cdb8-d8e3471a2bed@redhat.com \
--to=sebott@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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;
as well as URLs for NNTP newsgroup(s).