Skip to content

Commit 2c5ce2d

Browse files
committed
Merge tag 'x86_alternatives_for_v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 alternatives/paravirt updates from Borislav Petkov: "First big cleanup to the paravirt infra to use alternatives and thus eliminate custom code patching. For that, the alternatives infrastructure is extended to accomodate paravirt's needs and, as a result, a lot of paravirt patching code goes away, leading to a sizeable cleanup and simplification. Work by Juergen Gross" * tag 'x86_alternatives_for_v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/paravirt: Have only one paravirt patch function x86/paravirt: Switch functions with custom code to ALTERNATIVE x86/paravirt: Add new PVOP_ALT* macros to support pvops in ALTERNATIVEs x86/paravirt: Switch iret pvops to ALTERNATIVE x86/paravirt: Simplify paravirt macros x86/paravirt: Remove no longer needed 32-bit pvops cruft x86/paravirt: Add new features for paravirt patching x86/alternative: Use ALTERNATIVE_TERNARY() in _static_cpu_has() x86/alternative: Support ALTERNATIVE_TERNARY x86/alternative: Support not-feature x86/paravirt: Switch time pvops functions to use static_call() static_call: Add function to query current function static_call: Move struct static_call_key definition to static_call_types.h x86/alternative: Merge include files x86/alternative: Drop unused feature parameter from ALTINSTR_REPLACEMENT()
2 parents 2c53279 + 054ac8a commit 2c5ce2d

42 files changed

Lines changed: 482 additions & 638 deletions

Some content is hidden

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

‎arch/arm/include/asm/paravirt.h‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@
33
#define _ASM_ARM_PARAVIRT_H
44

55
#ifdef CONFIG_PARAVIRT
6+
#include <linux/static_call_types.h>
7+
68
struct static_key;
79
extern struct static_key paravirt_steal_enabled;
810
extern struct static_key paravirt_steal_rq_enabled;
911

10-
struct pv_time_ops {
11-
unsigned long long (*steal_clock)(int cpu);
12-
};
13-
14-
struct paravirt_patch_template {
15-
struct pv_time_ops time;
16-
};
12+
u64 dummy_steal_clock(int cpu);
1713

18-
extern struct paravirt_patch_template pv_ops;
14+
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
1915

2016
static inline u64 paravirt_steal_clock(int cpu)
2117
{
22-
return pv_ops.time.steal_clock(cpu);
18+
return static_call(pv_steal_clock)(cpu);
2319
}
2420
#endif
2521

‎arch/arm/kernel/paravirt.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
#include <linux/export.h>
1010
#include <linux/jump_label.h>
1111
#include <linux/types.h>
12+
#include <linux/static_call.h>
1213
#include <asm/paravirt.h>
1314

1415
struct static_key paravirt_steal_enabled;
1516
struct static_key paravirt_steal_rq_enabled;
1617

17-
struct paravirt_patch_template pv_ops;
18-
EXPORT_SYMBOL_GPL(pv_ops);
18+
static u64 native_steal_clock(int cpu)
19+
{
20+
return 0;
21+
}
22+
23+
DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@
33
#define _ASM_ARM64_PARAVIRT_H
44

55
#ifdef CONFIG_PARAVIRT
6+
#include <linux/static_call_types.h>
7+
68
struct static_key;
79
extern struct static_key paravirt_steal_enabled;
810
extern struct static_key paravirt_steal_rq_enabled;
911

10-
struct pv_time_ops {
11-
unsigned long long (*steal_clock)(int cpu);
12-
};
13-
14-
struct paravirt_patch_template {
15-
struct pv_time_ops time;
16-
};
12+
u64 dummy_steal_clock(int cpu);
1713

18-
extern struct paravirt_patch_template pv_ops;
14+
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
1915

2016
static inline u64 paravirt_steal_clock(int cpu)
2117
{
22-
return pv_ops.time.steal_clock(cpu);
18+
return static_call(pv_steal_clock)(cpu);
2319
}
2420

