Skip to content

Commit 9c6913b

Browse files
committed
Merge tag 'x86_urgent_for_v5.18_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Fix the MSI message data struct definition - Use local labels in the exception table macros to avoid symbol conflicts with clang LTO builds - A couple of fixes to objtool checking of the relatively newly added SLS and IBT code - Rename a local var in the WARN* macro machinery to prevent shadowing * tag 'x86_urgent_for_v5.18_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/msi: Fix msi message data shadow struct x86/extable: Prefer local labels in .set directives x86,bpf: Avoid IBT objtool warning objtool: Fix SLS validation for kcov tail-call replacement objtool: Fix IBT tail-call detection x86/bug: Prevent shadowing in __WARN_FLAGS x86/mm/tlb: Revert retpoline avoidance approach
2 parents b51f86e + 59b18a1 commit 9c6913b

File tree

6 files changed

+54
-57
lines changed

6 files changed

+54
-57
lines changed

arch/x86/include/asm/asm.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,24 @@
154154

155155
# define DEFINE_EXTABLE_TYPE_REG \
156156
".macro extable_type_reg type:req reg:req\n" \
157-
".set found, 0\n" \
158-
".set regnr, 0\n" \
157+
".set .Lfound, 0\n" \
158+
".set .Lregnr, 0\n" \
159159
".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n" \
160160
".ifc \\reg, %%\\rs\n" \
161-
".set found, found+1\n" \
162-
".long \\type + (regnr << 8)\n" \
161+
".set .Lfound, .Lfound+1\n" \
162+
".long \\type + (.Lregnr << 8)\n" \
163163
".endif\n" \
164-
".set regnr, regnr+1\n" \
164+
".set .Lregnr, .Lregnr+1\n" \
165165
".endr\n" \
166-
".set regnr, 0\n" \
166+
".set .Lregnr, 0\n" \
167167
".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n" \
168168
".ifc \\reg, %%\\rs\n" \
169-
".set found, found+1\n" \
170-
".long \\type + (regnr << 8)\n" \
169+
".set .Lfound, .Lfound+1\n" \
170+
".long \\type + (.Lregnr << 8)\n" \
171171
".endif\n" \
172-
".set regnr, regnr+1\n" \
172+
".set .Lregnr, .Lregnr+1\n" \
173173
".endr\n" \
174-
".if (found != 1)\n" \
174+
".if (.Lfound != 1)\n" \
175175
".error \"extable_type_reg: bad register argument\"\n" \
176176
".endif\n" \
177177
".endm\n"

arch/x86/include/asm/bug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ do { \
7878
*/
7979
#define __WARN_FLAGS(flags) \
8080
do { \
81-
__auto_type f = BUGFLAG_WARNING|(flags); \
81+
__auto_type __flags = BUGFLAG_WARNING|(flags); \
8282
instrumentation_begin(); \
83-
_BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \
83+
_BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \
8484
instrumentation_end(); \
8585
} while (0)
8686

arch/x86/include/asm/msi.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec,
1212
/* Structs and defines for the X86 specific MSI message format */
1313

1414
typedef struct x86_msi_data {
15-
u32 vector : 8,
16-
delivery_mode : 3,
17-
dest_mode_logical : 1,
18-
reserved : 2,
19-
active_low : 1,
20-
is_level : 1;
21-
22-
u32 dmar_subhandle;
15+
union {
16+
struct {
17+
u32 vector : 8,
18+
delivery_mode : 3,
19+
dest_mode_logical : 1,
20+
reserved : 2,
21+
active_low : 1,
22+
is_level : 1;
23+
};
24+
u32 dmar_subhandle;
25+
};
2326
} __attribute__ ((packed)) arch_msi_msg_data_t;
2427
#define arch_msi_msg_data x86_msi_data
2528

arch/x86/mm/tlb.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,11 @@ static void flush_tlb_func(void *info)
855855
nr_invalidate);
856856
}
857857

858-
static bool tlb_is_not_lazy(int cpu)
858+
static bool tlb_is_not_lazy(int cpu, void *data)
859859
{
860860
return !per_cpu(cpu_tlbstate_shared.is_lazy, cpu);
861861
}
862862

863-
static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask);
864-
865863
DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared);
866864
EXPORT_PER_CPU_SYMBOL(cpu_tlbstate_shared);
867865

