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

Re: [PATCH v1.1 5/5] tests: Introduce a TSX test


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 14 Jun 2021 15:50:43 +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=P/mfLfjGPmj7/MqpHaqFZy/eLTzP7lPftkwFZLmgMqI=; b=Y1LYIo+7PSr4dg+LgvJpn+KabPIzM6m9Ox2/nvrBIOnktIB0+JsEHJoNtfphsVzUSCQjb8ZUAQX8zB/6UMXNUC/8Ozzi6SLpjgTxeEgrWmsHOzkvVbgsmgCnvy7rp69hY3anETB1eYcJBDBiEC6vtZZ/97aITFJmLpevlzBjEkE+ggODSVYph5kRgJGjLvb8Z11ddZ7EpONG9XqU2bE07NE1zPsG0HcIV8C/r+nnuu6GLXWZZwjrzI2wSXWZ/anpIn6cekCk8UqDi59MsVnZXg7mInvlBy+XYYFUOfvxuK79RrvW+WX0OWeJTCEyOri/kxuxPvtsxC3kbawbu2+wEw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4DQNCWzI9ZBd7bi+vZgjJA0/Z61pq4fn+VNb3wIei9qIN0VYzOgUfSDUYXPzhHNPggXfoPP7eAXr9L0kmgpwRHv2btwSaoV4+8A8bo8C+7NRyMl5WcIivXNly866M2/RtQkfJxTPmDTgDbkmjmZfIcno8AIFwZWzxSZEUctoOLdLEns+pAOm1+hrYamipSoU7YlNgzB7MCoDJex0BfNy5RUq5ZqFzd1y0qoFhMQCCpr6bV9NWZBQLTdY0+GEa5AhW80DbL9dfjq2Ubjdwshhrnp46DILH21vIT/nA+KdCriMx6s0w/nIvvTSQPZmaAlyCsdQIqRr7+Sw8Hf6z3Ilw==
  • 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>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 14 Jun 2021 14:51:04 +0000
  • Ironport-hdrordr: A9a23:16Ct8q36w/3SI4Fs2T+1yQqjBVByeYIsimQD101hICG9Lfb2qy n+ppgmPEHP5Qr5OEtApTiBUJPwJE80hqQFnrX5Wo3SIDUO2VHYUb2KiLGN/9SOIVyHygcw79 YGT0E6MqyLMbEYt7eI3ODbKadY/DDvysnB7o2/vhQdOD2CKZsQizuRYjzrYnGeLzM2Y6bReq DshPav6wDQAkj+Oa+Adwg4tqX41pL2vaOjRSRDKw8s6QGIgz/twLnmEyKA1hNbdz9U278t/U XMjgS8v8yYwrCG4y6Z81WWw4VdmdPnxNcGLMuQivINIjGprgqzfoxuV5CLoThwiuCy71QBls XKvn4bTopOwkKUWlvwjQrm2gHm3jprwWTl00WkjXzqptG8bC4mCuJa7LgpMCfx2g4FhpVRwa hL12WWu958FhXbhhnw4NDOSlVDile0m3w/iuQe5kYvErf2UIUh6bD3wXklV6vpREnBmcYa+a hVfYHhDc9tABanhyuzhBg3/DTENU5DbCtvQSA5y4aoOnZt7ShEJ+Zx/r1Xop46zuNLd3Bz3Z WODk1ZrsA7ciYoV9MKOA4ge7r7NoWfe2OBDIqtSW6XXJ3vbEi91aIfpo9Fv92XRA==
  • Ironport-sdr: 9jIiICgrOBnigWMMlTpt9IplAMl7Sm7q+EGeXutXRt0kv3t74FZUfCJ38CQywAjet/c8lJRAY8 7gYuhgqrpRIfFyVtVbIHC7Av7OoflPv2sQm9TxrfqLU5gQhM8MAkppSLMZLG6XBJPeDD/kQSL3 vrVbkvRFVwxENm/6G/u+oGbyZTridSx8rub8uLnPCiFyKktEX4YBBpOWtqeRz8iqXMLrNcKuQ/ wgBBZlEI3ZRwwNpDDcNI/lF1ifyLWylJaQbPI8vtwqNDEqLpAX4dk2UJQZP+1MgXKHYxYzvxLj iRM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14/06/2021 14:31, Jan Beulich wrote:
> On 14.06.2021 12:47, Andrew Cooper wrote:
>> +.PHONY: distclean
>> +distclean: clean
>> +    $(RM) -f -- *~
>> +
>> +.PHONY: install
>> +install: all
>> +
>> +.PHONY: uninstall
>> +uninstall:
>> +
>> +CFLAGS += -Werror -std=gnu11
> Is this strictly necessary?

Appears not.  Dropped.

>
>> +            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 char xbegin_label[] asm(".Lxbegin");
> Perhaps add const? I'm also not sure about .L names used for extern-s.

Well - they work perfectly fine even with the Clang integrated assembler.

>
>> +    if ( info->si_addr == xbegin_label ||
>> +         memcmp(info->si_addr, "\xc7\xf8\x00\x00\x00\x00", 6) == 0 )
> Why the || here? I could see you use && if you really wanted to be on
> the safe side, but the way you have it I don't understand the
> intentions.

That should have been &&, but I also appear to have lost a noclone
attribute too.

>
>> +    {
>> +        ucontext_t *context = extra;
>> +
>> +        /*
>> +         * Found the XBEGIN instruction.  Step over it, and update `status` 
>> to
>> +         * signal #UD.
>> +         */
>> +#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
> At the very least for this, don't you need to constrain the test to
> just Linux?

I guess it was too much to hope that this would be compatible across the
BSDs too.

And the FreeBSD CI did notice it, but apparently didn't email me...

I'll try to make it BSD compatible.

>
>> +static void test_tsx(void)
>> +{
>> +    int rc;
>> +
>> +    /* Read all policies except raw. */
>> +    for ( int i = XEN_SYSCTL_cpu_policy_host;
> To avoid having this as bad precedent, even though it's "just" testing
> code: unsigned int? (I've first spotted this here, but later I've
> found more places elsewhere.)

Well - I question if it even is "bad" precedent.

For array bounds which are constants, the compiler can (and does) do
better than anything we can write in C here, as it is arch-dependent
whether signed or unsigned is better to use.

Beyond that, it's just code volume.

~Andrew




 


Rackspace

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