From: Andrew Cooper <andrew.cooper3@citrix.com>
To: John Haxby <john.haxby@oracle.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH 1/2] xen-detect: fix strict-aliasing compilation warning.
Date: Wed, 3 Dec 2014 15:44:48 +0000 [thread overview]
Message-ID: <547F2FF0.9000201@citrix.com> (raw)
In-Reply-To: <309AAB3D-A4EE-485C-BE09-AAC4192E7F27@oracle.com>
[-- Attachment #1.1: Type: text/plain, Size: 1680 bytes --]
On 01/12/14 18:45, John Haxby wrote:
>
>> On 1 Dec 2014, at 17:15, Andrew Cooper <andrew.cooper3@citrix.com
>> <mailto:andrew.cooper3@citrix.com>> wrote:
>>
>> On 01/12/14 14:37, John Haxby wrote:
>>> With gcc 4.8.3, compiling xen-detect gives a compilation warning if
>>> you're optimising:
>>>
>>> $ cc -Wall -Os xen-detect.c
>>> xen-detect.c: In function ‘check_for_xen’:
>>> xen-detect.c:65:9: warning: dereferencing type-punned pointer will break
>>> strict-aliasing rules [-Wstrict-aliasing]
>>> *(uint32_t *)(signature + 0) = regs[1];
>>> ^
>>>
>>> Signed-off-by: John Haxby <john.haxby@oracle.com
>>> <mailto:john.haxby@oracle.com>>
>>
>> Why are you compiling without the CFLAGS from the Xen build system?
>>
>> We explicitly disable strict alias optimisations, because optimisations
>> based upon the aliasing rules in C is mad. Even when you eliminate all
>> the warnings, there are still subtle bugs because the compiler is free
>> to assume a lot more than a programmer would typically deem reasonable.
>
>
> I wasn’t building the whole system, I just wanted xen-detect so I
> pulled it out and compiled it; I usually use "-Wall -Os” because the
> combination finds problems I might otherwise overlook. The patch
> also removes three lines of code :) but you can take it or leave it as
> you choose. The other patch — reversing the code of pv and hvm
> checking — was the real problem.
>
> jch
I feel it would be neater to fix this by using the
XEN_CPUID_SIGNATURE_E{B,C,D}X constants from the API. This fixes the
strict aliasing, and does away with the string handling completely.
~Andrew
[-- Attachment #1.2: Type: text/html, Size: 9560 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-12-03 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-01 14:37 Two miscellenous xen-detect patches John Haxby
2014-12-01 14:37 ` [PATCH 1/2] xen-detect: fix strict-aliasing compilation warning John Haxby
2014-12-01 17:15 ` Andrew Cooper
2014-12-01 18:45 ` John Haxby
2014-12-03 15:44 ` Andrew Cooper [this message]
2014-12-03 15:39 ` John Haxby
2014-12-03 15:51 ` Andrew Cooper
2014-12-01 14:37 ` [PATCH 2/2] xen-detect: check for XEN_PV before XEN_HVM John Haxby
2014-12-03 16:00 ` Andrew Cooper
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=547F2FF0.9000201@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=john.haxby@oracle.com \
--cc=xen-devel@lists.xen.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.