Skip to content

Commit 79ad891

Browse files
committed
Merge tag 'x86-cleanups-2022-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cleanups from Thomas Gleixner: "A set of x86 cleanups: - Rework the handling of x86_regset for 32 and 64 bit. The original implementation tried to minimize the allocation size with quite some hard to understand and fragile tricks. Make it robust and straight forward by separating the register enumerations for 32 and 64 bit completely. - Add a few missing static annotations - Remove the stale unused setup_once() assembly function - Address a few minor static analysis and kernel-doc warnings" * tag 'x86-cleanups-2022-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/asm/32: Remove setup_once() x86/kaslr: Fix process_mem_region()'s return value x86: Fix misc small issues x86/boot: Repair kernel-doc for boot_kstrtoul() x86: Improve formatting of user_regset arrays x86: Separate out x86_regset for 32 and 64 bit x86/i8259: Make default_legacy_pic static x86/tsc: Make art_related_clocksource static
2 parents 3690131 + ff4c85c commit 79ad891

8 files changed

Lines changed: 115 additions & 95 deletions

File tree

arch/x86/boot/compressed/kaslr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static bool process_mem_region(struct mem_vector *region,
668668
}
669669
}
670670
#endif
671-
return 0;
671+
return false;
672672
}
673673

674674
#ifdef CONFIG_EFI

arch/x86/boot/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
350350
}
351351

352352
/**
353-
* kstrtoul - convert a string to an unsigned long
353+
* boot_kstrtoul - convert a string to an unsigned long
354354
* @s: The start of the string. The string must be null-terminated, and may also
355355
* include a single newline before its terminating null. The first character
356356
* may also be a plus sign, but not a minus sign.

arch/x86/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ static void text_poke_loc_init(struct text_poke_loc *tp, void *addr,
16081608

16091609
default:
16101610
BUG_ON(len != insn.length);
1611-
};
1611+
}
16121612

16131613

16141614
switch (tp->opcode) {

arch/x86/kernel/head_32.S

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,6 @@ SYM_FUNC_START(startup_32_smp)
260260
/* Shift the stack pointer to a virtual address */
261261
addl $__PAGE_OFFSET, %esp
262262

263-
/*
264-
* start system 32-bit setup. We need to re-do some of the things done
265-
* in 16-bit mode for the "real" operations.
266-
*/
267-
movl setup_once_ref,%eax
268-
andl %eax,%eax
269-
jz 1f # Did we do this already?
270-
call *%eax
271-
1:
272-
273263
/*
274264
* Check if it is 486
275265
*/
@@ -331,18 +321,7 @@ SYM_FUNC_END(startup_32_smp)
331321

332322
#include "verify_cpu.S"
333323

334-
/*
335-
* setup_once
336-
*
337-
* The setup work we only want to run on the BSP.
338-
*
339-
* Warning: %esi is live across this function.
340-
*/
341324
__INIT
342-
setup_once:
343-
andl $0,setup_once_ref /* Once is enough, thanks */
344-
RET
345-
346325
SYM_FUNC_START(early_idt_handler_array)
347326
# 36(%esp) %eflags
348327
# 32(%esp) %cs
@@ -458,7 +437,6 @@ SYM_DATA(early_recursion_flag, .long 0)
458437
__REFDATA
459438
.align 4
460439
SYM_DATA(initial_code, .long i386_start_kernel)
461-
SYM_DATA(setup_once_ref, .long setup_once)
462440

463441
#ifdef CONFIG_PAGE_TABLE_ISOLATION
464442
#define PGD_ALIGN (2 * PAGE_SIZE)

arch/x86/kernel/i8259.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ struct legacy_pic null_legacy_pic = {
407407
.make_irq = legacy_pic_uint_noop,
408408
};
409409

