Re: [PATCH 2/3 v2] KVM: SVM: Add hardware-enforced cache coherency as a CPUID feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 9/10/20 7:45 AM, Tom Lendacky wrote:
On 9/9/20 9:22 PM, Krish Sadhukhan wrote:
Some AMD hardware platforms enforce cache coherency across encryption domains.
Add this hardware feature as a CPUID feature to the kernel.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
---
  arch/x86/include/asm/cpufeatures.h | 1 +
  arch/x86/kernel/cpu/amd.c          | 3 +++
  2 files changed, 4 insertions(+)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 81335e6fe47d..0e5b27ee5931 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -293,6 +293,7 @@
  #define X86_FEATURE_FENCE_SWAPGS_USER    (11*32+ 4) /* "" LFENCE in user entry SWAPGS path */   #define X86_FEATURE_FENCE_SWAPGS_KERNEL    (11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */   #define X86_FEATURE_SPLIT_LOCK_DETECT    (11*32+ 6) /* #AC for split lock */ +#define X86_FEATURE_HW_CACHE_COHERENCY (11*32+ 7) /* AMD hardware-enforced cache coherency */     /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */   #define X86_FEATURE_AVX512_BF16        (12*32+ 5) /* AVX512 BFLOAT16 instructions */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 4507ededb978..698884812989 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -632,6 +632,9 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)
           */
          c->x86_phys_bits -= (cpuid_ebx(CPUID_AMD_SME) >> 6) & 0x3f;
  +        if (cpuid_eax(CPUID_AMD_SME) & 0x400)
+            set_cpu_cap(c, X86_FEATURE_HW_CACHE_COHERENCY);

Why not add this to arch/x86/kernel/cpu/scattered.c?


The reason why I put it in amd.c is because it's AMD-specific, though I know we have SME and SEV in scattered.c. Shouldn't SME and SEV features be ideally placed in AMD-specific files and scattered.c be used for common CPUID features ?



Thanks,
Tom

+
          if (IS_ENABLED(CONFIG_X86_32))
              goto clear_all;




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux