All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
@ 2017-08-25  9:53 ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-08-25  9:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: David Gibson

This adds information about storage keys to the struct returned by
the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
which was zeroed by previous kernel versions.  Thus userspace that
knows about the new fields will see zeroes when running on an older
kernel, indicating that storage keys are not supported.  The size of
the structure has not changed.

The number of keys is hard-coded for the CPUs supported by HV KVM,
which is just POWER7, POWER8 and POWER9.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
This is intended to go in after Ram Pai's patch fixing the H_ENTER
code to not drop the top two bits of the key field.

 arch/powerpc/kvm/book3s_hv.c | 8 ++++++++
 include/uapi/linux/kvm.h     | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 359c79c..3d9b661 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,
 	if (radix_enabled())
 		return -EINVAL;
 
+	/*
+	 * POWER7, POWER8 and POWER9 all support 32 storage keys for data.
+	 * POWER7 doesn't support keys for instruction accesses,
+	 * POWER8 and POWER9 do.
+	 */
+	info->data_keys = 32;
+	info->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0;
+
 	info->flags = KVM_PPC_PAGE_SIZES_REAL;
 	if (mmu_has_feature(MMU_FTR_1T_SEGMENT))
 		info->flags |= KVM_PPC_1T_SEGMENTS;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 6cd63c1..8388875 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {
 struct kvm_ppc_smmu_info {
 	__u64 flags;
 	__u32 slb_size;
-	__u32 pad;
+	__u16 data_keys;	/* # storage keys supported for data */
+	__u16 instr_keys;	/* # storage keys supported for instructions */
 	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
 };
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
@ 2017-08-25  9:53 ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-08-25  9:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: David Gibson

This adds information about storage keys to the struct returned by
the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
which was zeroed by previous kernel versions.  Thus userspace that
knows about the new fields will see zeroes when running on an older
kernel, indicating that storage keys are not supported.  The size of
the structure has not changed.

The number of keys is hard-coded for the CPUs supported by HV KVM,
which is just POWER7, POWER8 and POWER9.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
This is intended to go in after Ram Pai's patch fixing the H_ENTER
code to not drop the top two bits of the key field.

 arch/powerpc/kvm/book3s_hv.c | 8 ++++++++
 include/uapi/linux/kvm.h     | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 359c79c..3d9b661 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,
 	if (radix_enabled())
 		return -EINVAL;
 
+	/*
+	 * POWER7, POWER8 and POWER9 all support 32 storage keys for data.
+	 * POWER7 doesn't support keys for instruction accesses,
+	 * POWER8 and POWER9 do.
+	 */
+	info->data_keys = 32;
+	info->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0;
+
 	info->flags = KVM_PPC_PAGE_SIZES_REAL;
 	if (mmu_has_feature(MMU_FTR_1T_SEGMENT))
 		info->flags |= KVM_PPC_1T_SEGMENTS;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 6cd63c1..8388875 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {
 struct kvm_ppc_smmu_info {
 	__u64 flags;
 	__u32 slb_size;
-	__u32 pad;
+	__u16 data_keys;	/* # storage keys supported for data */
+	__u16 instr_keys;	/* # storage keys supported for instructions */
 	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
  2017-08-25  9:53 ` Paul Mackerras
@ 2017-08-27  3:19   ` David Gibson
  -1 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2017-08-27  3:19 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc

[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:
> This adds information about storage keys to the struct returned by
> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
> which was zeroed by previous kernel versions.  Thus userspace that
> knows about the new fields will see zeroes when running on an older
> kernel, indicating that storage keys are not supported.  The size of
> the structure has not changed.
> 
> The number of keys is hard-coded for the CPUs supported by HV KVM,
> which is just POWER7, POWER8 and POWER9.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> This is intended to go in after Ram Pai's patch fixing the H_ENTER
> code to not drop the top two bits of the key field.
> 
>  arch/powerpc/kvm/book3s_hv.c | 8 ++++++++
>  include/uapi/linux/kvm.h     | 3 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 359c79c..3d9b661 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,
>  	if (radix_enabled())
>  		return -EINVAL;
>  
> +	/*
> +	 * POWER7, POWER8 and POWER9 all support 32 storage keys for data.
> +	 * POWER7 doesn't support keys for instruction accesses,
> +	 * POWER8 and POWER9 do.
> +	 */
> +	info->data_keys = 32;
> +	info->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0;
> +
>  	info->flags = KVM_PPC_PAGE_SIZES_REAL;
>  	if (mmu_has_feature(MMU_FTR_1T_SEGMENT))
>  		info->flags |= KVM_PPC_1T_SEGMENTS;
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 6cd63c1..8388875 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {
>  struct kvm_ppc_smmu_info {
>  	__u64 flags;
>  	__u32 slb_size;
> -	__u32 pad;
> +	__u16 data_keys;	/* # storage keys supported for data */
> +	__u16 instr_keys;	/* # storage keys supported for instructions */
>  	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
>  };
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
@ 2017-08-27  3:19   ` David Gibson
  0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2017-08-27  3:19 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc

[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:
> This adds information about storage keys to the struct returned by
> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
> which was zeroed by previous kernel versions.  Thus userspace that
> knows about the new fields will see zeroes when running on an older
> kernel, indicating that storage keys are not supported.  The size of
> the structure has not changed.
> 
> The number of keys is hard-coded for the CPUs supported by HV KVM,
> which is just POWER7, POWER8 and POWER9.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> This is intended to go in after Ram Pai's patch fixing the H_ENTER
> code to not drop the top two bits of the key field.
> 
>  arch/powerpc/kvm/book3s_hv.c | 8 ++++++++
>  include/uapi/linux/kvm.h     | 3 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 359c79c..3d9b661 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -3325,6 +3325,14 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,
>  	if (radix_enabled())
>  		return -EINVAL;
>  
> +	/*
> +	 * POWER7, POWER8 and POWER9 all support 32 storage keys for data.
> +	 * POWER7 doesn't support keys for instruction accesses,
> +	 * POWER8 and POWER9 do.
> +	 */
> +	info->data_keys = 32;
> +	info->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0;
> +
>  	info->flags = KVM_PPC_PAGE_SIZES_REAL;
>  	if (mmu_has_feature(MMU_FTR_1T_SEGMENT))
>  		info->flags |= KVM_PPC_1T_SEGMENTS;
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 6cd63c1..8388875 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {
>  struct kvm_ppc_smmu_info {
>  	__u64 flags;
>  	__u32 slb_size;
> -	__u32 pad;
> +	__u16 data_keys;	/* # storage keys supported for data */
> +	__u16 instr_keys;	/* # storage keys supported for instructions */
>  	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
>  };
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
  2017-08-25  9:53 ` Paul Mackerras
@ 2017-08-31  3:43   ` Paul Mackerras
  -1 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-08-31  3:43 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: David Gibson

On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:
> This adds information about storage keys to the struct returned by
> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
> which was zeroed by previous kernel versions.  Thus userspace that
> knows about the new fields will see zeroes when running on an older
> kernel, indicating that storage keys are not supported.  The size of
> the structure has not changed.
> 
> The number of keys is hard-coded for the CPUs supported by HV KVM,
> which is just POWER7, POWER8 and POWER9.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Patch applied to my kvm-ppc-next branch.

Paul.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace
@ 2017-08-31  3:43   ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-08-31  3:43 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: David Gibson

On Fri, Aug 25, 2017 at 07:53:39PM +1000, Paul Mackerras wrote:
> This adds information about storage keys to the struct returned by
> the KVM_PPC_GET_SMMU_INFO ioctl.  The new fields replace a pad field,
> which was zeroed by previous kernel versions.  Thus userspace that
> knows about the new fields will see zeroes when running on an older
> kernel, indicating that storage keys are not supported.  The size of
> the structure has not changed.
> 
> The number of keys is hard-coded for the CPUs supported by HV KVM,
> which is just POWER7, POWER8 and POWER9.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Patch applied to my kvm-ppc-next branch.

Paul.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-31  3:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25  9:53 [PATCH] KVM: PPC: Book3S HV: Report storage key support to userspace Paul Mackerras
2017-08-25  9:53 ` Paul Mackerras
2017-08-27  3:19 ` David Gibson
2017-08-27  3:19   ` David Gibson
2017-08-31  3:43 ` Paul Mackerras
2017-08-31  3:43   ` Paul Mackerras

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.