From: Ian Jackson Subject: Re: [PATCH 4/4] xen/public: arm: rework the macro set_xen_guest_handle_raw Date: Wed, 4 Nov 2015 15:46:07 +0000 Message-ID: <22074.10303.754270.899307@mariner.uk.xensource.com> References: <1446228813-2593-1-git-send-email-julien.grall@citrix.com> <1446228813-2593-5-git-send-email-julien.grall@citrix.com> <1446554124.10390.19.camel@citrix.com> <5638BE43.4080607@citrix.com> <1446561267.10390.48.camel@citrix.com> <5639E949.6020800@citrix.com> <1446636465.6461.70.camel@citrix.com> <5639EEB6.6040908@citrix.com> <1446650774.6461.112.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zu0GL-0005pD-TB for xen-devel@lists.xenproject.org; Wed, 04 Nov 2015 15:46:13 +0000 In-Reply-To: <1446650774.6461.112.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Keir Fraser , Stefano Stabellini , Tim Deegan , Julien Grall , Jan Beulich , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [Xen-devel] [PATCH 4/4] xen/public: arm: rework the macro set_xen_guest_handle_raw"): > The writer via one is the guest and reader via the other is the hypervisor, > so no matter what they are certainly different compilation units, even in > the face of whole program optimisations. The question of them being different `compilation units' (YM translation units) is irrelevant I think. > The concerning issue is that if the compiler can observe you writing to > both halves of the union then it can either omit the first write or dive > off into deep undefined behaviour territory. If the compiler can see you write to p, it is allowed to assume that all subsequent readers will read the object as typeof(p). Reading typeof(p) does not read the padding. Therefore the compiler is allowed to `prove' that the padding is a dead store, and remove the write to the padding. This applies even if the compiler can't see the code which is doing the reading. Ian.