Skip to content

Commit 14df326

Browse files
committed
x86: Support kmap_local() forced debugging
kmap_local() and related interfaces are NOOPs on 64bit and only create temporary fixmaps for highmem pages on 32bit. That means the test coverage for this code is pretty small. CONFIG_KMAP_LOCAL can be enabled independent from CONFIG_HIGHMEM, which allows to provide support for enforced kmap_local() debugging even on 64bit. For 32bit the support is unconditional, for 64bit it's only supported when CONFIG_NR_CPUS <= 4096 as supporting it for 8192 CPUs would require to set up yet another fixmap PGT. If CONFIG_KMAP_LOCAL_FORCE_DEBUG is enabled then kmap_local()/kmap_atomic() will use the temporary fixmap mapping path. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0e91a0c commit 14df326

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

arch/x86/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ config X86
9393
select ARCH_SUPPORTS_ACPI
9494
select ARCH_SUPPORTS_ATOMIC_RMW
9595
select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
96+
select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <= 4096
9697
select ARCH_USE_BUILTIN_BSWAP
9798
select ARCH_USE_QUEUED_RWLOCKS
9899
select ARCH_USE_QUEUED_SPINLOCKS

arch/x86/include/asm/fixmap.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
#ifndef _ASM_X86_FIXMAP_H
1515
#define _ASM_X86_FIXMAP_H
1616

17+
#include <asm/kmap_size.h>
18+
1719
/*
1820
* Exposed to assembly code for setting up initial page tables. Cannot be
1921
* calculated in assembly code (fixmap entries are an enum), but is sanity
2022
* checked in the actual fixmap C code to make sure that the fixmap is
2123
* covered fully.
2224
*/
23-
#define FIXMAP_PMD_NUM 2
25+
#ifndef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
26+
# define FIXMAP_PMD_NUM 2
27+
#else
28+
# define KM_PMDS (KM_MAX_IDX * ((CONFIG_NR_CPUS + 511) / 512))
29+
# define FIXMAP_PMD_NUM (KM_PMDS + 2)
30+
#endif
2431
/* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */
2532
#define FIXMAP_PMD_TOP 507
2633

@@ -31,7 +38,6 @@
3138
#include <asm/pgtable_types.h>
3239
#ifdef CONFIG_X86_32
3340
#include <linux/threads.h>
34-
#include <asm/kmap_size.h>
3541
#else
3642
#include <uapi/asm/vsyscall.h>
3743
#endif
@@ -92,7 +98,7 @@ enum fixed_addresses {
9298
FIX_IO_APIC_BASE_0,
9399
FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,
94100
#endif
95-
#ifdef CONFIG_X86_32
101+
#ifdef CONFIG_KMAP_LOCAL
96102
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
97103
FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1,
98104
#ifdef CONFIG_PCI_MMCONFIG

arch/x86/include/asm/pgtable_64_types.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ extern unsigned int ptrs_per_p4d;
143143

144144
#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
145145
/* The module sections ends with the start of the fixmap */
146-
#define MODULES_END _AC(0xffffffffff000000, UL)
146+
#ifndef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
147+
# define MODULES_END _AC(0xffffffffff000000, UL)
148+
#else
149+
# define MODULES_END _AC(0xfffffffffe000000, UL)
150+
#endif
147151
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
148152

149153
#define ESPFIX_PGD_ENTRY _AC(-2, UL)

0 commit comments

Comments
 (0)