On 02/11/18 15:55, Wei Liu wrote:
> Skip building x86_64/compat/entry.S and put CONFIG_PV in
> x86_64/entry.S.
>
> Signed-off-by: Wei Liu <wei.l...@citrix.com>
> ---
> v3:
> 1. make CR4_PV32_RESTORE expand to nothing when !PV
> 2. use unconditional jmp and add assertions
>
> v2: new
> ---
>  xen/arch/x86/x86_64/Makefile    |  2 +-
>  xen/arch/x86/x86_64/entry.S     | 39 +++++++++++++++++++++++++++++++++-
>  xen/include/asm-x86/asm_defns.h |  4 +++-
>  3 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/x86_64/Makefile b/xen/arch/x86/x86_64/Makefile
> index f336a6a..4bfa148 100644
> --- a/xen/arch/x86/x86_64/Makefile
> +++ b/xen/arch/x86/x86_64/Makefile
> @@ -1,4 +1,4 @@
> -subdir-y += compat
> +subdir-$(CONFIG_PV) += compat
>  
>  obj-bin-y += entry.o
>  obj-y += traps.o
> diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
> index 9b02899..975ed6a 100644
> --- a/xen/arch/x86/x86_64/entry.S
> +++ b/xen/arch/x86/x86_64/entry.S
> @@ -15,6 +15,18 @@
>  #include <public/xen.h>
>  #include <irq_vectors.h>
>  
> +#ifndef NDEBUG
> +/* %rsp: struct cpu_user_regs */
> +#define ASSERT_INTERRUPTED_XEN_CONTEXT            \

Could I suggest ASSERT_CONTEXT_IS_XEN which I think fits better in some
of the cases below?

> +        testb $3, UREGS_cs(%rsp);                 \
> +        jz    1f;                                 \
> +        ASSERT_FAILED("INTERRUPTED XEN CONTEXT"); \

This probably wants to be:

.macro ASSERT_CONTEXT_IS_XEN
#ifndef NDEBUG
    testb $3, UREGS_cs(%rsp);
    UNLIKELY_START(nz, ASSERT_XEN_\@);
    ASSERT_FAILED("CONTEXT IS XEN");
    __UNLIKELY_END(ASSERT_XEN_\@);
#endif
.endm

which will assemble in the fastpath to:

testb $3, UREGS_cs(%rsp);
jne <unlikely>
jmp restore_all_xen

And avoid a conditional jump in the expected path.  (Code completely
untested.)

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to