[CRIU] [PATCH] zdtm/x86: Don't override %ebx in fpu00
Andrei Vagin
avagin at gmail.com
Wed Oct 31 19:30:16 MSK 2018
Applied, thanks!
On Wed, Oct 31, 2018 at 12:16:14AM +0000, Dmitry Safonov wrote:
> %ebx, %ecx, %eax aren't specified as clobbers in chk_proc_fpu(),
> while asm cpuid overwrites them.
>
> In the turn, %ebx is used as a code position by gcc now:
> 1661: e8 9a 00 00 00 call 1700 <__x86.get_pc_thunk.bx>
> 1666: 81 c3 46 68 00 00 add $0x6846,%ebx
>
> Which results in dereferencing some ugly garbage (result of cpuid).
>
> Let's use zdtm/lib cpuid() function instead.
>
> Signed-off-by: Dmitry Safonov <dima at arista.com>
> ---
> test/zdtm/static/fpu00.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/test/zdtm/static/fpu00.c b/test/zdtm/static/fpu00.c
> index 3e168a2f..04aa738f 100644
> --- a/test/zdtm/static/fpu00.c
> +++ b/test/zdtm/static/fpu00.c
> @@ -7,6 +7,9 @@ const char *test_doc = "Start a calculation, leaving FPU in a certain state,\n"
> const char *test_author = "Pavel Emelianov <xemul at parallels.com>";
>
> #if defined(__i386__) || defined(__x86_64__)
> +
> +#include "cpuid.h"
> +
> void start(float a, float b, float c, float d)
> {
> __asm__ volatile (
> @@ -31,16 +34,15 @@ float finish(void)
> return res;
> }
>
> +#define CPUID_FEAT_EDX_FPU (1 << 0)
> +
> int chk_proc_fpu(void)
> {
> - unsigned long fi;
> + uint32_t eax, ebx, ecx, edx;
>
> - __asm__ volatile (
> - "mov $1, %%eax\n"
> - "cpuid\n"
> - : "=d" (fi) : : "eax"
> - );
> - return fi & (1 << 0);
> + cpuid(1, &eax, &ebx, &ecx, &edx);
> +
> + return edx & CPUID_FEAT_EDX_FPU;
> }
> #endif
>
> --
> 2.19.1
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list