Skip to content

Commit f0d25b5

Browse files
committed
Merge tag 'x86-mm-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm handling updates from Ingo Molnar: - Add new NX-stack self-test - Improve NUMA partial-CFMWS handling - Fix #VC handler bugs resulting in SEV-SNP boot failures - Drop the 4MB memory size restriction on minimal NUMA nodes - Reorganize headers a bit, in preparation to header dependency reduction efforts - Misc cleanups & fixes * tag 'x86-mm-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size selftests/x86/lam: Zero out buffer for readlink() x86/sev: Drop unneeded #include x86/sev: Move sev_setup_arch() to mem_encrypt.c x86/tdx: Replace deprecated strncpy() with strtomem_pad() selftests/x86/mm: Add new test that userspace stack is in fact NX x86/sev: Make boot_ghcb_page[] static x86/boot: Move x86_cache_alignment initialization to correct spot x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach x86/sev-es: Allow copy_from_kernel_nofault() in earlier boot x86_64: Show CR4.PSE on auxiliaries like on BSP x86/iommu/docs: Update AMD IOMMU specification document URL x86/sev/docs: Update document URL in amd-memory-encryption.rst x86/mm: Move arch_memory_failure() and arch_is_platform_page() definitions from <asm/processor.h> to <asm/pgtable.h> ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window x86/numa: Introduce numa_fill_memblks()
2 parents 1641b9b + a1e2b8b commit f0d25b5

File tree

21 files changed

+404
-95
lines changed

21 files changed

+404
-95
lines changed

Documentation/arch/x86/amd-memory-encryption.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ SNP feature support.
130130

131131
More details in AMD64 APM[1] Vol 2: 15.34.10 SEV_STATUS MSR
132132

133-
[1] https://www.amd.com/system/files/TechDocs/40332.pdf
133+
[1] https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf

Documentation/arch/x86/iommu.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x86 IOMMU Support
55
The architecture specs can be obtained from the below locations.
66

77
- Intel: http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf
8-
- AMD: https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf
8+
- AMD: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/specifications/48882_3_07_PUB.pdf
99

1010
This guide gives a quick cheat sheet for some basic understanding.
1111

arch/x86/boot/compressed/sev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "error.h"
2626
#include "../msr.h"
2727

28-
struct ghcb boot_ghcb_page __aligned(PAGE_SIZE);
28+
static struct ghcb boot_ghcb_page __aligned(PAGE_SIZE);
2929
struct ghcb *boot_ghcb;
3030

3131
/*

arch/x86/coco/tdx/tdx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void __noreturn tdx_panic(const char *msg)
119119
} message;
120120

121121
/* VMM assumes '\0' in byte 65, if the message took all 64 bytes */
122-
strncpy(message.str, msg, 64);
122+
strtomem_pad(message.str, msg, '\0');
123123

124124
args.r8 = message.r8;
125125
args.r9 = message.r9;

arch/x86/include/asm/mem_encrypt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
#ifdef CONFIG_X86_MEM_ENCRYPT
2121
void __init mem_encrypt_init(void);
22+
void __init mem_encrypt_setup_arch(void);
2223
#else
2324
static inline void mem_encrypt_init(void) { }
25+
static inline void __init mem_encrypt_setup_arch(void) { }
2426
#endif
2527

2628
#ifdef CONFIG_AMD_MEM_ENCRYPT
@@ -43,7 +45,6 @@ void __init sme_map_bootdata(char *real_mode_data);
4345
void __init sme_unmap_bootdata(char *real_mode_data);
4446

4547
void __init sme_early_init(void);
46-
void __init sev_setup_arch(void);
4748

4849
void __init sme_encrypt_kernel(struct boot_params *bp);
4950
void __init sme_enable(struct boot_params *bp);
@@ -73,7 +74,6 @@ static inline void __init sme_map_bootdata(char *real_mode_data) { }
7374
static inline void __init sme_unmap_bootdata(char *real_mode_data) { }
7475

7576
static inline void __init sme_early_init(void) { }
76-
static inline void __init sev_setup_arch(void) { }
7777

7878
static inline void __init sme_encrypt_kernel(struct boot_params *bp) { }
7979
static inline void __init sme_enable(struct boot_params *bp) { }

arch/x86/include/asm/numa.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212

1313
#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
1414

15-
/*
16-
* Too small node sizes may confuse the VM badly. Usually they
17-
* result from BIOS bugs. So dont recognize nodes as standalone
18-
* NUMA entities that have less than this amount of RAM listed:
19-
*/
20-
#define NODE_MIN_SIZE (4*1024*1024)
21-
2215
extern int numa_off;
2316

