Skip to content

Commit 9bad565

Browse files
jgross1KAGA-KOKO
authored andcommitted
x86/paravirt: Move the Xen-only pv_cpu_ops under the PARAVIRT_XXL umbrella
Most of the paravirt ops defined in pv_cpu_ops are for Xen PV guests only. Define them only if CONFIG_PARAVIRT_XXL is set. Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: xen-devel@lists.xenproject.org Cc: virtualization@lists.linux-foundation.org Cc: akataria@vmware.com Cc: rusty@rustcorp.com.au Cc: boris.ostrovsky@oracle.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/20180828074026.820-13-jgross@suse.com
1 parent 4018164 commit 9bad565

16 files changed

+78
-22
lines changed

arch/x86/include/asm/debugreg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
DECLARE_PER_CPU(unsigned long, cpu_dr7);
1010

11-
#ifndef CONFIG_PARAVIRT
11+
#ifndef CONFIG_PARAVIRT_XXL
1212
/*
1313
* These special macros can be used to get or set a debugging register
1414
*/

arch/x86/include/asm/desc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static inline int desc_empty(const void *ptr)
108108
return !(desc[0] | desc[1]);
109109
}
110110

111-
#ifdef CONFIG_PARAVIRT
111+
#ifdef CONFIG_PARAVIRT_XXL
112112
#include <asm/paravirt.h>
113113
#else
114114
#define load_TR_desc() native_load_tr_desc()
@@ -134,7 +134,7 @@ static inline void paravirt_alloc_ldt(struct desc_struct *ldt, unsigned entries)
134134
static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
135135
{
136136
}
137-
#endif /* CONFIG_PARAVIRT */
137+
#endif /* CONFIG_PARAVIRT_XXL */
138138

139139
#define store_ldt(ldt) asm("sldt %0" : "=m"(ldt))
140140

arch/x86/include/asm/irqflags.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ static inline notrace unsigned long arch_local_irq_save(void)
122122
#define ENABLE_INTERRUPTS(x) sti
123123
#define DISABLE_INTERRUPTS(x) cli
124124

125+
#ifdef CONFIG_X86_64
126+
#ifdef CONFIG_DEBUG_ENTRY
127+
#define SAVE_FLAGS(x) pushfq; popq %rax
128+
#endif
129+
#endif
130+
#endif /* __ASSEMBLY__ */
131+
#endif /* CONFIG_PARAVIRT */
132+
133+
#ifndef CONFIG_PARAVIRT_XXL
134+
#ifdef __ASSEMBLY__
125135
#ifdef CONFIG_X86_64
126136
#define SWAPGS swapgs
127137
/*
@@ -143,16 +153,12 @@ static inline notrace unsigned long arch_local_irq_save(void)
143153
swapgs; \
144154
sysretl
145155

146-
#ifdef CONFIG_DEBUG_ENTRY
147-
#define SAVE_FLAGS(x) pushfq; popq %rax
148-
#endif
149156
#else
150157
#define INTERRUPT_RETURN iret
151158
#endif
152159

153-
154160
#endif /* __ASSEMBLY__ */
155-
#endif /* CONFIG_PARAVIRT */
161+
#endif /* CONFIG_PARAVIRT_XXL */
156162

157163
#ifndef __ASSEMBLY__
158164
static inline int arch_irqs_disabled_flags(unsigned long flags)

arch/x86/include/asm/msr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static inline unsigned long long native_read_pmc(int counter)
242242
return EAX_EDX_VAL(val, low, high);
243243
}
244244

