* [PATCH 1/6] KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
@ 2024-06-03 11:14 ` Shivaprasad G Bhat
2024-06-03 11:14 ` [PATCH 2/6] KVM: PPC: Book3S HV: Fix the get_one_reg of SDAR Shivaprasad G Bhat
` (5 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:14 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
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 <sbhat@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
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;
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 2/6] KVM: PPC: Book3S HV: Fix the get_one_reg of SDAR
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
2024-06-03 11:14 ` [PATCH 1/6] KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3 Shivaprasad G Bhat
@ 2024-06-03 11:14 ` Shivaprasad G Bhat
2024-06-03 11:14 ` [PATCH 3/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync Shivaprasad G Bhat
` (4 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:14 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
The kvmppc_get_one_reg_hv() for SDAR is wrongly getting the SIAR
instead of SDAR, possibly a paste error emanating from the previous
refactoring.
Patch fixes the wrong get_one_reg() for the same.
Fixes: ebc88ea7a6ad ("KVM: PPC: Book3S HV: Use accessors for VCPU registers")
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
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 a4f34f94c86f..b576781d58d5 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2305,7 +2305,7 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
*val = get_reg_val(id, kvmppc_get_siar_hv(vcpu));
break;
case KVM_REG_PPC_SDAR:
- *val = get_reg_val(id, kvmppc_get_siar_hv(vcpu));
+ *val = get_reg_val(id, kvmppc_get_sdar_hv(vcpu));
break;
case KVM_REG_PPC_SIER:
*val = get_reg_val(id, kvmppc_get_sier_hv(vcpu, 0));
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 3/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
2024-06-03 11:14 ` [PATCH 1/6] KVM: PPC: Book3S HV: Fix the set_one_reg for MMCR3 Shivaprasad G Bhat
2024-06-03 11:14 ` [PATCH 2/6] KVM: PPC: Book3S HV: Fix the get_one_reg of SDAR Shivaprasad G Bhat
@ 2024-06-03 11:14 ` Shivaprasad G Bhat
2024-06-04 5:46 ` Nicholas Piggin
2024-06-03 11:14 ` [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register Shivaprasad G Bhat
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:14 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
The nestedv2 APIs has the guest state element defined for DEXCR
for the save-restore with L0. However, its ignored in the code.
The patch takes care of this for the DEXCR GSID.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
arch/powerpc/include/asm/kvm_host.h | 1 +
arch/powerpc/kvm/book3s_hv.h | 1 +
arch/powerpc/kvm/book3s_hv_nestedv2.c | 6 ++++++
3 files changed, 8 insertions(+)
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 8abac532146e..1e2fdcbecffd 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -599,6 +599,7 @@ struct kvm_vcpu_arch {
ulong dawrx0;
ulong dawr1;
ulong dawrx1;
+ ulong dexcr;
ulong ciabr;
ulong cfar;
ulong ppr;
diff --git a/arch/powerpc/kvm/book3s_hv.h b/arch/powerpc/kvm/book3s_hv.h
index 47b2c815641e..7b0fd282fe95 100644
--- a/arch/powerpc/kvm/book3s_hv.h
+++ b/arch/powerpc/kvm/book3s_hv.h
@@ -116,6 +116,7 @@ KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr0, 64, KVMPPC_GSID_DAWR0)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64, KVMPPC_GSID_DAWR1)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64, KVMPPC_GSID_DAWRX0)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64, KVMPPC_GSID_DAWRX1)
+KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dexcr, 64, KVMPPC_GSID_DEXCR)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64, KVMPPC_GSID_CIABR)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64, KVMPPC_GSID_WORT)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64, KVMPPC_GSID_PPR)
diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c
index 1091f7a83b25..d207a6d936ff 100644
--- a/arch/powerpc/kvm/book3s_hv_nestedv2.c
+++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c
@@ -193,6 +193,9 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,
case KVMPPC_GSID_DAWRX1:
rc = kvmppc_gse_put_u32(gsb, iden, vcpu->arch.dawrx1);
break;
+ case KVMPPC_GSID_DEXCR:
+ rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.dexcr);
+ break;
case KVMPPC_GSID_CIABR:
rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.ciabr);
break;
@@ -441,6 +444,9 @@ static int gs_msg_ops_vcpu_refresh_info(struct kvmppc_gs_msg *gsm,
case KVMPPC_GSID_DAWRX1:
vcpu->arch.dawrx1 = kvmppc_gse_get_u32(gse);
break;
+ case KVMPPC_GSID_DEXCR:
+ vcpu->arch.dexcr = kvmppc_gse_get_u64(gse);
+ break;
case KVMPPC_GSID_CIABR:
vcpu->arch.ciabr = kvmppc_gse_get_u64(gse);
break;
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 3/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync
2024-06-03 11:14 ` [PATCH 3/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync Shivaprasad G Bhat
@ 2024-06-04 5:46 ` Nicholas Piggin
0 siblings, 0 replies; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 5:46 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On Mon Jun 3, 2024 at 9:14 PM AEST, Shivaprasad G Bhat wrote:
> The nestedv2 APIs has the guest state element defined for DEXCR
> for the save-restore with L0. However, its ignored in the code.
>
> The patch takes care of this for the DEXCR GSID.
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_host.h | 1 +
> arch/powerpc/kvm/book3s_hv.h | 1 +
> arch/powerpc/kvm/book3s_hv_nestedv2.c | 6 ++++++
> 3 files changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 8abac532146e..1e2fdcbecffd 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -599,6 +599,7 @@ struct kvm_vcpu_arch {
> ulong dawrx0;
> ulong dawr1;
> ulong dawrx1;
> + ulong dexcr;
> ulong ciabr;
> ulong cfar;
> ulong ppr;
Actually I would reorder the patches so you introduce the KVM reg
first, and put this hunk there.
The nested v2 bits look okay. For them,
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
> diff --git a/arch/powerpc/kvm/book3s_hv.h b/arch/powerpc/kvm/book3s_hv.h
> index 47b2c815641e..7b0fd282fe95 100644
> --- a/arch/powerpc/kvm/book3s_hv.h
> +++ b/arch/powerpc/kvm/book3s_hv.h
> @@ -116,6 +116,7 @@ KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr0, 64, KVMPPC_GSID_DAWR0)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64, KVMPPC_GSID_DAWR1)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64, KVMPPC_GSID_DAWRX0)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64, KVMPPC_GSID_DAWRX1)
> +KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dexcr, 64, KVMPPC_GSID_DEXCR)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64, KVMPPC_GSID_CIABR)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64, KVMPPC_GSID_WORT)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64, KVMPPC_GSID_PPR)
> diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c
> index 1091f7a83b25..d207a6d936ff 100644
> --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c
> +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c
> @@ -193,6 +193,9 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,
> case KVMPPC_GSID_DAWRX1:
> rc = kvmppc_gse_put_u32(gsb, iden, vcpu->arch.dawrx1);
> break;
> + case KVMPPC_GSID_DEXCR:
> + rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.dexcr);
> + break;
> case KVMPPC_GSID_CIABR:
> rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.ciabr);
> break;
> @@ -441,6 +444,9 @@ static int gs_msg_ops_vcpu_refresh_info(struct kvmppc_gs_msg *gsm,
> case KVMPPC_GSID_DAWRX1:
> vcpu->arch.dawrx1 = kvmppc_gse_get_u32(gse);
> break;
> + case KVMPPC_GSID_DEXCR:
> + vcpu->arch.dexcr = kvmppc_gse_get_u64(gse);
> + break;
> case KVMPPC_GSID_CIABR:
> vcpu->arch.ciabr = kvmppc_gse_get_u64(gse);
> break;
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
` (2 preceding siblings ...)
2024-06-03 11:14 ` [PATCH 3/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest DEXCR in sync Shivaprasad G Bhat
@ 2024-06-03 11:14 ` Shivaprasad G Bhat
2024-06-04 5:43 ` Nicholas Piggin
2024-06-04 11:26 ` Michael Ellerman
2024-06-03 11:14 ` [PATCH 5/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync Shivaprasad G Bhat
` (2 subsequent siblings)
6 siblings, 2 replies; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:14 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
The patch adds a one-reg register identifier which can be used to
read and set the DEXCR for the guest during enter/exit with
KVM_REG_PPC_DEXCR. The specific SPR KVM API documentation
too updated.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
Documentation/virt/kvm/api.rst | 1 +
arch/powerpc/include/uapi/asm/kvm.h | 1 +
arch/powerpc/kvm/book3s_hv.c | 6 ++++++
tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
4 files changed, 9 insertions(+)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index a71d91978d9e..81077c654281 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -2441,6 +2441,7 @@ registers, find a list below:
PPC KVM_REG_PPC_PTCR 64
PPC KVM_REG_PPC_DAWR1 64
PPC KVM_REG_PPC_DAWRX1 64
+ PPC KVM_REG_PPC_DEXCR 64
PPC KVM_REG_PPC_TM_GPR0 64
...
PPC KVM_REG_PPC_TM_GPR31 64
diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
index 1691297a766a..fcb947f65667 100644
--- a/arch/powerpc/include/uapi/asm/kvm.h
+++ b/arch/powerpc/include/uapi/asm/kvm.h
@@ -645,6 +645,7 @@ struct kvm_ppc_cpu_char {
#define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3)
#define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
#define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
+#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
/* Transactional Memory checkpointed state:
* This is all GPRs, all VSX regs and a subset of SPRs
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index b576781d58d5..1294c6839d37 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2349,6 +2349,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
case KVM_REG_PPC_DAWRX1:
*val = get_reg_val(id, kvmppc_get_dawrx1_hv(vcpu));
break;
+ case KVM_REG_PPC_DEXCR:
+ *val = get_reg_val(id, kvmppc_get_dexcr_hv(vcpu));
+ break;
case KVM_REG_PPC_CIABR:
*val = get_reg_val(id, kvmppc_get_ciabr_hv(vcpu));
break;
@@ -2592,6 +2595,9 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
case KVM_REG_PPC_DAWRX1:
kvmppc_set_dawrx1_hv(vcpu, set_reg_val(id, *val) & ~DAWRX_HYP);
break;
+ case KVM_REG_PPC_DEXCR:
+ kvmppc_set_dexcr_hv(vcpu, set_reg_val(id, *val));
+ break;
case KVM_REG_PPC_CIABR:
kvmppc_set_ciabr_hv(vcpu, set_reg_val(id, *val));
/* Don't allow setting breakpoints in hypervisor code */
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
index 1691297a766a..fcb947f65667 100644
--- a/tools/arch/powerpc/include/uapi/asm/kvm.h
+++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
@@ -645,6 +645,7 @@ struct kvm_ppc_cpu_char {
#define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3)
#define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
#define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
+#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
/* Transactional Memory checkpointed state:
* This is all GPRs, all VSX regs and a subset of SPRs
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
2024-06-03 11:14 ` [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register Shivaprasad G Bhat
@ 2024-06-04 5:43 ` Nicholas Piggin
2024-06-04 11:29 ` Michael Ellerman
2024-06-04 11:26 ` Michael Ellerman
1 sibling, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 5:43 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On Mon Jun 3, 2024 at 9:14 PM AEST, Shivaprasad G Bhat wrote:
> The patch adds a one-reg register identifier which can be used to
> read and set the DEXCR for the guest during enter/exit with
> KVM_REG_PPC_DEXCR. The specific SPR KVM API documentation
> too updated.
I wonder if the uapi and documentation parts should go in their
own patch in a ppc kvm uapi topic branch? Otherwise looks okay.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> Documentation/virt/kvm/api.rst | 1 +
> arch/powerpc/include/uapi/asm/kvm.h | 1 +
> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
> tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
> 4 files changed, 9 insertions(+)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index a71d91978d9e..81077c654281 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -2441,6 +2441,7 @@ registers, find a list below:
> PPC KVM_REG_PPC_PTCR 64
> PPC KVM_REG_PPC_DAWR1 64
> PPC KVM_REG_PPC_DAWRX1 64
> + PPC KVM_REG_PPC_DEXCR 64
> PPC KVM_REG_PPC_TM_GPR0 64
> ...
> PPC KVM_REG_PPC_TM_GPR31 64
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index 1691297a766a..fcb947f65667 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -645,6 +645,7 @@ struct kvm_ppc_cpu_char {
> #define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3)
> #define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
> #define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
> +#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
>
> /* Transactional Memory checkpointed state:
> * This is all GPRs, all VSX regs and a subset of SPRs
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index b576781d58d5..1294c6839d37 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -2349,6 +2349,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
> case KVM_REG_PPC_DAWRX1:
> *val = get_reg_val(id, kvmppc_get_dawrx1_hv(vcpu));
> break;
> + case KVM_REG_PPC_DEXCR:
> + *val = get_reg_val(id, kvmppc_get_dexcr_hv(vcpu));
> + break;
> case KVM_REG_PPC_CIABR:
> *val = get_reg_val(id, kvmppc_get_ciabr_hv(vcpu));
> break;
> @@ -2592,6 +2595,9 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
> case KVM_REG_PPC_DAWRX1:
> kvmppc_set_dawrx1_hv(vcpu, set_reg_val(id, *val) & ~DAWRX_HYP);
> break;
> + case KVM_REG_PPC_DEXCR:
> + kvmppc_set_dexcr_hv(vcpu, set_reg_val(id, *val));
> + break;
> case KVM_REG_PPC_CIABR:
> kvmppc_set_ciabr_hv(vcpu, set_reg_val(id, *val));
> /* Don't allow setting breakpoints in hypervisor code */
> diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
> index 1691297a766a..fcb947f65667 100644
> --- a/tools/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
> @@ -645,6 +645,7 @@ struct kvm_ppc_cpu_char {
> #define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3)
> #define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
> #define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
> +#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
>
> /* Transactional Memory checkpointed state:
> * This is all GPRs, all VSX regs and a subset of SPRs
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
2024-06-04 5:43 ` Nicholas Piggin
@ 2024-06-04 11:29 ` Michael Ellerman
0 siblings, 0 replies; 16+ messages in thread
From: Michael Ellerman @ 2024-06-04 11:29 UTC (permalink / raw)
To: Nicholas Piggin, Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, jniethe5, linux-kernel, namhyung, naveen.n.rao,
pbonzini
"Nicholas Piggin" <npiggin@gmail.com> writes:
> On Mon Jun 3, 2024 at 9:14 PM AEST, Shivaprasad G Bhat wrote:
>> The patch adds a one-reg register identifier which can be used to
>> read and set the DEXCR for the guest during enter/exit with
>> KVM_REG_PPC_DEXCR. The specific SPR KVM API documentation
>> too updated.
>
> I wonder if the uapi and documentation parts should go in their
> own patch in a ppc kvm uapi topic branch?
I'll put the whole series in the topic/ppc-kvm branch, which I think is
probably sufficient.
cheers
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register
2024-06-03 11:14 ` [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register Shivaprasad G Bhat
2024-06-04 5:43 ` Nicholas Piggin
@ 2024-06-04 11:26 ` Michael Ellerman
1 sibling, 0 replies; 16+ messages in thread
From: Michael Ellerman @ 2024-06-04 11:26 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, jniethe5, linux-kernel, npiggin,
namhyung, naveen.n.rao, pbonzini
Shivaprasad G Bhat <sbhat@linux.ibm.com> writes:
> The patch adds a one-reg register identifier which can be used to
> read and set the DEXCR for the guest during enter/exit with
> KVM_REG_PPC_DEXCR. The specific SPR KVM API documentation
> too updated.
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> Documentation/virt/kvm/api.rst | 1 +
> arch/powerpc/include/uapi/asm/kvm.h | 1 +
> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
> tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
Headers under tools/ are not supposed to be updated directly, they're
synced later by the perf developers.
See: https://lore.kernel.org/all/ZlYxAdHjyAkvGtMW@x1/
cheers
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
` (3 preceding siblings ...)
2024-06-03 11:14 ` [PATCH 4/6] KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register Shivaprasad G Bhat
@ 2024-06-03 11:14 ` Shivaprasad G Bhat
2024-06-04 5:46 ` Nicholas Piggin
2024-06-03 11:15 ` [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register Shivaprasad G Bhat
2024-06-04 5:48 ` [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Nicholas Piggin
6 siblings, 1 reply; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:14 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
The nestedv2 APIs has the guest state element defined for HASHKEYR for
the save-restore with L0. However, its ignored in the code.
The patch takes care of this for the HASHKEYR GSID.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
arch/powerpc/include/asm/kvm_host.h | 1 +
arch/powerpc/kvm/book3s_hv.h | 1 +
arch/powerpc/kvm/book3s_hv_nestedv2.c | 6 ++++++
3 files changed, 8 insertions(+)
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 1e2fdcbecffd..a0cd9dbf534f 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -600,6 +600,7 @@ struct kvm_vcpu_arch {
ulong dawr1;
ulong dawrx1;
ulong dexcr;
+ ulong hashkeyr;
ulong ciabr;
ulong cfar;
ulong ppr;
diff --git a/arch/powerpc/kvm/book3s_hv.h b/arch/powerpc/kvm/book3s_hv.h
index 7b0fd282fe95..c073fdfa7dc4 100644
--- a/arch/powerpc/kvm/book3s_hv.h
+++ b/arch/powerpc/kvm/book3s_hv.h
@@ -117,6 +117,7 @@ KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64, KVMPPC_GSID_DAWR1)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64, KVMPPC_GSID_DAWRX0)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64, KVMPPC_GSID_DAWRX1)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dexcr, 64, KVMPPC_GSID_DEXCR)
+KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(hashkeyr, 64, KVMPPC_GSID_HASHKEYR)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64, KVMPPC_GSID_CIABR)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64, KVMPPC_GSID_WORT)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64, KVMPPC_GSID_PPR)
diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c
index d207a6d936ff..bbff933f2ccc 100644
--- a/arch/powerpc/kvm/book3s_hv_nestedv2.c
+++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c
@@ -196,6 +196,9 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,
case KVMPPC_GSID_DEXCR:
rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.dexcr);
break;
+ case KVMPPC_GSID_HASHKEYR:
+ rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.hashkeyr);
+ break;
case KVMPPC_GSID_CIABR:
rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.ciabr);
break;
@@ -447,6 +450,9 @@ static int gs_msg_ops_vcpu_refresh_info(struct kvmppc_gs_msg *gsm,
case KVMPPC_GSID_DEXCR:
vcpu->arch.dexcr = kvmppc_gse_get_u64(gse);
break;
+ case KVMPPC_GSID_HASHKEYR:
+ vcpu->arch.hashkeyr = kvmppc_gse_get_u64(gse);
+ break;
case KVMPPC_GSID_CIABR:
vcpu->arch.ciabr = kvmppc_gse_get_u64(gse);
break;
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 5/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync
2024-06-03 11:14 ` [PATCH 5/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync Shivaprasad G Bhat
@ 2024-06-04 5:46 ` Nicholas Piggin
0 siblings, 0 replies; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 5:46 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On Mon Jun 3, 2024 at 9:14 PM AEST, Shivaprasad G Bhat wrote:
> The nestedv2 APIs has the guest state element defined for HASHKEYR for
> the save-restore with L0. However, its ignored in the code.
>
> The patch takes care of this for the HASHKEYR GSID.
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_host.h | 1 +
> arch/powerpc/kvm/book3s_hv.h | 1 +
> arch/powerpc/kvm/book3s_hv_nestedv2.c | 6 ++++++
> 3 files changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 1e2fdcbecffd..a0cd9dbf534f 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -600,6 +600,7 @@ struct kvm_vcpu_arch {
> ulong dawr1;
> ulong dawrx1;
> ulong dexcr;
> + ulong hashkeyr;
> ulong ciabr;
> ulong cfar;
> ulong ppr;
Same comment applies
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Thanks,
Nick
> diff --git a/arch/powerpc/kvm/book3s_hv.h b/arch/powerpc/kvm/book3s_hv.h
> index 7b0fd282fe95..c073fdfa7dc4 100644
> --- a/arch/powerpc/kvm/book3s_hv.h
> +++ b/arch/powerpc/kvm/book3s_hv.h
> @@ -117,6 +117,7 @@ KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64, KVMPPC_GSID_DAWR1)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64, KVMPPC_GSID_DAWRX0)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64, KVMPPC_GSID_DAWRX1)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dexcr, 64, KVMPPC_GSID_DEXCR)
> +KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(hashkeyr, 64, KVMPPC_GSID_HASHKEYR)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64, KVMPPC_GSID_CIABR)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64, KVMPPC_GSID_WORT)
> KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64, KVMPPC_GSID_PPR)
> diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c
> index d207a6d936ff..bbff933f2ccc 100644
> --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c
> +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c
> @@ -196,6 +196,9 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb,
> case KVMPPC_GSID_DEXCR:
> rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.dexcr);
> break;
> + case KVMPPC_GSID_HASHKEYR:
> + rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.hashkeyr);
> + break;
> case KVMPPC_GSID_CIABR:
> rc = kvmppc_gse_put_u64(gsb, iden, vcpu->arch.ciabr);
> break;
> @@ -447,6 +450,9 @@ static int gs_msg_ops_vcpu_refresh_info(struct kvmppc_gs_msg *gsm,
> case KVMPPC_GSID_DEXCR:
> vcpu->arch.dexcr = kvmppc_gse_get_u64(gse);
> break;
> + case KVMPPC_GSID_HASHKEYR:
> + vcpu->arch.hashkeyr = kvmppc_gse_get_u64(gse);
> + break;
> case KVMPPC_GSID_CIABR:
> vcpu->arch.ciabr = kvmppc_gse_get_u64(gse);
> break;
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
` (4 preceding siblings ...)
2024-06-03 11:14 ` [PATCH 5/6] KVM: PPC: Book3S HV nestedv2: Keep nested guest HASHKEYR in sync Shivaprasad G Bhat
@ 2024-06-03 11:15 ` Shivaprasad G Bhat
2024-06-04 5:43 ` Nicholas Piggin
2024-06-04 6:07 ` Nicholas Piggin
2024-06-04 5:48 ` [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Nicholas Piggin
6 siblings, 2 replies; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-03 11:15 UTC (permalink / raw)
To: kvm, linux-doc, linuxppc-dev
Cc: atrajeev, sbhat, corbet, linux-kernel, npiggin, namhyung,
naveen.n.rao, pbonzini, jniethe5
The patch adds a one-reg register identifier which can be used to
read and set the virtual HASHKEYR for the guest during enter/exit
with KVM_REG_PPC_HASHKEYR. The specific SPR KVM API documentation
too updated.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
Documentation/virt/kvm/api.rst | 1 +
arch/powerpc/include/uapi/asm/kvm.h | 1 +
arch/powerpc/kvm/book3s_hv.c | 6 ++++++
tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
4 files changed, 9 insertions(+)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 81077c654281..0c22cb4196d8 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -2439,6 +2439,7 @@ registers, find a list below:
PPC KVM_REG_PPC_PSSCR 64
PPC KVM_REG_PPC_DEC_EXPIRY 64
PPC KVM_REG_PPC_PTCR 64
+ PPC KVM_REG_PPC_HASHKEYR 64
PPC KVM_REG_PPC_DAWR1 64
PPC KVM_REG_PPC_DAWRX1 64
PPC KVM_REG_PPC_DEXCR 64
diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
index fcb947f65667..23a0af739c78 100644
--- a/arch/powerpc/include/uapi/asm/kvm.h
+++ b/arch/powerpc/include/uapi/asm/kvm.h
@@ -646,6 +646,7 @@ struct kvm_ppc_cpu_char {
#define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
#define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
+#define KVM_REG_PPC_HASHKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc7)
/* Transactional Memory checkpointed state:
* This is all GPRs, all VSX regs and a subset of SPRs
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 1294c6839d37..ccc9564c5a31 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2352,6 +2352,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
case KVM_REG_PPC_DEXCR:
*val = get_reg_val(id, kvmppc_get_dexcr_hv(vcpu));
break;
+ case KVM_REG_PPC_HASHKEYR:
+ *val = get_reg_val(id, kvmppc_get_hashkeyr_hv(vcpu));
+ break;
case KVM_REG_PPC_CIABR:
*val = get_reg_val(id, kvmppc_get_ciabr_hv(vcpu));
break;
@@ -2598,6 +2601,9 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
case KVM_REG_PPC_DEXCR:
kvmppc_set_dexcr_hv(vcpu, set_reg_val(id, *val));
break;
+ case KVM_REG_PPC_HASHKEYR:
+ kvmppc_set_hashkeyr_hv(vcpu, set_reg_val(id, *val));
+ break;
case KVM_REG_PPC_CIABR:
kvmppc_set_ciabr_hv(vcpu, set_reg_val(id, *val));
/* Don't allow setting breakpoints in hypervisor code */
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
index fcb947f65667..23a0af739c78 100644
--- a/tools/arch/powerpc/include/uapi/asm/kvm.h
+++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
@@ -646,6 +646,7 @@ struct kvm_ppc_cpu_char {
#define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
#define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
+#define KVM_REG_PPC_HASHKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc7)
/* Transactional Memory checkpointed state:
* This is all GPRs, all VSX regs and a subset of SPRs
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register
2024-06-03 11:15 ` [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register Shivaprasad G Bhat
@ 2024-06-04 5:43 ` Nicholas Piggin
2024-06-04 6:07 ` Nicholas Piggin
1 sibling, 0 replies; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 5:43 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On Mon Jun 3, 2024 at 9:15 PM AEST, Shivaprasad G Bhat wrote:
> The patch adds a one-reg register identifier which can be used to
> read and set the virtual HASHKEYR for the guest during enter/exit
> with KVM_REG_PPC_HASHKEYR. The specific SPR KVM API documentation
> too updated.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> Documentation/virt/kvm/api.rst | 1 +
> arch/powerpc/include/uapi/asm/kvm.h | 1 +
> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
> tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
> 4 files changed, 9 insertions(+)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index 81077c654281..0c22cb4196d8 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -2439,6 +2439,7 @@ registers, find a list below:
> PPC KVM_REG_PPC_PSSCR 64
> PPC KVM_REG_PPC_DEC_EXPIRY 64
> PPC KVM_REG_PPC_PTCR 64
> + PPC KVM_REG_PPC_HASHKEYR 64
> PPC KVM_REG_PPC_DAWR1 64
> PPC KVM_REG_PPC_DAWRX1 64
> PPC KVM_REG_PPC_DEXCR 64
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index fcb947f65667..23a0af739c78 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -646,6 +646,7 @@ struct kvm_ppc_cpu_char {
> #define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
> #define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
> #define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
> +#define KVM_REG_PPC_HASHKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc7)
>
> /* Transactional Memory checkpointed state:
> * This is all GPRs, all VSX regs and a subset of SPRs
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 1294c6839d37..ccc9564c5a31 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -2352,6 +2352,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
> case KVM_REG_PPC_DEXCR:
> *val = get_reg_val(id, kvmppc_get_dexcr_hv(vcpu));
> break;
> + case KVM_REG_PPC_HASHKEYR:
> + *val = get_reg_val(id, kvmppc_get_hashkeyr_hv(vcpu));
> + break;
> case KVM_REG_PPC_CIABR:
> *val = get_reg_val(id, kvmppc_get_ciabr_hv(vcpu));
> break;
> @@ -2598,6 +2601,9 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
> case KVM_REG_PPC_DEXCR:
> kvmppc_set_dexcr_hv(vcpu, set_reg_val(id, *val));
> break;
> + case KVM_REG_PPC_HASHKEYR:
> + kvmppc_set_hashkeyr_hv(vcpu, set_reg_val(id, *val));
> + break;
> case KVM_REG_PPC_CIABR:
> kvmppc_set_ciabr_hv(vcpu, set_reg_val(id, *val));
> /* Don't allow setting breakpoints in hypervisor code */
> diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
> index fcb947f65667..23a0af739c78 100644
> --- a/tools/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
> @@ -646,6 +646,7 @@ struct kvm_ppc_cpu_char {
> #define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
> #define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
> #define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
> +#define KVM_REG_PPC_HASHKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc7)
>
> /* Transactional Memory checkpointed state:
> * This is all GPRs, all VSX regs and a subset of SPRs
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register
2024-06-03 11:15 ` [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register Shivaprasad G Bhat
2024-06-04 5:43 ` Nicholas Piggin
@ 2024-06-04 6:07 ` Nicholas Piggin
2024-06-05 13:13 ` Shivaprasad G Bhat
1 sibling, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 6:07 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On Mon Jun 3, 2024 at 9:15 PM AEST, Shivaprasad G Bhat wrote:
> The patch adds a one-reg register identifier which can be used to
> read and set the virtual HASHKEYR for the guest during enter/exit
> with KVM_REG_PPC_HASHKEYR. The specific SPR KVM API documentation
> too updated.
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> Documentation/virt/kvm/api.rst | 1 +
> arch/powerpc/include/uapi/asm/kvm.h | 1 +
> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
> tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
> 4 files changed, 9 insertions(+)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index 81077c654281..0c22cb4196d8 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -2439,6 +2439,7 @@ registers, find a list below:
> PPC KVM_REG_PPC_PSSCR 64
> PPC KVM_REG_PPC_DEC_EXPIRY 64
> PPC KVM_REG_PPC_PTCR 64
> + PPC KVM_REG_PPC_HASHKEYR 64
Just looking at the QEMU side of this change made me think... AFAIKS
we need to also set and get and migrate the HASHPKEY SPR.
The hashst/hashchk test cases might be "working" by chance if the SPR
is always zero :/
Thanks,
Nick
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register
2024-06-04 6:07 ` Nicholas Piggin
@ 2024-06-05 13:13 ` Shivaprasad G Bhat
0 siblings, 0 replies; 16+ messages in thread
From: Shivaprasad G Bhat @ 2024-06-05 13:13 UTC (permalink / raw)
To: Nicholas Piggin, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
On 6/4/24 11:37, Nicholas Piggin wrote:
> On Mon Jun 3, 2024 at 9:15 PM AEST, Shivaprasad G Bhat wrote:
>> The patch adds a one-reg register identifier which can be used to
>> read and set the virtual HASHKEYR for the guest during enter/exit
>> with KVM_REG_PPC_HASHKEYR. The specific SPR KVM API documentation
>> too updated.
>>
>> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
>> ---
>> Documentation/virt/kvm/api.rst | 1 +
>> arch/powerpc/include/uapi/asm/kvm.h | 1 +
>> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
>> tools/arch/powerpc/include/uapi/asm/kvm.h | 1 +
>> 4 files changed, 9 insertions(+)
>>
>> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
>> index 81077c654281..0c22cb4196d8 100644
>> --- a/Documentation/virt/kvm/api.rst
>> +++ b/Documentation/virt/kvm/api.rst
>> @@ -2439,6 +2439,7 @@ registers, find a list below:
>> PPC KVM_REG_PPC_PSSCR 64
>> PPC KVM_REG_PPC_DEC_EXPIRY 64
>> PPC KVM_REG_PPC_PTCR 64
>> + PPC KVM_REG_PPC_HASHKEYR 64
> Just looking at the QEMU side of this change made me think... AFAIKS
> we need to also set and get and migrate the HASHPKEY SPR.
Thanks Nick. I have posted the v2 with changes for HASHPKEYR
and your other suggestions at
171759276071.1480.9356137231993600304.stgit@linux.ibm.com
Regards,
Shivaprasad
>
> The hashst/hashchk test cases might be "working" by chance if the SPR
> is always zero :/
>
> Thanks,
> Nick
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes
2024-06-03 11:13 [PATCH 0/6] KVM: PPC: Book3S HV: Nested guest migration fixes Shivaprasad G Bhat
` (5 preceding siblings ...)
2024-06-03 11:15 ` [PATCH 6/6] KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register Shivaprasad G Bhat
@ 2024-06-04 5:48 ` Nicholas Piggin
6 siblings, 0 replies; 16+ messages in thread
From: Nicholas Piggin @ 2024-06-04 5:48 UTC (permalink / raw)
To: Shivaprasad G Bhat, kvm, linux-doc, linuxppc-dev
Cc: atrajeev, corbet, linux-kernel, namhyung, naveen.n.rao, pbonzini,
jniethe5
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
^ permalink raw reply [flat|nested] 16+ messages in thread