Hi! > This patch adds the support to check for and enable SME when available > on the processor and when the mem_encrypt=on command line option is set. > This consists of setting the encryption mask, calculating the number of > physical bits of addressing lost and encrypting the kernel "in place." > > Signed-off-by: Tom Lendacky <thomas.lendacky@xxxxxxx> > --- > Documentation/kernel-parameters.txt | 3 > arch/x86/kernel/asm-offsets.c | 2 > arch/x86/kernel/mem_encrypt.S | 306 +++++++++++++++++++++++++++++++++++ > 3 files changed, 311 insertions(+) > > diff --git a/arch/x86/kernel/mem_encrypt.S b/arch/x86/kernel/mem_encrypt.S > index f2e0536..4d3326d 100644 > --- a/arch/x86/kernel/mem_encrypt.S > +++ b/arch/x86/kernel/mem_encrypt.S > @@ -12,13 +12,236 @@ > > #include <linux/linkage.h> > > +#include <asm/processor-flags.h> > +#include <asm/pgtable.h> > +#include <asm/page.h> > +#include <asm/msr.h> > +#include <asm/asm-offsets.h> > + > .text > .code64 > ENTRY(sme_enable) > +#ifdef CONFIG_AMD_MEM_ENCRYPT > + /* Check for AMD processor */ > + xorl %eax, %eax > + cpuid > + cmpl $0x68747541, %ebx # AuthenticAMD > + jne .Lno_mem_encrypt > + cmpl $0x69746e65, %edx > + jne .Lno_mem_encrypt > + cmpl $0x444d4163, %ecx > + jne .Lno_mem_encrypt > + > + /* Check for memory encryption leaf */ > + movl $0x80000000, %eax > + cpuid > + cmpl $0x8000001f, %eax > + jb .Lno_mem_encrypt > + > + /* > + * Check for memory encryption feature: > + * CPUID Fn8000_001F[EAX] - Bit 0 > + */ > + movl $0x8000001f, %eax > + cpuid > + bt $0, %eax > + jnc .Lno_mem_encrypt > + > + /* Check for the mem_encrypt=on command line option */ > + push %rsi /* Save RSI (real_mode_data) */ > + movl BP_ext_cmd_line_ptr(%rsi), %ecx > + shlq $32, %rcx > + movl BP_cmd_line_ptr(%rsi), %edi > + addq %rcx, %rdi > + leaq mem_encrypt_enable_option(%rip), %rsi > + call cmdline_find_option_bool > + pop %rsi /* Restore RSI (real_mode_data) */ > + testl %eax, %eax > + jz .Lno_mem_encrypt Can you move parts to C here, so that it is more readable? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html