Skip to content

Commit 43972cf

Browse files
committed
Merge tag 'x86_urgent_for_v6.5_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Do not parse the confidential computing blob on non-AMD hardware as it leads to an EFI config table ending up unmapped - Use the correct segment selector in the 32-bit version of getcpu() in the vDSO - Make sure vDSO and VVAR regions are placed in the 47-bit VA range even on 5-level paging systems - Add models 0x90-0x91 to the range of AMD Zenbleed-affected CPUs * tag 'x86_urgent_for_v6.5_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu/amd: Enable Zenbleed fix for AMD Custom APU 0405 x86/mm: Fix VDSO and VVAR placement on 5-level paging machines x86/linkage: Fix typo of BUILD_VDSO in asm/linkage.h x86/vdso: Choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel x86/sev: Do not try to parse for the CC blob on non-AMD hardware
2 parents 272b86b + 6dbef74 commit 43972cf

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

arch/x86/boot/compressed/idt_64.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ void load_stage2_idt(void)
6363
set_idt_entry(X86_TRAP_PF, boot_page_fault);
6464

6565
#ifdef CONFIG_AMD_MEM_ENCRYPT
66-
set_idt_entry(X86_TRAP_VC, boot_stage2_vc);
66+
/*
67+
* Clear the second stage #VC handler in case guest types
68+
* needing #VC have not been detected.
69+
*/
70+
if (sev_status & BIT(1))
71+
set_idt_entry(X86_TRAP_VC, boot_stage2_vc);
72+
else
73+
set_idt_entry(X86_TRAP_VC, NULL);
6774
#endif
6875

6976
load_boot_idt(&boot_idt_desc);

arch/x86/boot/compressed/sev.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,21 +404,54 @@ void sev_enable(struct boot_params *bp)
404404
if (bp)
405405
bp->cc_blob_address = 0;
406406

407+
/*
408+
* Do an initial SEV capability check before snp_init() which
409+
* loads the CPUID page and the same checks afterwards are done
410+
* without the hypervisor and are trustworthy.
411+
*
412+
* If the HV fakes SEV support, the guest will crash'n'burn
413+
* which is good enough.
414+
*/
415+
416+
/* Check for the SME/SEV support leaf */
417+
eax = 0x80000000;
418+
ecx = 0;
419+
native_cpuid(&eax, &ebx, &ecx, &edx);
420+
if (eax < 0x8000001f)
421+
return;
422+
423+
/*
424+
* Check for the SME/SEV feature:
425+
* CPUID Fn8000_001F[EAX]
426+
* - Bit 0 - Secure Memory Encryption support
427+
* - Bit 1 - Secure Encrypted Virtualization support
428+
* CPUID Fn8000_001F[EBX]
429+
* - Bits 5:0 - Pagetable bit position used to indicate encryption
430+
*/
431+
eax = 0x8000001f;
432+
ecx = 0;
433+
native_cpuid(&eax, &ebx, &ecx, &edx);
434+
/* Check whether SEV is supported */
435+
if (!(eax & BIT(1)))
436+
return;
437+
407438
/*
408439
* Setup/preliminary detection of SNP. This will be sanity-checked
409440
* against CPUID/MSR values later.
410441
*/
411442
snp = snp_init(bp);
412443

413-
/* Check for the SME/SEV support leaf */
444+
/* Now repeat the checks with the SNP CPUID table. */
445+
446+
/* Recheck the SME/SEV support leaf */
414447
eax = 0x80000000;
415448
ecx = 0;
416449
native_cpuid(&eax, &ebx, &ecx, &edx);
417450
if (eax < 0x8000001f)
418451
return;
419452

420453
/*
421-
* Check for the SME/SEV feature:
454+
* Recheck for the SME/SEV feature:
422455
* CPUID Fn8000_001F[EAX]
423456
* - Bit 0 - Secure Memory Encryption support
424457
* - Bit 1 - Secure Encrypted Virtualization support

arch/x86/entry/vdso/vma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
299299

300300
/* Round the lowest possible end address up to a PMD boundary. */
301301
end = (start + len + PMD_SIZE - 1) & PMD_MASK;
302-
if (end >= TASK_SIZE_MAX)
303-
end = TASK_SIZE_MAX;
302+
if (end >= DEFAULT_MAP_WINDOW)
303+
end = DEFAULT_MAP_WINDOW;
304304
end -= len;
305305

306306
if (end > start) {

arch/x86/include/asm/linkage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define FUNCTION_PADDING
2222
#endif
2323

24-
#if (CONFIG_FUNCTION_ALIGNMENT > 8) && !defined(__DISABLE_EXPORTS) && !defined(BULID_VDSO)
24+
#if (CONFIG_FUNCTION_ALIGNMENT > 8) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO)
2525
# define __FUNC_ALIGN __ALIGN; FUNCTION_PADDING
2626
#else
2727
# define __FUNC_ALIGN __ALIGN

arch/x86/include/asm/segment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
#define GDT_ENTRY_INVALID_SEG 0
5858

59-
#ifdef CONFIG_X86_32
59+
#if defined(CONFIG_X86_32) && !defined(BUILD_VDSO32_64)
6060
/*
6161
* The layout of the per-CPU GDT under Linux:
6262
*

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static const int amd_erratum_1054[] =
7373
static const int amd_zenbleed[] =
7474
AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x30, 0x0, 0x4f, 0xf),
7575
AMD_MODEL_RANGE(0x17, 0x60, 0x0, 0x7f, 0xf),
76+
AMD_MODEL_RANGE(0x17, 0x90, 0x0, 0x91, 0xf),
7677
AMD_MODEL_RANGE(0x17, 0xa0, 0x0, 0xaf, 0xf));
7778

7879
static const int amd_div0[] =

0 commit comments

Comments
 (0)