Skip to content

Commit 1de564b

Browse files
committed
Merge tag 'x86_build_for_v5.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 build updates from Borislav Petkov: - Add a "make x86_debug.config" target which enables a bunch of useful config debug options when trying to debug an issue - A gcc-12 build warnings fix * tag 'x86_build_for_v5.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Wrap literal addresses in absolute_pointer() x86/configs: Add x86 debugging Kconfig fragment plus docs
2 parents 42b682a + aeb8441 commit 1de564b

File tree

5 files changed

+58
-13
lines changed

5 files changed

+58
-13
lines changed

Documentation/process/maintainer-tip.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,20 @@ in a private repository which allows interested people to easily pull the
437437
series for testing. The usual way to offer this is a git URL in the cover
438438
letter of the patch series.
439439

440+
Testing
441+
^^^^^^^
442+
443+
Code should be tested before submitting to the tip maintainers. Anything
444+
other than minor changes should be built, booted and tested with
445+
comprehensive (and heavyweight) kernel debugging options enabled.
446+
447+
These debugging options can be found in kernel/configs/x86_debug.config
448+
and can be added to an existing kernel config by running:
449+
450+
make x86_debug.config
451+
452+
Some of these options are x86-specific and can be left out when testing
453+
on other architectures.
440454

441455
Coding style notes
442456
------------------

arch/x86/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,6 @@ define archhelp
313313
echo ''
314314
echo ' kvm_guest.config - Enable Kconfig items for running this kernel as a KVM guest'
315315
echo ' xen.config - Enable Kconfig items for running this kernel as a Xen guest'
316+
echo ' x86_debug.config - Enable tip tree debugging options for testing'
316317

317318
endef

arch/x86/boot/boot.h

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,66 +77,78 @@ typedef unsigned int addr_t;
7777

7878
static inline u8 rdfs8(addr_t addr)
7979
{
80+
u8 *ptr = (u8 *)absolute_pointer(addr);
8081
u8 v;
81-
asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));
82+
asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*ptr));
8283
return v;
8384
}
8485
static inline u16 rdfs16(addr_t addr)
8586
{
87+
u16 *ptr = (u16 *)absolute_pointer(addr);
8688
u16 v;
87-
asm volatile("movw %%fs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
89+
asm volatile("movw %%fs:%1,%0" : "=r" (v) : "m" (*ptr));
8890
return v;
8991
}
9092
static inline u32 rdfs32(addr_t addr)
9193
{
94+
u32 *ptr = (u32 *)absolute_pointer(addr);
9295
u32 v;
93-
asm volatile("movl %%fs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
96+
asm volatile("movl %%fs:%1,%0" : "=r" (v) : "m" (*ptr));
9497
return v;
9598
}
9699

97100
static inline void wrfs8(u8 v, addr_t addr)
98101
{
99-
asm volatile("movb %1,%%fs:%0" : "+m" (*(u8 *)addr) : "qi" (v));
102+
u8 *ptr = (u8 *)absolute_pointer(addr);
103+
asm volatile("movb %1,%%fs:%0" : "+m" (*ptr) : "qi" (v));
100104
}
101105
static inline void wrfs16(u16 v, addr_t addr)
102106
{
103-
asm volatile("movw %1,%%fs:%0" : "+m" (*(u16 *)addr) : "ri" (v));
107+
u16 *ptr = (u16 *)absolute_pointer(addr);
108+
asm volatile("movw %1,%%fs:%0" : "+m" (*ptr) : "ri" (v));
104109
}
105110
static inline void wrfs32(u32 v, addr_t addr)
106111
{
107-
asm volatile("movl %1,%%fs:%0" : "+m" (*(u32 *)addr) : "ri" (v));
112+
u32 *ptr = (u32 *)absolute_pointer(addr);
113+
asm volatile("movl %1,%%fs:%0" : "+m" (*ptr) : "ri" (v));
108114
}
109115

110116
static inline u8 rdgs8(addr_t addr)
111117
{
118+
u8 *ptr = (u8 *)absolute_pointer(addr);
112119
u8 v;
113-
asm volatile("movb %%gs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));
120+
asm volatile("movb %%gs:%1,%0" : "=q" (v) : "m" (*ptr));
114121
return v;
115122
}
116123
static inline u16 rdgs16(addr_t addr)
117124
{
125+
u16 *ptr = (u16 *)absolute_pointer(addr);
118126
u16 v;
119-
asm volatile("movw %%gs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
127+
asm volatile("movw %%gs:%1,%0" : "=r" (v) : "m" (*ptr));
120128
return v;
121129
}
122130
static inline u32 rdgs32(addr_t addr)
123131
{
132+
u32 *ptr = (u32 *)absolute_pointer(addr);
124133
u32 v;
125-
asm volatile("movl %%gs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
134+
asm volatile("movl %%gs:%1,%0" : "=r" (v) : "m" (*ptr));
126135
return v;
127136
}
128137

129138
static inline void wrgs8(u8 v, addr_t addr)
130139
{
131-
asm volatile("movb %1,%%gs:%0" : "+m" (*(u8 *)addr) : "qi" (v));
140+
u8 *ptr = (u8 *)absolute_pointer(addr);
141+
asm volatile("movb %1,%%gs:%0" : "+m" (*ptr) : "qi" (v));
132142
}
133143
static inline void wrgs16(u16 v, addr_t addr)
134144
{
135-
asm volatile("movw %1,%%gs:%0" : "+m" (*(u16 *)addr) : "ri" (v));
145+
u16 *ptr = (u16 *)absolute_pointer(addr);
146+
asm volatile("movw %1,%%gs:%0" : "+m" (*ptr) : "ri" (v));
136147
}
137148
static inline void wrgs32(u32 v, addr_t addr)
138149
{
139-
asm volatile("movl %1,%%gs:%0" : "+m" (*(u32 *)addr) : "ri" (v));
150+
u32 *ptr = (u32 *)absolute_pointer(addr);
151+
asm volatile("movl %1,%%gs:%0" : "+m" (*ptr) : "ri" (v));
140152
}
141153

142154
/* Note: these only return true/false, not a signed return value! */

arch/x86/boot/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static void copy_boot_params(void)
3535
u16 cl_offset;
3636
};
3737
const struct old_cmdline * const oldcmd =
38-
(const struct old_cmdline *)OLD_CL_ADDRESS;
38+
absolute_pointer(OLD_CL_ADDRESS);
3939

4040
BUILD_BUG_ON(sizeof(boot_params) != 4096);
4141
memcpy(&boot_params.hdr, &hdr, sizeof(hdr));

kernel/configs/x86_debug.config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CONFIG_X86_DEBUG_FPU=y
2+
CONFIG_LOCK_STAT=y
3+
CONFIG_DEBUG_VM=y
4+
CONFIG_DEBUG_VM_VMACACHE=y
5+
CONFIG_DEBUG_VM_RB=y
6+
CONFIG_DEBUG_SLAB=y
7+
CONFIG_DEBUG_KMEMLEAK=y
8+
CONFIG_DEBUG_PAGEALLOC=y
9+
CONFIG_SLUB_DEBUG_ON=y
10+
CONFIG_KMEMCHECK=y
11+
CONFIG_DEBUG_OBJECTS=y
12+
CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT=1
13+
CONFIG_GCOV_KERNEL=y
14+
CONFIG_LOCKDEP=y
15+
CONFIG_PROVE_LOCKING=y
16+
CONFIG_SCHEDSTATS=y
17+
CONFIG_VMLINUX_VALIDATION=y
18+
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y

0 commit comments

Comments
 (0)