2521
int __init pv_time_init(void);

‎arch/arm64/kernel/paravirt.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/reboot.h>
1919
#include <linux/slab.h>
2020
#include <linux/types.h>
21+
#include <linux/static_call.h>
2122

2223
#include <asm/paravirt.h>
2324
#include <asm/pvclock-abi.h>
@@ -26,8 +27,12 @@
2627
struct static_key paravirt_steal_enabled;
2728
struct static_key paravirt_steal_rq_enabled;
2829

29-
struct paravirt_patch_template pv_ops;
30-
EXPORT_SYMBOL_GPL(pv_ops);
30+
static u64 native_steal_clock(int cpu)
31+
{
32+
return 0;
33+
}
34+
35+
DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
3136

3237
struct pv_time_stolen_time_region {
3338
struct pvclock_vcpu_stolen_time *kaddr;
@@ -45,7 +50,7 @@ static int __init parse_no_stealacc(char *arg)
4550
early_param("no-steal-acc", parse_no_stealacc);
4651

4752
/* return stolen time in ns by asking the hypervisor */
48-
static u64 pv_steal_clock(int cpu)
53+
static u64 para_steal_clock(int cpu)
4954
{
5055
struct pv_time_stolen_time_region *reg;
5156

@@ -150,7 +155,7 @@ int __init pv_time_init(void)
150155
if (ret)
151156
return ret;
152157

153-
pv_ops.time.steal_clock = pv_steal_clock;
158+
static_call_update(pv_steal_clock, para_steal_clock);
154159

155160
static_key_slow_inc(&paravirt_steal_enabled);
156161
if (steal_acc)

‎arch/x86/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ if HYPERVISOR_GUEST
777777

778778
config PARAVIRT
779779
bool "Enable paravirtualization code"
780+
depends on HAVE_STATIC_CALL
780781
help
781782
This changes the kernel so it can modify itself when it is run
782783
under a hypervisor, potentially improving performance significantly

‎arch/x86/entry/entry_32.S‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <asm/processor-flags.h>
4141
#include <asm/irq_vectors.h>
4242
#include <asm/cpufeatures.h>
43-
#include <asm/alternative-asm.h>
43+
#include <asm/alternative.h>
4444
#include <asm/asm.h>
4545
#include <asm/smap.h>
4646
#include <asm/frame.h>
@@ -430,7 +430,7 @@
430430
* will soon execute iret and the tracer was already set to
431431
* the irqstate after the IRET:
432432
*/
433-
DISABLE_INTERRUPTS(CLBR_ANY)
433+
cli
434434
lss (%esp), %esp /* switch to espfix segment */
435435
.Lend_\@:
436436
#endif /* CONFIG_X86_ESPFIX32 */
@@ -1077,7 +1077,7 @@ restore_all_switch_stack:
10771077
* when returning from IPI handler and when returning from
10781078
* scheduler to user-space.
10791079
*/
1080-
INTERRUPT_RETURN
1080+
iret
10811081

10821082
.section .fixup, "ax"
10831083
SYM_CODE_START(asm_iret_error)

‎arch/x86/entry/entry_64.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ SYM_CODE_END(ret_from_fork)
305305
.macro DEBUG_ENTRY_ASSERT_IRQS_OFF
306306
#ifdef CONFIG_DEBUG_ENTRY
307307
pushq %rax
308-
SAVE_FLAGS(CLBR_RAX)
308+
SAVE_FLAGS
309309
testl $X86_EFLAGS_IF, %eax
310310
jz .Lokay_\@
311311
ud2

‎arch/x86/entry/vdso/vdso32/system_call.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <linux/linkage.h>
77
#include <asm/dwarf2.h>
88
#include <asm/cpufeatures.h>
9-
#include <asm/alternative-asm.h>
9+
#include <asm/alternative.h>
1010

1111
.text
1212
.globl __kernel_vsyscall

‎arch/x86/include/asm/alternative-asm.h‎

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)