@@ -890,36 +888,11 @@ STATIC_NOPV void native_flush_tlb_multi(const struct cpumask *cpumask,
890888
* up on the new contents of what used to be page tables, while
891889
* doing a speculative memory access.
892890
*/
893-
if (info->freed_tables) {
891+
if (info->freed_tables)
894892
on_each_cpu_mask(cpumask, flush_tlb_func, (void *)info, true);
895-
} else {
896-
/*
897-
* Although we could have used on_each_cpu_cond_mask(),
898-
* open-coding it has performance advantages, as it eliminates
899-
* the need for indirect calls or retpolines. In addition, it
900-
* allows to use a designated cpumask for evaluating the
901-
* condition, instead of allocating one.
902-
*
903-
* This code works under the assumption that there are no nested
904-
* TLB flushes, an assumption that is already made in
905-
* flush_tlb_mm_range().
906-
*
907-
* cond_cpumask is logically a stack-local variable, but it is
908-
* more efficient to have it off the stack and not to allocate
909-
* it on demand. Preemption is disabled and this code is
910-
* non-reentrant.
911-
*/
912-
struct cpumask *cond_cpumask = this_cpu_ptr(&flush_tlb_mask);
913-
int cpu;
914-
915-
cpumask_clear(cond_cpumask);
916-
917-
for_each_cpu(cpu, cpumask) {
918-
if (tlb_is_not_lazy(cpu))
919-
__cpumask_set_cpu(cpu, cond_cpumask);
920-
}
921-
on_each_cpu_mask(cond_cpumask, flush_tlb_func, (void *)info, true);
922-
}
893+
else
894+
on_each_cpu_cond_mask(tlb_is_not_lazy, flush_tlb_func,
895+
(void *)info, 1, cpumask);
923896
}
924897

925898
void flush_tlb_multi(const struct cpumask *cpumask,

arch/x86/net/bpf_jit_comp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip)
412412
EMIT_LFENCE();
413413
EMIT2(0xFF, 0xE0 + reg);
414414
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
415+
OPTIMIZER_HIDE_VAR(reg);
415416
emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
416417
} else
417418
#endif

tools/objtool/check.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,17 @@ static void annotate_call_site(struct objtool_file *file,
11551155
: arch_nop_insn(insn->len));
11561156

11571157
insn->type = sibling ? INSN_RETURN : INSN_NOP;
1158+
1159+
if (sibling) {
1160+
/*
1161+
* We've replaced the tail-call JMP insn by two new
1162+
* insn: RET; INT3, except we only have a single struct
1163+
* insn here. Mark it retpoline_safe to avoid the SLS
1164+
* warning, instead of adding another insn.
1165+
*/
1166+
insn->retpoline_safe = true;
1167+
}
1168+
11581169
return;
11591170
}
11601171

@@ -1239,11 +1250,20 @@ static bool same_function(struct instruction *insn1, struct instruction *insn2)
12391250
return insn1->func->pfunc == insn2->func->pfunc;
12401251
}
12411252

1242-
static bool is_first_func_insn(struct instruction *insn)
1253+
static bool is_first_func_insn(struct objtool_file *file, struct instruction *insn)
12431254
{
1244-
return insn->offset == insn->func->offset ||
1245-
(insn->type == INSN_ENDBR &&
1246-
insn->offset == insn->func->offset + insn->len);
1255+
if (insn->offset == insn->func->offset)
1256+
return true;
1257+
1258+
if (ibt) {
1259+
struct instruction *prev = prev_insn_same_sym(file, insn);
1260+
1261+
if (prev && prev->type == INSN_ENDBR &&
1262+
insn->offset == insn->func->offset + prev->len)
1263+
return true;
1264+
}
1265+
1266+
return false;
12471267
}
12481268

12491269
/*
@@ -1327,7 +1347,7 @@ static int add_jump_destinations(struct objtool_file *file)
13271347
insn->jump_dest->func->pfunc = insn->func;
13281348

13291349
} else if (!same_function(insn, insn->jump_dest) &&
1330-
is_first_func_insn(insn->jump_dest)) {
1350+
is_first_func_insn(file, insn->jump_dest)) {
13311351
/* internal sibling call (without reloc) */
13321352
add_call_dest(file, insn, insn->jump_dest->func, true);
13331353
}

0 commit comments

Comments
 (0)