2417
/*

arch/x86/include/asm/pgtable.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,14 @@ static inline bool pud_user_accessible_page(pud_t pud)
17161716
}
17171717
#endif
17181718

1719+
#ifdef CONFIG_X86_SGX
1720+
int arch_memory_failure(unsigned long pfn, int flags);
1721+
#define arch_memory_failure arch_memory_failure
1722+
1723+
bool arch_is_platform_page(u64 paddr);
1724+
#define arch_is_platform_page arch_is_platform_page
1725+
#endif
1726+
17191727
#endif /* __ASSEMBLY__ */
17201728

17211729
#endif /* _ASM_X86_PGTABLE_H */

arch/x86/include/asm/processor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,6 @@ enum mds_mitigations {
724724
MDS_MITIGATION_VMWERV,
725725
};
726726

727-
#ifdef CONFIG_X86_SGX
728-
int arch_memory_failure(unsigned long pfn, int flags);
729-
#define arch_memory_failure arch_memory_failure
730-
731-
bool arch_is_platform_page(u64 paddr);
732-
#define arch_is_platform_page arch_is_platform_page
733-
#endif
734-
735727
extern bool gds_ucode_mitigated(void);
736728

737729
#endif /* _ASM_X86_PROCESSOR_H */

arch/x86/include/asm/sparsemem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ extern int phys_to_target_node(phys_addr_t start);
3737
#define phys_to_target_node phys_to_target_node
3838
extern int memory_add_physaddr_to_nid(u64 start);
3939
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
40+
extern int numa_fill_memblks(u64 start, u64 end);
41+
#define numa_fill_memblks numa_fill_memblks
4042
#endif
4143
#endif /* __ASSEMBLY__ */
4244

arch/x86/kernel/cpu/common.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,18 +1115,34 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
11151115
void get_cpu_address_sizes(struct cpuinfo_x86 *c)
11161116
{
11171117
u32 eax, ebx, ecx, edx;
1118+
bool vp_bits_from_cpuid = true;
11181119

1119-
if (c->extended_cpuid_level >= 0x80000008) {
1120+
if (!cpu_has(c, X86_FEATURE_CPUID) ||
1121+
(c->extended_cpuid_level < 0x80000008))
1122+
vp_bits_from_cpuid = false;
1123+
1124+
if (vp_bits_from_cpuid) {
11201125
cpuid(0x80000008, &eax, &ebx, &ecx, &edx);
11211126

11221127
c->x86_virt_bits = (eax >> 8) & 0xff;
11231128
c->x86_phys_bits = eax & 0xff;
1129+
} else {
1130+
if (IS_ENABLED(CONFIG_X86_64)) {
1131+
c->x86_clflush_size = 64;
1132+
c->x86_phys_bits = 36;
1133+
c->x86_virt_bits = 48;
1134+
} else {
1135+
c->x86_clflush_size = 32;
1136+
c->x86_virt_bits = 32;
1137+
c->x86_phys_bits = 32;
1138+
1139+
if (cpu_has(c, X86_FEATURE_PAE) ||
1140+
cpu_has(c, X86_FEATURE_PSE36))
1141+
c->x86_phys_bits = 36;
1142+
}
11241143
}
1125-
#ifdef CONFIG_X86_32
1126-
else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))
1127-
c->x86_phys_bits = 36;
1128-
#endif
11291144
c->x86_cache_bits = c->x86_phys_bits;
1145+
c->x86_cache_alignment = c->x86_clflush_size;
11301146
}
11311147

11321148
static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
@@ -1580,17 +1596,6 @@ static void __init cpu_parse_early_param(void)
15801596
*/
15811597
static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15821598
{
1583-
#ifdef CONFIG_X86_64
1584-
c->x86_clflush_size = 64;
1585-
c->x86_phys_bits = 36;
1586-
c->x86_virt_bits = 48;
1587-
#else
1588-
c->x86_clflush_size = 32;
1589-
c->x86_phys_bits = 32;
1590-
c->x86_virt_bits = 32;
1591-
#endif
1592-
c->x86_cache_alignment = c->x86_clflush_size;
1593-
15941599
memset(&c->x86_capability, 0, sizeof(c->x86_capability));
15951600
c->extended_cpuid_level = 0;
15961601

@@ -1602,7 +1607,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16021607
cpu_detect(c);
16031608
get_cpu_vendor(c);
16041609
get_cpu_cap(c);
1605-
get_cpu_address_sizes(c);
16061610
setup_force_cpu_cap(X86_FEATURE_CPUID);
16071611
cpu_parse_early_param();
16081612

@@ -1618,6 +1622,8 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16181622
setup_clear_cpu_cap(X86_FEATURE_CPUID);
16191623
}
16201624

1625+
get_cpu_address_sizes(c);
1626+
16211627
setup_force_cpu_cap(X86_FEATURE_ALWAYS);
16221628

16231629
cpu_set_bug_bits(c);

0 commit comments

Comments
 (0)