Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+115 -95
+1 -1
arch/x86/boot/compressed/kaslr.c
··· 668 668 } 669 669 } 670 670 #endif 671 - return 0; 671 + return false; 672 672 } 673 673 674 674 #ifdef CONFIG_EFI
+1 -1
arch/x86/boot/string.c
··· 350 350 } 351 351 352 352 /** 353 - * kstrtoul - convert a string to an unsigned long 353 + * boot_kstrtoul - convert a string to an unsigned long 354 354 * @s: The start of the string. The string must be null-terminated, and may also 355 355 * include a single newline before its terminating null. The first character 356 356 * may also be a plus sign, but not a minus sign.
+1 -1
arch/x86/kernel/alternative.c
··· 1608 1608 1609 1609 default: 1610 1610 BUG_ON(len != insn.length); 1611 - }; 1611 + } 1612 1612 1613 1613 1614 1614 switch (tp->opcode) {
-22
arch/x86/kernel/head_32.S
··· 261 261 addl $__PAGE_OFFSET, %esp 262 262 263 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 - 273 - /* 274 264 * Check if it is 486 275 265 */ 276 266 movb $4,X86 # at least 486 ··· 321 331 322 332 #include "verify_cpu.S" 323 333 324 - /* 325 - * setup_once 326 - * 327 - * The setup work we only want to run on the BSP. 328 - * 329 - * Warning: %esi is live across this function. 330 - */ 331 334 __INIT 332 - setup_once: 333 - andl $0,setup_once_ref /* Once is enough, thanks */ 334 - RET 335 - 336 335 SYM_FUNC_START(early_idt_handler_array) 337 336 # 36(%esp) %eflags 338 337 # 32(%esp) %cs ··· 437 458 __REFDATA 438 459 .align 4 439 460 SYM_DATA(initial_code, .long i386_start_kernel) 440 - SYM_DATA(setup_once_ref, .long setup_once) 441 461 442 462 #ifdef CONFIG_PAGE_TABLE_ISOLATION 443 463 #define PGD_ALIGN (2 * PAGE_SIZE)
+1 -1
arch/x86/kernel/i8259.c
··· 407 407 .make_irq = legacy_pic_uint_noop, 408 408 }; 409 409 410 - struct legacy_pic default_legacy_pic = { 410 + static struct legacy_pic default_legacy_pic = { 411 411 .nr_legacy_irqs = NR_IRQS_LEGACY, 412 412 .chip = &i8259A_chip, 413 413 .mask = mask_8259A_irq,
+108 -66
arch/x86/kernel/ptrace.c
··· 44 44 45 45 #include "tls.h" 46 46 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, 55 54 }; 55 + 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 + 56 75 57 76 struct pt_regs_offset { 58 77 const char *name; ··· 807 788 #ifdef CONFIG_X86_32 808 789 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */ 809 790 return copy_regset_to_user(child, &user_x86_32_view, 810 - REGSET_XFP, 791 + REGSET32_XFP, 811 792 0, sizeof(struct user_fxsr_struct), 812 793 datap) ? -EIO : 0; 813 794 814 795 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */ 815 796 return copy_regset_from_user(child, &user_x86_32_view, 816 - REGSET_XFP, 797 + REGSET32_XFP, 817 798 0, sizeof(struct user_fxsr_struct), 818 799 datap) ? -EIO : 0; 819 800 #endif ··· 1105 1086 1106 1087 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */ 1107 1088 return copy_regset_to_user(child, &user_x86_32_view, 1108 - REGSET_XFP, 0, 1089 + REGSET32_XFP, 0, 1109 1090 sizeof(struct user32_fxsr_struct), 1110 1091 datap); 1111 1092 1112 1093 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */ 1113 1094 return copy_regset_from_user(child, &user_x86_32_view, 1114 - REGSET_XFP, 0, 1095 + REGSET32_XFP, 0, 1115 1096 sizeof(struct user32_fxsr_struct), 1116 1097 datap); 1117 1098 ··· 1234 1215 #ifdef CONFIG_X86_64 1235 1216 1236 1217 static struct user_regset x86_64_regsets[] __ro_after_init = { 1237 - [REGSET_GENERAL] = { 1238 - .core_note_type = NT_PRSTATUS, 1239 - .n = sizeof(struct user_regs_struct) / sizeof(long), 1240 - .size = sizeof(long), .align = sizeof(long), 1241 - .regset_get = genregs_get, .set = genregs_set 1218 + [REGSET64_GENERAL] = { 1219 + .core_note_type = NT_PRSTATUS, 1220 + .n = sizeof(struct user_regs_struct) / sizeof(long), 1221 + .size = sizeof(long), 1222 + .align = sizeof(long), 1223 + .regset_get = genregs_get, 1224 + .set = genregs_set 1242 1225 }, 1243 - [REGSET_FP] = { 1244 - .core_note_type = NT_PRFPREG, 1245 - .n = sizeof(struct fxregs_state) / sizeof(long), 1246 - .size = sizeof(long), .align = sizeof(long), 1247 - .active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set 1226 + [REGSET64_FP] = { 1227 + .core_note_type = NT_PRFPREG, 1228 + .n = sizeof(struct fxregs_state) / sizeof(long), 1229 + .size = sizeof(long), 1230 + .align = sizeof(long), 1231 + .active = regset_xregset_fpregs_active, 1232 + .regset_get = xfpregs_get, 1233 + .set = xfpregs_set 1248 1234 }, 1249 - [REGSET_XSTATE] = { 1250 - .core_note_type = NT_X86_XSTATE, 1251 - .size = sizeof(u64), .align = sizeof(u64), 1252 - .active = xstateregs_active, .regset_get = xstateregs_get, 1253 - .set = xstateregs_set 1235 + [REGSET64_XSTATE] = { 1236 + .core_note_type = NT_X86_XSTATE, 1237 + .size = sizeof(u64), 1238 + .align = sizeof(u64), 1239 + .active = xstateregs_active, 1240 + .regset_get = xstateregs_get, 1241 + .set = xstateregs_set 1254 1242 }, 1255 - [REGSET_IOPERM64] = { 1256 - .core_note_type = NT_386_IOPERM, 1257 - .n = IO_BITMAP_LONGS, 1258 - .size = sizeof(long), .align = sizeof(long), 1259 - .active = ioperm_active, .regset_get = ioperm_get 1243 + [REGSET64_IOPERM] = { 1244 + .core_note_type = NT_386_IOPERM, 1245 + .n = IO_BITMAP_LONGS, 1246 + .size = sizeof(long), 1247 + .align = sizeof(long), 1248 + .active = ioperm_active, 1249 + .regset_get = ioperm_get 1260 1250 }, 1261 1251 }; 1262 1252 ··· 1284 1256 1285 1257 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 1286 1258 static struct user_regset x86_32_regsets[] __ro_after_init = { 1287 - [REGSET_GENERAL] = { 1288 - .core_note_type = NT_PRSTATUS, 1289 - .n = sizeof(struct user_regs_struct32) / sizeof(u32), 1290 - .size = sizeof(u32), .align = sizeof(u32), 1291 - .regset_get = genregs32_get, .set = genregs32_set 1259 + [REGSET32_GENERAL] = { 1260 + .core_note_type = NT_PRSTATUS, 1261 + .n = sizeof(struct user_regs_struct32) / sizeof(u32), 1262 + .size = sizeof(u32), 1263 + .align = sizeof(u32), 1264 + .regset_get = genregs32_get, 1265 + .set = genregs32_set 1292 1266 }, 1293 - [REGSET_FP] = { 1294 - .core_note_type = NT_PRFPREG, 1295 - .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32), 1296 - .size = sizeof(u32), .align = sizeof(u32), 1297 - .active = regset_fpregs_active, .regset_get = fpregs_get, .set = fpregs_set 1267 + [REGSET32_FP] = { 1268 + .core_note_type = NT_PRFPREG, 1269 + .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32), 1270 + .size = sizeof(u32), 1271 + .align = sizeof(u32), 1272 + .active = regset_fpregs_active, 1273 + .regset_get = fpregs_get, 1274 + .set = fpregs_set 1298 1275 }, 1299 - [REGSET_XFP] = { 1300 - .core_note_type = NT_PRXFPREG, 1301 - .n = sizeof(struct fxregs_state) / sizeof(u32), 1302 - .size = sizeof(u32), .align = sizeof(u32), 1303 - .active = regset_xregset_fpregs_active, .regset_get = xfpregs_get, .set = xfpregs_set 1276 + [REGSET32_XFP] = { 1277 + .core_note_type = NT_PRXFPREG, 1278 + .n = sizeof(struct fxregs_state) / sizeof(u32), 1279 + .size = sizeof(u32), 1280 + .align = sizeof(u32), 1281 + .active = regset_xregset_fpregs_active, 1282 + .regset_get = xfpregs_get, 1283 + .set = xfpregs_set 1304 1284 }, 1305 - [REGSET_XSTATE] = { 1306 - .core_note_type = NT_X86_XSTATE, 1307 - .size = sizeof(u64), .align = sizeof(u64), 1308 - .active = xstateregs_active, .regset_get = xstateregs_get, 1309 - .set = xstateregs_set 1285 + [REGSET32_XSTATE] = { 1286 + .core_note_type = NT_X86_XSTATE, 1287 + .size = sizeof(u64), 1288 + .align = sizeof(u64), 1289 + .active = xstateregs_active, 1290 + .regset_get = xstateregs_get, 1291 + .set = xstateregs_set 1310 1292 }, 1311 - [REGSET_TLS] = { 1312 - .core_note_type = NT_386_TLS, 1313 - .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN, 1314 - .size = sizeof(struct user_desc), 1315 - .align = sizeof(struct user_desc), 1316 - .active = regset_tls_active, 1317 - .regset_get = regset_tls_get, .set = regset_tls_set 1293 + [REGSET32_TLS] = { 1294 + .core_note_type = NT_386_TLS, 1295 + .n = GDT_ENTRY_TLS_ENTRIES, 1296 + .bias = GDT_ENTRY_TLS_MIN, 1297 + .size = sizeof(struct user_desc), 1298 + .align = sizeof(struct user_desc), 1299 + .active = regset_tls_active, 1300 + .regset_get = regset_tls_get, 1301 + .set = regset_tls_set 1318 1302 }, 1319 - [REGSET_IOPERM32] = { 1320 - .core_note_type = NT_386_IOPERM, 1321 - .n = IO_BITMAP_BYTES / sizeof(u32), 1322 - .size = sizeof(u32), .align = sizeof(u32), 1323 - .active = ioperm_active, .regset_get = ioperm_get 1303 + [REGSET32_IOPERM] = { 1304 + .core_note_type = NT_386_IOPERM, 1305 + .n = IO_BITMAP_BYTES / sizeof(u32), 1306 + .size = sizeof(u32), 1307 + .align = sizeof(u32), 1308 + .active = ioperm_active, 1309 + .regset_get = ioperm_get 1324 1310 }, 1325 1311 }; 1326 1312 ··· 1353 1311 void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask) 1354 1312 { 1355 1313 #ifdef CONFIG_X86_64 1356 - x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64); 1314 + x86_64_regsets[REGSET64_XSTATE].n = size / sizeof(u64); 1357 1315 #endif 1358 1316 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 1359 - x86_32_regsets[REGSET_XSTATE].n = size / sizeof(u64); 1317 + x86_32_regsets[REGSET32_XSTATE].n = size / sizeof(u64); 1360 1318 #endif 1361 1319 xstate_fx_sw_bytes[USER_XSTATE_XCR0_WORD] = xstate_mask; 1362 1320 }
+2 -2
arch/x86/kernel/traps.c
··· 68 68 69 69 #ifdef CONFIG_X86_64 70 70 #include <asm/x86_init.h> 71 - #include <asm/proto.h> 72 71 #else 73 72 #include <asm/processor-flags.h> 74 73 #include <asm/setup.h> 75 - #include <asm/proto.h> 76 74 #endif 75 + 76 + #include <asm/proto.h> 77 77 78 78 DECLARE_BITMAP(system_vectors, NR_VECTORS); 79 79
+1 -1
arch/x86/kernel/tsc.c
··· 51 51 static u32 art_to_tsc_numerator; 52 52 static u32 art_to_tsc_denominator; 53 53 static u64 art_to_tsc_offset; 54 - struct clocksource *art_related_clocksource; 54 + static struct clocksource *art_related_clocksource; 55 55 56 56 struct cyc2ns { 57 57 struct cyc2ns_data data[2]; /* 0 + 2*16 = 32 */