410-
struct legacy_pic default_legacy_pic = {
410+
static struct legacy_pic default_legacy_pic = {
411411
.nr_legacy_irqs = NR_IRQS_LEGACY,
412412
.chip = &i8259A_chip,
413413
.mask = mask_8259A_irq,

arch/x86/kernel/ptrace.c

Lines changed: 108 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,35 @@
4444

4545
#include "tls.h"
4646

47-
enum x86_regset {
48-
REGSET_GENERAL,
49-
REGSET_FP,
50-
REGSET_XFP,
51-
REGSET_IOPERM64 = REGSET_XFP,
52-
REGSET_XSTATE,
53-
REGSET_TLS,
54-
REGSET_IOPERM32,
47+
enum x86_regset_32 {
48+
REGSET32_GENERAL,
49+
REGSET32_FP,
50+
REGSET32_XFP,
51+
REGSET32_XSTATE,
52+
REGSET32_TLS,
53+
REGSET32_IOPERM,
5554
};
5655

56+
enum x86_regset_64 {
57+
REGSET64_GENERAL,
58+
REGSET64_FP,
59+
REGSET64_IOPERM,
60+
REGSET64_XSTATE,
61+
};
62+
63+
#define REGSET_GENERAL \
64+
({ \
65+
BUILD_BUG_ON((int)REGSET32_GENERAL != (int)REGSET64_GENERAL); \
66+
REGSET32_GENERAL; \
67+
})
68+
69+
#define REGSET_FP \
70+
({ \
71+
BUILD_BUG_ON((int)REGSET32_FP != (int)REGSET64_FP); \
72+
REGSET32_FP; \
73+
})
74+
75+
5776
struct pt_regs_offset {
5877
const char *name;
5978
int offset;
@@ -788,13 +807,13 @@ long arch_ptrace(struct task_struct *child, long request,
788807
#ifdef CONFIG_X86_32
789808
case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
790809
return copy_regset_to_user(child, &user_x86_32_view,
791-
REGSET_XFP,
810+
REGSET32_XFP,
792811
0, sizeof(struct user_fxsr_struct),
793812
datap) ? -EIO : 0;
794813

795814
case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
796815
return copy_regset_from_user(child, &user_x86_32_view,
797-
REGSET_XFP,
816+
REGSET32_XFP,
798817
0, sizeof(struct user_fxsr_struct),
799818
datap) ? -EIO : 0;
800819
#endif
@@ -1086,13 +1105,13 @@ static long ia32_arch_ptrace(struct task_struct *child, compat_long_t request,
10861105

10871106
case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
10881107
return copy_regset_to_user(child, &user_x86_32_view,
1089-
REGSET_XFP, 0,
1108+
REGSET32_XFP, 0,
10901109
sizeof(struct user32_fxsr_struct),
10911110
datap);
10921111

10931112
case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
10941113
return copy_regset_from_user(child, &user_x86_32_view,
1095-
REGSET_XFP, 0,
1114+
REGSET32_XFP, 0,
10961115
sizeof(struct user32_fxsr_struct),
10971116
datap);
10981117

@@ -1215,29 +1234,38 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
12151234
#ifdef CONFIG_X86_64
12161235

12171236
static struct user_regset x86_64_regsets[] __ro_after_init = {
1218-
[REGSET_GENERAL] = {
1219-
.core_note_type = NT_PRSTATUS,
1220-
.n = sizeof(struct user_regs_struct) / sizeof(long),
1221-
.size = sizeof(long), .align = sizeof(long),
1222-
.regset_get = genregs_get, .set = genregs_set
1237+
[REGSET64_GENERAL] = {
1238+
.core_note_type = NT_PRSTATUS,
1239+
.n = sizeof(struct user_regs_struct) / sizeof(long),
1240+
.size = sizeof(long),
1241+
.align = sizeof(long),
1242+
.regset_get = genregs_get,
1243+
.set = genregs_set
12231244
},
1224-
[REGSET_FP] = {
1225-
.core_note_type = NT_PRFPREG,
1226-
.n = sizeof(struct fxregs_state) / sizeof(long),
1227-
.size = sizeof(long), .align = sizeof(long),
1228-
.active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set
1245+
[REGSET64_FP] = {
1246+
.core_note_type = NT_PRFPREG,
1247+
.n = sizeof(struct fxregs_state) / sizeof(long),
1248+
.size = sizeof(long),
1249+
.align = sizeof(long),
1250+
.active = regset_xregset_fpregs_active,
1251+
.regset_get = xfpregs_get,
1252+
.set = xfpregs_set
12291253
},
1230-
[REGSET_XSTATE] = {
1231-
.core_note_type = NT_X86_XSTATE,
1232-
.size = sizeof(u64), .align = sizeof(u64),
1233-
.active = xstateregs_active, .regset_get = xstateregs_get,
1234-
.set = xstateregs_set
1254+
[REGSET64_XSTATE] = {
1255+
.core_note_type = NT_X86_XSTATE,
1256+
.size = sizeof(u64),
1257+
.align = sizeof(u64),
1258+
.active = xstateregs_active,
1259+
.regset_get = xstateregs_get,
1260+
.set = xstateregs_set
12351261
},
1236-
[REGSET_IOPERM64] = {
1237-
.core_note_type = NT_386_IOPERM,
1238-
.n = IO_BITMAP_LONGS,
1239-
.size = sizeof(long), .align = sizeof(long),
1240-
.active = ioperm_active, .regset_get = ioperm_get
1262+
[REGSET64_IOPERM] = {
1263+
.core_note_type = NT_386_IOPERM,
1264+
.n = IO_BITMAP_LONGS,
1265+
.size = sizeof(long),
1266+
.align = sizeof(long),
1267+
.active = ioperm_active,
1268+
.regset_get = ioperm_get
12411269
},
12421270
};
12431271

@@ -1256,43 +1284,57 @@ static const struct user_regset_view user_x86_64_view = {
12561284

12571285
#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
12581286
static struct user_regset x86_32_regsets[] __ro_after_init = {
1259-
[REGSET_GENERAL] = {
1260-
.core_note_type = NT_PRSTATUS,
1261-
.n = sizeof(struct user_regs_struct32) / sizeof(u32),
1262-
.size = sizeof(u32), .align = sizeof(u32),
1263-
.regset_get = genregs32_get, .set = genregs32_set
1287+
[REGSET32_GENERAL] = {
1288+
.core_note_type = NT_PRSTATUS,
1289+
.n = sizeof(struct user_regs_struct32) / sizeof(u32),
1290+
.size = sizeof(u32),
1291+
.align = sizeof(u32),
1292+
.regset_get = genregs32_get,
1293+
.set = genregs32_set
12641294
},
1265-
[REGSET_FP] = {
1266-
.core_note_type = NT_PRFPREG,
1267-
.n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
1268-
.size = sizeof(u32), .align = sizeof(u32),
1269-
.active = regset_fpregs_active, .regset_get = fpregs_get, .set = fpregs_set
1295+
[REGSET32_FP] = {
1296+
.core_note_type = NT_PRFPREG,
1297+
.n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
1298+
.size = sizeof(u32),
1299+
.align = sizeof(u32),
1300+
.active = regset_fpregs_active,
1301+
.regset_get = fpregs_get,
1302+
.set = fpregs_set
12701303
},
1271-
[REGSET_XFP] = {
1272-
.core_note_type = NT_PRXFPREG,
1273-
.n = sizeof(struct fxregs_state) / sizeof(u32),
1274-
.size = sizeof(u32), .align = sizeof(u32),
1275-
.active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set
1304+
[REGSET32_XFP] = {
1305+
.core_note_type = NT_PRXFPREG,
1306+
.n = sizeof(struct fxregs_state) / sizeof(u32),
1307+
.size = sizeof(u32),
1308+
.align = sizeof(u32),
1309+
.active = regset_xregset_fpregs_active,
1310+
.regset_get = xfpregs_get,
1311+
.set = xfpregs_set
12761312
},
1277-
[REGSET_XSTATE] = {
1278-
.core_note_type = NT_X86_XSTATE,
1279-
.size = sizeof(u64), .align = sizeof(u64),
1280-
.active = xstateregs_active, .regset_get = xstateregs_get,
1281-
.set = xstateregs_set
1313+
[REGSET32_XSTATE] = {
1314+
.core_note_type = NT_X86_XSTATE,
1315+
.size = sizeof(u64),
1316+
.align = sizeof(u64),
1317+
.active = xstateregs_active,
1318+
.regset_get = xstateregs_get,
1319+
.set = xstateregs_set
12821320
},
1283-
[REGSET_TLS] = {
1284-
.core_note_type = NT_386_TLS,
1285-
.n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
1286-
.size = sizeof(struct user_desc),
1287-
.align = sizeof(struct user_desc),
1288-
.active = regset_tls_active,
1289-
.regset_get = regset_tls_get, .set = regset_tls_set
1321+
[REGSET32_TLS] = {
1322+
.core_note_type = NT_386_TLS,
1323+
.n = GDT_ENTRY_TLS_ENTRIES,
1324+
.bias = GDT_ENTRY_TLS_MIN,
1325+
.size = sizeof(struct user_desc),
1326+
.align = sizeof(struct user_desc),
1327+
.active = regset_tls_active,
1328+
.regset_get = regset_tls_get,
1329+
.set = regset_tls_set
12901330
},
1291-
[REGSET_IOPERM32] = {
1292-
.core_note_type = NT_386_IOPERM,
1293-
.n = IO_BITMAP_BYTES / sizeof(u32),
1294-
.size = sizeof(u32), .align = sizeof(u32),
1295-
.active = ioperm_active, .regset_get = ioperm_get
1331+
[REGSET32_IOPERM] = {
1332+
.core_note_type = NT_386_IOPERM,
1333+
.n = IO_BITMAP_BYTES / sizeof(u32),
1334+
.size = sizeof(u32),
1335+
.align = sizeof(u32),
1336+
.active = ioperm_active,
1337+
.regset_get = ioperm_get
12961338
},
12971339
};
12981340

@@ -1311,10 +1353,10 @@ u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
13111353
void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
13121354
{
13131355
#ifdef CONFIG_X86_64
1314-
x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
1356+
x86_64_regsets[REGSET64_XSTATE].n = size / sizeof(u64);
13151357
#endif
13161358
#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1317-
x86_32_regsets[REGSET_XSTATE].n = size / sizeof(u64);
1359+
x86_32_regsets[REGSET32_XSTATE].n = size / sizeof(u64);
13181360
#endif
13191361
xstate_fx_sw_bytes[USER_XSTATE_XCR0_WORD] = xstate_mask;
13201362
}

arch/x86/kernel/traps.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@
6868

6969
#ifdef CONFIG_X86_64
7070
#include <asm/x86_init.h>
71-
#include <asm/proto.h>
7271
#else
7372
#include <asm/processor-flags.h>
7473
#include <asm/setup.h>
75-
#include <asm/proto.h>
7674
#endif
7775

76+
#include <asm/proto.h>
77+
7878
DECLARE_BITMAP(system_vectors, NR_VECTORS);
7979

8080
static inline void cond_local_irq_enable(struct pt_regs *regs)

arch/x86/kernel/tsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int tsc_clocksource_reliable;
5151
static u32 art_to_tsc_numerator;
5252
static u32 art_to_tsc_denominator;
5353
static u64 art_to_tsc_offset;
54-
struct clocksource *art_related_clocksource;
54+
static struct clocksource *art_related_clocksource;
5555

5656
struct cyc2ns {
5757
struct cyc2ns_data data[2]; /* 0 + 2*16 = 32 */

0 commit comments

Comments
 (0)