Skip to content

Commit c42b59b

Browse files
committed
Merge tag 'x86_paravirt_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 paravirt updates from Borislav Petkov: - Convert a couple of paravirt callbacks to asm to prevent '-fzero-call-used-regs' builds from zeroing live registers because paravirt hides the CALLs from the compiler so latter doesn't know there's a CALL in the first place - Merge two paravirt callbacks into one, as their functionality is identical * tag 'x86_paravirt_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/paravirt: Convert simple paravirt functions to asm x86/paravirt: Merge activate_mm() and dup_mmap() callbacks
2 parents 4a4a28f + 11af36c commit c42b59b

File tree

6 files changed

+24
-60
lines changed

6 files changed

+24
-60
lines changed

arch/x86/include/asm/mmu_context.h

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

1717
extern atomic64_t last_mm_ctx_id;
1818

19-
#ifndef CONFIG_PARAVIRT_XXL
20-
static inline void paravirt_activate_mm(struct mm_struct *prev,
21-
struct mm_struct *next)
22-
{
23-
}
24-
#endif /* !CONFIG_PARAVIRT_XXL */
25-
2619
#ifdef CONFIG_PERF_EVENTS
2720
DECLARE_STATIC_KEY_FALSE(rdpmc_never_available_key);
2821
DECLARE_STATIC_KEY_FALSE(rdpmc_always_available_key);
@@ -135,7 +128,7 @@ extern void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
135128

136129
#define activate_mm(prev, next) \
137130
do { \
138-
paravirt_activate_mm((prev), (next)); \
131+
paravirt_enter_mmap(next); \
139132
switch_mm((prev), (next), NULL); \
140133
} while (0);
141134

@@ -168,7 +161,7 @@ static inline void arch_dup_pkeys(struct mm_struct *oldmm,
168161
static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
169162
{
170163
arch_dup_pkeys(oldmm, mm);
171-
paravirt_arch_dup_mmap(oldmm, mm);
164+
paravirt_enter_mmap(mm);
172165
return ldt_dup_context(oldmm, mm);
173166
}
174167

arch/x86/include/asm/paravirt.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,9 @@ static inline void tss_update_io_bitmap(void)
334334
}
335335
#endif
336336

337-
static inline void paravirt_activate_mm(struct mm_struct *prev,
338-
struct mm_struct *next)
337+
static inline void paravirt_enter_mmap(struct mm_struct *next)
339338
{
340-
PVOP_VCALL2(mmu.activate_mm, prev, next);
341-
}
342-
343-
static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
344-
struct mm_struct *mm)
345-
{
346-
PVOP_VCALL2(mmu.dup_mmap, oldmm, mm);
339+
PVOP_VCALL1(mmu.enter_mmap, next);
347340
}
348341

349342
static inline int paravirt_pgd_alloc(struct mm_struct *mm)
@@ -789,8 +782,7 @@ extern void default_banner(void);
789782

790783
#ifndef __ASSEMBLY__
791784
#ifndef CONFIG_PARAVIRT_XXL
792-
static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
793-
struct mm_struct *mm)
785+
static inline void paravirt_enter_mmap(struct mm_struct *mm)
794786
{
795787
}
796788
#endif

arch/x86/include/asm/paravirt_types.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,8 @@ struct pv_mmu_ops {
164164
unsigned long (*read_cr3)(void);
165165
void (*write_cr3)(unsigned long);
166166

167-
/* Hooks for intercepting the creation/use of an mm_struct. */
168-
void (*activate_mm)(struct mm_struct *prev,
169-
struct mm_struct *next);
170-
void (*dup_mmap)(struct mm_struct *oldmm,
171-
struct mm_struct *mm);
167+
/* Hook for intercepting the creation/use of an mm_struct. */
168+
void (*enter_mmap)(struct mm_struct *mm);
172169

173170
/* Hooks for allocating and freeing a pagetable top-level */
174171
int (*pgd_alloc)(struct mm_struct *mm);
@@ -562,8 +559,14 @@ void paravirt_flush_lazy_mmu(void);
562559

563560
void _paravirt_nop(void);
564561
void paravirt_BUG(void);
565-
u64 _paravirt_ident_64(u64);
566562
unsigned long paravirt_ret0(void);
563+
#ifdef CONFIG_PARAVIRT_XXL
564+
u64 _paravirt_ident_64(u64);
565+
unsigned long pv_native_save_fl(void);
566+
void pv_native_irq_disable(void);
567+
void pv_native_irq_enable(void);
568+
unsigned long pv_native_read_cr2(void);
569+
#endif
567570

568571
#define paravirt_nop ((void *)_paravirt_nop)
569572

arch/x86/kernel/paravirt.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ static unsigned paravirt_patch_call(void *insn_buff, const void *target,
6464
}
6565

6666
#ifdef CONFIG_PARAVIRT_XXL
67-
/* identity function, which can be inlined */
68-
u64 notrace _paravirt_ident_64(u64 x)
69-
{
70-
return x;
71-
}
67+
DEFINE_PARAVIRT_ASM(_paravirt_ident_64, "mov %rdi, %rax", .text);
68+
DEFINE_PARAVIRT_ASM(pv_native_save_fl, "pushf; pop %rax", .noinstr.text);
69+
DEFINE_PARAVIRT_ASM(pv_native_irq_disable, "cli", .noinstr.text);
70+
DEFINE_PARAVIRT_ASM(pv_native_irq_enable, "sti", .noinstr.text);
71+
DEFINE_PARAVIRT_ASM(pv_native_read_cr2, "mov %cr2, %rax", .noinstr.text);
7272
#endif
7373

7474
DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);
@@ -197,11 +197,6 @@ void paravirt_end_context_switch(struct task_struct *next)
197197
arch_enter_lazy_mmu_mode();
198198
}
199199

