[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 5/5] x86: use MOV for PFN/PDX conversion when possible
... and (of course) also maddr / direct-map-offset ones. Most x86 systems don't actually require the use of PDX compression. Now that we have patching for the conversion code in place anyway, extend it to use simple MOV when possible. Introduce a new pseudo-CPU-feature to key the patching off of. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- This patch will only apply cleanly on top of "x86: NOP out XPTI entry/exit code when it's not in use". --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1410,6 +1410,9 @@ void __init noreturn __start_xen(unsigne numa_initmem_init(0, raw_max_page); + if ( !pfn_pdx_hole_shift ) + setup_force_cpu_cap(X86_FEATURE_PFN_PDX_IDENT); + if ( max_page - 1 > virt_to_mfn(HYPERVISOR_VIRT_END - 1) ) { unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); --- a/xen/include/asm-x86/cpufeatures.h +++ b/xen/include/asm-x86/cpufeatures.h @@ -31,3 +31,4 @@ XEN_CPUFEATURE(XEN_IBRS_CLEAR, (FSCAPIN XEN_CPUFEATURE(RSB_NATIVE, (FSCAPINTS+0)*32+18) /* RSB overwrite needed for native */ XEN_CPUFEATURE(RSB_VMEXIT, (FSCAPINTS+0)*32+19) /* RSB overwrite needed for vmexit */ XEN_CPUFEATURE(NO_XPTI, (FSCAPINTS+0)*32+20) /* XPTI mitigation not in use */ +XEN_CPUFEATURE(PFN_PDX_IDENT, (FSCAPINTS+0)*32+21) /* PFN <-> PDX mapping is 1:1 */ --- a/xen/include/asm-x86/pdx.h +++ b/xen/include/asm-x86/pdx.h @@ -13,7 +13,7 @@ static always_inline unsigned long pdx_t #ifdef HAVE_GAS_QUOTED_EXPR_SYM #define SYMNAME(pfx...) "\"" #pfx "pdx2pfn_%[pfn]_%[pdx]\"" - alternative_io_2("call " SYMNAME() "; " ASM_NOP4 "\t" + alternative_io_3("call " SYMNAME() "; " ASM_NOP4 "\t" LINKONCE_PROLOGUE(SYMNAME) "mov %[shift], %%ecx\n\t" "mov %[pdx], %[pfn]\n\t" @@ -25,6 +25,7 @@ static always_inline unsigned long pdx_t LINKONCE_EPILOGUE(SYMNAME), "call " SYMNAME(), X86_FEATURE_ALWAYS, "pdep %[mask], %[pdx], %[pfn]", X86_FEATURE_BMI2, + "mov %[pdx], %[pfn]", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2([pfn] "=&r" (pfn), [pdx] "+r" (pdx)), [mask] "m" (pfn_real_mask), [shift] "m" (pfn_pdx_hole_shift), @@ -33,12 +34,13 @@ static always_inline unsigned long pdx_t : "ecx"); #undef SYMNAME #else - alternative_io_2("call pdx2pfn; " ASM_NOP4, + alternative_io_3("call pdx2pfn; " ASM_NOP4, "call pdx2pfn", X86_FEATURE_ALWAYS, /* pdep pfn_real_mask(%rip), %rdi, %rax */ ".byte 0xc4, 0xe2, 0xc3, 0xf5, 0x05\n\t" ".long pfn_real_mask - 4 - .", X86_FEATURE_BMI2, + "mov %%rdi, %%rax", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2("=a" (pfn), "+D" (pdx)), "m" (pfn_real_mask) : "rcx", "rdx", "rsi", "r8", "r9", "r10", "r11"); #endif @@ -52,7 +54,7 @@ static always_inline unsigned long pfn_t #ifdef HAVE_GAS_QUOTED_EXPR_SYM #define SYMNAME(pfx...) "\"" #pfx "pfn2pdx_%[pdx]_%[pfn]\"" - alternative_io_2("call " SYMNAME() "; " ASM_NOP4 "\t" + alternative_io_3("call " SYMNAME() "; " ASM_NOP4 "\t" LINKONCE_PROLOGUE(SYMNAME) "mov %[tmask], %[pdx]\n\t" "mov %[shift], %%ecx\n\t" @@ -64,6 +66,7 @@ static always_inline unsigned long pfn_t LINKONCE_EPILOGUE(SYMNAME), "call " SYMNAME(), X86_FEATURE_ALWAYS, "pext %[mask], %[pfn], %[pdx]", X86_FEATURE_BMI2, + "mov %[pfn], %[pdx]", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2([pdx] "=&r" (pdx), [pfn] "+r" (pfn)), [mask] "m" (pfn_real_mask), [shift] "m" (pfn_pdx_hole_shift), @@ -72,12 +75,13 @@ static always_inline unsigned long pfn_t : "ecx"); #undef SYMNAME #else - alternative_io_2("call pfn2pdx; " ASM_NOP4, + alternative_io_3("call pfn2pdx; " ASM_NOP4, "call pfn2pdx", X86_FEATURE_ALWAYS, /* pext pfn_real_mask(%rip), %rdi, %rax */ ".byte 0xc4, 0xe2, 0xc2, 0xf5, 0x05\n\t" ".long pfn_real_mask - 4 - .", X86_FEATURE_BMI2, + "mov %%rdi, %%rax", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2("=a" (pdx), "+D" (pfn)), "m" (pfn_real_mask) : "rcx", "rdx", "rsi", "r8", "r9", "r10", "r11"); #endif --- a/xen/include/asm-x86/x86_64/page.h +++ b/xen/include/asm-x86/x86_64/page.h @@ -75,7 +75,7 @@ static always_inline paddr_t __virt_to_m #ifdef HAVE_GAS_QUOTED_EXPR_SYM #define SYMNAME(pfx...) "\"" #pfx "do2ma_%[ma]_%[off]\"" - alternative_io_2("call " SYMNAME() "; " ASM_NOP4 "\t" + alternative_io_3("call " SYMNAME() "; " ASM_NOP4 "\t" LINKONCE_PROLOGUE(SYMNAME) "mov %[shift], %%ecx\n\t" "mov %[off], %[ma]\n\t" @@ -87,6 +87,7 @@ static always_inline paddr_t __virt_to_m LINKONCE_EPILOGUE(SYMNAME), "call " SYMNAME(), X86_FEATURE_ALWAYS, "pdep %[mask], %[off], %[ma]", X86_FEATURE_BMI2, + "mov %[off], %[ma]", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2([ma] "=&r" (ma), [off] "+r" (va)), [mask] "m" (ma_real_mask), [shift] "m" (pfn_pdx_hole_shift), @@ -95,12 +96,13 @@ static always_inline paddr_t __virt_to_m : "ecx"); #undef SYMNAME #else - alternative_io_2("call do2ma; " ASM_NOP4, + alternative_io_3("call do2ma; " ASM_NOP4, "call do2ma", X86_FEATURE_ALWAYS, /* pdep ma_real_mask(%rip), %rdi, %rax */ ".byte 0xc4, 0xe2, 0xc3, 0xf5, 0x05\n\t" ".long ma_real_mask - 4 - .", X86_FEATURE_BMI2, + "mov %%rdi, %%rax", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2("=a" (ma), "+D" (va)), "m" (ma_real_mask) : "rcx", "rdx", "rsi", "r8", "r9", "r10", "r11"); #endif @@ -116,7 +118,7 @@ static always_inline void *__maddr_to_vi #ifdef HAVE_GAS_QUOTED_EXPR_SYM #define SYMNAME(pfx...) "\"" #pfx "ma2do_%[off]_%[ma]\"" - alternative_io_2("call " SYMNAME() "; " ASM_NOP4 "\t" + alternative_io_3("call " SYMNAME() "; " ASM_NOP4 "\t" LINKONCE_PROLOGUE(SYMNAME) "mov %[tmask], %[off]\n\t" "mov %[shift], %%ecx\n\t" @@ -128,6 +130,7 @@ static always_inline void *__maddr_to_vi LINKONCE_EPILOGUE(SYMNAME), "call " SYMNAME(), X86_FEATURE_ALWAYS, "pext %[mask], %[ma], %[off]", X86_FEATURE_BMI2, + "mov %[ma], %[off]", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2([off] "=&r" (off), [ma] "+r" (ma)), [mask] "m" (ma_real_mask), [shift] "m" (pfn_pdx_hole_shift), @@ -136,12 +139,13 @@ static always_inline void *__maddr_to_vi : "ecx"); #undef SYMNAME #else - alternative_io_2("call ma2do; " ASM_NOP4, + alternative_io_3("call ma2do; " ASM_NOP4, "call ma2do", X86_FEATURE_ALWAYS, /* pext ma_real_mask(%rip), %rdi, %rax */ ".byte 0xc4, 0xe2, 0xc2, 0xf5, 0x05\n\t" ".long ma_real_mask - 4 - .", X86_FEATURE_BMI2, + "mov %%rdi, %%rax", X86_FEATURE_PFN_PDX_IDENT, ASM_OUTPUT2("=a" (off), "+D" (ma)), "m" (ma_real_mask) : "rcx", "rdx", "rsi", "r8", "r9", "r10", "r11"); #endif _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |