Skip to contentSkip to conversation

xen: Silence compiler warnings

PATCH Superseded Daniel Kiper 2 participants 13 messages Jul 11, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover xen: Silence compiler warnings

Hi,

Here are two patches that follow earlier Xen dom0 EFI series and fix some compiler warnings found during detailed build tests.

Both patches should be applied to:

git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git next

Daniel

PS I will be on vacation from 14th Jul till 25th Jul.

 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 include/xen/xen-ops.h    |    2 +-
 2 files changed, 23 insertions(+), 14 deletions(-)

Daniel Kiper (2):
xen: Silence compiler warnings
arch/x86/xen: Silence compiler warnings

#1 lore raw

PATCH 1/2 xen: Silence compiler warnings

Add inline keyword to silence the following compiler warnings if xen_efi_probe() is not used:

CC arch/x86/xen/setup.o
In file included from arch/x86/xen/xen-ops.h:7:0,

                 from arch/x86/xen/setup.c:31:

include/xen/xen-ops.h:43:35: warning: ‘xen_efi_probe’ defined but not used [-Wunused-function]

---
 include/xen/xen-ops.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/xen/xen-ops.h +1 -1
index 771bbba..7491ee5 100644
@@ -40,7 +40,7 @@ bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 #ifdef CONFIG_XEN_EFI
 extern efi_system_table_t *xen_efi_probe(void);
 #else
-static efi_system_table_t __init *xen_efi_probe(void)
+static inline efi_system_table_t __init *xen_efi_probe(void)
 {
 	return NULL;
 }
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

PATCH 1/2 xen: Silence compiler warnings

In reply to Daniel Kiper

Add inline keyword to silence the following compiler warnings if xen_efi_probe() is not used:

CC arch/x86/xen/setup.o
In file included from arch/x86/xen/xen-ops.h:7:0,

                 from arch/x86/xen/setup.c:31:

include/xen/xen-ops.h:43:35: warning: ‘xen_efi_probe’ defined but not used [-Wunused-function]

---
 include/xen/xen-ops.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/xen/xen-ops.h +1 -1
index 771bbba..7491ee5 100644
@@ -40,7 +40,7 @@ bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 #ifdef CONFIG_XEN_EFI
 extern efi_system_table_t *xen_efi_probe(void);
 #else
-static efi_system_table_t __init *xen_efi_probe(void)
+static inline efi_system_table_t __init *xen_efi_probe(void)
 {
 	return NULL;
 }
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/2 arch/x86/xen: Silence compiler warnings

In reply to Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +22 -13
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
 
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();
 
 	/* Start the world */
 #ifdef CONFIG_X86_32
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw

PATCH 2/2 arch/x86/xen: Silence compiler warnings

In reply to Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +22 -13
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
 
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_setup_runstate_info(0);
 
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();
 
 	/* Start the world */
 #ifdef CONFIG_X86_32
Signature · 1 line
1.7.10.4
#5 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

Quoted 68 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
  arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
  1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -4
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
  #endif
  }
 
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
  /* First C function to be called on Xen boot */
  asmlinkage __visible void __init xen_start_kernel(void)
  {
  	struct physdev_set_iopl set_iopl;
  	int rc;
-	efi_system_table_t *efi_systab_xen;
 
  	if (!xen_start_info)
  		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
  	xen_setup_runstate_info(0);
 
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 10 lines
arch/x86/xen/enlighten.c +1 -9
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

-boris

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1743

Quoted 3 lines
arch/x86/xen/enlighten.c +0 -0
  	/* Start the world */
  #ifdef CONFIG_X86_32

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

In reply to Daniel Kiper
Quoted 68 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
  arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
  1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -4
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
  #endif
  }
 
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
  /* First C function to be called on Xen boot */
  asmlinkage __visible void __init xen_start_kernel(void)
  {
  	struct physdev_set_iopl set_iopl;
  	int rc;
-	efi_system_table_t *efi_systab_xen;
 
  	if (!xen_start_info)
  		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
  	xen_setup_runstate_info(0);
 
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 10 lines
arch/x86/xen/enlighten.c +1 -9
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

-boris

Quoted 3 lines
arch/x86/xen/enlighten.c +0 -0
  	/* Start the world */
  #ifdef CONFIG_X86_32
#7 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

Quoted 70 lines · Boris Ostrovsky
Quoted 69 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -9
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
Quoted 8 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 5 lines
arch/x86/xen/enlighten.c +1 -4
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

In reply to Boris Ostrovsky
Quoted 70 lines · Boris Ostrovsky
Quoted 69 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -9
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
Quoted 8 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 5 lines
arch/x86/xen/enlighten.c +1 -4
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

Daniel

#9 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

Quoted 78 lines · Daniel Kiper
Quoted 69 lines · Boris Ostrovsky
Quoted 68 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
  arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
  1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -8
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
  #endif
  }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
  /* First C function to be called on Xen boot */
  asmlinkage __visible void __init xen_start_kernel(void)
  {
  	struct physdev_set_iopl set_iopl;
  	int rc;
-	efi_system_table_t *efi_systab_xen;
  	if (!xen_start_info)
  		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
  	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
Quoted 8 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 6 lines
arch/x86/xen/enlighten.c +1 -5
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Quoted 3 lines

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

I am not arguing against having a separate routine. All I am saying is that calling xen_efi_init() when CONFIG_XEN_EFI is not defined doesn't look logical. It will also add an unnecessary call (although compiler may optimize it out).

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

In reply to Daniel Kiper
Quoted 78 lines · Daniel Kiper
Quoted 69 lines · Boris Ostrovsky
Quoted 68 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
  arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
  1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -8
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
  #endif
  }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
  /* First C function to be called on Xen boot */
  asmlinkage __visible void __init xen_start_kernel(void)
  {
  	struct physdev_set_iopl set_iopl;
  	int rc;
-	efi_system_table_t *efi_systab_xen;
  	if (!xen_start_info)
  		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
  	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
Quoted 8 lines

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1740

Quoted 6 lines
arch/x86/xen/enlighten.c +1 -5
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Quoted 3 lines

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

I am not arguing against having a separate routine. All I am saying is that calling xen_efi_init() when CONFIG_XEN_EFI is not defined doesn't look logical. It will also add an unnecessary call (although compiler may optimize it out).

-boris

#11 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

Quoted 79 lines · Boris Ostrovsky
Quoted 78 lines · Daniel Kiper
Quoted 77 lines · Boris Ostrovsky
Quoted 64 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -4
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1738

Quoted 10 lines
arch/x86/xen/enlighten.c +1 -9
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Quoted 7 lines
Quoted 3 lines

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

I am not arguing against having a separate routine. All I am saying is that calling xen_efi_init() when CONFIG_XEN_EFI is not defined doesn't look logical. It will also add an unnecessary call (although

Ahh... I misunderstood you. However, your proposal, as below:

#ifdef CONFIG_XEN_EFI
xen_efi_init();
#endif

does not solve the problem because this vulnerable shift will be still visible for compiler during x86 32-bit kernel build.

Quoted 1 line

compiler may optimize it out).

