1
0
Fork 0
freescale-linux-fslc/arch/x86/mm
Pu Wen 445477e927 x86/sev: Check SME/SEV support in CPUID first
commit 009767dbf42ac0dbe3cf48c1ee224f6b778aa85a upstream.

The first two bits of the CPUID leaf 0x8000001F EAX indicate whether SEV
or SME is supported, respectively. It's better to check whether SEV or
SME is actually supported before accessing the MSR_AMD64_SEV to check
whether SEV or SME is enabled.

This is both a bare-metal issue and a guest/VM issue. Since the first
generation Hygon Dhyana CPU doesn't support the MSR_AMD64_SEV, reading that
MSR results in a #GP - either directly from hardware in the bare-metal
case or via the hypervisor (because the RDMSR is actually intercepted)
in the guest/VM case, resulting in a failed boot. And since this is very
early in the boot phase, rdmsrl_safe()/native_read_msr_safe() can't be
used.

So check the CPUID bits first, before accessing the MSR.

 [ tlendacky: Expand and improve commit message. ]
 [ bp: Massage commit message. ]

Fixes: eab696d8e8 ("x86/sev: Do not require Hypervisor CPUID bit for SEV guests")
Signed-off-by: Pu Wen <puwen@hygon.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: <stable@vger.kernel.org> # v5.10+
Link: https://lkml.kernel.org/r/20210602070207.2480-1-puwen@hygon.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-10 13:39:27 +02:00
..
pat x86: fix seq_file iteration for pat/memtype.c 2021-03-04 11:38:38 +01:00
Makefile kbuild: remove cc-option test of -fno-stack-protector 2020-07-07 11:13:10 +09:00
amdtopology.c
cpu_entry_area.c x86/dumpstack/64: Add noinstr version of get_stack_info() 2020-09-09 11:33:19 +02:00
debug_pagetables.c mm: introduce include/linux/pgtable.h 2020-06-09 09:39:13 -07:00
dump_pagetables.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
extable.c This feature enhances the current guest memory encryption support 2020-10-14 10:21:34 -07:00
fault.c x86/fault: Fix AMD erratum #91 errata fixup for user code 2021-03-04 11:38:34 +01:00
highmem_32.c arch/kunmap_atomic: consolidate duplicate code 2020-06-04 19:06:22 -07:00
hugetlbpage.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
ident_map.c x86/mm/ident_map: Check for errors from ident_pud_init() 2020-12-30 11:52:58 +01:00
init.c x86/mm: Fix -Wmissing-prototypes warnings for arch/x86/mm/init.c 2020-06-17 10:45:46 +02:00
init_32.c A set of locking fixes and updates: 2020-08-10 19:07:44 -07:00
init_64.c x86/mm/64: Update comment in preallocate_vmalloc_pages() 2020-08-15 13:56:16 +02:00
iomap_32.c x86/mm/pat: Rename <asm/pat.h> => <asm/memtype.h> 2019-12-10 10:12:55 +01:00
ioremap.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
kasan_init_64.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
kaslr.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
kmmio.c Misc changes: 2020-06-05 11:18:53 -07:00
maccess.c maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault 2020-06-17 10:57:41 -07:00
mem_encrypt.c x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc() 2021-03-30 14:32:07 +02:00
mem_encrypt_boot.S mm: introduce include/linux/pgtable.h 2020-06-09 09:39:13 -07:00
mem_encrypt_identity.c x86/sev: Check SME/SEV support in CPUID first 2021-06-10 13:39:27 +02:00
mm_internal.h x86/mm: thread pgprot_t through init_memory_mapping() 2020-04-10 15:36:21 -07:00
mmap.c x86/mm/mmap: Fix -Wmissing-prototypes warnings 2020-04-22 20:19:48 +02:00
mmio-mod.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
numa.c mm: fix phys_to_target_node() and memory_add_physaddr_to_nid() exports 2020-11-22 10:48:22 -08:00
numa_32.c x86/mm: Drop deprecated DISCONTIGMEM support for 32-bit 2020-05-28 18:34:30 +02:00
numa_64.c
numa_emulation.c x86/numa: cleanup configuration dependent command-line options 2020-10-13 18:38:27 -07:00
numa_internal.h
pf_in.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
pf_in.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
pgtable.c x86/mm: Fix leak of pmd ptlock 2021-01-12 20:18:22 +01:00
pgtable_32.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
physaddr.c mm, x86/mm: Untangle address space layout definitions from basic pgtable type definitions 2019-12-10 10:12:55 +01:00
physaddr.h
pkeys.c mm/vma: introduce VM_ACCESS_FLAGS 2020-04-10 15:36:21 -07:00
pti.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
setup_nx.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
srat.c
testmmiotrace.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
tlb.c x86/membarrier: Get rid of a dubious optimization 2020-12-09 09:37:42 +01:00