Skip to content

Commit edcb5cf

Browse files
jgross1ingomolnar
authored andcommitted
x86/paravirt/xen: Remove xen_patch()
Xen's paravirt patch function xen_patch() does some special casing for irq_ops functions to apply relocations when those functions can be patched inline instead of calls. Unfortunately none of the special case function replacements is small enough to be patched inline, so the special case never applies. As xen_patch() will call paravirt_patch_default() in all cases it can be just dropped. xen-asm.h doesn't seem necessary without xen_patch() as the only thing left in it would be the definition of XEN_EFLAGS_NMI used only once. So move that definition and remove xen-asm.h. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: boris.ostrovsky@oracle.com Cc: lguest@lists.ozlabs.org Cc: rusty@rustcorp.com.au Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/20170816173157.8633-2-jgross@suse.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent ee97638 commit edcb5cf

6 files changed

Lines changed: 21 additions & 138 deletions

File tree

‎arch/x86/xen/enlighten_pv.c‎

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -981,59 +981,6 @@ void __ref xen_setup_vcpu_info_placement(void)
981981
}
982982
}
983983

984-
static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
985-
unsigned long addr, unsigned len)
986-
{
987-
char *start, *end, *reloc;
988-
unsigned ret;
989-
990-
start = end = reloc = NULL;
991-
992-
#define SITE(op, x) \
993-
case PARAVIRT_PATCH(op.x): \
994-
if (xen_have_vcpu_info_placement) { \
995-
start = (char *)xen_##x##_direct; \
996-
end = xen_##x##_direct_end; \
997-
reloc = xen_##x##_direct_reloc; \
998-
} \
999-
goto patch_site
1000-
1001-
switch (type) {
1002-
SITE(pv_irq_ops, irq_enable);
1003-
SITE(pv_irq_ops, irq_disable);
1004-
SITE(pv_irq_ops, save_fl);
1005-
SITE(pv_irq_ops, restore_fl);
1006-
#undef SITE
1007-
1008-
patch_site:
1009-
if (start == NULL || (end-start) > len)
1010-
goto default_patch;
1011-
1012-
ret = paravirt_patch_insns(insnbuf, len, start, end);
1013-
1014-
/* Note: because reloc is assigned from something that
1015-
appears to be an array, gcc assumes it's non-null,
1016-
but doesn't know its relationship with start and
1017-
end. */
1018-
if (reloc > start && reloc < end) {
1019-
int reloc_off = reloc - start;
1020-
long *relocp = (long *)(insnbuf + reloc_off);
1021-
long delta = start - (char *)addr;
1022-
1023-
*relocp += delta;
1024-
}
1025-
break;
1026-
1027-
default_patch:
1028-
default:
1029-
ret = paravirt_patch_default(type, clobbers, insnbuf,
1030-
addr, len);
1031-
break;
1032-
}
1033-
1034-
return ret;
1035-
}
1036-
1037984
static const struct pv_info xen_info __initconst = {
1038985
.shared_kernel_pmd = 0,
1039986

@@ -1043,10 +990,6 @@ static const struct pv_info xen_info __initconst = {
1043990
.name = "Xen",
1044991
};
1045992

1046-
static const struct pv_init_ops xen_init_ops __initconst = {
1047-
.patch = xen_patch,
1048-
};
1049-
1050993
static const struct pv_cpu_ops xen_cpu_ops __initconst = {
1051994
.cpuid = xen_cpuid,
1052995

@@ -1244,7 +1187,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
12441187

12451188
/* Install Xen paravirt ops */
12461189
pv_info = xen_info;
1247-
pv_init_ops = xen_init_ops;
1190+
pv_init_ops.patch = paravirt_patch_default;
12481191
pv_cpu_ops = xen_cpu_ops;
12491192

12501193
x86_platform.get_nmi_reason = xen_get_nmi_reason;

‎arch/x86/xen/xen-asm.S‎

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
/*
2-
* Asm versions of Xen pv-ops, suitable for either direct use or
3-
* inlining. The inline versions are the same as the direct-use
4-
* versions, with the pre- and post-amble chopped off.
5-
*
6-
* This code is encoded for size rather than absolute efficiency, with
7-
* a view to being able to inline as much as possible.
2+
* Asm versions of Xen pv-ops, suitable for direct use.
83
*
94
* We only bother with direct forms (ie, vcpu in percpu data) of the
10-
* operations here; the indirect forms are better handled in C, since
11-
* they're generally too large to inline anyway.
5+
* operations here; the indirect forms are better handled in C.
126
*/
137

148
#include <asm/asm-offsets.h>
159
#include <asm/percpu.h>
1610
#include <asm/processor-flags.h>
1711
#include <asm/frame.h>
1812

19-
#include "xen-asm.h"
13+
#include <linux/linkage.h>
2014

2115
/*
2216
* Enable events. This clears the event mask and tests the pending
@@ -38,13 +32,11 @@ ENTRY(xen_irq_enable_direct)
3832
testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
3933
jz 1f
4034

41-
2: call check_events
35+
call check_events
4236
1:
43-
ENDPATCH(xen_irq_enable_direct)
4437
FRAME_END
4538
ret
4639
ENDPROC(xen_irq_enable_direct)
47-
RELOC(xen_irq_enable_direct, 2b+1)
4840

4941

5042
/*
@@ -53,10 +45,8 @@ ENDPATCH(xen_irq_enable_direct)
5345
*/
5446
ENTRY(xen_irq_disable_direct)
5547
movb $1, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
56-
ENDPATCH(xen_irq_disable_direct)
5748
ret
58-
ENDPROC(xen_irq_disable_direct)
59-
RELOC(xen_irq_disable_direct, 0)
49+
ENDPROC(xen_irq_disable_direct)
6050

6151
/*
6252
* (xen_)save_fl is used to get the current interrupt enable status.
@@ -71,10 +61,8 @@ ENTRY(xen_save_fl_direct)
7161
testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
7262
setz %ah
7363
addb %ah, %ah
74-
ENDPATCH(xen_save_fl_direct)
7564
ret
7665
ENDPROC(xen_save_fl_direct)
77-
RELOC(xen_save_fl_direct, 0)
7866

7967

8068
/*
@@ -101,13 +89,11 @@ ENTRY(xen_restore_fl_direct)
10189
/* check for unmasked and pending */
10290
cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
10391
jnz 1f
104-
2: call check_events
92+
call check_events
10593
1:
106-
ENDPATCH(xen_restore_fl_direct)
10794
FRAME_END
10895
ret
10996
ENDPROC(xen_restore_fl_direct)
110-
RELOC(xen_restore_fl_direct, 2b+1)
11197

11298

11399
/*

‎arch/x86/xen/xen-asm.h‎

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

‎arch/x86/xen/xen-asm_32.S‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
/*
2-
* Asm versions of Xen pv-ops, suitable for either direct use or
3-
* inlining. The inline versions are the same as the direct-use
4-
* versions, with the pre- and post-amble chopped off.
5-
*
6-
* This code is encoded for size rather than absolute efficiency, with
7-
* a view to being able to inline as much as possible.
2+
* Asm versions of Xen pv-ops, suitable for direct use.
83
*
94
* We only bother with direct forms (ie, vcpu in pda) of the
10-
* operations here; the indirect forms are better handled in C, since
11-
* they're generally too large to inline anyway.
5+
* operations here; the indirect forms are better handled in C.
126
*/
137

148
#include <asm/thread_info.h>
@@ -18,21 +12,10 @@
1812

1913
#include <xen/interface/xen.h>
2014

21-
#include "xen-asm.h"
15+
#include <linux/linkage.h>
2216

23-
/*
24-
* Force an event check by making a hypercall, but preserve regs
25-
* before making the call.
26-
*/
27-
check_events:
28-
push %eax
29-
push %ecx
30-
push %edx
31-
call xen_force_evtchn_callback
32-
pop %edx
33-
pop %ecx
34-
pop %eax
35-
ret
17+
/* Pseudo-flag used for virtual NMI, which we don't implement yet */
18+
#define XEN_EFLAGS_NMI 0x80000000
3619

3720
/*
3821
* This is run where a normal iret would be run, with the same stack setup:

‎arch/x86/xen/xen-asm_64.S‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
/*
2-
* Asm versions of Xen pv-ops, suitable for either direct use or
3-
* inlining. The inline versions are the same as the direct-use
4-
* versions, with the pre- and post-amble chopped off.
5-
*
6-
* This code is encoded for size rather than absolute efficiency, with
7-
* a view to being able to inline as much as possible.
2+
* Asm versions of Xen pv-ops, suitable for direct use.
83
*
94
* We only bother with direct forms (ie, vcpu in pda) of the
10-
* operations here; the indirect forms are better handled in C, since
11-
* they're generally too large to inline anyway.
5+
* operations here; the indirect forms are better handled in C.
126
*/
137

148
#include <asm/errno.h>
@@ -20,7 +14,7 @@
2014

2115
#include <xen/interface/xen.h>
2216

23-
#include "xen-asm.h"
17+
#include <linux/linkage.h>
2418

2519
ENTRY(xen_adjust_exception_frame)
2620
mov 8+0(%rsp), %rcx
@@ -46,9 +40,7 @@ hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
4640
*/
4741
ENTRY(xen_iret)
4842
pushq $0
49-
1: jmp hypercall_iret
50-
ENDPATCH(xen_iret)
51-
RELOC(xen_iret, 1b+1)
43+
jmp hypercall_iret
5244

5345
ENTRY(xen_sysret64)
5446
/*
@@ -65,9 +57,7 @@ ENTRY(xen_sysret64)
6557
pushq %rcx
6658

6759
pushq $VGCF_in_syscall
68-
1: jmp hypercall_iret
69-
ENDPATCH(xen_sysret64)
70-
RELOC(xen_sysret64, 1b+1)
60+
jmp hypercall_iret
7161

7262
/*
7363
* Xen handles syscall callbacks much like ordinary exceptions, which

‎arch/x86/xen/xen-ops.h‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,10 @@ static inline void __init xen_efi_init(void)
129129
}
130130
#endif
131131

132-
/* Declare an asm function, along with symbols needed to make it
133-
inlineable */
134-
#define DECL_ASM(ret, name, ...) \
135-
__visible ret name(__VA_ARGS__); \
136-
extern char name##_end[] __visible; \
137-
extern char name##_reloc[] __visible
138-
139-
DECL_ASM(void, xen_irq_enable_direct, void);
140-
DECL_ASM(void, xen_irq_disable_direct, void);
141-
DECL_ASM(unsigned long, xen_save_fl_direct, void);
142-
DECL_ASM(void, xen_restore_fl_direct, unsigned long);
132+
__visible void xen_irq_enable_direct(void);
133+
__visible void xen_irq_disable_direct(void);
134+
__visible unsigned long xen_save_fl_direct(void);
135+
__visible void xen_restore_fl_direct(unsigned long);
143136

144137
/* These are not functions, and cannot be called normally */
145138
__visible void xen_iret(void);

0 commit comments

Comments
 (0)