linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD
@ 2020-05-13 22:39 Babu Moger
  2020-05-13 22:44 ` Dave Hansen
  2020-05-23 12:21 ` Borislav Petkov
  0 siblings, 2 replies; 4+ messages in thread
From: Babu Moger @ 2020-05-13 22:39 UTC (permalink / raw)
  To: corbet, tglx, mingo, bp, hpa, pbonzini, sean.j.christopherson
  Cc: x86, vkuznets, wanpengli, jmattson, joro, dave.hansen, luto,
	peterz, mchehab+samsung, babu.moger, changbin.du, namit, bigeasy,
	yang.shi, asteinhauser, anshuman.khandual, jan.kiszka, akpm,
	steven.price, rppt, peterx, dan.j.williams, arjunroy, logang,
	thellstrom, aarcange, justin.he, robin.murphy, ira.weiny,
	keescook, jgross, andrew.cooper3, pawan.kumar.gupta, fenghua.yu,
	vineela.tummalapalli, yamada.masahiro, sam, acme, linux-doc,
	linux-kernel, kvm

AMD's next generation of EPYC processors support the MPK (Memory
Protection Keys) feature.

Add a generic X86_MEMORY_PROTECTION_KEYS config shadowing
X86_INTEL_MEMORY_PROTECTION_KEYS and update the kernel
documentation.

No functional changes.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v5:
 - Just submiting the first config update patch. Paulo said he already queued
   patch 2 & 3.
 - This patch addresses the few text changes suggested by Dave Hansen.

v4:
https://lore.kernel.org/lkml/158932780954.44260.4292038705292213548.stgit@naples-babu.amd.com/
- Removed all the source changes related to config parameter.
    Just kept the doc cahnges and add new config parameter
    X86_MEMORY_PROTECTION_KEYS which shadows X86_INTEL_MEMORY_PROTECTION_KEYS.
 - Minor change in feature detection in kvm/cpuid.c 

v3:
  https://lore.kernel.org/lkml/158923982830.20128.14580309786525588408.stgit@naples-babu.amd.com/#r
  - Fixed the problem Jim Mattson pointed out which can cause pkru
    resources to get corrupted during host and guest switches. 
  - Moved the PKU feature detection code from VMX.c to common code.
  
v2:
  https://lore.kernel.org/lkml/158897190718.22378.3974700869904223395.stgit@naples-babu.amd.com/
  - Introduced intermediate config option X86_MEMORY_PROTECTION_KEYS to
    avoid user propmpts. Kept X86_INTEL_MEMORY_PROTECTION_KEYS as is.
    Eventually, we will be moving to X86_MEMORY_PROTECTION_KEYS after
    couple of kernel revisions. 
  - Moved pkru data structures to kvm_vcpu_arch. Moved save/restore pkru
    to kvm_load_host_xsave_state/kvm_load_guest_xsave_state.

v1:
  https://lore.kernel.org/lkml/158880240546.11615.2219410169137148044.stgit@naples-babu.amd.com/


 Documentation/core-api/protection-keys.rst |    5 +++--
 arch/x86/Kconfig                           |   11 +++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Documentation/core-api/protection-keys.rst b/Documentation/core-api/protection-keys.rst
index 49d9833af871..ec575e72d0b2 100644
--- a/Documentation/core-api/protection-keys.rst
+++ b/Documentation/core-api/protection-keys.rst
@@ -5,8 +5,9 @@ Memory Protection Keys
 ======================
 
 Memory Protection Keys for Userspace (PKU aka PKEYs) is a feature
-which is found on Intel's Skylake "Scalable Processor" Server CPUs.
-It will be avalable in future non-server parts.
+which is found on Intel's Skylake (and later) "Scalable Processor"
+Server CPUs. It will be available in future non-server Intel parts
+and future AMD processors.
 
 For anyone wishing to test or use this feature, it is available in
 Amazon's EC2 C5 instances and is known to work there using an Ubuntu
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1197b5596d5a..6b7303ccc1dd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1887,10 +1887,10 @@ config X86_UMIP
 	  results are dummy.
 
 config X86_INTEL_MEMORY_PROTECTION_KEYS
