diff mbox series

[v3,4/4] KVM: arm64: Reenable pmu in Protected Mode

Message ID 20220509120330.3043773-5-tabba@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: Do not communicate host pmu event changes by accessing hyp data | expand

Commit Message

Fuad Tabba May 9, 2022, 12:03 p.m. UTC
Now that the pmu code does not access hyp data, reenable it in
protected mode.

Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/kvm/pmu-emul.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Oliver Upton May 9, 2022, 10:36 p.m. UTC | #1
Hi Fuad,

On Mon, May 09, 2022 at 12:03:30PM +0000, Fuad Tabba wrote:
> Now that the pmu code does not access hyp data, reenable it in
> protected mode.
> 
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
>  arch/arm64/kvm/pmu-emul.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> index 3dc990ac4f44..11c43bed5f97 100644
> --- a/arch/arm64/kvm/pmu-emul.c
> +++ b/arch/arm64/kvm/pmu-emul.c
> @@ -774,8 +774,7 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
>  {
>  	struct arm_pmu_entry *entry;
>  
> -	if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF ||
> -	    is_protected_kvm_enabled())
> +	if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF)

IIUC, you intend to enable the PMU for non-pVM guests, right? Based on
the pKVM feature registers + trap handlers I can see that pVM use of the
PMU is in fact disabled. It'd be good to state in the commit message
what is exactly intended for pVMs and non-pVMs.

Since the PMU counters are disabled outright for pVMs, is there any
value in context switching between host/guest in this case?

--
Thanks,
Oliver
Fuad Tabba May 10, 2022, 6:45 a.m. UTC | #2
Hi Oliver,


On Mon, May 9, 2022 at 11:36 PM Oliver Upton <oupton@google.com> wrote:
>
> Hi Fuad,
>
> On Mon, May 09, 2022 at 12:03:30PM +0000, Fuad Tabba wrote:
> > Now that the pmu code does not access hyp data, reenable it in
> > protected mode.
> >
> > Signed-off-by: Fuad Tabba <tabba@google.com>
> > ---
> >  arch/arm64/kvm/pmu-emul.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> > index 3dc990ac4f44..11c43bed5f97 100644
> > --- a/arch/arm64/kvm/pmu-emul.c
> > +++ b/arch/arm64/kvm/pmu-emul.c
> > @@ -774,8 +774,7 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
> >  {
> >       struct arm_pmu_entry *entry;
> >
> > -     if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF ||
> > -         is_protected_kvm_enabled())
> > +     if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF)
>
> IIUC, you intend to enable the PMU for non-pVM guests, right? Based on
> the pKVM feature registers + trap handlers I can see that pVM use of the
> PMU is in fact disabled. It'd be good to state in the commit message
> what is exactly intended for pVMs and non-pVMs.
>
> Since the PMU counters are disabled outright for pVMs, is there any
> value in context switching between host/guest in this case?

I will make this clearer in the commit message. PMU won't be supported
for protected VMs but should be for non-protected VMs in protected
mode.

Thanks,
/fuad

> --
> Thanks,
> Oliver
diff mbox series

Patch

diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
index 3dc990ac4f44..11c43bed5f97 100644
--- a/arch/arm64/kvm/pmu-emul.c
+++ b/arch/arm64/kvm/pmu-emul.c
@@ -774,8 +774,7 @@  void kvm_host_pmu_init(struct arm_pmu *pmu)
 {
 	struct arm_pmu_entry *entry;
 
-	if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF ||
-	    is_protected_kvm_enabled())
+	if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_PMUVER_IMP_DEF)
 		return;
 
 	mutex_lock(&arm_pmus_lock);