200-
static noinstr unsigned long pv_native_read_cr2(void)
201-
{
202-
return native_read_cr2();
203-
}
204-
205200
static noinstr void pv_native_write_cr2(unsigned long val)
206201
{
207202
native_write_cr2(val);
@@ -222,16 +217,6 @@ noinstr void pv_native_wbinvd(void)
222217
native_wbinvd();
223218
}
224219

225-
static noinstr void pv_native_irq_enable(void)
226-
{
227-
native_irq_enable();
228-
}
229-
230-
static noinstr void pv_native_irq_disable(void)
231-
{
232-
native_irq_disable();
233-
}
234-
235220
static noinstr void pv_native_safe_halt(void)
236221
{
237222
native_safe_halt();
@@ -298,7 +283,7 @@ struct paravirt_patch_template pv_ops = {
298283
.cpu.end_context_switch = paravirt_nop,
299284

300285
/* Irq ops. */
301-
.irq.save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
286+
.irq.save_fl = __PV_IS_CALLEE_SAVE(pv_native_save_fl),
302287
.irq.irq_disable = __PV_IS_CALLEE_SAVE(pv_native_irq_disable),
303288
.irq.irq_enable = __PV_IS_CALLEE_SAVE(pv_native_irq_enable),
304289
.irq.safe_halt = pv_native_safe_halt,
@@ -363,8 +348,7 @@ struct paravirt_patch_template pv_ops = {
363348
.mmu.make_pte = PTE_IDENT,
364349
.mmu.make_pgd = PTE_IDENT,
365350

366-
.mmu.dup_mmap = paravirt_nop,
367-
.mmu.activate_mm = paravirt_nop,
351+
.mmu.enter_mmap = paravirt_nop,
368352

369353
.mmu.lazy_mode = {
370354
.enter = paravirt_nop,

arch/x86/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ void __init poking_init(void)
806806
BUG_ON(!poking_mm);
807807

808808
/* Xen PV guests need the PGD to be pinned. */
809-
paravirt_arch_dup_mmap(NULL, poking_mm);
809+
paravirt_enter_mmap(poking_mm);
810810

811811
/*
812812
* Randomize the poking address, but make sure that the following page

arch/x86/xen/mmu_pv.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,7 @@ void xen_mm_unpin_all(void)
885885
spin_unlock(&pgd_lock);
886886
}
887887

888-
static void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next)
889-
{
890-
spin_lock(&next->page_table_lock);
891-
xen_pgd_pin(next);
892-
spin_unlock(&next->page_table_lock);
893-
}
894-
895-
static void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
888+
static void xen_enter_mmap(struct mm_struct *mm)
896889
{
897890
spin_lock(&mm->page_table_lock);
898891
xen_pgd_pin(mm);
@@ -2153,8 +2146,7 @@ static const typeof(pv_ops) xen_mmu_ops __initconst = {
21532146
.make_p4d = PV_CALLEE_SAVE(xen_make_p4d),
21542147
#endif
21552148

2156-
.activate_mm = xen_activate_mm,
2157-
.dup_mmap = xen_dup_mmap,
2149+
.enter_mmap = xen_enter_mmap,
21582150
.exit_mmap = xen_exit_mmap,
21592151

21602152
.lazy_mode = {

0 commit comments

Comments
 (0)