-	prompt "Intel Memory Protection Keys"
+	prompt "Memory Protection Keys"
 	def_bool y
 	# Note: only available in 64-bit mode
-	depends on CPU_SUP_INTEL && X86_64
+	depends on X86_64 && (CPU_SUP_INTEL || CPU_SUP_AMD)
 	select ARCH_USES_HIGH_VMA_FLAGS
 	select ARCH_HAS_PKEYS
 	---help---
@@ -1902,6 +1902,13 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS
 
 	  If unsure, say y.
 
+config X86_MEMORY_PROTECTION_KEYS
+	# Set the "INTEL_"-free option whenever the "INTEL_" one is set.
+	# The "INTEL_" one should be removed and replaced by this option
+	# after 5.10. This avoids exposing most 'oldconfig' users to this
+	# churn.
+	def_bool X86_INTEL_MEMORY_PROTECTION_KEYS
+
 choice
 	prompt "TSX enable mode"
 	depends on CPU_SUP_INTEL


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

* Re: [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD
  2020-05-13 22:39 [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD Babu Moger
@ 2020-05-13 22:44 ` Dave Hansen
  2020-05-23 12:21 ` Borislav Petkov
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2020-05-13 22:44 UTC (permalink / raw)
  To: Babu Moger, corbet, tglx, mingo, bp, hpa, pbonzini,
	sean.j.christopherson
  Cc: x86, vkuznets, wanpengli, jmattson, joro, dave.hansen, luto,
	peterz, mchehab+samsung, changbin.du, namit, bigeasy, yang.shi,
	asteinhauser, anshuman.khandual, jan.kiszka, akpm, steven.price,
	rppt, peterx, dan.j.williams, arjunroy, logang, thellstrom,
	aarcange, justin.he, robin.murphy, ira.weiny, keescook, jgross,
	andrew.cooper3, pawan.kumar.gupta, fenghua.yu,
	vineela.tummalapalli, yamada.masahiro, sam, acme, linux-doc,
	linux-kernel, kvm

On 5/13/20 3:39 PM, Babu Moger wrote:
> AMD's next generation of EPYC processors support the MPK (Memory
> Protection Keys) feature.
> 
> Add a generic X86_MEMORY_PROTECTION_KEYS config shadowing
> X86_INTEL_MEMORY_PROTECTION_KEYS and update the kernel
> documentation.
> 
> No functional changes.

Thanks for making all those changes:

Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>

BTW, I'd certainly classify the dependency change as a functional
change.  I usually save the "No functional changes" blurb for where
literally no effect should be noticeable.  The folks that don't set
CPU_SUP_INTEL will obviously see a functional change here!

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

* Re: [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD
  2020-05-13 22:39 [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD Babu Moger
  2020-05-13 22:44 ` Dave Hansen
@ 2020-05-23 12:21 ` Borislav Petkov
  2020-05-26 15:33   ` Dave Hansen
  1 sibling, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2020-05-23 12:21 UTC (permalink / raw)
  To: Babu Moger
  Cc: corbet, tglx, mingo, hpa, pbonzini, sean.j.christopherson, x86,
	vkuznets, wanpengli, jmattson, joro, dave.hansen, luto, peterz,
	mchehab+samsung, changbin.du, namit, bigeasy, yang.shi,
	asteinhauser, anshuman.khandual, jan.kiszka, akpm, steven.price,
	rppt, peterx, dan.j.williams, arjunroy, logang, thellstrom,
	aarcange, justin.he, robin.murphy, ira.weiny, keescook, jgross,
	andrew.cooper3, pawan.kumar.gupta, fenghua.yu,
	vineela.tummalapalli, yamada.masahiro, sam, acme, linux-doc,
	linux-kernel, kvm

On Wed, May 13, 2020 at 05:39:12PM -0500, Babu Moger wrote:
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 1197b5596d5a..6b7303ccc1dd 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -1887,10 +1887,10 @@ config X86_UMIP
>  	  results are dummy.
>  
>  config X86_INTEL_MEMORY_PROTECTION_KEYS
> -	prompt "Intel Memory Protection Keys"
> +	prompt "Memory Protection Keys"
>  	def_bool y
>  	# Note: only available in 64-bit mode
> -	depends on CPU_SUP_INTEL && X86_64
> +	depends on X86_64 && (CPU_SUP_INTEL || CPU_SUP_AMD)
>  	select ARCH_USES_HIGH_VMA_FLAGS
>  	select ARCH_HAS_PKEYS
>  	---help---
> @@ -1902,6 +1902,13 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS
>  
>  	  If unsure, say y.
>  
> +config X86_MEMORY_PROTECTION_KEYS
> +	# Set the "INTEL_"-free option whenever the "INTEL_" one is set.
> +	# The "INTEL_" one should be removed and replaced by this option
> +	# after 5.10. This avoids exposing most 'oldconfig' users to this
> +	# churn.
> +	def_bool X86_INTEL_MEMORY_PROTECTION_KEYS

I only picked up the discussion from the sidelines but why do we need
this at all? If we don't want to have churn, then we can leave it be
called X86_INTEL_MEMORY_PROTECTION_KEYS, not change the manpage and
have this depend on CPU_SUP_AMD too so that people can select it on AMD
machines, and get on with our lives.

So what's up?

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* Re: [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD
  2020-05-23 12:21 ` Borislav Petkov
@ 2020-05-26 15:33   ` Dave Hansen
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2020-05-26 15:33 UTC (permalink / raw)
  To: Borislav Petkov, Babu Moger
  Cc: corbet, tglx, mingo, hpa, pbonzini, sean.j.christopherson, x86,
	vkuznets, wanpengli, jmattson, joro, dave.hansen, luto, peterz,
	mchehab+samsung, changbin.du, namit, bigeasy, yang.shi,
	asteinhauser, anshuman.khandual, jan.kiszka, akpm, steven.price,
	rppt, peterx, dan.j.williams, arjunroy, logang, thellstrom,
	aarcange, justin.he, robin.murphy, ira.weiny, keescook, jgross,
	andrew.cooper3, pawan.kumar.gupta, fenghua.yu,
	vineela.tummalapalli, yamada.masahiro, sam, acme, linux-doc,
	linux-kernel, kvm

On 5/23/20 5:21 AM, Borislav Petkov wrote:
>> +config X86_MEMORY_PROTECTION_KEYS
>> +	# Set the "INTEL_"-free option whenever the "INTEL_" one is set.
>> +	# The "INTEL_" one should be removed and replaced by this option
>> +	# after 5.10. This avoids exposing most 'oldconfig' users to this
>> +	# churn.
>> +	def_bool X86_INTEL_MEMORY_PROTECTION_KEYS
> I only picked up the discussion from the sidelines but why do we need
> this at all? If we don't want to have churn, then we can leave it be
> called X86_INTEL_MEMORY_PROTECTION_KEYS, not change the manpage and
> have this depend on CPU_SUP_AMD too so that people can select it on AMD
> machines, and get on with our lives.
> 
> So what's up?

Thanks for pointing that out.  I think this ended up mixing together the
two alternative, which doesn't make much sense.

Babu, let's just leave the config option _naming_ entirely in place.
The only change should be to the dependencies and the description text.

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

end of thread, other threads:[~2020-05-26 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 22:39 [PATCH v5] arch/x86: Update config and kernel doc for MPK feature on AMD Babu Moger
2020-05-13 22:44 ` Dave Hansen
2020-05-23 12:21 ` Borislav Petkov
2020-05-26 15:33   ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).