245-
#ifdef CONFIG_PARAVIRT
245+
#ifdef CONFIG_PARAVIRT_XXL
246246
#include <asm/paravirt.h>
247247
#else
248248
#include <linux/errno.h>
@@ -305,7 +305,7 @@ do { \
305305

306306
#define rdpmcl(counter, val) ((val) = native_read_pmc(counter))
307307

308-
#endif /* !CONFIG_PARAVIRT */
308+
#endif /* !CONFIG_PARAVIRT_XXL */
309309

310310
/*
311311
* 64-bit version of wrmsr_safe():

arch/x86/include/asm/paravirt.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/cpumask.h>
1818
#include <asm/frame.h>
1919

20+
#ifdef CONFIG_PARAVIRT_XXL
2021
static inline void load_sp0(unsigned long sp0)
2122
{
2223
PVOP_VCALL1(cpu.load_sp0, sp0);
@@ -51,6 +52,7 @@ static inline void write_cr0(unsigned long x)
5152
{
5253
PVOP_VCALL1(cpu.write_cr0, x);
5354
}
55+
#endif
5456

5557
static inline unsigned long read_cr2(void)
5658
{
@@ -72,6 +74,7 @@ static inline void write_cr3(unsigned long x)
7274
PVOP_VCALL1(mmu.write_cr3, x);
7375
}
7476

77+
#ifdef CONFIG_PARAVIRT_XXL
7578
static inline void __write_cr4(unsigned long x)
7679
{
7780
PVOP_VCALL1(cpu.write_cr4, x);
@@ -88,6 +91,7 @@ static inline void write_cr8(unsigned long x)
8891
PVOP_VCALL1(cpu.write_cr8, x);
8992
}
9093
#endif
94+
#endif
9195

9296
static inline void arch_safe_halt(void)
9397
{
@@ -99,14 +103,13 @@ static inline void halt(void)
99103
PVOP_VCALL0(irq.halt);
100104
}
101105

106+
#ifdef CONFIG_PARAVIRT_XXL
102107
static inline void wbinvd(void)
103108
{
104109
PVOP_VCALL0(cpu.wbinvd);
105110
}
106111

107-
#ifdef CONFIG_PARAVIRT_XXL
108112
#define get_kernel_rpl() (pv_info.kernel_rpl)
109-
#endif
110113

111114
static inline u64 paravirt_read_msr(unsigned msr)
112115
{
@@ -171,6 +174,7 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
171174
*p = paravirt_read_msr_safe(msr, &err);
172175
return err;
173176
}
177+
#endif
174178

175179
static inline unsigned long long paravirt_sched_clock(void)
176180
{
@@ -186,6 +190,7 @@ static inline u64 paravirt_steal_clock(int cpu)
186190
return PVOP_CALL1(u64, time.steal_clock, cpu);
187191
}
188192

193+
#ifdef CONFIG_PARAVIRT_XXL
189194
static inline unsigned long long paravirt_read_pmc(int counter)
190195
{
191196
return PVOP_CALL1(u64, cpu.read_pmc, counter);
@@ -230,6 +235,7 @@ static inline unsigned long paravirt_store_tr(void)
230235
{
231236
return PVOP_CALL0(unsigned long, cpu.store_tr);
232237
}
238+
233239
#define store_tr(tr) ((tr) = paravirt_store_tr())
234240
static inline void load_TLS(struct thread_struct *t, unsigned cpu)
235241
{
@@ -263,6 +269,7 @@ static inline void set_iopl_mask(unsigned mask)
263269
{
264270
PVOP_VCALL1(cpu.set_iopl_mask, mask);
265271
}
272+
#endif
266273

267274
/* The paravirtualized I/O functions */
268275
static inline void slow_down_io(void)
@@ -618,6 +625,7 @@ static inline void pmd_clear(pmd_t *pmdp)
618625
}
619626
#endif /* CONFIG_X86_PAE */
620627

