Skip to content

Commit 054ac8a

Browse files
jgross1suryasaimadhu
authored andcommitted
x86/paravirt: Have only one paravirt patch function
There is no need any longer to have different paravirt patch functions for native and Xen. Eliminate native_patch() and rename paravirt_patch_default() to paravirt_patch(). Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent fafe5e7 commit 054ac8a

File tree

6 files changed

+5
-51
lines changed

6 files changed

+5
-51
lines changed

arch/x86/include/asm/paravirt_types.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ struct pv_info {
6868
const char *name;
6969
};
7070

71-
struct pv_init_ops {
72-
/*
73-
* Patch may replace one of the defined code sequences with
74-
* arbitrary code, subject to the same register constraints.
75-
* This generally means the code is not free to clobber any
76-
* registers other than EAX. The patch function should return
77-
* the number of bytes of code generated, as we nop pad the
78-
* rest in generic code.
79-
*/
80-
unsigned (*patch)(u8 type, void *insn_buff,
81-
unsigned long addr, unsigned len);
82-
} __no_randomize_layout;
83-
8471
#ifdef CONFIG_PARAVIRT_XXL
8572
struct pv_lazy_ops {
8673
/* Set deferred update mode, used for batching operations. */
@@ -276,7 +263,6 @@ struct pv_lock_ops {
276263
* number for each function using the offset which we use to indicate
277264
* what to patch. */
278265
struct paravirt_patch_template {
279-
struct pv_init_ops init;
280266
struct pv_cpu_ops cpu;
281267
struct pv_irq_ops irq;
282268
struct pv_mmu_ops mmu;
@@ -317,10 +303,7 @@ extern void (*paravirt_iret)(void);
317303
/* Simple instruction patching code. */
318304
#define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
319305

320-
unsigned paravirt_patch_default(u8 type, void *insn_buff, unsigned long addr, unsigned len);
321-
unsigned paravirt_patch_insns(void *insn_buff, unsigned len, const char *start, const char *end);
322-
323-
unsigned native_patch(u8 type, void *insn_buff, unsigned long addr, unsigned len);
306+
unsigned int paravirt_patch(u8 type, void *insn_buff, unsigned long addr, unsigned int len);
324307

325308
int paravirt_disable_iospace(void);
326309

arch/x86/kernel/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ KASAN_SANITIZE_sev-es.o := n
3535
KCSAN_SANITIZE := n
3636

3737
OBJECT_FILES_NON_STANDARD_test_nx.o := y
38-
OBJECT_FILES_NON_STANDARD_paravirt_patch.o := y
3938

4039
ifdef CONFIG_FRAME_POINTER
4140
OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y
@@ -121,7 +120,7 @@ obj-$(CONFIG_AMD_NB) += amd_nb.o
121120
obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
122121

123122
obj-$(CONFIG_KVM_GUEST) += kvm.o kvmclock.o
124-
obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch.o
123+
obj-$(CONFIG_PARAVIRT) += paravirt.o
125124
obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
126125
obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o
127126
obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o

arch/x86/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
616616
BUG_ON(p->len > MAX_PATCH_LEN);
617617
/* prep the buffer with the original instructions */
618618
memcpy(insn_buff, p->instr, p->len);
619-
used = pv_ops.init.patch(p->type, insn_buff, (unsigned long)p->instr, p->len);
619+
used = paravirt_patch(p->type, insn_buff, (unsigned long)p->instr, p->len);
620620

621621
BUG_ON(used > p->len);
622622

arch/x86/kernel/paravirt.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ void __init native_pv_lock_init(void)
9999
static_branch_disable(&virt_spin_lock_key);
100100
}
101101

102-
unsigned paravirt_patch_default(u8 type, void *insn_buff,
103-
unsigned long addr, unsigned len)
102+
unsigned int paravirt_patch(u8 type, void *insn_buff, unsigned long addr,
103+
unsigned int len)
104104
{
105105
/*
106106
* Neat trick to map patch type back to the call within the
@@ -121,19 +121,6 @@ unsigned paravirt_patch_default(u8 type, void *insn_buff,
121121
return ret;
122122
}
123123

124-
unsigned paravirt_patch_insns(void *insn_buff, unsigned len,
125-
const char *start, const char *end)
126-
{
127-
unsigned insn_len = end - start;
128-
129-
/* Alternative instruction is too large for the patch site and we cannot continue: */
130-
BUG_ON(insn_len > len || start == NULL);
131-
132-
memcpy(insn_buff, start, insn_len);
133-
134-
return insn_len;
135-
}
136-
137124
struct static_key paravirt_steal_enabled;
138125
struct static_key paravirt_steal_rq_enabled;
139126

@@ -252,9 +239,6 @@ struct pv_info pv_info = {
252239
#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
253240

254241
struct paravirt_patch_template pv_ops = {
255-
/* Init ops. */
256-
.init.patch = native_patch,
257-
258242
/* Cpu ops. */
259243
.cpu.io_delay = native_io_delay,
260244

arch/x86/kernel/paravirt_patch.c

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

arch/x86/xen/enlighten_pv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
12311231

12321232
/* Install Xen paravirt ops */
12331233
pv_info = xen_info;
1234-
pv_ops.init.patch = paravirt_patch_default;
12351234
pv_ops.cpu = xen_cpu_ops;
12361235
paravirt_iret = xen_iret;
12371236
xen_init_irq_ops();

0 commit comments

Comments
 (0)