[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC v2 3/7] x86emul/test: factor out emul_test_{read_cr, cpuid}



>>> On 09.12.16 at 13:23, <wei.liu2@xxxxxxxxxx> wrote:
> --- a/tools/tests/x86_emulator/test_x86_emulator.c
> +++ b/tools/tests/x86_emulator/test_x86_emulator.c
> @@ -92,51 +92,33 @@ static int cmpxchg(
>      return X86EMUL_OKAY;
>  }
>  
> -static int cpuid(
> -    unsigned int *eax,
> -    unsigned int *ebx,
> -    unsigned int *ecx,
> -    unsigned int *edx,
> -    struct x86_emulate_ctxt *ctxt)
> -{
> -    unsigned int leaf = *eax;
> -
> -    asm ("cpuid" : "+a" (*eax), "+c" (*ecx), "=d" (*edx), "=b" (*ebx));
> -
> -    /* The emulator doesn't itself use MOVBE, so we can always run the test. 
> */
> -    if ( leaf == 1 )
> -        *ecx |= 1U << 22;
> -
> -    return X86EMUL_OKAY;
> -}
> -
>  #define cache_line_size() ({ \
>      unsigned int eax = 1, ebx, ecx = 0, edx; \
> -    cpuid(&eax, &ebx, &ecx, &edx, NULL); \
> +    emul_test_cpuid(&eax, &ebx, &ecx, &edx, NULL); \
>      edx & (1U << 19) ? (ebx >> 5) & 0x7f8 : 0; \
>  })
>  
>  #define cpu_has_mmx ({ \
>      unsigned int eax = 1, ecx = 0, edx; \
> -    cpuid(&eax, &ecx, &ecx, &edx, NULL); \
> +    emul_test_cpuid(&eax, &ecx, &ecx, &edx, NULL); \
>      (edx & (1U << 23)) != 0; \
>  })
>  
>  #define cpu_has_sse ({ \
>      unsigned int eax = 1, ecx = 0, edx; \
> -    cpuid(&eax, &ecx, &ecx, &edx, NULL); \
> +    emul_test_cpuid(&eax, &ecx, &ecx, &edx, NULL); \
>      (edx & (1U << 25)) != 0; \
>  })
>  
>  #define cpu_has_sse2 ({ \
>      unsigned int eax = 1, ecx = 0, edx; \
> -    cpuid(&eax, &ecx, &ecx, &edx, NULL); \
> +    emul_test_cpuid(&eax, &ecx, &ecx, &edx, NULL); \
>      (edx & (1U << 26)) != 0; \
>  })
>  
>  #define cpu_has_xsave ({ \
>      unsigned int eax = 1, ecx = 0; \
> -    cpuid(&eax, &eax, &ecx, &eax, NULL); \
> +    emul_test_cpuid(&eax, &eax, &ecx, &eax, NULL); \
>      /* Intentionally checking OSXSAVE here. */ \
>      (ecx & (1U << 27)) != 0; \
>  })

Hmm, you cpu_has_xsave in place here, but you also ...

> --- a/tools/tests/x86_emulator/x86_emulate.h
> +++ b/tools/tests/x86_emulator/x86_emulate.h
> @@ -37,3 +37,22 @@
>  bool emul_test_make_stack_executable(void);
>  
>  #include "x86_emulate/x86_emulate.h"
> +
> +#define cpu_has_xsave ({        \
> +    unsigned int eax = 1, ecx = 0; \
> +    emul_test_cpuid(&eax, &eax, &ecx, &eax, NULL); \
> +    /* Intentionally checking OSXSAVE here. */ \
> +    (ecx & (1U << 27)) != 0; \
> +})

... add it here - why? If you mean to put it here, perhaps all of the
cpu_has_* should be moved?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.