628+
#ifdef CONFIG_PARAVIRT_XXL
621629
#define __HAVE_ARCH_START_CONTEXT_SWITCH
622630
static inline void arch_start_context_switch(struct task_struct *prev)
623631
{
@@ -628,6 +636,7 @@ static inline void arch_end_context_switch(struct task_struct *next)
628636
{
629637
PVOP_VCALL1(cpu.end_context_switch, next);
630638
}
639+
#endif
631640

632641
#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
633642
static inline void arch_enter_lazy_mmu_mode(void)
@@ -870,10 +879,12 @@ extern void default_banner(void);
870879
#define PARA_INDIRECT(addr) *%cs:addr
871880
#endif
872881

882+
#ifdef CONFIG_PARAVIRT_XXL
873883
#define INTERRUPT_RETURN \
874884
PARA_SITE(PARA_PATCH(PV_CPU_iret), \
875885
ANNOTATE_RETPOLINE_SAFE; \
876886
jmp PARA_INDIRECT(pv_ops+PV_CPU_iret);)
887+
#endif
877888

878889
#define DISABLE_INTERRUPTS(clobbers) \
879890
PARA_SITE(PARA_PATCH(PV_IRQ_irq_disable), \
@@ -890,6 +901,7 @@ extern void default_banner(void);
890901
PV_RESTORE_REGS(clobbers | CLBR_CALLEE_SAVE);)
891902

892903
#ifdef CONFIG_X86_64
904+
#ifdef CONFIG_PARAVIRT_XXL
893905
/*
894906
* If swapgs is used while the userspace stack is still current,
895907
* there's no way to call a pvop. The PV replacement *must* be
@@ -909,15 +921,18 @@ extern void default_banner(void);
909921
ANNOTATE_RETPOLINE_SAFE; \
910922
call PARA_INDIRECT(pv_ops+PV_CPU_swapgs); \
911923
)
924+
#endif
912925

913926
#define GET_CR2_INTO_RAX \
914927
ANNOTATE_RETPOLINE_SAFE; \
915928
call PARA_INDIRECT(pv_ops+PV_MMU_read_cr2);
916929

930+
#ifdef CONFIG_PARAVIRT_XXL
917931
#define USERGS_SYSRET64 \
918932
PARA_SITE(PARA_PATCH(PV_CPU_usergs_sysret64), \
919933
ANNOTATE_RETPOLINE_SAFE; \
920934
jmp PARA_INDIRECT(pv_ops+PV_CPU_usergs_sysret64);)
935+
#endif
921936

922937
#ifdef CONFIG_DEBUG_ENTRY
923938
#define SAVE_FLAGS(clobbers) \

arch/x86/include/asm/paravirt_types.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ struct pv_time_ops {
106106

107107
struct pv_cpu_ops {
108108
/* hooks for various privileged instructions */
109+
void (*io_delay)(void);
110+
111+
#ifdef CONFIG_PARAVIRT_XXL
109112
unsigned long (*get_debugreg)(int regno);
110113
void (*set_debugreg)(int regno, unsigned long value);
111114

@@ -143,7 +146,6 @@ struct pv_cpu_ops {
143146
void (*set_iopl_mask)(unsigned mask);
144147

145148
void (*wbinvd)(void);
146-
void (*io_delay)(void);
147149

148150
/* cpuid emulation, mostly so that caps bits can be disabled */
149151
void (*cpuid)(unsigned int *eax, unsigned int *ebx,
@@ -178,6 +180,7 @@ struct pv_cpu_ops {
178180

179181
void (*start_context_switch)(struct task_struct *prev);
180182
void (*end_context_switch)(struct task_struct *next);
183+
#endif
181184
} __no_randomize_layout;
182185

183186
struct pv_irq_ops {

arch/x86/include/asm/pgtable.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ extern pmdval_t early_pmd_flags;
111111
#define pte_val(x) native_pte_val(x)
112112
#define __pte(x) native_make_pte(x)
113113

114-
#define arch_end_context_switch(prev) do {} while(0)
115-
116114
#endif /* CONFIG_PARAVIRT */
117115

116+
#ifndef CONFIG_PARAVIRT_XXL
117+
#define arch_end_context_switch(prev) do {} while(0)
118+
#endif /* CONFIG_PARAVIRT_XXL */
119+
118120
/*
119121
* The following only work if pte_present() is true.
120122
* Undefined behaviour if not..

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ static inline bool on_thread_stack(void)
578578
current_stack_pointer) < THREAD_SIZE;
579579
}
580580

581-
#ifdef CONFIG_PARAVIRT
581+
#ifdef CONFIG_PARAVIRT_XXL
582582
#include <asm/paravirt.h>
583583
#else
584584
#define __cpuid native_cpuid
@@ -589,7 +589,7 @@ static inline void load_sp0(unsigned long sp0)
589589
}
590590

591591
#define set_iopl_mask native_set_iopl_mask
592-
#endif /* CONFIG_PARAVIRT */
592+
#endif /* CONFIG_PARAVIRT_XXL */
593593

594594
/* Free all resources held by a thread. */
595595
extern void release_thread(struct task_struct *);

arch/x86/include/asm/special_insns.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ static inline unsigned long __read_cr4(void)
143143

144144
#ifdef CONFIG_PARAVIRT
145145
#include <asm/paravirt.h>
146-
#else
146+
#endif
147147

148+
#ifndef CONFIG_PARAVIRT_XXL
148149
static inline unsigned long read_cr0(void)
149150
{
150151
return native_read_cr0();
@@ -154,7 +155,9 @@ static inline void write_cr0(unsigned long x)
154155
{
155156
native_write_cr0(x);
156157
}
158+
#endif
157159

160+
#ifndef CONFIG_PARAVIRT
158161
static inline unsigned long read_cr2(void)
159162
{
160163
return native_read_cr2();
@@ -178,7 +181,9 @@ static inline void write_cr3(unsigned long x)
178181
{
179182
native_write_cr3(x);
180183
}
184+
#endif
181185

186+
#ifndef CONFIG_PARAVIRT_XXL
182187
static inline void __write_cr4(unsigned long x)
183188
{
184189
native_write_cr4(x);
@@ -208,7 +213,7 @@ static inline void load_gs_index(unsigned selector)
208213

209214
#endif
210215

211-
#endif/* CONFIG_PARAVIRT */
216+
#endif/* CONFIG_PARAVIRT_XXL */
212217

213218
static inline void clflush(volatile void *__p)
214219
{

arch/x86/kernel/asm-offsets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ void common(void) {
6868
BLANK();
6969
OFFSET(PV_IRQ_irq_disable, paravirt_patch_template, irq.irq_disable);
7070
OFFSET(PV_IRQ_irq_enable, paravirt_patch_template, irq.irq_enable);
71+
#ifdef CONFIG_PARAVIRT_XXL
7172
OFFSET(PV_CPU_iret, paravirt_patch_template, cpu.iret);
73+
#endif
7274
OFFSET(PV_MMU_read_cr2, paravirt_patch_template, mmu.read_cr2);
7375
#endif
7476

arch/x86/kernel/asm-offsets_64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ static char syscalls_ia32[] = {
2121
int main(void)
2222
{
2323
#ifdef CONFIG_PARAVIRT
24+
#ifdef CONFIG_PARAVIRT_XXL
2425
OFFSET(PV_CPU_usergs_sysret64, paravirt_patch_template,
2526
cpu.usergs_sysret64);
2627
OFFSET(PV_CPU_swapgs, paravirt_patch_template, cpu.swapgs);
28+
#endif
2729
#ifdef CONFIG_DEBUG_ENTRY
2830
OFFSET(PV_IRQ_save_fl, paravirt_patch_template, irq.save_fl);
2931
#endif

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ static void generic_identify(struct cpuinfo_x86 *c)
12401240
* ESPFIX issue, we can change this.
12411241
*/
12421242
#ifdef CONFIG_X86_32
1243-
# ifdef CONFIG_PARAVIRT
1243+
# ifdef CONFIG_PARAVIRT_XXL
12441244
do {
12451245
extern void native_iret(void);
12461246
if (pv_ops.cpu.iret == native_iret)

arch/x86/kernel/head_64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define GET_CR2_INTO(reg) GET_CR2_INTO_RAX ; movq %rax, reg
3232
#else
3333
#define GET_CR2_INTO(reg) movq %cr2, reg
34+
#endif
35+
#ifndef CONFIG_PARAVIRT_XXL
3436
#define INTERRUPT_RETURN iretq
3537
#endif
3638

0 commit comments

Comments
 (0)