Skip to content

Commit

Permalink
Merge tag 'x86_alternatives_for_v5.13' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/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()
  • Loading branch information
torvalds committed Apr 26, 2021
2 parents 2c53279 + 054ac8a commit 2c5ce2d
Show file tree
Hide file tree
Showing 42 changed files with 482 additions and 638 deletions.
14 changes: 5 additions & 9 deletions arch/arm/include/asm/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
#define _ASM_ARM_PARAVIRT_H

#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>

struct static_key;
extern struct static_key paravirt_steal_enabled;
extern struct static_key paravirt_steal_rq_enabled;

struct pv_time_ops {
unsigned long long (*steal_clock)(int cpu);
};

struct paravirt_patch_template {
struct pv_time_ops time;
};
u64 dummy_steal_clock(int cpu);

extern struct paravirt_patch_template pv_ops;
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

static inline u64 paravirt_steal_clock(int cpu)
{
return pv_ops.time.steal_clock(cpu);
return static_call(pv_steal_clock)(cpu);
}
#endif

Expand Down
9 changes: 7 additions & 2 deletions arch/arm/kernel/paravirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
#include <linux/export.h>
#include <linux/jump_label.h>
#include <linux/types.h>
#include <linux/static_call.h>
#include <asm/paravirt.h>

struct static_key paravirt_steal_enabled;
struct static_key paravirt_steal_rq_enabled;

struct paravirt_patch_template pv_ops;
EXPORT_SYMBOL_GPL(pv_ops);
static u64 native_steal_clock(int cpu)
{
return 0;
}

DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
14 changes: 5 additions & 9 deletions arch/arm64/include/asm/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
#define _ASM_ARM64_PARAVIRT_H

#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>

struct static_key;
extern struct static_key paravirt_steal_enabled;
extern struct static_key paravirt_steal_rq_enabled;

struct pv_time_ops {
unsigned long long (*steal_clock)(int cpu);
};

struct paravirt_patch_template {
struct pv_time_ops time;
};
u64 dummy_steal_clock(int cpu);

extern struct paravirt_patch_template pv_ops;
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

static inline u64 paravirt_steal_clock(int cpu)
{
return pv_ops.time.steal_clock(cpu);
return static_call(pv_steal_clock)(cpu);
}

int __init pv_time_init(void);
Expand Down
13 changes: 9 additions & 4 deletions arch/arm64/kernel/paravirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/reboot.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/static_call.h>

#include <asm/paravirt.h>
#include <asm/pvclock-abi.h>
Expand All @@ -26,8 +27,12 @@
struct static_key paravirt_steal_enabled;
struct static_key paravirt_steal_rq_enabled;

struct paravirt_patch_template pv_ops;
EXPORT_SYMBOL_GPL(pv_ops);
static u64 native_steal_clock(int cpu)
{
return 0;
}

DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);

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

/* return stolen time in ns by asking the hypervisor */
static u64 pv_steal_clock(int cpu)
static u64 para_steal_clock(int cpu)
{
struct pv_time_stolen_time_region *reg;

Expand Down Expand Up @@ -150,7 +155,7 @@ int __init pv_time_init(void)
if (ret)
return ret;

pv_ops.time.steal_clock = pv_steal_clock;
static_call_update(pv_steal_clock, para_steal_clock);

static_key_slow_inc(&paravirt_steal_enabled);
if (steal_acc)
Expand Down
1 change: 1 addition & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ if HYPERVISOR_GUEST

config PARAVIRT
bool "Enable paravirtualization code"
depends on HAVE_STATIC_CALL
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/entry/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <asm/processor-flags.h>
#include <asm/irq_vectors.h>
#include <asm/cpufeatures.h>
#include <asm/alternative-asm.h>
#include <asm/alternative.h>
#include <asm/asm.h>
#include <asm/smap.h>
#include <asm/frame.h>
Expand Down Expand Up @@ -430,7 +430,7 @@
* will soon execute iret and the tracer was already set to
* the irqstate after the IRET:
*/
DISABLE_INTERRUPTS(CLBR_ANY)
cli
lss (%esp), %esp /* switch to espfix segment */
.Lend_\@:
#endif /* CONFIG_X86_ESPFIX32 */
Expand Down Expand Up @@ -1077,7 +1077,7 @@ restore_all_switch_stack:
* when returning from IPI handler and when returning from
* scheduler to user-space.
*/
INTERRUPT_RETURN
iret

.section .fixup, "ax"
SYM_CODE_START(asm_iret_error)
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/entry/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ SYM_CODE_END(ret_from_fork)
.macro DEBUG_ENTRY_ASSERT_IRQS_OFF
#ifdef CONFIG_DEBUG_ENTRY
pushq %rax
SAVE_FLAGS(CLBR_RAX)
SAVE_FLAGS
testl $X86_EFLAGS_IF, %eax
jz .Lokay_\@
ud2
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/entry/vdso/vdso32/system_call.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <linux/linkage.h>
#include <asm/dwarf2.h>
#include <asm/cpufeatures.h>
#include <asm/alternative-asm.h>
#include <asm/alternative.h>

.text
.globl __kernel_vsyscall
Expand Down
114 changes: 0 additions & 114 deletions arch/x86/include/asm/alternative-asm.h

This file was deleted.

Loading

0 comments on commit 2c5ce2d

Please sign in to comment.