mbox series

[0/2] KVM: arm64: PMU: Preserve vPMC registers properly on migration

Message ID 20230302055033.3081456-1-reijiw@google.com (mailing list archive)
Headers show
Series KVM: arm64: PMU: Preserve vPMC registers properly on migration | expand

Message

Reiji Watanabe March 2, 2023, 5:50 a.m. UTC
The series fixes two problems in preserving vPMU counter (vPMC)
registers (PMCCNTR_EL0/PMEVCNTR<n>_EL0) during migration.

One of the problems is that KVM may not return the current values
of the vPMC registers for KVM_GET_ONE_REG.

The other one might cause KVM to reset the vPMC registers on the
first KVM_RUN on the destination. This is because userspace might
save PMCR_EL0 with PMCR_EL0.{C,P} bits set on the source, and
restore it on the destination.

See patch-1 and patch-2 for details on these issues respectively.

The series is based on v6.2.

Reiji Watanabe (2):
  KVM: arm64: PMU: Fix GET_ONE_REG for vPMC regs to return the current
    value
  KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU

 arch/arm64/kvm/pmu-emul.c |  4 +++-
 arch/arm64/kvm/sys_regs.c | 21 +++++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)


base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c

Comments

Marc Zyngier March 12, 2023, 3:04 p.m. UTC | #1
On Thu, 02 Mar 2023 05:50:31 +0000,
Reiji Watanabe <reijiw@google.com> wrote:
> 
> The series fixes two problems in preserving vPMU counter (vPMC)
> registers (PMCCNTR_EL0/PMEVCNTR<n>_EL0) during migration.
> 
> One of the problems is that KVM may not return the current values
> of the vPMC registers for KVM_GET_ONE_REG.
> 
> The other one might cause KVM to reset the vPMC registers on the
> first KVM_RUN on the destination. This is because userspace might
> save PMCR_EL0 with PMCR_EL0.{C,P} bits set on the source, and
> restore it on the destination.

This looks good to me. Can you please add the relevant Fixes: tags and
a Cc: to stable? With that, that'd be a candidate for -rc3, I think.

Thanks,

	M.
Reiji Watanabe March 13, 2023, 3:35 a.m. UTC | #2
Hi Marc,

On Sun, Mar 12, 2023 at 8:04 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On Thu, 02 Mar 2023 05:50:31 +0000,
> Reiji Watanabe <reijiw@google.com> wrote:
> >
> > The series fixes two problems in preserving vPMU counter (vPMC)
> > registers (PMCCNTR_EL0/PMEVCNTR<n>_EL0) during migration.
> >
> > One of the problems is that KVM may not return the current values
> > of the vPMC registers for KVM_GET_ONE_REG.
> >
> > The other one might cause KVM to reset the vPMC registers on the
> > first KVM_RUN on the destination. This is because userspace might
> > save PMCR_EL0 with PMCR_EL0.{C,P} bits set on the source, and
> > restore it on the destination.
>
> This looks good to me. Can you please add the relevant Fixes: tags and
> a Cc: to stable? With that, that'd be a candidate for -rc3, I think.

Thank you for the review!

I posted v2, which addressed the comments above, and the comment
for the patch-2 (remove the line break).

Thank you,
Reiji



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