Skip to content

Commit fdc0269

Browse files
jgross1KAGA-KOKO
authored andcommitted
x86/paravirt: Move the Xen-only pv_mmu_ops under the PARAVIRT_XXL umbrella
Most of the paravirt ops defined in pv_mmu_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-15-jgross@suse.com
1 parent 6da63eb commit fdc0269

File tree

12 files changed

+103
-112
lines changed

12 files changed

+103
-112
lines changed

arch/x86/include/asm/fixmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
152152
void native_set_fixmap(enum fixed_addresses idx,
153153
phys_addr_t phys, pgprot_t flags);
154154

155-
#ifndef CONFIG_PARAVIRT
155+
#ifndef CONFIG_PARAVIRT_XXL
156156
static inline void __set_fixmap(enum fixed_addresses idx,
157157
phys_addr_t phys, pgprot_t flags)
158158
{

arch/x86/include/asm/mmu_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
extern atomic64_t last_mm_ctx_id;
1818

19-
#ifndef CONFIG_PARAVIRT
19+
#ifndef CONFIG_PARAVIRT_XXL
2020
static inline void paravirt_activate_mm(struct mm_struct *prev,
2121
struct mm_struct *next)
2222
{
2323
}
24-
#endif /* !CONFIG_PARAVIRT */
24+
#endif /* !CONFIG_PARAVIRT_XXL */
2525

2626
#ifdef CONFIG_PERF_EVENTS
2727

arch/x86/include/asm/paravirt.h

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

20+
static inline unsigned long long paravirt_sched_clock(void)
21+
{
22+
return PVOP_CALL0(unsigned long long, time.sched_clock);
23+
}
24+
25+
struct static_key;
26+
extern struct static_key paravirt_steal_enabled;
27+
extern struct static_key paravirt_steal_rq_enabled;
28+
29+
static inline u64 paravirt_steal_clock(int cpu)
30+
{
31+
return PVOP_CALL1(u64, time.steal_clock, cpu);
32+
}
33+
34+
/* The paravirtualized I/O functions */
35+
static inline void slow_down_io(void)
36+
{
37+
pv_ops.cpu.io_delay();
38+
#ifdef REALLY_SLOW_IO
39+
pv_ops.cpu.io_delay();
40+
pv_ops.cpu.io_delay();
41+
pv_ops.cpu.io_delay();
42+
#endif
43+
}
44+
45+
static inline void __flush_tlb(void)
46+
{
47+
PVOP_VCALL0(mmu.flush_tlb_user);
48+
}
49+
50+
static inline void __flush_tlb_global(void)
51+
{
52+
PVOP_VCALL0(mmu.flush_tlb_kernel);
53+
}
54+
55+
static inline void __flush_tlb_one_user(unsigned long addr)
56+
{
57+
PVOP_VCALL1(mmu.flush_tlb_one_user, addr);
58+
}
59+
60+
static inline void flush_tlb_others(const struct cpumask *cpumask,
61+
const struct flush_tlb_info *info)
62+
{
63+
PVOP_VCALL2(mmu.flush_tlb_others, cpumask, info);
64+
}
65+
66+
static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table)
67+
{
68+
PVOP_VCALL2(mmu.tlb_remove_table, tlb, table);
69+
}
70+
71+
static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
72+
{
73+
PVOP_VCALL1(mmu.exit_mmap, mm);
74+
}
75+
2076
#ifdef CONFIG_PARAVIRT_XXL
2177
static inline void load_sp0(unsigned long sp0)
2278
{
@@ -52,7 +108,6 @@ static inline void write_cr0(unsigned long x)
52108
{
53109
PVOP_VCALL1(cpu.write_cr0, x);
54110
}
55-
#endif
56111

57112
static inline unsigned long read_cr2(void)
58113
{
@@ -74,7 +129,6 @@ static inline void write_cr3(unsigned long x)
74129
PVOP_VCALL1(mmu.write_cr3, x);
75130
}
76131

77-
#ifdef CONFIG_PARAVIRT_XXL
78132
static inline void __write_cr4(unsigned long x)
79133
{
80134
PVOP_VCALL1(cpu.write_cr4, x);
@@ -172,23 +226,7 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
172226
*p = paravirt_read_msr_safe(msr, &err);
173227
return err;
174228
}
175-
#endif
176229

177-
static inline unsigned long long paravirt_sched_clock(void)
178-
{
179-
return PVOP_CALL0(unsigned long long, time.sched_clock);
180-
}
181-
182-
struct static_key;
183-
extern struct static_key paravirt_steal_enabled;
184-
extern struct static_key paravirt_steal_rq_enabled;
185-
186-
static inline u64 paravirt_steal_clock(int cpu)
187-
{
188-
return PVOP_CALL1(u64, time.steal_clock, cpu);
189-
}
190-
191-
#ifdef CONFIG_PARAVIRT_XXL
192230
static inline unsigned long long paravirt_read_pmc(int counter)
193231
{
194232
return PVOP_CALL1(u64, cpu.read_pmc, counter);
@@ -267,18 +305,6 @@ static inline void set_iopl_mask(unsigned mask)
267305
{
268306
PVOP_VCALL1(cpu.set_iopl_mask, mask);
269307
}
270-
#endif
271-
272-
/* The paravirtualized I/O functions */
273-
static inline void slow_down_io(void)
274-
{
275-
pv_ops.cpu.io_delay();
276-
#ifdef REALLY_SLOW_IO
277-
pv_ops.cpu.io_delay();
278-
pv_ops.cpu.io_delay();
279-
pv_ops.cpu.io_delay();
280-
#endif
281-
}
282308

283309
static inline void paravirt_activate_mm(struct mm_struct *prev,
284310
struct mm_struct *next)
@@ -292,35 +318,6 @@ static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
292318
PVOP_VCALL2(mmu.dup_mmap, oldmm, mm);
293319
}
294320

295-
static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
296-
{
297-
PVOP_VCALL1(mmu.exit_mmap, mm);
298-
}
299-
300-
static inline void __flush_tlb(void)
301-
{
302-
PVOP_VCALL0(mmu.flush_tlb_user);
303-
}
304-
static inline void __flush_tlb_global(void)
305-
{
306-
PVOP_VCALL0(mmu.flush_tlb_kernel);
307-
}
308-
static inline void __flush_tlb_one_user(unsigned long addr)
309-
{
310-
PVOP_VCALL1(mmu.flush_tlb_one_user, addr);
311-
}
312-
313-
static inline void flush_tlb_others(const struct cpumask *cpumask,
314-
const struct flush_tlb_info *info)
315-
{
316-
PVOP_VCALL2(mmu.flush_tlb_others, cpumask, info);
317-
}
318-
319-
static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table)
320-
{
321-
PVOP_VCALL2(mmu.tlb_remove_table, tlb, table);
322-
}
323-
324321
static inline int paravirt_pgd_alloc(struct mm_struct *mm)
325322
{
326323
return PVOP_CALL1(int, mmu.pgd_alloc, mm);
@@ -623,7 +620,6 @@ static inline void pmd_clear(pmd_t *pmdp)
623620
}
624621
#endif /* CONFIG_X86_PAE */
625622

