From: Oliver Upton <oliver.upton@linux.dev>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.linux.dev, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>, Will Deacon <will@kernel.org>
Subject: Re: [PATCH 1/3] KVM: arm64: pkvm: Actually enable/disable PMU events when running vCPU
Date: Wed, 6 Mar 2024 02:18:31 -0800 [thread overview]
Message-ID: <ZehC96E3Y8lgidOC@linux.dev> (raw)
In-Reply-To: <87a5nbr7x3.wl-maz@kernel.org>
On Wed, Mar 06, 2024 at 10:06:32AM +0000, Marc Zyngier wrote:
> On Tue, 05 Mar 2024 18:48:38 +0000, Oliver Upton <oliver.upton@linux.dev> wrote:
> > +static void flush_debug_state(struct pkvm_hyp_vcpu *hyp_vcpu)
> > +{
> > + struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
> > +
> > + hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
> > + hyp_vcpu->vcpu.arch.debug_ptr = kern_hyp_va(host_vcpu->arch.debug_ptr);
> > +
> > + /*
> > + * The host's PMU context cannot be trusted for protected VMs. Refer to
> > + * hardware to determine which PMCs need to be disabled/enabled on vCPU
> > + * entry/exit, respectively.
> > + */
> > + if (kvm_vm_is_protected(kern_hyp_va(host_vcpu->kvm))) {
>
> This looks wrong. We should never rely on *host* controlled data to
> make a decision at EL2 in the pKVM case. Use of this helper at EL2
> should be constrained to the hyp view of the kvm structure only.
I should've spelled this out explicitly. Looking at what we have
upstream, there's no hyp-controlled view on a VM's protection (yet).
I had imagined this hilariously wrong expression was a placeholder for
pKVM folks, much like we have in early_exit_filter() and
kvm_get_exit_handler_array(). But that's no good, and I probably
should've added one myself that can be updated with the 'right' thing
later on.
> The other thing is that most of this code is going to be thrown away,
> hopefully soon... (hint, nudge...).
I was hoping Will could provide some insight on whether or not the
'real' pKVM hyp state management carries the same bug. Nothing wrong
with fixing what we already have though...
--
Thanks,
Oliver
next prev parent reply other threads:[~2024-03-06 10:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 18:48 [PATCH 0/3] KVM: arm64: PMU fixes for nVHE, protected mode Oliver Upton
2024-03-05 18:48 ` [PATCH 1/3] KVM: arm64: pkvm: Actually enable/disable PMU events when running vCPU Oliver Upton
2024-03-06 10:06 ` Marc Zyngier
2024-03-06 10:18 ` Oliver Upton [this message]
2024-03-06 13:23 ` Fuad Tabba
2024-03-05 18:48 ` [PATCH 2/3] KVM: arm64: Fix host-programmed guest events in nVHE Oliver Upton
2024-03-06 9:59 ` Marc Zyngier
2024-03-05 18:48 ` [PATCH 3/3] KVM: arm64: Do not disable preemption in kvm_vcpu_pmu_restore_guest() Oliver Upton
2024-03-06 9:52 ` Marc Zyngier
2024-03-06 9:54 ` Oliver Upton
2024-03-26 13:44 ` (subset) [PATCH 0/3] KVM: arm64: PMU fixes for nVHE, protected mode 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=ZehC96E3Y8lgidOC@linux.dev \
--to=oliver.upton@linux.dev \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--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