From: Marc Zyngier <maz@kernel.org>
To: Joey Gouly <joey.gouly@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
anshuman.khandual@arm.com, james.morse@arm.com,
Oliver Upton <oliver.upton@linux.dev>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Jing Zhang <jingzhangos@google.com>,
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>
Subject: Re: [PATCH v5 4/7] KVM: arm64: Fix missing traps of guest accesses to the MPAM registers
Date: Thu, 17 Oct 2024 14:38:49 +0100 [thread overview]
Message-ID: <86ldym4zo6.wl-maz@kernel.org> (raw)
In-Reply-To: <20241017130638.GA139029@e124191.cambridge.arm.com>
On Thu, 17 Oct 2024 14:06:38 +0100,
Joey Gouly <joey.gouly@arm.com> wrote:
>
> Hi Marc,
>
> Thanks for looking!
>
> On Thu, Oct 17, 2024 at 12:54:09PM +0100, Marc Zyngier wrote:
> > On Tue, 15 Oct 2024 14:39:20 +0100,
> > Joey Gouly <joey.gouly@arm.com> wrote:
> > >
> > > @@ -204,6 +205,35 @@ static inline void __deactivate_traps_hfgxtr(struct kvm_vcpu *vcpu)
> > > __deactivate_fgt(hctxt, vcpu, kvm, HAFGRTR_EL2);
> > > }
> > >
> > > +static inline void __activate_traps_mpam(struct kvm_vcpu *vcpu)
> > > +{
> > > + u64 r = MPAM2_EL2_TRAPMPAM0EL1 | MPAM2_EL2_TRAPMPAM1EL1;
> > > +
> > > + if (!cpus_support_mpam())
> > > + return;
> > > +
> > > + /* trap guest access to MPAMIDR_EL1 */
> > > + if (mpam_cpus_have_mpam_hcr()) {
> > > + write_sysreg_s(MPAMHCR_EL2_TRAP_MPAMIDR_EL1, SYS_MPAMHCR_EL2);
> > > + } else {
> > > + /* From v1.1 TIDR can trap MPAMIDR, set it unconditionally */
> > > + r |= MPAM2_EL2_TIDR;
> > > + }
> > > +
> > > + write_sysreg_s(r, SYS_MPAM2_EL2);
> >
> > Please use the write_sysreg_el2() accessor, so that VHE under NV has
> > an easier time, should we ever get there.
>
> Are you suggesting this, to avoid a trap (and instead get the register-memory
> redirection)?
>
> The two reasons I could see to keep it as-is:
> - The name changes from MPAM2_EL2 to MPAM1_EL1 (1 and 2 suffixes after
> MPAM)
Arghhh.
> - It's setting trap behaviour, which is an EL2 concept (and are RES0
> bits in the MPAM1_EL1 reg). Other trap registers such as HCRX_EL2 use
> that register directly, however they don't have an _EL1 counterpart so have to.
Arghhh again.
So this is yet another register that doesn't match FEAT_NV2p1, by
having RES0 fields in its EL2-equivalent-EL1 register, and we can't
even use MPAM1_EL1 for NV.
> I'm fine to change it, just want to clarify before I do.
Nah, don't bother. This thing can't be rescued.
Thanks for the gory details!
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2024-10-17 13:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 13:39 [PATCH v5 0/7] KVM: arm64: Hide unsupported MPAM from the guest Joey Gouly
2024-10-15 13:39 ` [PATCH v5 1/7] arm64/sysreg: Convert existing MPAM sysregs and add the remaining entries Joey Gouly
2024-10-16 23:41 ` Gavin Shan
2024-10-15 13:39 ` [PATCH v5 2/7] arm64: head.S: Initialise MPAM EL2 registers and disable traps Joey Gouly
2024-10-16 23:41 ` Gavin Shan
2024-10-15 13:39 ` [PATCH v5 3/7] arm64: cpufeature: discover CPU support for MPAM Joey Gouly
2024-10-17 2:36 ` Gavin Shan
2024-10-15 13:39 ` [PATCH v5 4/7] KVM: arm64: Fix missing traps of guest accesses to the MPAM registers Joey Gouly
2024-10-17 0:10 ` Oliver Upton
2024-10-17 10:58 ` Joey Gouly
2024-10-17 16:07 ` Oliver Upton
2024-10-22 14:31 ` Joey Gouly
2024-10-17 2:37 ` Gavin Shan
2024-10-17 11:54 ` Marc Zyngier
2024-10-17 13:06 ` Joey Gouly
2024-10-17 13:38 ` Marc Zyngier [this message]
2024-10-17 13:43 ` Marc Zyngier
2024-10-15 13:39 ` [PATCH v5 5/7] KVM: arm64: Add a macro for creating filtered sys_reg_descs entries Joey Gouly
2024-10-17 2:37 ` Gavin Shan
2024-10-15 13:39 ` [PATCH v5 6/7] KVM: arm64: Disable MPAM visibility by default and ignore VMM writes Joey Gouly
2024-10-17 2:37 ` Gavin Shan
2024-10-15 13:39 ` [PATCH v5 7/7] KVM: arm64: selftests: Test ID_AA64PFR0.MPAM isn't completely ignored Joey Gouly
2024-10-17 0:41 ` Gavin Shan
2024-10-17 11:03 ` Joey Gouly
2024-10-17 8:34 ` [PATCH v5 0/7] KVM: arm64: Hide unsupported MPAM from the guest Shameerali Kolothum Thodi
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=86ldym4zo6.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=jingzhangos@google.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.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