All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "stefanos@xilinx.com" <stefanos@xilinx.com>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	George Dunlap <George.Dunlap@citrix.com>,
	"julien.grall@arm.com" <julien.grall@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS
Date: Fri, 8 Mar 2019 15:31:49 +0000	[thread overview]
Message-ID: <23682.35557.153834.423011@mariner.uk.xensource.com> (raw)
In-Reply-To: <5C8224A70200007800150142@prv1-mh.provo.novell.com>

Jan Beulich writes ("Re: [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS"):
> >No.  This is not fine.  Signed integer subtraction sometimes has UB.
...
> I've spent an hour trying to find the relevant parts of the spec, but I'm
> afraid I've once again failed at finding all necessary pieces.

The spec is obtuse indeed.

> This does not make any provisions for unsigned types being special.

6.2.5 9
   .... A computation involving unsigned operands can never overfow,
   because a result that cannot be represented by the resulting
   unsigned integer type is reduced modulo the number that is one
   greater than the largest value that can be represented by the
   resulting type.

> As to the unsigned -> signed conversion, according to, again in the
> Conversions section,
> 
> "Otherwise, the new type is signed and the value cannot be represented
>  in it; either the result is implementation-defined or an implementation-
>  defined signal is raised."
> 
> this is implementation defined according to my understanding (but I take
> it that we're fine with this).

Yes.  On the platforms currently supported by Xen, the
`implementation' `defines' that the result is simply the same bit
pattern.  I say `implementation' in quotes because really we mean
compiler, and `defines' because while no doubt there is a formal
conformance statement somewhere, what we are relying on is instead
something much more general:

The community of C programmers for `normal' architectures effectively
require that conversion to signed integer work this way.  A platform
where that didn't work would be strange and would produce a lot of
other porting difficulties too.  And because the result is *defined*,
the compiler authors can't use this as an optimisation opportunity so
aren't motivated to sophistic justifications for misbehaviour.

> >Conversely, I think the discussion of the sizes of these types is not
> >really relevant.  To port Xen it is necessary to have an environment
> >where
> >sizeof(ptrdiff_t) == sizeof(uintptr_t)
> >== sizeof(void*) == sizeof(struct maxalign*)
> >and I think there is little harm in further baking in those
> >assumptions.
> 
> Good (except that I don't understand the struct maxalign* part - neither
> why you use a pointer there, nor - assuming there was no pointer - how
> that would be in line with __{,u}int128_t or with vector types).

On some machines, pointers to different types have different
representations and even different sizes.  Xen cannot be ported to
such machines - at least, not without an awful lot of work.

Xen assumes that all pointers have the same representation.

`struct maxalign*' was a somewhat-informal way of referring to the
type of a pointer to an object type with the maximal alignment.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-03-08 15:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 22:38 [PATCH v11 0/9] misc safety certification fixes Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 1/9] xen: use __UINTPTR_TYPE__ for uintptr_t Stefano Stabellini
2019-03-06  7:47   ` Jan Beulich
2019-03-06 21:16     ` Stefano Stabellini
2019-03-07  8:29       ` Jan Beulich
2019-03-07 15:43         ` Ian Jackson
2019-03-08  7:23           ` Jan Beulich
2019-03-08 14:18   ` Andrew Cooper
2019-03-08 15:19     ` Ian Jackson
2019-03-05 22:38 ` [PATCH v11 2/9] xen: introduce ptrdiff_t Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS Stefano Stabellini
2019-03-06 15:24   ` Jan Beulich
2019-03-06 20:55     ` Stefano Stabellini
2019-03-07  8:39       ` Jan Beulich
2019-03-07 14:16         ` Ian Jackson
2019-03-08  8:15           ` Jan Beulich
2019-03-08 15:31             ` Ian Jackson [this message]
2019-03-05 22:38 ` [PATCH v11 4/9] xen/arm: use DECLARE_BOUNDS as required Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 5/9] xen/x86: " Stefano Stabellini
2019-03-06 15:33   ` Jan Beulich
2019-03-06 21:05     ` Stefano Stabellini
2019-03-07  8:40       ` Jan Beulich
2019-03-07 14:02       ` Ian Jackson
2019-03-07 14:42         ` George Dunlap
2019-03-08  8:46         ` Jan Beulich
2019-03-08  8:55           ` Juergen Gross
2019-03-08 15:33           ` Ian Jackson
2019-03-06 15:48   ` Jan Beulich
2019-03-06 21:38     ` Stefano Stabellini
2019-03-07  8:50       ` Jan Beulich
2019-03-07 14:43         ` Ian Jackson
2019-03-08  8:22           ` Jan Beulich
2019-03-08 15:36             ` Ian Jackson
2019-03-08 15:57               ` Jan Beulich
2019-03-07 14:00       ` Ian Jackson
2019-03-08 15:43   ` Ian Jackson
2019-03-08 15:49     ` Jan Beulich
2019-03-05 22:38 ` [PATCH v11 6/9] xen/common: " Stefano Stabellini
2019-03-06 15:37   ` Jan Beulich
2019-03-06 21:08     ` Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 7/9] xen: " Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 8/9] xen: use DECLARE_BOUNDS in alternative.c Stefano Stabellini
2019-03-06 16:35   ` Jan Beulich
2019-03-06 21:38     ` Stefano Stabellini
2019-03-05 22:38 ` [PATCH v11 9/9] xen: explicit casts when DECLARE_BOUNDS cannot be used Stefano Stabellini
2019-03-07 11:40   ` Jan Beulich
2019-03-07 15:25     ` [PATCH v11 9/9] xen: explicit casts when DECLARE_BOUNDS cannot be used [and 1 more messages] Ian Jackson
2019-03-07 22:55       ` Stefano Stabellini
2019-03-08 15:39         ` [PATCH v11 9/9] xen: explicit casts when DECLARE_BOUNDS cannot be used [and 1 more messages] " Ian Jackson
2019-03-08  8:28       ` [PATCH v11 9/9] xen: explicit casts when DECLARE_BOUNDS cannot be used " Jan Beulich
2019-03-08 15:26 ` SRSL People... [PATCH v11 0/9] misc safety certification fixes Andrew Cooper
2019-03-08 15:44   ` Ian Jackson
2019-03-08 15:46   ` Jan Beulich
2019-03-08 20:14     ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23682.35557.153834.423011@mariner.uk.xensource.com \
    --to=ian.jackson@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.