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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86-urgent-2020-11-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
"A set of x86 fixes:

- Use SYM_FUNC_START_WEAK in the mem* ASM functions instead of a
combination of .weak and SYM_FUNC_START_LOCAL which makes LLVMs
integrated assembler upset

- Correct the mitigation selection logic which prevented the related
prctl to work correctly

- Make the UV5 hubless system work correctly by fixing up the
malformed table entries and adding the missing ones"

* tag 'x86-urgent-2020-11-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/platform/uv: Recognize UV5 hubless system identifier
x86/platform/uv: Remove spaces from OEM IDs
x86/platform/uv: Fix missing OEM_TABLE_ID
x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP
x86/lib: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S

+54 -32
+18 -5
arch/x86/kernel/apic/x2apic_uv_x.c
··· 290 290 { 291 291 /* Relies on 'to' being NULL chars so result will be NULL terminated */ 292 292 strncpy(to, from, len-1); 293 + 294 + /* Trim trailing spaces */ 295 + (void)strim(to); 293 296 } 294 297 295 298 /* Find UV arch type entry in UVsystab */ ··· 369 366 return ret; 370 367 } 371 368 372 - static int __init uv_set_system_type(char *_oem_id) 369 + static int __init uv_set_system_type(char *_oem_id, char *_oem_table_id) 373 370 { 374 371 /* Save OEM_ID passed from ACPI MADT */ 375 372 uv_stringify(sizeof(oem_id), oem_id, _oem_id); ··· 389 386 /* (Not hubless), not a UV */ 390 387 return 0; 391 388 389 + /* Is UV hubless system */ 390 + uv_hubless_system = 0x01; 391 + 392 + /* UV5 Hubless */ 393 + if (strncmp(uv_archtype, "NSGI5", 5) == 0) 394 + uv_hubless_system |= 0x20; 395 + 392 396 /* UV4 Hubless: CH */ 393 - if (strncmp(uv_archtype, "NSGI4", 5) == 0) 394 - uv_hubless_system = 0x11; 397 + else if (strncmp(uv_archtype, "NSGI4", 5) == 0) 398 + uv_hubless_system |= 0x10; 395 399 396 400 /* UV3 Hubless: UV300/MC990X w/o hub */ 397 401 else 398 - uv_hubless_system = 0x9; 402 + uv_hubless_system |= 0x8; 403 + 404 + /* Copy APIC type */ 405 + uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id); 399 406 400 407 pr_info("UV: OEM IDs %s/%s, SystemType %d, HUBLESS ID %x\n", 401 408 oem_id, oem_table_id, uv_system_type, uv_hubless_system); ··· 469 456 uv_cpu_info->p_uv_hub_info = &uv_hub_info_node0; 470 457 471 458 /* If not UV, return. */ 472 - if (likely(uv_set_system_type(_oem_id) == 0)) 459 + if (uv_set_system_type(_oem_id, _oem_table_id) == 0) 473 460 return 0; 474 461 475 462 /* Save and Decode OEM Table ID */
+33 -18
arch/x86/kernel/cpu/bugs.c
··· 1254 1254 return 0; 1255 1255 } 1256 1256 1257 + static bool is_spec_ib_user_controlled(void) 1258 + { 1259 + return spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL || 1260 + spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP || 1261 + spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL || 1262 + spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP; 1263 + } 1264 + 1257 1265 static int ib_prctl_set(struct task_struct *task, unsigned long ctrl) 1258 1266 { 1259 1267 switch (ctrl) { ··· 1269 1261 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE && 1270 1262 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE) 1271 1263 return 0; 1264 + 1272 1265 /* 1273 - * Indirect branch speculation is always disabled in strict 1274 - * mode. It can neither be enabled if it was force-disabled 1275 - * by a previous prctl call. 1266 + * With strict mode for both IBPB and STIBP, the instruction 1267 + * code paths avoid checking this task flag and instead, 1268 + * unconditionally run the instruction. However, STIBP and IBPB 1269 + * are independent and either can be set to conditionally 1270 + * enabled regardless of the mode of the other. 1271 + * 1272 + * If either is set to conditional, allow the task flag to be 1273 + * updated, unless it was force-disabled by a previous prctl 1274 + * call. Currently, this is possible on an AMD CPU which has the 1275 + * feature X86_FEATURE_AMD_STIBP_ALWAYS_ON. In this case, if the 1276 + * kernel is booted with 'spectre_v2_user=seccomp', then 1277 + * spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP and 1278 + * spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED. 1276 1279 */ 1277 - if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT || 1278 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT || 1279 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED || 1280 + if (!is_spec_ib_user_controlled() || 1280 1281 task_spec_ib_force_disable(task)) 1281 1282 return -EPERM; 1283 + 1282 1284 task_clear_spec_ib_disable(task); 1283 1285 task_update_spec_tif(task); 1284 1286 break; ··· 1301 1283 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE && 1302 1284 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE) 1303 1285 return -EPERM; 1304 - if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT || 1305 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT || 1306 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED) 1286 + 1287 + if (!is_spec_ib_user_controlled()) 1307 1288 return 0; 1289 + 1308 1290 task_set_spec_ib_disable(task); 1309 1291 if (ctrl == PR_SPEC_FORCE_DISABLE) 1310 1292 task_set_spec_ib_force_disable(task); ··· 1369 1351 if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE && 1370 1352 spectre_v2_user_stibp == SPECTRE_V2_USER_NONE) 1371 1353 return PR_SPEC_ENABLE; 1372 - else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT || 1373 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT || 1374 - spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED) 1375 - return PR_SPEC_DISABLE; 1376 - else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL || 1377 - spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP || 1378 - spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL || 1379 - spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP) { 1354 + else if (is_spec_ib_user_controlled()) { 1380 1355 if (task_spec_ib_force_disable(task)) 1381 1356 return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE; 1382 1357 if (task_spec_ib_disable(task)) 1383 1358 return PR_SPEC_PRCTL | PR_SPEC_DISABLE; 1384 1359 return PR_SPEC_PRCTL | PR_SPEC_ENABLE; 1385 - } else 1360 + } else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT || 1361 + spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT || 1362 + spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED) 1363 + return PR_SPEC_DISABLE; 1364 + else 1386 1365 return PR_SPEC_NOT_AFFECTED; 1387 1366 } 1388 1367
+1 -3
arch/x86/lib/memcpy_64.S
··· 16 16 * to a jmp to memcpy_erms which does the REP; MOVSB mem copy. 17 17 */ 18 18 19 - .weak memcpy 20 - 21 19 /* 22 20 * memcpy - Copy a memory block. 23 21 * ··· 28 30 * rax original destination 29 31 */ 30 32 SYM_FUNC_START_ALIAS(__memcpy) 31 - SYM_FUNC_START_LOCAL(memcpy) 33 + SYM_FUNC_START_WEAK(memcpy) 32 34 ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \ 33 35 "jmp memcpy_erms", X86_FEATURE_ERMS 34 36
+1 -3
arch/x86/lib/memmove_64.S
··· 24 24 * Output: 25 25 * rax: dest 26 26 */ 27 - .weak memmove 28 - 29 - SYM_FUNC_START_ALIAS(memmove) 27 + SYM_FUNC_START_WEAK(memmove) 30 28 SYM_FUNC_START(__memmove) 31 29 32 30 mov %rdi, %rax
+1 -3
arch/x86/lib/memset_64.S
··· 6 6 #include <asm/alternative-asm.h> 7 7 #include <asm/export.h> 8 8 9 - .weak memset 10 - 11 9 /* 12 10 * ISO C memset - set a memory block to a byte value. This function uses fast 13 11 * string to get better performance than the original function. The code is ··· 17 19 * 18 20 * rax original destination 19 21 */ 20 - SYM_FUNC_START_ALIAS(memset) 22 + SYM_FUNC_START_WEAK(memset) 21 23 SYM_FUNC_START(__memset) 22 24 /* 23 25 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended