Skip to content

Commit 0200fbd

Browse files
committed
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking and misc x86 updates from Ingo Molnar: "Lots of changes in this cycle - in part because locking/core attracted a number of related x86 low level work which was easier to handle in a single tree: - Linux Kernel Memory Consistency Model updates (Alan Stern, Paul E. McKenney, Andrea Parri) - lockdep scalability improvements and micro-optimizations (Waiman Long) - rwsem improvements (Waiman Long) - spinlock micro-optimization (Matthew Wilcox) - qspinlocks: Provide a liveness guarantee (more fairness) on x86. (Peter Zijlstra) - Add support for relative references in jump tables on arm64, x86 and s390 to optimize jump labels (Ard Biesheuvel, Heiko Carstens) - Be a lot less permissive on weird (kernel address) uaccess faults on x86: BUG() when uaccess helpers fault on kernel addresses (Jann Horn) - macrofy x86 asm statements to un-confuse the GCC inliner. (Nadav Amit) - ... and a handful of other smaller changes as well" * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (57 commits) locking/lockdep: Make global debug_locks* variables read-mostly locking/lockdep: Fix debug_locks off performance problem locking/pvqspinlock: Extend node size when pvqspinlock is configured locking/qspinlock_stat: Count instances of nested lock slowpaths locking/qspinlock, x86: Provide liveness guarantee x86/asm: 'Simplify' GEN_*_RMWcc() macros locking/qspinlock: Rework some comments locking/qspinlock: Re-order code locking/lockdep: Remove duplicated 'lock_class_ops' percpu array x86/defconfig: Enable CONFIG_USB_XHCI_HCD=y futex: Replace spin_is_locked() with lockdep locking/lockdep: Make class->ops a percpu counter and move it under CONFIG_DEBUG_LOCKDEP=y x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs x86/cpufeature: Macrofy inline assembly code to work around GCC inlining bugs x86/extable: Macrofy inline assembly code to work around GCC inlining bugs x86/paravirt: Work around GCC inlining bugs when compiling paravirt ops x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs x86/alternatives: Macrofy lock prefixes to work around GCC inlining bugs x86/refcount: Work around GCC inlining bug x86/objtool: Use asm macros to work around GCC inlining bugs ...
2 parents de3fbb2 + 01a14bd commit 0200fbd

95 files changed

Lines changed: 1522 additions & 934 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/locking/lockstat.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Look at the current lock statistics:
9191
07 &mm->mmap_sem-R: 37 100 1.31 299502.61 325629.52 3256.30 212344 34316685 0.10 7744.91 95016910.20 2.77
9292
08 ---------------
9393
09 &mm->mmap_sem 1 [<ffffffff811502a7>] khugepaged_scan_mm_slot+0x57/0x280
94-
19 &mm->mmap_sem 96 [<ffffffff815351c4>] __do_page_fault+0x1d4/0x510
94+
10 &mm->mmap_sem 96 [<ffffffff815351c4>] __do_page_fault+0x1d4/0x510
9595
11 &mm->mmap_sem 34 [<ffffffff81113d77>] vm_mmap_pgoff+0x87/0xd0
9696
12 &mm->mmap_sem 17 [<ffffffff81127e71>] vm_munmap+0x41/0x80
9797
13 ---------------

‎Documentation/memory-barriers.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ And a couple of implicit varieties:
471471
operations after the ACQUIRE operation will appear to happen after the
472472
ACQUIRE operation with respect to the other components of the system.
473473
ACQUIRE operations include LOCK operations and both smp_load_acquire()
474-
and smp_cond_acquire() operations. The later builds the necessary ACQUIRE
475-
semantics from relying on a control dependency and smp_rmb().
474+
and smp_cond_load_acquire() operations.
476475

477476
Memory operations that occur before an ACQUIRE operation may appear to
478477
happen after it completes.

‎Makefile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
10731073
# version.h and scripts_basic is processed / created.
10741074

10751075
# Listed in dependency order
1076-
PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
1076+
PHONY += prepare archprepare macroprepare prepare0 prepare1 prepare2 prepare3
10771077

10781078
# prepare3 is used to check if we are building in a separate output directory,
10791079
# and if so do:
@@ -1096,7 +1096,9 @@ prepare2: prepare3 outputmakefile asm-generic
10961096
prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
10971097
$(cmd_crmodverdir)
10981098

1099-
archprepare: archheaders archscripts prepare1 scripts_basic
1099+
macroprepare: prepare1 archmacros
1100+
1101+
archprepare: archheaders archscripts macroprepare scripts_basic
11001102

11011103
prepare0: archprepare gcc-plugins
11021104
$(Q)$(MAKE) $(build)=.
@@ -1164,6 +1166,9 @@ archheaders:
11641166
PHONY += archscripts
11651167
archscripts:
11661168

1169+
PHONY += archmacros
1170+
archmacros:
1171+
11671172
PHONY += __headers
11681173
__headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts
11691174
$(Q)$(MAKE) $(build)=scripts build_unifdef

‎arch/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ config HAVE_PERF_USER_STACK_DUMP
359359
config HAVE_ARCH_JUMP_LABEL
360360
bool
361361

362+
config HAVE_ARCH_JUMP_LABEL_RELATIVE
363+
bool
364+
362365
config HAVE_RCU_TABLE_FREE
363366
bool
364367

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ config ARM64
105105
select HAVE_ARCH_BITREVERSE
106106
select HAVE_ARCH_HUGE_VMAP
107107
select HAVE_ARCH_JUMP_LABEL
108+
select HAVE_ARCH_JUMP_LABEL_RELATIVE
108109
select HAVE_ARCH_KASAN if !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
109110
select HAVE_ARCH_KGDB
110111
select HAVE_ARCH_MMAP_RND_BITS

‎arch/arm64/include/asm/jump_label.h‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,39 @@
2626

2727
#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE
2828

29-
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
29+
static __always_inline bool arch_static_branch(struct static_key *key,
30+
bool branch)
3031
{
31-
asm_volatile_goto("1: nop\n\t"
32-
".pushsection __jump_table, \"aw\"\n\t"
33-
".align 3\n\t"
34-
".quad 1b, %l[l_yes], %c0\n\t"
35-
".popsection\n\t"
32+
asm_volatile_goto(
33+
"1: nop \n\t"
34+
" .pushsection __jump_table, \"aw\" \n\t"
35+
" .align 3 \n\t"
36+
" .long 1b - ., %l[l_yes] - . \n\t"
37+
" .quad %c0 - . \n\t"
38+
" .popsection \n\t"
3639
: : "i"(&((char *)key)[branch]) : : l_yes);
3740

3841
return false;
3942
l_yes:
4043
return true;
4144
}
4245

43-
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
46+
static __always_inline bool arch_static_branch_jump(struct static_key *key,
47+
bool branch)
4448
{
45-
asm_volatile_goto("1: b %l[l_yes]\n\t"
46-
".pushsection __jump_table, \"aw\"\n\t"
47-
".align 3\n\t"
48-
".quad 1b, %l[l_yes], %c0\n\t"
49-
".popsection\n\t"
49+
asm_volatile_goto(
50+
"1: b %l[l_yes] \n\t"
51+
" .pushsection __jump_table, \"aw\" \n\t"
52+
" .align 3 \n\t"
53+
" .long 1b - ., %l[l_yes] - . \n\t"
54+
" .quad %c0 - . \n\t"
55+
" .popsection \n\t"
5056
: : "i"(&((char *)key)[branch]) : : l_yes);
5157

5258
return false;
5359
l_yes:
5460
return true;
5561
}
5662

57-
typedef u64 jump_label_t;
58-
59-
struct jump_entry {
60-
jump_label_t code;
61-
jump_label_t target;
62-
jump_label_t key;
63-
};
64-
6563
#endif /* __ASSEMBLY__ */
6664
#endif /* __ASM_JUMP_LABEL_H */

‎arch/arm64/kernel/jump_label.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
void arch_jump_label_transform(struct jump_entry *entry,
2626
enum jump_label_type type)
2727
{
28-
void *addr = (void *)entry->code;
28+
void *addr = (void *)jump_entry_code(entry);
2929
u32 insn;
3030

3131
if (type == JUMP_LABEL_JMP) {
32-
insn = aarch64_insn_gen_branch_imm(entry->code,
33-
entry->target,
32+
insn = aarch64_insn_gen_branch_imm(jump_entry_code(entry),
33+
jump_entry_target(entry),
3434
AARCH64_INSN_BRANCH_NOLINK);
3535
} else {
3636
insn = aarch64_insn_gen_nop();

‎arch/s390/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ config S390
126126
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
127127
select HAVE_ARCH_AUDITSYSCALL
128128
select HAVE_ARCH_JUMP_LABEL
129+
select HAVE_ARCH_JUMP_LABEL_RELATIVE
129130
select HAVE_ARCH_KASAN
130131
select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
131132
select HAVE_ARCH_SECCOMP_FILTER

‎arch/s390/include/asm/jump_label.h‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,33 @@
1414
* We use a brcl 0,2 instruction for jump labels at compile time so it
1515
* can be easily distinguished from a hotpatch generated instruction.
1616
*/
17-
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
17+
static inline bool arch_static_branch(struct static_key *key, bool branch)
1818
{
19-
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
20-
".pushsection __jump_table, \"aw\"\n"
21-
".balign 8\n"
22-
".quad 0b, %l[label], %0\n"
23-
".popsection\n"
24-
: : "X" (&((char *)key)[branch]) : : label);
25-
19+
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
20+
".pushsection __jump_table,\"aw\"\n"
21+
".balign 8\n"
22+
".long 0b-.,%l[label]-.\n"
23+
".quad %0-.\n"
24+
".popsection\n"
25+
: : "X" (&((char *)key)[branch]) : : label);
2626
return false;
2727
label:
2828
return true;
2929
}
3030

31-
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
31+
static inline bool arch_static_branch_jump(struct static_key *key, bool branch)
3232
{
33-
asm_volatile_goto("0: brcl 15, %l[label]\n"
34-
".pushsection __jump_table, \"aw\"\n"
35-
".balign 8\n"
36-
".quad 0b, %l[label], %0\n"
37-
".popsection\n"
38-
: : "X" (&((char *)key)[branch]) : : label);
39-
33+
asm_volatile_goto("0: brcl 15,%l[label]\n"
34+
".pushsection __jump_table,\"aw\"\n"
35+
".balign 8\n"
36+
".long 0b-.,%l[label]-.\n"
37+
".quad %0-.\n"
38+
".popsection\n"
39+
: : "X" (&((char *)key)[branch]) : : label);
4040
return false;
4141
label:
4242
return true;
4343
}
4444

45-
typedef unsigned long jump_label_t;
46-
47-
struct jump_entry {
48-
jump_label_t code;
49-
jump_label_t target;
50-
jump_label_t key;
51-
};
52-
5345
#endif /* __ASSEMBLY__ */
5446
#endif

‎arch/s390/kernel/jump_label.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ static void jump_label_make_branch(struct jump_entry *entry, struct insn *insn)
3333
{
3434
/* brcl 15,offset */
3535
insn->opcode = 0xc0f4;
36-
insn->offset = (entry->target - entry->code) >> 1;
36+
insn->offset = (jump_entry_target(entry) - jump_entry_code(entry)) >> 1;
3737
}
3838

3939
static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
4040
struct insn *new)
4141
{
42-
unsigned char *ipc = (unsigned char *)entry->code;
42+
unsigned char *ipc = (unsigned char *)jump_entry_code(entry);
4343
unsigned char *ipe = (unsigned char *)expected;
4444
unsigned char *ipn = (unsigned char *)new;
4545

@@ -59,6 +59,7 @@ static void __jump_label_transform(struct jump_entry *entry,
5959
enum jump_label_type type,
6060
int init)
6161
{
62+
void *code = (void *)jump_entry_code(entry);
6263
struct insn old, new;
6364

6465
if (type == JUMP_LABEL_JMP) {
@@ -69,13 +70,13 @@ static void __jump_label_transform(struct jump_entry *entry,
6970
jump_label_make_nop(entry, &new);
7071
}
7172
if (init) {
72-
if (memcmp((void *)entry->code, &orignop, sizeof(orignop)))
73+
if (memcmp(code, &orignop, sizeof(orignop)))
7374
jump_label_bug(entry, &orignop, &new);
7475
} else {
75-
if (memcmp((void *)entry->code, &old, sizeof(old)))
76+
if (memcmp(code, &old, sizeof(old)))
7677
jump_label_bug(entry, &old, &new);
7778
}
78-
s390_kernel_write((void *)entry->code, &new, sizeof(new));
79+
s390_kernel_write(code, &new, sizeof(new));
7980
}
8081

8182
static int __sm_arch_jump_label_transform(void *data)

0 commit comments

Comments
 (0)