2024-06-03 11:22:01

by Shivaprasad G Bhat

[permalink] [raw]
Subject: [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes

The series fixes the issues exposed by the kvm-unit-tests[1]
sprs-migration test.

The SDAR, MMCR3 were seen to have some typo/refactoring bugs.
The first two patches fix them.

Though the nestedv2 APIs defined the guest state elements for
Power ISA 3.1B SPRs to save-restore with PHYP during entry-exit,
the DEXCR and HASHKEYR were ignored in code. The KVM_PPC_REG too
for them are missing without which the Qemu is not setting them
to their 'previous' value during guest migration at destination.
The remaining patches take care of this.

References:
[1]: https://github.com/kvm-unit-tests/kvm-unit-tests

---

Shivaprasad G Bhat (6):
KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3
KVM: PPC: Book3S HV: Fix the get_one_reg of SDAR
KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync
KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync
KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register


Documentation/virt/kvm/api.rst | 2 ++
arch/powerpc/include/asm/kvm_host.h | 2 ++
arch/powerpc/include/uapi/asm/kvm.h | 2 ++
arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++++++--
arch/powerpc/kvm/book3s_hv.h | 2 ++
arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++++
tools/arch/powerpc/include/uapi/asm/kvm.h | 2 ++
7 files changed, 36 insertions(+), 2 deletions(-)

--
Signature



2024-06-03 11:22:31

by Shivaprasad G Bhat

[permalink] [raw]
Subject: [PATCH 1/6] KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3

The kvmppc_set_one_reg_hv() wrongly get() the value
instead of set() for MMCR3. Fix the same.

Fixes: 5752fe0b811b ("KVM: PPC: Book3S HV: Save/restore new PMU registers")
Signed-off-by: Shivaprasad G Bhat <[email protected]>
Reviewed-by: Nicholas Piggin <[email protected]>
---
arch/powerpc/kvm/book3s_hv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index daaf7faf21a5..a4f34f94c86f 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2540,7 +2540,7 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
vcpu->arch.mmcrs = set_reg_val(id, *val);
break;
case KVM_REG_PPC_MMCR3:
- *val = get_reg_val(id, vcpu->arch.mmcr[3]);
+ kvmppc_set_mmcr_hv(vcpu, 3, set_reg_val(id, *val));
break;
case KVM_REG_PPC_PMC1 ... KVM_REG_PPC_PMC8:
i = id - KVM_REG_PPC_PMC1;



2024-06-04 05:49:00

by Nicholas Piggin

[permalink] [raw]
Subject: Re: [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes

On Mon Jun 3, 2024 at 9:13 PM AEST, Shivaprasad G Bhat wrote:
> The series fixes the issues exposed by the kvm-unit-tests[1]
> sprs-migration test.
>
> The SDAR, MMCR3 were seen to have some typo/refactoring bugs.
> The first two patches fix them.
>
> Though the nestedv2 APIs defined the guest state elements for
> Power ISA 3.1B SPRs to save-restore with PHYP during entry-exit,
> the DEXCR and HASHKEYR were ignored in code. The KVM_PPC_REG too
> for them are missing without which the Qemu is not setting them
> to their 'previous' value during guest migration at destination.
> The remaining patches take care of this.

These aren't just fixes for nested v2 or even just migration,
by the way. Good fixes.

Thanks,
Nick

>
> References:
> [1]: https://github.com/kvm-unit-tests/kvm-unit-tests
>
> ---
>
> Shivaprasad G Bhat (6):
> KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3
> KVM: PPC: Book3S HV: Fix the get_one_reg of SDAR
> KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync
> KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
> KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync
> KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register
>
>
> Documentation/virt/kvm/api.rst | 2 ++
> arch/powerpc/include/asm/kvm_host.h | 2 ++
> arch/powerpc/include/uapi/asm/kvm.h | 2 ++
> arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++++++--
> arch/powerpc/kvm/book3s_hv.h | 2 ++
> arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++++
> tools/arch/powerpc/include/uapi/asm/kvm.h | 2 ++
> 7 files changed, 36 insertions(+), 2 deletions(-)
>
> --
> Signature