[PATCH v3 3/4] KVM: arm64: Pass pmu events to hyp via vcpu

Marc Zyngier maz at kernel.org
Tue May 10 02:21:00 PDT 2022


On Tue, 10 May 2022 07:43:45 +0100,
Fuad Tabba <tabba at google.com> wrote:
> 
> Hi Oliver,
> 
> 
> On Mon, May 9, 2022 at 9:21 PM Oliver Upton <oupton at google.com> wrote:
> >
> > On Mon, May 09, 2022 at 12:03:29PM +0000, Fuad Tabba wrote:
> > > Instead of the host accessing hyp data directly, pass the pmu
> > > events of the current cpu to hyp via the vcpu.
> > >
> > > This adds 64 bits (in two fields) to the vcpu that need to be
> > > synced before every vcpu run in nvhe and protected modes.
> > > However, it isolates the hypervisor from the host, which allows
> > > us to use pmu in protected mode in a subsequent patch.
> > >
> > > No visible side effects in behavior intended.
> > >
> > > Signed-off-by: Fuad Tabba <tabba at google.com>
> > > ---
> > >  arch/arm64/include/asm/kvm_host.h |  8 ++------
> > >  arch/arm64/kvm/arm.c              | 15 +++++++++++++++
> > >  arch/arm64/kvm/hyp/nvhe/switch.c  | 20 ++++++--------------
> > >  arch/arm64/kvm/pmu.c              | 12 ++++--------
> > >  include/kvm/arm_pmu.h             |  6 ++++++
> > >  5 files changed, 33 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> > > index dfd360404dd8..90476e713643 100644
> > > --- a/arch/arm64/include/asm/kvm_host.h
> > > +++ b/arch/arm64/include/asm/kvm_host.h
> > > @@ -273,14 +273,8 @@ struct kvm_cpu_context {
> > >       struct kvm_vcpu *__hyp_running_vcpu;
> > >  };
> > >
> > > -struct kvm_pmu_events {
> > > -     u32 events_host;
> > > -     u32 events_guest;
> > > -};
> > > -
> >
> > Looks like you're moving this to arm_pmu.h as well. Probably a better
> > home for it, but unclear why it is done in this patch.
> 
> Like you said, I thought it was a better home, and it's not needed
> here anymore. I could maybe move it to the repacking patch and make it
> as a general "cleanup" patch, if you think that would be clearer.
> >
> > >  struct kvm_host_data {
> > >       struct kvm_cpu_context host_ctxt;
> > > -     struct kvm_pmu_events pmu_events;
> > >  };
> > >
> >
> > Are we going to need this struct any more since it now has a single
> > member?
> 
> I thought about removing it, but it would cause a bit of code churn.
> That said, I could remove it in a new patch that I have as the last
> one, and leave it to the maintainer to decide whether to take it.

Unless there is a compelling reason for getting rid of kvm_host_data,
I'd keep it. Because next thing you know, we'll need another bit in
there, and we'll reintroduce it. This costs us nothing, so let's not
worry about it.

> 
> >
> > >  struct kvm_host_psci_config {
> > > @@ -763,6 +757,7 @@ void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);
> > >  struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
> > >
> > >  DECLARE_KVM_HYP_PER_CPU(struct kvm_host_data, kvm_host_data);
> > > +DECLARE_PER_CPU(struct kvm_pmu_events, kvm_pmu_events);
> >
> > Why do you need this declaration? I don't see the percpu data being
> > accessed outside of pmu.c.
> 
> You're right. At one previous iteration I did need it, which is why
> it's here, but not anymore. Will remove it.

And then make the definition static?

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list