Skip to content

Commit 8cded8f

Browse files
committed
Merge tag 'x86_core_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 core fixes from Borislav Petkov: - Make sure an INT3 is slapped after every unconditional retpoline JMP as both vendors suggest - Clean up pciserial a bit * tag 'x86_core_for_v6.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86,retpoline: Be sure to emit INT3 after JMP *%\reg x86/earlyprintk: Clean up pciserial
2 parents 5bb3a16 + 8c03af3 commit 8cded8f

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

arch/x86/kernel/alternative.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ static int patch_retpoline(void *addr, struct insn *insn, u8 *bytes)
453453
return ret;
454454
i += ret;
455455

456+
/*
457+
* The compiler is supposed to EMIT an INT3 after every unconditional
458+
* JMP instruction due to AMD BTC. However, if the compiler is too old
459+
* or SLS isn't enabled, we still need an INT3 after indirect JMPs
460+
* even on Intel.
461+
*/
462+
if (op == JMP32_INSN_OPCODE && i < insn->length)
463+
bytes[i++] = INT3_INSN_OPCODE;
464+
456465
for (; i < insn->length;)
457466
bytes[i++] = BYTES_NOP1;
458467

arch/x86/kernel/early_printk.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,34 +264,34 @@ static __init void early_pci_serial_init(char *s)
264264
bar0 = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);
265265

266266
/*
267-
* Verify it is a UART type device
267+
* Verify it is a 16550-UART type device
268268
*/
269269
if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) &&
270270
(classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) ||
271-
(((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */ {
271+
(((classcode >> 8) & 0xff) != PCI_SERIAL_16550_COMPATIBLE)) {
272272
if (!force)
273273
return;
274274
}
275275

276276
/*
277277
* Determine if it is IO or memory mapped
278278
*/
279-
if (bar0 & 0x01) {
279+
if ((bar0 & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
280280
/* it is IO mapped */
281281
serial_in = io_serial_in;
282282
serial_out = io_serial_out;
283-
early_serial_base = bar0&0xfffffffc;
283+
early_serial_base = bar0 & PCI_BASE_ADDRESS_IO_MASK;
284284
write_pci_config(bus, slot, func, PCI_COMMAND,
285-
cmdreg|PCI_COMMAND_IO);
285+
cmdreg|PCI_COMMAND_IO);
286286
} else {
287287
/* It is memory mapped - assume 32-bit alignment */
288288
serial_in = mem32_serial_in;
289289
serial_out = mem32_serial_out;
290290
/* WARNING! assuming the address is always in the first 4G */
291291
early_serial_base =
292-
(unsigned long)early_ioremap(bar0 & 0xfffffff0, 0x10);
292+
(unsigned long)early_ioremap(bar0 & PCI_BASE_ADDRESS_MEM_MASK, 0x10);
293293
write_pci_config(bus, slot, func, PCI_COMMAND,
294-
cmdreg|PCI_COMMAND_MEMORY);
294+
cmdreg|PCI_COMMAND_MEMORY);
295295
}
296296

297297
/*

arch/x86/net/bpf_jit_comp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,9 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip)
419419
OPTIMIZER_HIDE_VAR(reg);
420420
emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
421421
} else {
422-
EMIT2(0xFF, 0xE0 + reg);
422+
EMIT2(0xFF, 0xE0 + reg); /* jmp *%\reg */
423+
if (IS_ENABLED(CONFIG_RETPOLINE) || IS_ENABLED(CONFIG_SLS))
424+
EMIT1(0xCC); /* int3 */
423425
}
424426

425427
*pprog = prog;

include/linux/pci_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
#define PCI_CLASS_COMMUNICATION_MODEM 0x0703
7676
#define PCI_CLASS_COMMUNICATION_OTHER 0x0780
7777

78+
/* Interface for SERIAL/MODEM */
79+
#define PCI_SERIAL_16550_COMPATIBLE 0x02
80+
7881
#define PCI_BASE_CLASS_SYSTEM 0x08
7982
#define PCI_CLASS_SYSTEM_PIC 0x0800
8083
#define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010

0 commit comments

Comments
 (0)