626-
#ifdef CONFIG_PARAVIRT_XXL
627623
#define __HAVE_ARCH_START_CONTEXT_SWITCH
628624
static inline void arch_start_context_switch(struct task_struct *prev)
629625
{
@@ -634,7 +630,6 @@ static inline void arch_end_context_switch(struct task_struct *next)
634630
{
635631
PVOP_VCALL1(cpu.end_context_switch, next);
636632
}
637-
#endif
638633

639634
#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
640635
static inline void arch_enter_lazy_mmu_mode(void)
@@ -657,6 +652,7 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
657652
{
658653
pv_ops.mmu.set_fixmap(idx, phys, flags);
659654
}
655+
#endif
660656

661657
#if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
662658

@@ -948,15 +944,20 @@ extern void default_banner(void);
948944
#endif /* __ASSEMBLY__ */
949945
#else /* CONFIG_PARAVIRT */
950946
# define default_banner x86_init_noop
947+
#endif /* !CONFIG_PARAVIRT */
948+
951949
#ifndef __ASSEMBLY__
950+
#ifndef CONFIG_PARAVIRT_XXL
952951
static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
953952
struct mm_struct *mm)
954953
{
955954
}
955+
#endif
956956

957+
#ifndef CONFIG_PARAVIRT
957958
static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
958959
{
959960
}
961+
#endif
960962
#endif /* __ASSEMBLY__ */
961-
#endif /* !CONFIG_PARAVIRT */
962963
#endif /* _ASM_X86_PARAVIRT_H */

arch/x86/include/asm/paravirt_types.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ struct pv_init_ops {
9191
unsigned long addr, unsigned len);
9292
} __no_randomize_layout;
9393

94-
94+
#ifdef CONFIG_PARAVIRT_XXL
9595
struct pv_lazy_ops {
9696
/* Set deferred update mode, used for batching operations. */
9797
void (*enter)(void);
9898
void (*leave)(void);
9999
void (*flush)(void);
100100
} __no_randomize_layout;
101+
#endif
101102

