xen/arm: fix build errors with -Og
cover xen/arm: fix build errors with -Og
This is a collection of fixes needed to build the hypervisor with -Og for arm64.
I build-tested this with the following command:
make -j $(nproc) \
EXTRA_CFLAGS_XEN_CORE="-Og" \
XEN_TARGET_ARCH=arm64 \
CROSS_COMPILE=aarch64-none-linux-gnu- \
dist-xenStewart Hildebrand (3):
xen/arm: mark __guest_cmpxchg always_inline
xen/efi: fix unitialized use warning
xen/arm: fix unitialized use warning
xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/include/asm/guest_atomics.h | 10 +++++----- xen/common/efi/boot.c | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
2.40.0
PATCH 1/3 xen/arm: mark __guest_cmpxchg always_inline
When building the hypervisor with -Og, we run into a __bad_cmpxchg link error:
aarch64-none-linux-gnu-ld: prelink.o: in function `__int_cmpxchg':.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld: .../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld: ./.xen-syms.0: hidden symbol `__bad_cmpxchg' isn't defined
aarch64-none-linux-gnu-ld: final link failed: bad value
This is due to the function __guest_cmpxchg not being inlined in the -Og build with gcc 12. Fix this by marking __guest_cmpxchg always_inline.
---
I considered also changing "guest_cmpxchg64" just below in the same file to always_inline, but I decided not to because this function does not take a size parameter.
--- xen/arch/arm/include/asm/guest_atomics.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/include/asm/guest_atomics.h +5 -5
@@ -86,11 +86,11 @@ static inline void guest_clear_mask16(struct domain *d, uint16_t mask,domain_unpause (d); } -static inline unsigned long __guest_cmpxchg (struct domain *d, -volatile void *ptr, -unsigned long old, -unsigned long new, -unsigned int size) +static always_inline unsigned long __guest_cmpxchg (struct domain *d, +volatile void *ptr, +unsigned long old, +unsigned long new, +unsigned int size) {unsigned long oldval = old;
Signature · 1 line
2.40.0
RE: [PATCH 1/3] xen/arm: mark __guest_cmpxchg always_inline
Hi Stewart,
Quoted 16 lines
-----Original Message-----
Subject: [PATCH 1/3] xen/arm: mark__guest_cmpxchgalways_inlineWhen building the hypervisor with -Og, we run into a
__bad_cmpxchglink error:aarch64-none-linux-gnu-ld: prelink.o: in function `__int_cmpxchg':
.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-
ld:.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld: ./.xen-syms.0: hidden symbol `__bad_cmpxchg' isn't defined
aarch64-none-linux-gnu-ld: final link failed: bad value
Quoted 4 lines
This is due to the function
__guest_cmpxchgnot being inlined in the -Og build with gcc 12. Fix this by marking__guest_cmpxchgalways_inline.Signed-off-by Stewart Hildebrand <[email protected]
Hmmm I think you missed the ">" in the end of your signoff...But anyway the patch looks good to me so:
Kind regards,
Henry
Re: [PATCH 1/3] xen/arm: mark __guest_cmpxchg always_inline
In reply to Stewart HildebrandHi Stewart,
Quoted 8 lines · Stewart Hildebrand
When building the hypervisor with -Og, we run into a
__bad_cmpxchglink error:aarch64-none-linux-gnu-ld: prelink.o: in function `__int_cmpxchg':
.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld:.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld: ./.xen-syms.0: hidden symbol `__bad_cmpxchg' isn't defined
aarch64-none-linux-gnu-ld: final link failed: bad value
Quoted 8 lines
This is due to the function
__guest_cmpxchgnot being inlined in the -Og build with gcc 12. Fix this by marking__guest_cmpxchgalways_inline.Signed-off-by Stewart Hildebrand <[email protected]---
I considered also changing "guest_cmpxchg64" just below in the same file toalways_inline, but I decided not to because this function does not take a size parameter.
Make sense. I will fixed the signed-off-by line issue reported by Henry while committing:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm: mark __guest_cmpxchg always_inline
Quoted 20 lines · Julien Grall
Hi Stewart,
Quoted 8 lines · Stewart Hildebrand
When building the hypervisor with -Og, we run into a
__bad_cmpxchglink error:aarch64-none-linux-gnu-ld: prelink.o: in function `__int_cmpxchg':
.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld:.../xen/./arch/arm/include/asm/arm64/cmpxchg.h:117: undefined reference to `__bad_cmpxchg'
aarch64-none-linux-gnu-ld: ./.xen-syms.0: hidden symbol `__bad_cmpxchg' isn't defined
aarch64-none-linux-gnu-ld: final link failed: bad valueQuoted 8 lines
This is due to the function
__guest_cmpxchgnot being inlined in the -Og build with gcc 12. Fix this by marking__guest_cmpxchgalways_inline.Signed-off-by Stewart Hildebrand <[email protected]---
I considered also changing "guest_cmpxchg64" just below in the same file toalways_inline, but I decided not to because this function does not take a size parameter.
Quoted 4 lines
Make sense. I will fixed the signed-off-by line issue reported by Henry while committing:
Reviewed-by Julien Grall <[email protected]>
Thank you!
PATCH 2/3 xen/efi: fix unitialized use warning
In reply to Stewart HildebrandWhen building the hypervisor for arm64 with -Og, we encounter a (false) uninitialized use warning:
arch/arm/efi/boot.c: In function ‘efi_start’:arch/arm/efi/boot.c:1468:9: error: ‘argc’ may be used uninitialized [-Werror=maybe-uninitialized]
1468 | efi_arch_handle_cmdline(argc ? *argv : NULL, options, name.s);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~arch/arm/efi/boot.c:1263:21: note: ‘argc’ was declared here
1263 | unsigned int i, argc;
| ^~~~
cc1: all warnings being treated as errors
Fix this by initializing argc. As a precaution, also initialize argv.
---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00805.html
--- xen/common/efi/boot.c | 9 +++++++++ 1 file changed, 9 insertions(+)
xen/common/efi/boot.c +9 -0
@@ -1344,6 +1344,15 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)if ( !base_video )efi_console_set_mode (); } +else + { +/* +* Some compilers may emit a false "uninitialized use" warning for argc, +* so initialize argc/argv here to avoid the warning. +*/ + argc =0 ; + argv =NULL ; + }PrintStr (L"Xen " XEN_VERSION_STRING XEN_EXTRAVERSION " (c/s " XEN_CHANGESET ") EFI loader\r\n" );
Signature · 1 line
2.40.0
Re: [PATCH 2/3] xen/efi: fix unitialized use warning
Quoted 5 lines · Stewart Hildebrand
When building the hypervisor for arm64 with -Og, we encounter a (false) uninitialized use warning:
arch/arm/efi/boot.c: In function ‘efi_start’:arch/arm/efi/boot.c:1468:9: error: ‘argc’ may be used uninitialized [-Werror=maybe-uninitialized]
Quoted 8 lines
1468 | efi_arch_handle_cmdline(argc ? *argv : NULL, options, name.s); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm/efi/boot.c:1263:21: note: ‘argc’ was declared here
1263 | unsigned int i, argc;
| ^~~~
cc1: all warnings being treated as errorsFix this by initializing argc. As a precaution, also initialize argv.
I'm not happy about this kind of change, and I also wonder whether we wouldn't better use initializers for both variables if we already have to work around compiler shortcomings like this one. Nevertheless I can see the need, so ...
Quoted 1 line
Signed-off-by Stewart Hildebrand <[email protected]>
Jan
PATCH 3/3 xen/arm: fix unitialized use warning
In reply to Stewart HildebrandWhen building the hypervisor with -Og, we encounter the following error:
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized]
2040 | if ( clock_valid )
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here
1947 | bool clock_valid;
| ^~~~~~~~~~~cc1: all warnings being treated as errors
Fix it by initializing the variable.
---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00741.html
--- xen/arch/arm/domain_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
@@ -1944,7 +1944,7 @@ static int __init make_cpus_node(const struct domain *d, void *fdt)/* Placeholder for cpu@ + a 32-bit hexadecimal number + \0 */ char buf[13 ];u32 clock_frequency; -bool clock_valid; +bool clock_valid = false;uint64_t mpidr_aff;dt_dprintk ("Create cpus node\n" );
Signature · 1 line
2.40.0
RE: [PATCH 3/3] xen/arm: fix unitialized use warning
Hi Stewart,
Quoted 11 lines
-----Original Message-----
Subject: [PATCH 3/3] xen/arm: fix unitialized use warningWhen building the hypervisor with -Og, we encounter the following error:
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized]
2040 | if (clock_valid)
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here
Quoted 7 lines
1947 | bool clock_valid; | ^~~~~~~~~~~cc1: all warnings being treated as errors
Fix it by initializing the variable.
Signed-off-by Stewart Hildebrand <[email protected]>
Kind regards,
Henry
Re: [PATCH 3/3] xen/arm: fix unitialized use warning
In reply to Stewart HildebrandHi Stewart,
Quoted 1 line · Stewart Hildebrand
When building the hypervisor with -Og, we encounter the following error:
Is this with GCC 12 as well?
Quoted 24 lines
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized]
2040 | if (clock_valid)
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here1947 | bool clock_valid; | ^~~~~~~~~~~cc1: all warnings being treated as errors
Fix it by initializing the variable.
Signed-off-by Stewart Hildebrand <[email protected]>---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00741.html--- xen/arch/arm/domain_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c static int __init make_cpus_node(const struct domain *d, void *fdt) · line 1947
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1944,7 +1944,7 @@ static int __init make_cpus_node(const struct domain *d, void *fdt)/* Placeholder for cpu@ + a 32-bit hexadecimal number + \0 */ char buf[13 ];u32 clock_frequency; -bool clock_valid; +bool clock_valid = false;
NIT: I would add "Keep the compiler happy with -Og"
I am happy to add it while committing if you agree.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 3/3] xen/arm: fix unitialized use warning
Quoted 1 line · Julien Grall
Hi Stewart,
Hi Julien,
Quoted 4 lines · Stewart Hildebrand
Quoted 1 line
When building the hypervisor with -Og, we encounter the following error:
Is this with GCC 12 as well?
Yes. If my memory serves me correctly this particular one occurs with both GCC 11 and 12.
Quoted 32 lines
Quoted 24 lines
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized] 2040 | if (clock_valid)
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here
1947 | boolclock_valid;
| ^~~~~~~~~~~
cc1: all warnings being treated as errorsFix it by initializing the variable.
Signed-off-by Stewart Hildebrand <[email protected]>---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00741.html
---
xen/arch/arm/domain_build.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c static int __init make_cpus_node(const struct domain *d, void *fdt) · line 1947
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1944,7 +1944,7 @@ static int __init make_cpus_node(const struct domain *d, void *fdt) /* Placeholder for cpu@ + a 32-bit hexadecimal number + \0 */ char buf[13]; u32 clock_frequency; - bool clock_valid; + bool clock_valid = false;NIT: I would add "Keep the compiler happy with -Og"
Quoted 1 line
I am happy to add it while committing if you agree.
Yes, please do. Thanks.
Quoted 6 lines
Reviewed-by Julien Grall <[email protected]>Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 3/3] xen/arm: fix unitialized use warning
Quoted 44 lines · Stewart Hildebrand
Quoted 1 line · Julien Grall
Hi Stewart,
Hi Julien,
Quoted 4 lines · Stewart Hildebrand
Quoted 1 line
When building the hypervisor with -Og, we encounter the following error:
Is this with GCC 12 as well?
Yes. If my memory serves me correctly this particular one occurs with both GCC 11 and 12.
Quoted 32 lines
Quoted 24 lines
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized]
2040 | if (clock_valid)
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here1947 | bool clock_valid; | ^~~~~~~~~~~cc1: all warnings being treated as errors
Fix it by initializing the variable.
Signed-off-by Stewart Hildebrand <[email protected]>---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00741.html--- xen/arch/arm/domain_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c static int __init make_cpus_node(const struct domain *d, void *fdt) · line 1947
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1944,7 +1944,7 @@ static int __init make_cpus_node(const struct domain *d, void *fdt)/* Placeholder for cpu@ + a 32-bit hexadecimal number + \0 */ char buf[13 ];u32 clock_frequency; -bool clock_valid; +bool clock_valid = false;NIT: I would add "Keep the compiler happy with -Og"
Quoted 3 lines
Quoted 1 line
I am happy to add it while committing if you agree.
Yes, please do. Thanks.
One more thing, there is a typo in the subject, if you are willing to correct it while committing. s/unitialized/uninitialized/
Quoted 7 lines
Quoted 6 lines
Reviewed-by Julien Grall <[email protected]>Cheers,
--
Julien Grall
Re: [PATCH 3/3] xen/arm: fix unitialized use warning
Hi Stewart,
Quoted 4 lines · Stewart Hildebrand
Quoted 3 lines · Stewart Hildebrand
Quoted 1 line · Julien Grall
Hi Stewart,
Quoted 8 lines
Quoted 8 lines
Hi Julien,
Quoted 4 lines · Stewart Hildebrand
Quoted 1 line
When building the hypervisor with -Og, we encounter the following error:
Is this with GCC 12 as well?
Yes. If my memory serves me correctly this particular one occurs with both GCC 11 and 12.
Thanks. I will update the commit message to mention it.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 25 lines
arch/arm/domain_build.c: In function ‘make_cpus_node’:arch/arm/domain_build.c:2040:12: error: ‘clock_valid’ may be used uninitialized [-Werror=maybe-uninitialized]
2040 | if (clock_valid)
| ^arch/arm/domain_build.c:1947:10: note: ‘clock_valid’ was declared here1947 | bool clock_valid; | ^~~~~~~~~~~cc1: all warnings being treated as errors
Fix it by initializing the variable.
Signed-off-by Stewart Hildebrand <[email protected]>---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00741.html--- xen/arch/arm/domain_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c static int __init make_cpus_node(const struct domain *d, void *fdt) · line 1947
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -1944,7 +1944,7 @@ static int __init make_cpus_node(const struct domain *d, void *fdt)/* Placeholder for cpu@ + a 32-bit hexadecimal number + \0 */ char buf[13 ];u32 clock_frequency; -bool clock_valid; +bool clock_valid = false;NIT: I would add "Keep the compiler happy with -Og"
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I am happy to add it while committing if you agree.
Yes, please do. Thanks.
One more thing, there is a typo in the subject, if you are willing to correct it while committing. s/unitialized/uninitialized/
Sure. I will do that.
Cheers,
Signature · 1 line
Julien Grall
Hi Stewart,
Quoted 11 lines · Stewart Hildebrand
This is a collection of fixes needed to build the hypervisor with -Og for arm64.
I build-tested this with the following command:
make -j $(nproc) \ EXTRA_CFLAGS_XEN_CORE="-Og" \ XEN_TARGET_ARCH=arm64 \ CROSS_COMPILE=aarch64-none-linux-gnu- \ dist-xen
Quoted 4 lines
Stewart Hildebrand (3):
xen/arm: mark__guest_cmpxchgalways_inline
xen/efi: fix unitialized use warning
xen/arm: fix unitialized use warning
I have committed patch #1 and #3. Jan already committed patch #2.
Thanks,
Signature · 1 line
Julien Grall