Please loot at arch/x86/xen/enlighten.c:xen_check_mwait() and arch/x86/xen/enlighten.c:xen_boot_params_init_edd() (probably there are more stuff like that around). As I can see this is fairly common solution and probably compiler cope with it quite well.

Have a nice weekend,

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#12 lore raw

Re: [PATCH 2/2] arch/x86/xen: Silence compiler warnings

In reply to Boris Ostrovsky
Quoted 79 lines · Boris Ostrovsky
Quoted 78 lines · Daniel Kiper
Quoted 77 lines · Boris Ostrovsky
Quoted 64 lines · Daniel Kiper

Compiler complains in the following way when x86 32-bit kernel with Xen support is build:

CC arch/x86/xen/enlighten.o
arch/x86/xen/enlighten.c: In function ‘xen_start_kernel’:
arch/x86/xen/enlighten.c:1726:3: warning: right shift count >= width of type [enabled by default]

Such line contains following EFI initialization code:

boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

There is no issue if x86 64-bit kernel is build. However, 32-bit case generate warning (even if that code will not be executed because Xen does not work on 32-bit EFI platforms) due to __pa() returning unsigned long type which has 32-bits width. So move whole EFI initialization stuff to separate function and build its body conditionally to avoid above mentioned warning on x86 32-bit architecture.

---
 arch/x86/xen/enlighten.c |   35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/xen/enlighten.c +21 -4
index bc89647..6abec74 100644
@@ -1516,12 +1516,32 @@ static void __init xen_pvh_early_guest_init(void)
 #endif
 }
+static void __init xen_efi_init(void)
+{
+#ifdef CONFIG_XEN_EFI
+	efi_system_table_t *efi_systab_xen;
+
+	efi_systab_xen = xen_efi_probe();
+
+	if (efi_systab_xen == NULL)
+		return;
+
+	strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
+			sizeof(boot_params.efi_info.efi_loader_signature));
+	boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
+	boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
+
+	set_bit(EFI_BOOT, &efi.flags);
+	set_bit(EFI_PARAVIRT, &efi.flags);
+	set_bit(EFI_64BIT, &efi.flags);
+#endif
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
 	struct physdev_set_iopl set_iopl;
 	int rc;
-	efi_system_table_t *efi_systab_xen;
 	if (!xen_start_info)
 		return;
@@ -1717,18 +1737,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	xen_setup_runstate_info(0);
-	efi_systab_xen = xen_efi_probe();
-
-	if (efi_systab_xen) {

arch/x86/xen/enlighten.c asmlinkage __visible void __init xen_start_kernel(void) · line 1738

Quoted 10 lines
arch/x86/xen/enlighten.c +1 -9
-		strncpy((char *)&boot_params.efi_info.efi_loader_signature, "Xen",
-				sizeof(boot_params.efi_info.efi_loader_signature));
-		boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
-		boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);
-
-		set_bit(EFI_BOOT, &efi.flags);
-		set_bit(EFI_PARAVIRT, &efi.flags);
-		set_bit(EFI_64BIT, &efi.flags);
-	}
+	xen_efi_init();

I'd put ifdef CONFIG_XEN_EFI around the call instead of having it inside the routine.

Quoted 7 lines
Quoted 3 lines

Well, I thought about that a bit and I prefer function like Konrad. Could you agree with him which solution do you (as maintainers) prefer?

I am not arguing against having a separate routine. All I am saying is that calling xen_efi_init() when CONFIG_XEN_EFI is not defined doesn't look logical. It will also add an unnecessary call (although

Ahh... I misunderstood you. However, your proposal, as below:

#ifdef CONFIG_XEN_EFI
xen_efi_init();
#endif

does not solve the problem because this vulnerable shift will be still visible for compiler during x86 32-bit kernel build.

Quoted 1 line

compiler may optimize it out).

Please loot at arch/x86/xen/enlighten.c:xen_check_mwait() and arch/x86/xen/enlighten.c:xen_boot_params_init_edd() (probably there are more stuff like that around). As I can see this is fairly common solution and probably compiler cope with it quite well.

Have a nice weekend,

Daniel