102103
struct pv_time_ops {
103104
unsigned long long (*sched_clock)(void);
@@ -205,31 +206,30 @@ struct pv_irq_ops {
205206
} __no_randomize_layout;
206207

207208
struct pv_mmu_ops {
209+
/* TLB operations */
210+
void (*flush_tlb_user)(void);
211+
void (*flush_tlb_kernel)(void);
212+
void (*flush_tlb_one_user)(unsigned long addr);
213+
void (*flush_tlb_others)(const struct cpumask *cpus,
214+
const struct flush_tlb_info *info);
215+
216+
void (*tlb_remove_table)(struct mmu_gather *tlb, void *table);
217+
218+
/* Hook for intercepting the destruction of an mm_struct. */
219+
void (*exit_mmap)(struct mm_struct *mm);
220+
221+
#ifdef CONFIG_PARAVIRT_XXL
208222
unsigned long (*read_cr2)(void);
209223
void (*write_cr2)(unsigned long);
210224

211225
unsigned long (*read_cr3)(void);
212226
void (*write_cr3)(unsigned long);
213227

214-
/*
215-
* Hooks for intercepting the creation/use/destruction of an
216-
* mm_struct.
217-
*/
228+
/* Hooks for intercepting the creation/use of an mm_struct. */
218229
void (*activate_mm)(struct mm_struct *prev,
219230
struct mm_struct *next);
220231
void (*dup_mmap)(struct mm_struct *oldmm,
221232
struct mm_struct *mm);
222-
void (*exit_mmap)(struct mm_struct *mm);
223-
224-
225-
/* TLB operations */
226-
void (*flush_tlb_user)(void);
227-
void (*flush_tlb_kernel)(void);
228-
void (*flush_tlb_one_user)(unsigned long addr);
229-
void (*flush_tlb_others)(const struct cpumask *cpus,
230-
const struct flush_tlb_info *info);
231-
232-
void (*tlb_remove_table)(struct mmu_gather *tlb, void *table);
233233

234234
/* Hooks for allocating and freeing a pagetable top-level */
235235
int (*pgd_alloc)(struct mm_struct *mm);
@@ -304,6 +304,7 @@ struct pv_mmu_ops {
304304
an mfn. We can tell which is which from the index. */
305305
void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
306306
phys_addr_t phys, pgprot_t flags);
307+
#endif
307308
} __no_randomize_layout;
308309

309310
struct arch_spinlock;

arch/x86/include/asm/pgalloc.h

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

99
static inline int __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
1010

11-
#ifdef CONFIG_PARAVIRT
11+
#ifdef CONFIG_PARAVIRT_XXL
1212
#include <asm/paravirt.h>
1313
#else
1414
#define paravirt_pgd_alloc(mm) __paravirt_pgd_alloc(mm)

arch/x86/include/asm/pgtable.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
5555

5656
extern pmdval_t early_pmd_flags;
5757

58-
#ifdef CONFIG_PARAVIRT
58+
#ifdef CONFIG_PARAVIRT_XXL
5959
#include <asm/paravirt.h>
60-
#else /* !CONFIG_PARAVIRT */
60+
#else /* !CONFIG_PARAVIRT_XXL */
6161
#define set_pte(ptep, pte) native_set_pte(ptep, pte)
6262
#define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte)
6363

@@ -111,9 +111,6 @@ 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-
#endif /* CONFIG_PARAVIRT */
115-
116-
#ifndef CONFIG_PARAVIRT_XXL
117114
#define arch_end_context_switch(prev) do {} while(0)
118115
#endif /* CONFIG_PARAVIRT_XXL */
119116

arch/x86/include/asm/special_insns.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ static inline unsigned long __read_cr4(void)
141141
return native_read_cr4();
142142
}
143143

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

148-
#ifndef CONFIG_PARAVIRT_XXL
149148
static inline unsigned long read_cr0(void)
150149
{
151150
return native_read_cr0();
@@ -155,9 +154,7 @@ static inline void write_cr0(unsigned long x)
155154
{
156155
native_write_cr0(x);
157156
}
158-
#endif
159157

160-
#ifndef CONFIG_PARAVIRT
161158
static inline unsigned long read_cr2(void)
162159
{
163160
return native_read_cr2();
@@ -181,9 +178,7 @@ static inline void write_cr3(unsigned long x)
181178
{
182179
native_write_cr3(x);
183180
}
184-
#endif
185181

186-
#ifndef CONFIG_PARAVIRT_XXL
187182
static inline void __write_cr4(unsigned long x)
188183
{
189184
native_write_cr4(x);
@@ -213,7 +208,7 @@ static inline void load_gs_index(unsigned selector)
213208

214209
#endif
215210

216-
#endif/* CONFIG_PARAVIRT_XXL */
211+
#endif /* CONFIG_PARAVIRT_XXL */
217212

218213
static inline void clflush(volatile void *__p)
219214
{

arch/x86/kernel/asm-offsets.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ void common(void) {
6464
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
6565
#endif
6666

67-
#ifdef CONFIG_PARAVIRT
68-
BLANK();
6967
#ifdef CONFIG_PARAVIRT_XXL
68+
BLANK();
7069
OFFSET(PV_IRQ_irq_disable, paravirt_patch_template, irq.irq_disable);
7170
OFFSET(PV_IRQ_irq_enable, paravirt_patch_template, irq.irq_enable);
7271
OFFSET(PV_CPU_iret, paravirt_patch_template, cpu.iret);
73-
#endif
7472
OFFSET(PV_MMU_read_cr2, paravirt_patch_template, mmu.read_cr2);
7573
#endif
7674

0 commit comments

Comments
 (0)