diff mbox

xen: Fix build with older versions of GCC following e34bc403c3

Message ID 1483639302-3084-1-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper Jan. 5, 2017, 6:01 p.m. UTC
GCCs of at least 4.4 and earlier do not tollerate the initialisiation of the
$VENDOR_cpu_dev structures, because of c_ident becoming an anonymous union.

Instead of using an anonymous union, reintepret c_ident[] in its CPUID form
just in get_cpu_vendor().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>

RFC, as I don't have easy access to a compiler which causes this to fail in
the first place.
---
 xen/arch/x86/cpu/common.c | 7 +++++--
 xen/arch/x86/cpu/cpu.h    | 8 +-------
 2 files changed, 6 insertions(+), 9 deletions(-)

Comments

Boris Ostrovsky Jan. 5, 2017, 7:41 p.m. UTC | #1
On 01/05/2017 01:01 PM, Andrew Cooper wrote:
> GCCs of at least 4.4 and earlier do not tollerate the initialisiation of the
> $VENDOR_cpu_dev structures, because of c_ident becoming an anonymous union.
>
> Instead of using an anonymous union, reintepret c_ident[] in its CPUID form
> just in get_cpu_vendor().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>
> RFC, as I don't have easy access to a compiler which causes this to fail in
> the first place.

Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

with gcc 4.4.4
Jan Beulich Jan. 6, 2017, 1:46 p.m. UTC | #2
>>> On 05.01.17 at 19:01, <andrew.cooper3@citrix.com> wrote:
> GCCs of at least 4.4 and earlier do not tollerate the initialisiation of the
> $VENDOR_cpu_dev structures, because of c_ident becoming an anonymous union.
> 
> Instead of using an anonymous union, reintepret c_ident[] in its CPUID form
> just in get_cpu_vendor().
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox

Patch

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index d17a2ee..7d6d024 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -163,8 +163,11 @@  int get_cpu_vendor(uint32_t b, uint32_t c, uint32_t d, enum get_cpu_vendor mode)
 
 	for (i = 0; i < X86_VENDOR_NUM; i++) {
 		if (cpu_devs[i]) {
-			if (cpu_devs[i]->b == b && cpu_devs[i]->c == c &&
-			    cpu_devs[i]->d == d) {
+			struct {
+				uint32_t b, d, c;
+			} *ptr = (void *)cpu_devs[i]->c_ident;
+
+			if (ptr->b == b && ptr->c == c && ptr->d == d) {
 				if (mode == gcv_host)
 					this_cpu = cpu_devs[i];
 				return i;
diff --git a/xen/arch/x86/cpu/cpu.h b/xen/arch/x86/cpu/cpu.h
index 5a7905c..3eeebe3 100644
--- a/xen/arch/x86/cpu/cpu.h
+++ b/xen/arch/x86/cpu/cpu.h
@@ -1,13 +1,7 @@ 
 /* attempt to consolidate cpu attributes */
 struct cpu_dev {
 	char	c_vendor[8];
-
-	union {
-		char	c_ident[13];
-		struct {
-			uint32_t b, d, c;
-		};
-	};
+	char	c_ident[13];
 
 	void		(*c_early_init)(struct cpuinfo_x86 *c);
 	void		(*c_init)(struct cpuinfo_x86 * c);