Commit 772ca413 authored by Juergen Gross's avatar Juergen Gross Committed by Borislav Petkov (AMD)

x86/paravirt: Introduce ALT_NOT_XEN

Introduce the macro ALT_NOT_XEN as a short form of
ALT_NOT(X86_FEATURE_XENPV).

No functional changes.
Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231129133332.31043-2-jgross@suse.com
parent fe22bc43
...@@ -142,8 +142,7 @@ static inline void write_cr0(unsigned long x) ...@@ -142,8 +142,7 @@ static inline void write_cr0(unsigned long x)
static __always_inline unsigned long read_cr2(void) static __always_inline unsigned long read_cr2(void)
{ {
return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2, return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,
"mov %%cr2, %%rax;", "mov %%cr2, %%rax;", ALT_NOT_XEN);
ALT_NOT(X86_FEATURE_XENPV));
} }
static __always_inline void write_cr2(unsigned long x) static __always_inline void write_cr2(unsigned long x)
...@@ -154,13 +153,12 @@ static __always_inline void write_cr2(unsigned long x) ...@@ -154,13 +153,12 @@ static __always_inline void write_cr2(unsigned long x)
static inline unsigned long __read_cr3(void) static inline unsigned long __read_cr3(void)
{ {
return PVOP_ALT_CALL0(unsigned long, mmu.read_cr3, return PVOP_ALT_CALL0(unsigned long, mmu.read_cr3,
"mov %%cr3, %%rax;", ALT_NOT(X86_FEATURE_XENPV)); "mov %%cr3, %%rax;", ALT_NOT_XEN);
} }
static inline void write_cr3(unsigned long x) static inline void write_cr3(unsigned long x)
{ {
PVOP_ALT_VCALL1(mmu.write_cr3, x, PVOP_ALT_VCALL1(mmu.write_cr3, x, "mov %%rdi, %%cr3", ALT_NOT_XEN);
"mov %%rdi, %%cr3", ALT_NOT(X86_FEATURE_XENPV));
} }
static inline void __write_cr4(unsigned long x) static inline void __write_cr4(unsigned long x)
...@@ -182,7 +180,7 @@ extern noinstr void pv_native_wbinvd(void); ...@@ -182,7 +180,7 @@ extern noinstr void pv_native_wbinvd(void);
static __always_inline void wbinvd(void) static __always_inline void wbinvd(void)
{ {
PVOP_ALT_VCALL0(cpu.wbinvd, "wbinvd", ALT_NOT(X86_FEATURE_XENPV)); PVOP_ALT_VCALL0(cpu.wbinvd, "wbinvd", ALT_NOT_XEN);
} }
static inline u64 paravirt_read_msr(unsigned msr) static inline u64 paravirt_read_msr(unsigned msr)
...@@ -390,27 +388,25 @@ static inline void paravirt_release_p4d(unsigned long pfn) ...@@ -390,27 +388,25 @@ static inline void paravirt_release_p4d(unsigned long pfn)
static inline pte_t __pte(pteval_t val) static inline pte_t __pte(pteval_t val)
{ {
return (pte_t) { PVOP_ALT_CALLEE1(pteval_t, mmu.make_pte, val, return (pte_t) { PVOP_ALT_CALLEE1(pteval_t, mmu.make_pte, val,
"mov %%rdi, %%rax", "mov %%rdi, %%rax", ALT_NOT_XEN) };
ALT_NOT(X86_FEATURE_XENPV)) };
} }
static inline pteval_t pte_val(pte_t pte) static inline pteval_t pte_val(pte_t pte)
{ {
return PVOP_ALT_CALLEE1(pteval_t, mmu.pte_val, pte.pte, return PVOP_ALT_CALLEE1(pteval_t, mmu.pte_val, pte.pte,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
} }
static inline pgd_t __pgd(pgdval_t val) static inline pgd_t __pgd(pgdval_t val)
{ {
return (pgd_t) { PVOP_ALT_CALLEE1(pgdval_t, mmu.make_pgd, val, return (pgd_t) { PVOP_ALT_CALLEE1(pgdval_t, mmu.make_pgd, val,
"mov %%rdi, %%rax", "mov %%rdi, %%rax", ALT_NOT_XEN) };
ALT_NOT(X86_FEATURE_XENPV)) };
} }
static inline pgdval_t pgd_val(pgd_t pgd) static inline pgdval_t pgd_val(pgd_t pgd)
{ {
return PVOP_ALT_CALLEE1(pgdval_t, mmu.pgd_val, pgd.pgd, return PVOP_ALT_CALLEE1(pgdval_t, mmu.pgd_val, pgd.pgd,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
} }
#define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION
...@@ -444,14 +440,13 @@ static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) ...@@ -444,14 +440,13 @@ static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
static inline pmd_t __pmd(pmdval_t val) static inline pmd_t __pmd(pmdval_t val)
{ {
return (pmd_t) { PVOP_ALT_CALLEE1(pmdval_t, mmu.make_pmd, val, return (pmd_t) { PVOP_ALT_CALLEE1(pmdval_t, mmu.make_pmd, val,
"mov %%rdi, %%rax", "mov %%rdi, %%rax", ALT_NOT_XEN) };
ALT_NOT(X86_FEATURE_XENPV)) };
} }
static inline pmdval_t pmd_val(pmd_t pmd) static inline pmdval_t pmd_val(pmd_t pmd)
{ {
return PVOP_ALT_CALLEE1(pmdval_t, mmu.pmd_val, pmd.pmd, return PVOP_ALT_CALLEE1(pmdval_t, mmu.pmd_val, pmd.pmd,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
} }
static inline void set_pud(pud_t *pudp, pud_t pud) static inline void set_pud(pud_t *pudp, pud_t pud)
...@@ -464,7 +459,7 @@ static inline pud_t __pud(pudval_t val) ...@@ -464,7 +459,7 @@ static inline pud_t __pud(pudval_t val)
pudval_t ret; pudval_t ret;
ret = PVOP_ALT_CALLEE1(pudval_t, mmu.make_pud, val, ret = PVOP_ALT_CALLEE1(pudval_t, mmu.make_pud, val,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
return (pud_t) { ret }; return (pud_t) { ret };
} }
...@@ -472,7 +467,7 @@ static inline pud_t __pud(pudval_t val) ...@@ -472,7 +467,7 @@ static inline pud_t __pud(pudval_t val)
static inline pudval_t pud_val(pud_t pud) static inline pudval_t pud_val(pud_t pud)
{ {
return PVOP_ALT_CALLEE1(pudval_t, mmu.pud_val, pud.pud, return PVOP_ALT_CALLEE1(pudval_t, mmu.pud_val, pud.pud,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
} }
static inline void pud_clear(pud_t *pudp) static inline void pud_clear(pud_t *pudp)
...@@ -492,8 +487,7 @@ static inline void set_p4d(p4d_t *p4dp, p4d_t p4d) ...@@ -492,8 +487,7 @@ static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
static inline p4d_t __p4d(p4dval_t val) static inline p4d_t __p4d(p4dval_t val)
{ {
p4dval_t ret = PVOP_ALT_CALLEE1(p4dval_t, mmu.make_p4d, val, p4dval_t ret = PVOP_ALT_CALLEE1(p4dval_t, mmu.make_p4d, val,
"mov %%rdi, %%rax", "mov %%rdi, %%rax", ALT_NOT_XEN);
ALT_NOT(X86_FEATURE_XENPV));
return (p4d_t) { ret }; return (p4d_t) { ret };
} }
...@@ -501,7 +495,7 @@ static inline p4d_t __p4d(p4dval_t val) ...@@ -501,7 +495,7 @@ static inline p4d_t __p4d(p4dval_t val)
static inline p4dval_t p4d_val(p4d_t p4d) static inline p4dval_t p4d_val(p4d_t p4d)
{ {
return PVOP_ALT_CALLEE1(p4dval_t, mmu.p4d_val, p4d.p4d, return PVOP_ALT_CALLEE1(p4dval_t, mmu.p4d_val, p4d.p4d,
"mov %%rdi, %%rax", ALT_NOT(X86_FEATURE_XENPV)); "mov %%rdi, %%rax", ALT_NOT_XEN);
} }
static inline void __set_pgd(pgd_t *pgdp, pgd_t pgd) static inline void __set_pgd(pgd_t *pgdp, pgd_t pgd)
...@@ -687,17 +681,17 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu); ...@@ -687,17 +681,17 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
static __always_inline unsigned long arch_local_save_flags(void) static __always_inline unsigned long arch_local_save_flags(void)
{ {
return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax;", return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax;",
ALT_NOT(X86_FEATURE_XENPV)); ALT_NOT_XEN);
} }
static __always_inline void arch_local_irq_disable(void) static __always_inline void arch_local_irq_disable(void)
{ {
PVOP_ALT_VCALLEE0(irq.irq_disable, "cli;", ALT_NOT(X86_FEATURE_XENPV)); PVOP_ALT_VCALLEE0(irq.irq_disable, "cli;", ALT_NOT_XEN);
} }
static __always_inline void arch_local_irq_enable(void) static __always_inline void arch_local_irq_enable(void)
{ {
PVOP_ALT_VCALLEE0(irq.irq_enable, "sti;", ALT_NOT(X86_FEATURE_XENPV)); PVOP_ALT_VCALLEE0(irq.irq_enable, "sti;", ALT_NOT_XEN);
} }
static __always_inline unsigned long arch_local_irq_save(void) static __always_inline unsigned long arch_local_irq_save(void)
...@@ -769,7 +763,7 @@ void native_pv_lock_init(void) __init; ...@@ -769,7 +763,7 @@ void native_pv_lock_init(void) __init;
.endm .endm
#define SAVE_FLAGS ALTERNATIVE "PARA_IRQ_save_fl;", "pushf; pop %rax;", \ #define SAVE_FLAGS ALTERNATIVE "PARA_IRQ_save_fl;", "pushf; pop %rax;", \
ALT_NOT(X86_FEATURE_XENPV) ALT_NOT_XEN
#endif #endif
#endif /* CONFIG_PARAVIRT_XXL */ #endif /* CONFIG_PARAVIRT_XXL */
#endif /* CONFIG_X86_64 */ #endif /* CONFIG_X86_64 */
......
...@@ -557,5 +557,8 @@ extern struct paravirt_patch_site __parainstructions[], ...@@ -557,5 +557,8 @@ extern struct paravirt_patch_site __parainstructions[],
__parainstructions_end[]; __parainstructions_end[];
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#define ALT_NOT_XEN ALT_NOT(X86_FEATURE_XENPV)
#endif /* CONFIG_PARAVIRT */ #endif /* CONFIG_PARAVIRT */
#endif /* _ASM_X86_PARAVIRT_TYPES_H */ #endif /* _ASM_X86_PARAVIRT_TYPES_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment