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

Re: [PATCH v2 5/5] tests: Introduce a TSX test


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 14 Jun 2021 18:21:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XrO1I7RtTsJNiVkcx05KnjXlIafK7T0CJKH8Yf3+WcY=; b=O3iHqtyLsPmj7fdfkNUmfRx0O8hmxGoiAOMmZadGft5MqbALI0NfkwUI0dBC5+TVMTjSF9Q+fFdiOHsS2TQUOR8PqgVC4isorqFwMvIKJmyYO4KEFuRVYez8loDt3ed5OJUN5E3GsAXBwePxHjdS5L3ad4i72H7yNsir4h/zEKMyslvd/h+kJ39sXxeqjdfyGFn/qw6dnntMz8fWULD2eQltwamQ1FJn1V2+CXCp0cwW+mdSXtXqgwa1/sHikFxWyW726BoiQUweXrWRh7b1DM2YiTDz1axCQfJhjEFAi4k/rK7MyjxBFkrhY0uYBXyth44qmQG46vmPJJ9Ml3bcHg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5KNWay1OtnTEChhCywQBXxtbNbCUoIOEX/SdRNPqpVyQtfQvCK2j1DPZ14EkrK/P7Ij/V30Fz4LWxVl/u8ZxFJgVEyJK6ZQw4VnrD+Zs0f5Ra8+vc1klHqbrGdtNTWioVvOyO8pxVvYHdxsqHxfw+mDe5q6vcxyJrLqMbdfV64vtlz7hARj2eEuVu/evJcA1dEufs2svz+PARpQzDMP4UAJ7j1tBqMXdizYaQvrx6LWUjPgoD+HZSU6lbd644LaGWvG8Xl7oqIQQg4I0QrbmXBYsgDfSeoI+tvgLyjrgbcVmU/yT8qEyAHmN9qVo8VCzYP0iKRPnPzeEohukiRqdg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>, Edwin Torok <edvin.torok@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 14 Jun 2021 17:37:14 +0000
  • Ironport-hdrordr: A9a23:guuaY6MHi7pB8sBcTyX155DYdb4zR+YMi2TDiHoedfUFSKOlfp 6V8MjztSWVtN4QMEtQ/uxoS5PwP080kqQFnrX5XI3SIDUO3VHIEGgM1/qY/9SNIVyGygcZ79 YcT0EcMqyDMbEZt7eD3ODQKb9Jq7PrgcPY55ar854ud3ANV0gJ1XYLNu/xKDwSeOApP+tcKH PR3Ls8m9L2Ek5nHvhTS0N1EdTrlpnurtbLcBQGDxko5E2nii6p0qfzF1y90g0FWz1C7L8++S yd+jaJppmLgrWe8FvxxmXT55NZlJ/IzcZCPtWFjowwJi/3ggilSYx9U/mpvSwzosuo9FE2+e O84isIDoBW0Tf8b2u1qRzi103LyzA18ULvzleenD/KvdH5bChSMbsFuatpNj/ir2YwttB116 xGm0iDsYBMMB/GlCPho/DVShBRkFauq3ZKq59Qs5Vma/pYVFZtl/1YwKsMe61wRR4SqbpXU9 WGNfusoMq/KjihHijkVgAF+q3YYpwxdi32D3Tq9PbliAS/MRhCvgMlLfck7wE9HaQGOtN5Dt T/Q9NVfY51P4YrhIJGdas8qJiMeyPwqSylChPYHb2xLtB3B5uKke+s3IkI
  • Ironport-sdr: geFQI56TdYjUmNR7E+fUq0iX8yCr8sfnsYbqbczihcowwGM3M4UmKTn5xiGThudYFlJQcy+3cp NmLwNoJ3aCw4JyeVae86ZGqJd9vjTIZs8EDQWPY5NaGzSk6OFYQwkXRLW+Fglb+2BOs+bb3IDW Qctb9TIoo5v8XGw8TDFZbfV/s557kX+4K1tFaDZFFd5RdLwiA+XF20pF7vD17efW2V+kc3GI4K eqLY/lEnoaHnKGhX93OR3+0iHg8FFMxUVlaw6uWg05kwCcFAkvVmdW8CC3x+NSEU3PKjBcR5AL F9M=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14/06/2021 17:13, Andrew Cooper wrote:
> +/*
> + * Probe for how RTM behaves, deliberately not inspecting CPUID.
> + * Distinguishes between "no support at all" (i.e. XBEGIN suffers #UD),
> + * working ok, and appearing to always abort.
> + */
> +static enum rtm_behaviour __attribute__((noclone)) probe_rtm_behaviour(void)

This doesn't compile, because Clang doesn't understand noclone.

With it dropped, https://cirrus-ci.com/build/6399801072812032 is the
FreeBSD build, confirming that sigill_handler() below is seemingly ok.

~Andrew

> +{
> +    for ( unsigned int i = 0; i < 1000; ++i )
> +    {
> +        /*
> +         * Opencoding the RTM infrastructure from immintrin.h, because we
> +         * still support older versions of GCC.  ALso so we can include #UD
> +         * detection logic.
> +         */
> +#define XBEGIN_STARTED -1
> +#define XBEGIN_UD      -2
> +        unsigned int status = XBEGIN_STARTED;
> +
> +        asm volatile ( ".Lxbegin: .byte 0xc7,0xf8,0,0,0,0" /* XBEGIN 1f; 1: 
> */
> +                       : "+a" (status) :: "memory" );
> +        if ( status == XBEGIN_STARTED )
> +        {
> +            asm volatile ( ".byte 0x0f,0x01,0xd5" ::: "memory" ); /* XEND */
> +            return RTM_OK;
> +        }
> +        else if ( status == XBEGIN_UD )
> +            return RTM_UD;
> +    }
> +
> +    return RTM_ABORT;
> +}
> +
> +static struct sigaction old_sigill;
> +
> +static void sigill_handler(int signo, siginfo_t *info, void *extra)
> +{
> +    extern const char xbegin_label[] asm(".Lxbegin");
> +
> +    if ( info->si_addr == xbegin_label &&
> +         memcmp(info->si_addr, "\xc7\xf8\x00\x00\x00\x00", 6) == 0 )
> +    {
> +        ucontext_t *context = extra;
> +
> +        /*
> +         * Found the XBEGIN instruction.  Step over it, and update `status` 
> to
> +         * signal #UD.
> +         */
> +#if defined(__linux__)
> +# ifdef __x86_64__
> +        context->uc_mcontext.gregs[REG_RIP] += 6;
> +        context->uc_mcontext.gregs[REG_RAX] = XBEGIN_UD;
> +# else
> +        context->uc_mcontext.gregs[REG_EIP] += 6;
> +        context->uc_mcontext.gregs[REG_EAX] = XBEGIN_UD;
> +# endif
> +
> +#elif defined(__FreeBSD__)
> +# ifdef __x86_64__
> +        context->uc_mcontext.mc_rip += 6;
> +        context->uc_mcontext.mc_rax = XBEGIN_UD;
> +# else
> +        context->uc_mcontext.mc_eip += 6;
> +        context->uc_mcontext.mc_eax = XBEGIN_UD;
> +# endif
> +
> +#elif defined(__NetBSD__)
> +# ifdef __x86_64__
> +        context->uc_mcontext.__gregs[_REG_RIP] += 6;
> +        context->uc_mcontext.__gregs[_REG_RAX] = XBEGIN_UD;
> +# else
> +        context->uc_mcontext.__gregs[_REG_EIP] += 6;
> +        context->uc_mcontext.__gregs[_REG_EAX] = XBEGIN_UD;
> +# endif
> +
> +#else
> +# error Unknown environment - please adjust
> +#endif
> +    }
> +    else
> +    {
> +        /*
> +         * Not the SIGILL we're looking for...  Restore the old handler and
> +         * try again.  Will likely coredump as a result.
> +         */
> +        sigaction(SIGILL, &old_sigill, NULL);
> +    }
> +}




 


Rackspace

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