From: Oliver Upton <oliver.upton@linux.dev>
To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
Cc: "kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"maz@kernel.org" <maz@kernel.org>,
"will@kernel.org" <will@kernel.org>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"james.morse@arm.com" <james.morse@arm.com>,
"suzuki.poulose@arm.com" <suzuki.poulose@arm.com>,
yuzenghui <yuzenghui@huawei.com>,
"Wangzhou (B)" <wangzhou1@hisilicon.com>,
Linuxarm <linuxarm@huawei.com>
Subject: Re: [PATCH] KVM: arm64: Disable OS double lock visibility by default and ignore VMM writes
Date: Thu, 8 Aug 2024 18:31:25 +0000 [thread overview]
Message-ID: <ZrUO_RG6a9We7neT@linux.dev> (raw)
In-Reply-To: <f81365c28d1b4ae1a5e9c2345d24b2c7@huawei.com>
On Thu, Aug 08, 2024 at 06:10:33PM +0000, Shameerali Kolothum Thodi wrote:
> > I find myself asking *why* we need this, could you share some details
> > on the issue you're encountering?
>
> Sorry, I missed the why part. Mainly for VM migration purposes as we have systems
> with DoubleLock implemented and not implemented(with DebugVer 8.2).
Ah, got it, thanks for the context.
> >
> > Indeed, RAZ/WI is not a faithful implementation of FEAT_DoubleLock, but
> > I wouldn't expect it to be used in a VM in the first place.
> >
> > On Thu, Aug 08, 2024 at 01:57:11PM +0100, Shameer Kolothum wrote:
> > > KVM exposes the OS double lock feature bit to Guests but returns
> > > RAZ/WI on Guest OSDLR_EL1 access. Make sure we are hiding OS double
> > > lock from Guests now. However we can't hide DoubleLock if the reported
> > > DebugVer is < 8.2. So report a minimum DebugVer of 8.2 to Guests.
> >
> > What if a user wanted to virtualize an exact CPU model that only
> > implemented v8.0?
>
> Yeah. I was a bit concerned as mentioned below of bumping up DebugVer to 8.2.
> But then I found a similar attempt you made a while back,
> https://lore.kernel.org/linux-arm-kernel/20211029003202.158161-1-oupton@google.com/T/#meee94d87db3f8042156557dbf9743bb03cf0aaa9
Using my own crap patches against me, drat! :-)
In all seriousness, this has since been resolved with the 'writable' ID
register infrastructure and corresponding changes raising the max
possible debug arch to v8.8. DebugVer will match the HW value up to
v8.8, but userspace can 'downgrade' the feature by writing a lesser
value.
So in the case of cross-system migration, the old value is still
accepted by KVM + advertised to the VM.
> >
> > > All this may break migration from the older kernels. Take care of
> > > that by ignoring VMM writes for these values.
> >
> > Ignoring userspace writes is a pretty big hammer. In situations where
> > KVM had advertised a feature that was outright not supported (e.g. IMP DEF
> > PMUs) it _might_ make sense. But with this change we're messing with a
> > CPU feature we *do* support.
>
> The concern here is for the DebugVer I guess.
Indeed.
> But if VMs are not making use of any 8.0 specific features(as I understand it,
> only external debugger support is the difference), then is that an issue?
You're absolutely right to point out that v8.0 -> v8.2 doesn't change
anything from the VM's POV.
My concern is that the guest does not anticipate ID registers changing
values at runtime, and we should only reach for that big hammer if we
(KVM) have done something truly stupid.
Which never happens, of course :)
> > Would allowing userspace to downgrade ID_AA664DFR0_EL1.DoubleLock to
> > 0b1111 be enough?
>
> Yeah. Could I guess. But then we need to check the DebugVer matches to 8.2 or not
> as well.
Eh, I don't think that KVM needs to be policing the VMM for total
compliance with the architecture. What's far more important is
guaranteeing the selected CPU feature set is a subset of what KVM
virtualizes.
So even though the architecture says
!FEAT_DoubleLock && !FEAT_Debugv8p2
is not allowed, it isn't a problematic configuration for KVM. Still,
the defaults from KVM should still comply with the architecture as
closely as possible.
> Idea was, is there any point in exposing features that are not supported or used
> by VMs in the first place.
And I generally agree, but the need to churn other fields to get to a
sane starting point gave me a bit of pause.
Would you be willing to cook up a patch that just opens up the
DoubleLock field to downgrades?
--
Thanks,
Oliver
next prev parent reply other threads:[~2024-08-08 18:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 12:57 [PATCH] KVM: arm64: Disable OS double lock visibility by default and ignore VMM writes Shameer Kolothum
2024-08-08 17:39 ` Oliver Upton
2024-08-08 18:10 ` Shameerali Kolothum Thodi
2024-08-08 18:31 ` Oliver Upton [this message]
2024-08-08 18:38 ` Shameerali Kolothum Thodi
2024-08-08 23:19 ` 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=ZrUO_RG6a9We7neT@linux.dev \
--to=oliver.upton@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suzuki.poulose@arm.com \
--cc=wangzhou1@hisilicon.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).