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

Re: [PATCH 2/2] hvmloader: do not include system headers for type declarations


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 24 Feb 2021 13:01:19 +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=UxFW7RVYTR75gQJZBY19+9Q+oJH44WliVf6AYexgJuY=; b=FjIjMrG16U9o1kYOpuRPIw5Mg45Z8Ulk0CV3HB7pIcl+/aECHxiyUzjl9+qC81+K4gsrxVkE9wng+3dCypUoFUGKDNCJPUR1gZ4lFUjBMWiQMO9wD5qL+YY/i+apJkNwW1W3LxDy92J83/U6UB2nrVeIokmilt4+8mLwbldd9SSE5ZxYU1b30kQTsX7GVud87LHZQVfYO6XGaLnLPij46FXnAjZq8g4PMF2gPlm+nfan8Jfh+f/AVbslAjDqUFuoQFIWLsr+Y3XvoqzfZDMOn/Pj3ZT4nvXq9jBqu3R0t/D/R+FWOuLZ1DGGCH1lxN1NPpvlg1xvTvUkSYL7OvG5ww==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOdE1Y/pf5SNar6yxJrcUMz+zaZ5P3B7K9RreAUM+SwOC7AV6tf1rk9aNw/8dlas2RovRK8gxK7KtMQZ5mXhhabrtQnIF/6FAKdJcja0PtdQwpUtN7HDTTpt6UtPahPY1lugAy7IIt00A4lMVnyjY2ihaewfODfhdC/9yxcmDXD9l9vJp42mJ6ezc/JwyVAoPdU5dYBnLbCAGDQiQ4pgVrmNTVz/w554dpP/+B+VaFEfbnTgItw1sayI4sctJNdjSqauSCg+NYTpBna8cLi0fMMwIOJNt2SbakOKEUsowPVrvl88SbT0slKoMxi6J3ibsANsS5v2H+9XDLt1SxU+ow==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "Ian Jackson" <iwj@xxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 24 Feb 2021 12:01:46 +0000
  • Ironport-sdr: a7x+pRvs27SmkhG9MWSjkknWzCQT8Op4wLpv73zxRHLCiL+O6Kdb/OgziL9yKRYLcDhmLvVCoW ToXklTvCvww/jPSUo3k5vKrv2t725Zy4c/Kc5toDt4ICI+POzEpZWtMzSej7S/6zEUa8D8Vy1U kP5BwCdYJFZAWw0ocRR9l131UMrljjJSKJADZqVBydj+p2s0FpWxLnsHaRuH1C9ZnUxClVI4ac aalKNCo/Wu/YJOn2qdD7w0kPxUocpOun6dT/ZG0eS7roO3e8kANmPaB5CP+kQ7yz8QzyFqidxY ujE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Feb 24, 2021 at 11:51:39AM +0100, Jan Beulich wrote:
> On 24.02.2021 11:26, Roger Pau Monne wrote:
> > --- /dev/null
> > +++ b/tools/firmware/hvmloader/types.h
> > @@ -0,0 +1,47 @@
> > +#ifndef _HVMLOADER_TYPES_H_
> > +#define _HVMLOADER_TYPES_H_
> > +
> > +typedef unsigned char uint8_t;
> > +typedef signed char int8_t;
> > +
> > +typedef unsigned short uint16_t;
> > +typedef signed short int16_t;
> > +
> > +typedef unsigned int uint32_t;
> > +typedef signed int int32_t;
> > +
> > +typedef unsigned long long uint64_t;
> > +typedef signed long long int64_t;
> 
> I wonder if we weren't better of not making assumptions on
> short / int / long long, and instead use
> __attribute__((__mode__(...))) or, if available, the compiler
> provided __{,U}INT*_TYPE__.

Oh, didn't know about all this fancy stuff.

Clang doens't seem to support the same mode attributes, for example
QImode is unknown, and that's just on one version of clang that I
happened to test on.

Using __{,U}INT*_TYPE__ does seem to be supported on the clang version
I've tested with, so that might be an option if it's supported
everywhere we care about. If we still need to keep the current typedef
chunk for fallback purposes then I see no real usefulness of using
__{,U}INT*_TYPE__.

> > +#define INT8_MIN        (-0x7f-1)
> > +#define INT16_MIN       (-0x7fff-1)
> > +#define INT32_MIN       (-0x7fffffff-1)
> > +#define INT64_MIN       (-0x7fffffffffffffffll-1)
> > +
> > +#define INT8_MAX        0x7f
> > +#define INT16_MAX       0x7fff
> > +#define INT32_MAX       0x7fffffff
> > +#define INT64_MAX       0x7fffffffffffffffll
> > +
> > +#define UINT8_MAX       0xff
> > +#define UINT16_MAX      0xffff
> > +#define UINT32_MAX      0xffffffffu
> > +#define UINT64_MAX      0xffffffffffffffffull
> 
> At least if going the above outlined route, I think we'd then
> also be better off not #define-ing any of these which we don't
> really use. Afaics it's really only UINTPTR_MAX which needs
> providing.

I've assumed that for consistency we would like to provide those
already. I can switch them to using __{U}INT*_{MAX,MIN}__ if we agree
that it's supported on all compilers we care about, but I would rather
not drop them. I think those might be useful in the future, and having
them already does no harm.

> > +typedef uint32_t size_t;
> 
> Like the hypervisor, we should prefer using __SIZE_TYPE__
> when available.
> 
> > +typedef uint32_t uintptr_t;
> 
> Again - use __UINTPTR_TYPE__ or, like Xen,
> __attribute__((__mode__(__pointer__))).

Let me run a gitlab test suite using the __{,U}INT*_TYPE__ stuff and
if that's fine everywhere we test then I think we can go for that if
you prefer over the current proposal?

I still think that coding them like I've done above should be fine as
we don't expect hvmloader to ever be built in a mode different than
i386?

Thanks, Roger.



 


Rackspace

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