diff mbox series

[1/3] xen/arm: mark __guest_cmpxchg always_inline

Message ID 20230414185714.292881-2-stewart.hildebrand@amd.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: fix build errors with -Og | expand

Commit Message

Stewart Hildebrand April 14, 2023, 6:57 p.m. UTC
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.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com
---
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(-)

Comments

Henry Wang April 15, 2023, 4:58 a.m. UTC | #1
Hi Stewart,

> -----Original Message-----
> Subject: [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.
> 
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com

Hmmm I think you missed the ">" in the end of your signoff...But anyway the
patch looks good to me so:

Reviewed-by: Henry Wang <Henry.Wang@arm.com>

Kind regards,
Henry
Julien Grall April 16, 2023, 12:50 p.m. UTC | #2
Hi Stewart,

On 14/04/2023 19:57, Stewart Hildebrand wrote:
> 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.
> 
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com
> ---
> 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.

Make sense. I will fixed the signed-off-by line issue reported by Henry 
while committing:

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,
Stewart Hildebrand April 17, 2023, 1:56 a.m. UTC | #3
On 4/16/23 08:50, Julien Grall wrote:
> Hi Stewart,
> 
> On 14/04/2023 19:57, Stewart Hildebrand wrote:
>> 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.
>>
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com
>> ---
>> 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.
> 
> Make sense. I will fixed the signed-off-by line issue reported by Henry
> while committing:
> 
> Reviewed-by: Julien Grall <jgrall@amazon.com>

Thank you!
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/guest_atomics.h b/xen/arch/arm/include/asm/guest_atomics.h
index 9e2e96d4ff72..a1745f8613f6 100644
--- a/xen/arch/arm/include/asm/guest_atomics.h
+++ b/xen/arch/arm/include/asm/guest_atomics.h
@@ -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;