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@xxxxxxxxxx>
Why are you compiling without the CFLAGS from the Xen build system?We explicitly disable strict alias optimisations, because optimisationsbased upon the aliasing rules in C is mad. Even when you eliminate allthe warnings, there are still subtle bugs because the compiler is freeto 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 |