Commit da5de7c2 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by H. Peter Anvin

x86/paravirt: use callee-saved convention for pte_val/make_pte/etc

Impact: Optimization

In the native case, pte_val, make_pte, etc are all just identity
functions, so there's no need to clobber a lot of registers over them.

(This changes the 32-bit callee-save calling convention to return both
EAX and EDX so functions can return 64-bit values.)
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 791bad9d
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define CLBR_ANY ((1 << 4) - 1) #define CLBR_ANY ((1 << 4) - 1)
#define CLBR_ARG_REGS (CLBR_EAX | CLBR_EDX | CLBR_ECX) #define CLBR_ARG_REGS (CLBR_EAX | CLBR_EDX | CLBR_ECX)
#define CLBR_RET_REG (CLBR_EAX) #define CLBR_RET_REG (CLBR_EAX | CLBR_EDX)
#define CLBR_SCRATCH (0) #define CLBR_SCRATCH (0)
#else #else
#define CLBR_RAX CLBR_EAX #define CLBR_RAX CLBR_EAX
...@@ -308,11 +308,11 @@ struct pv_mmu_ops { ...@@ -308,11 +308,11 @@ struct pv_mmu_ops {
void (*ptep_modify_prot_commit)(struct mm_struct *mm, unsigned long addr, void (*ptep_modify_prot_commit)(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t pte); pte_t *ptep, pte_t pte);
pteval_t (*pte_val)(pte_t); struct paravirt_callee_save pte_val;
pte_t (*make_pte)(pteval_t pte); struct paravirt_callee_save make_pte;
pgdval_t (*pgd_val)(pgd_t); struct paravirt_callee_save pgd_val;
pgd_t (*make_pgd)(pgdval_t pgd); struct paravirt_callee_save make_pgd;
#if PAGETABLE_LEVELS >= 3 #if PAGETABLE_LEVELS >= 3
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
...@@ -327,12 +327,12 @@ struct pv_mmu_ops { ...@@ -327,12 +327,12 @@ struct pv_mmu_ops {
void (*set_pud)(pud_t *pudp, pud_t pudval); void (*set_pud)(pud_t *pudp, pud_t pudval);
pmdval_t (*pmd_val)(pmd_t); struct paravirt_callee_save pmd_val;
pmd_t (*make_pmd)(pmdval_t pmd); struct paravirt_callee_save make_pmd;
#if PAGETABLE_LEVELS == 4 #if PAGETABLE_LEVELS == 4
pudval_t (*pud_val)(pud_t); struct paravirt_callee_save pud_val;
pud_t (*make_pud)(pudval_t pud); struct paravirt_callee_save make_pud;
void (*set_pgd)(pgd_t *pudp, pgd_t pgdval); void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
#endif /* PAGETABLE_LEVELS == 4 */ #endif /* PAGETABLE_LEVELS == 4 */
...@@ -1155,11 +1155,11 @@ static inline pte_t __pte(pteval_t val) ...@@ -1155,11 +1155,11 @@ static inline pte_t __pte(pteval_t val)
pteval_t ret; pteval_t ret;
if (sizeof(pteval_t) > sizeof(long)) if (sizeof(pteval_t) > sizeof(long))
ret = PVOP_CALL2(pteval_t, ret = PVOP_CALLEE2(pteval_t,
pv_mmu_ops.make_pte, pv_mmu_ops.make_pte,
val, (u64)val >> 32); val, (u64)val >> 32);
else else
ret = PVOP_CALL1(pteval_t, ret = PVOP_CALLEE1(pteval_t,
pv_mmu_ops.make_pte, pv_mmu_ops.make_pte,
val); val);
...@@ -1171,10 +1171,10 @@ static inline pteval_t pte_val(pte_t pte) ...@@ -1171,10 +1171,10 @@ static inline pteval_t pte_val(pte_t pte)
pteval_t ret; pteval_t ret;
if (sizeof(pteval_t) > sizeof(long)) if (sizeof(pteval_t) > sizeof(long))
ret = PVOP_CALL2(pteval_t, pv_mmu_ops.pte_val, ret = PVOP_CALLEE2(pteval_t, pv_mmu_ops.pte_val,
pte.pte, (u64)pte.pte >> 32); pte.pte, (u64)pte.pte >> 32);
else else
ret = PVOP_CALL1(pteval_t, pv_mmu_ops.pte_val, ret = PVOP_CALLEE1(pteval_t, pv_mmu_ops.pte_val,
pte.pte); pte.pte);
return ret; return ret;
...@@ -1185,10 +1185,10 @@ static inline pgd_t __pgd(pgdval_t val) ...@@ -1185,10 +1185,10 @@ static inline pgd_t __pgd(pgdval_t val)
pgdval_t ret; pgdval_t ret;
if (sizeof(pgdval_t) > sizeof(long)) if (sizeof(pgdval_t) > sizeof(long))
ret = PVOP_CALL2(pgdval_t, pv_mmu_ops.make_pgd, ret = PVOP_CALLEE2(pgdval_t, pv_mmu_ops.make_pgd,
val, (u64)val >> 32); val, (u64)val >> 32);
else else
ret = PVOP_CALL1(pgdval_t, pv_mmu_ops.make_pgd, ret = PVOP_CALLEE1(pgdval_t, pv_mmu_ops.make_pgd,
val); val);
return (pgd_t) { ret }; return (pgd_t) { ret };
...@@ -1199,10 +1199,10 @@ static inline pgdval_t pgd_val(pgd_t pgd) ...@@ -1199,10 +1199,10 @@ static inline pgdval_t pgd_val(pgd_t pgd)
pgdval_t ret; pgdval_t ret;
if (sizeof(pgdval_t) > sizeof(long)) if (sizeof(pgdval_t) > sizeof(long))
ret = PVOP_CALL2(pgdval_t, pv_mmu_ops.pgd_val, ret = PVOP_CALLEE2(pgdval_t, pv_mmu_ops.pgd_val,
pgd.pgd, (u64)pgd.pgd >> 32); pgd.pgd, (u64)pgd.pgd >> 32);
else else
ret = PVOP_CALL1(pgdval_t, pv_mmu_ops.pgd_val, ret = PVOP_CALLEE1(pgdval_t, pv_mmu_ops.pgd_val,
pgd.pgd); pgd.pgd);
return ret; return ret;
...@@ -1267,10 +1267,10 @@ static inline pmd_t __pmd(pmdval_t val) ...@@ -1267,10 +1267,10 @@ static inline pmd_t __pmd(pmdval_t val)
pmdval_t ret; pmdval_t ret;
if (sizeof(pmdval_t) > sizeof(long)) if (sizeof(pmdval_t) > sizeof(long))
ret = PVOP_CALL2(pmdval_t, pv_mmu_ops.make_pmd, ret = PVOP_CALLEE2(pmdval_t, pv_mmu_ops.make_pmd,
val, (u64)val >> 32); val, (u64)val >> 32);
else else
ret = PVOP_CALL1(pmdval_t, pv_mmu_ops.make_pmd, ret = PVOP_CALLEE1(pmdval_t, pv_mmu_ops.make_pmd,
val); val);
return (pmd_t) { ret }; return (pmd_t) { ret };
...@@ -1281,10 +1281,10 @@ static inline pmdval_t pmd_val(pmd_t pmd) ...@@ -1281,10 +1281,10 @@ static inline pmdval_t pmd_val(pmd_t pmd)
pmdval_t ret; pmdval_t ret;
if (sizeof(pmdval_t) > sizeof(long)) if (sizeof(pmdval_t) > sizeof(long))
ret = PVOP_CALL2(pmdval_t, pv_mmu_ops.pmd_val, ret = PVOP_CALLEE2(pmdval_t, pv_mmu_ops.pmd_val,
pmd.pmd, (u64)pmd.pmd >> 32); pmd.pmd, (u64)pmd.pmd >> 32);
else else
ret = PVOP_CALL1(pmdval_t, pv_mmu_ops.pmd_val, ret = PVOP_CALLEE1(pmdval_t, pv_mmu_ops.pmd_val,
pmd.pmd); pmd.pmd);
return ret; return ret;
...@@ -1307,10 +1307,10 @@ static inline pud_t __pud(pudval_t val) ...@@ -1307,10 +1307,10 @@ static inline pud_t __pud(pudval_t val)
pudval_t ret; pudval_t ret;
if (sizeof(pudval_t) > sizeof(long)) if (sizeof(pudval_t) > sizeof(long))
ret = PVOP_CALL2(pudval_t, pv_mmu_ops.make_pud, ret = PVOP_CALLEE2(pudval_t, pv_mmu_ops.make_pud,
val, (u64)val >> 32); val, (u64)val >> 32);
else else
ret = PVOP_CALL1(pudval_t, pv_mmu_ops.make_pud, ret = PVOP_CALLEE1(pudval_t, pv_mmu_ops.make_pud,
val); val);
return (pud_t) { ret }; return (pud_t) { ret };
......
...@@ -391,43 +391,12 @@ struct pv_apic_ops pv_apic_ops = { ...@@ -391,43 +391,12 @@ struct pv_apic_ops pv_apic_ops = {
#endif #endif
}; };
typedef pte_t make_pte_t(pteval_t);
typedef pmd_t make_pmd_t(pmdval_t);
typedef pud_t make_pud_t(pudval_t);
typedef pgd_t make_pgd_t(pgdval_t);
typedef pteval_t pte_val_t(pte_t);
typedef pmdval_t pmd_val_t(pmd_t);
typedef pudval_t pud_val_t(pud_t);
typedef pgdval_t pgd_val_t(pgd_t);
#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
/* 32-bit pagetable entries */ /* 32-bit pagetable entries */
#define paravirt_native_make_pte (make_pte_t *)_paravirt_ident_32 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
#define paravirt_native_pte_val (pte_val_t *)_paravirt_ident_32
#define paravirt_native_make_pmd (make_pmd_t *)_paravirt_ident_32
#define paravirt_native_pmd_val (pmd_val_t *)_paravirt_ident_32
#define paravirt_native_make_pud (make_pud_t *)_paravirt_ident_32
#define paravirt_native_pud_val (pud_val_t *)_paravirt_ident_32
#define paravirt_native_make_pgd (make_pgd_t *)_paravirt_ident_32
#define paravirt_native_pgd_val (pgd_val_t *)_paravirt_ident_32
#else #else
/* 64-bit pagetable entries */ /* 64-bit pagetable entries */
#define paravirt_native_make_pte (make_pte_t *)_paravirt_ident_64 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
#define paravirt_native_pte_val (pte_val_t *)_paravirt_ident_64
#define paravirt_native_make_pmd (make_pmd_t *)_paravirt_ident_64
#define paravirt_native_pmd_val (pmd_val_t *)_paravirt_ident_64
#define paravirt_native_make_pud (make_pud_t *)_paravirt_ident_64
#define paravirt_native_pud_val (pud_val_t *)_paravirt_ident_64
#define paravirt_native_make_pgd (make_pgd_t *)_paravirt_ident_64
#define paravirt_native_pgd_val (pgd_val_t *)_paravirt_ident_64
#endif #endif
struct pv_mmu_ops pv_mmu_ops = { struct pv_mmu_ops pv_mmu_ops = {
...@@ -481,21 +450,23 @@ struct pv_mmu_ops pv_mmu_ops = { ...@@ -481,21 +450,23 @@ struct pv_mmu_ops pv_mmu_ops = {
.pmd_clear = native_pmd_clear, .pmd_clear = native_pmd_clear,
#endif #endif
.set_pud = native_set_pud, .set_pud = native_set_pud,
.pmd_val = paravirt_native_pmd_val,
.make_pmd = paravirt_native_make_pmd, .pmd_val = PTE_IDENT,
.make_pmd = PTE_IDENT,
#if PAGETABLE_LEVELS == 4 #if PAGETABLE_LEVELS == 4
.pud_val = paravirt_native_pud_val, .pud_val = PTE_IDENT,
.make_pud = paravirt_native_make_pud, .make_pud = PTE_IDENT,
.set_pgd = native_set_pgd, .set_pgd = native_set_pgd,
#endif #endif
#endif /* PAGETABLE_LEVELS >= 3 */ #endif /* PAGETABLE_LEVELS >= 3 */
.pte_val = paravirt_native_pte_val, .pte_val = PTE_IDENT,
.pgd_val = paravirt_native_pgd_val, .pgd_val = PTE_IDENT,
.make_pte = paravirt_native_make_pte, .make_pte = PTE_IDENT,
.make_pgd = paravirt_native_make_pgd, .make_pgd = PTE_IDENT,
.dup_mmap = paravirt_nop, .dup_mmap = paravirt_nop,
.exit_mmap = paravirt_nop, .exit_mmap = paravirt_nop,
......
...@@ -492,28 +492,33 @@ pteval_t xen_pte_val(pte_t pte) ...@@ -492,28 +492,33 @@ pteval_t xen_pte_val(pte_t pte)
{ {
return pte_mfn_to_pfn(pte.pte); return pte_mfn_to_pfn(pte.pte);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val);
pgdval_t xen_pgd_val(pgd_t pgd) pgdval_t xen_pgd_val(pgd_t pgd)
{ {
return pte_mfn_to_pfn(pgd.pgd); return pte_mfn_to_pfn(pgd.pgd);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val);
pte_t xen_make_pte(pteval_t pte) pte_t xen_make_pte(pteval_t pte)
{ {
pte = pte_pfn_to_mfn(pte); pte = pte_pfn_to_mfn(pte);
return native_make_pte(pte); return native_make_pte(pte);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte);
pgd_t xen_make_pgd(pgdval_t pgd) pgd_t xen_make_pgd(pgdval_t pgd)
{ {
pgd = pte_pfn_to_mfn(pgd); pgd = pte_pfn_to_mfn(pgd);
return native_make_pgd(pgd); return native_make_pgd(pgd);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_make_pgd);
pmdval_t xen_pmd_val(pmd_t pmd) pmdval_t xen_pmd_val(pmd_t pmd)
{ {
return pte_mfn_to_pfn(pmd.pmd); return pte_mfn_to_pfn(pmd.pmd);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_pmd_val);
void xen_set_pud_hyper(pud_t *ptr, pud_t val) void xen_set_pud_hyper(pud_t *ptr, pud_t val)
{ {
...@@ -590,12 +595,14 @@ pmd_t xen_make_pmd(pmdval_t pmd) ...@@ -590,12 +595,14 @@ pmd_t xen_make_pmd(pmdval_t pmd)
pmd = pte_pfn_to_mfn(pmd); pmd = pte_pfn_to_mfn(pmd);
return native_make_pmd(pmd); return native_make_pmd(pmd);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_make_pmd);
#if PAGETABLE_LEVELS == 4 #if PAGETABLE_LEVELS == 4
pudval_t xen_pud_val(pud_t pud) pudval_t xen_pud_val(pud_t pud)
{ {
return pte_mfn_to_pfn(pud.pud); return pte_mfn_to_pfn(pud.pud);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_pud_val);
pud_t xen_make_pud(pudval_t pud) pud_t xen_make_pud(pudval_t pud)
{ {
...@@ -603,6 +610,7 @@ pud_t xen_make_pud(pudval_t pud) ...@@ -603,6 +610,7 @@ pud_t xen_make_pud(pudval_t pud)
return native_make_pud(pud); return native_make_pud(pud);
} }
PV_CALLEE_SAVE_REGS_THUNK(xen_make_pud);
pgd_t *xen_get_user_pgd(pgd_t *pgd) pgd_t *xen_get_user_pgd(pgd_t *pgd)
{ {
...@@ -1813,11 +1821,11 @@ const struct pv_mmu_ops xen_mmu_ops __initdata = { ...@@ -1813,11 +1821,11 @@ const struct pv_mmu_ops xen_mmu_ops __initdata = {
.ptep_modify_prot_start = __ptep_modify_prot_start, .ptep_modify_prot_start = __ptep_modify_prot_start,
.ptep_modify_prot_commit = __ptep_modify_prot_commit, .ptep_modify_prot_commit = __ptep_modify_prot_commit,
.pte_val = xen_pte_val, .pte_val = PV_CALLEE_SAVE(xen_pte_val),
.pgd_val = xen_pgd_val, .pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
.make_pte = xen_make_pte, .make_pte = PV_CALLEE_SAVE(xen_make_pte),
.make_pgd = xen_make_pgd, .make_pgd = PV_CALLEE_SAVE(xen_make_pgd),
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
.set_pte_atomic = xen_set_pte_atomic, .set_pte_atomic = xen_set_pte_atomic,
...@@ -1827,12 +1835,12 @@ const struct pv_mmu_ops xen_mmu_ops __initdata = { ...@@ -1827,12 +1835,12 @@ const struct pv_mmu_ops xen_mmu_ops __initdata = {
#endif /* CONFIG_X86_PAE */ #endif /* CONFIG_X86_PAE */
.set_pud = xen_set_pud_hyper, .set_pud = xen_set_pud_hyper,
.make_pmd = xen_make_pmd, .make_pmd = PV_CALLEE_SAVE(xen_make_pmd),
.pmd_val = xen_pmd_val, .pmd_val = PV_CALLEE_SAVE(xen_pmd_val),
#if PAGETABLE_LEVELS == 4 #if PAGETABLE_LEVELS == 4
.pud_val = xen_pud_val, .pud_val = PV_CALLEE_SAVE(xen_pud_val),
.make_pud = xen_make_pud, .make_pud = PV_CALLEE_SAVE(xen_make_pud),
.set_pgd = xen_set_pgd_hyper, .set_pgd = xen_set_pgd_hyper,
.alloc_pud = xen_alloc_pte_init, .alloc_pud = xen_alloc_pte_init,
......
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