diff mbox series

[v2,2/3] ARM: uaccess: use unified assembler language syntax

Message ID 5ef2acc655abfbe8bfa2cd30ecc5c2286b8fdfa3.1546551693.git.stefan@agner.ch (mailing list archive)
State Mainlined, archived
Commit 32fdb046ac43aa884d960165072ca37b26d78543
Headers show
Series ARM: trivial assembly fixes to enable LLVM as | expand

Commit Message

Stefan Agner Jan. 3, 2019, 9:48 p.m. UTC
Convert the conditional infix to a postfix to make sure this inline
assembly is unified syntax. Since gcc assumes non-unified syntax
when emitting ARM instructions, make sure to define the syntax as
unified.

This allows to use LLVM's integrated assembler.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Changes since v1:
- Explicitly use unified syntax for inline assembly


 arch/arm/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Nicolas Pitre Jan. 5, 2019, 4:12 p.m. UTC | #1
On Thu, 3 Jan 2019, Stefan Agner wrote:

> Convert the conditional infix to a postfix to make sure this inline
> assembly is unified syntax. Since gcc assumes non-unified syntax
> when emitting ARM instructions, make sure to define the syntax as
> unified.
> 
> This allows to use LLVM's integrated assembler.
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> Changes since v1:
> - Explicitly use unified syntax for inline assembly
> 
> 
>  arch/arm/include/asm/uaccess.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
> index 6390a40f16e7..a50f9b4e2574 100644
> --- a/arch/arm/include/asm/uaccess.h
> +++ b/arch/arm/include/asm/uaccess.h
> @@ -86,7 +86,8 @@ static inline void set_fs(mm_segment_t fs)
>  #define __range_ok(addr, size) ({ \
>  	unsigned long flag, roksum; \
>  	__chk_user_ptr(addr);	\
> -	__asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
> +	__asm__(".syntax unified\n" \
> +		"adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \

Instead of sprinkling ".syntax unified" around, you could consider 
including <asm/unified.h> when needed.


Nicolas
Stefan Agner Jan. 7, 2019, 9:50 p.m. UTC | #2
On 05.01.2019 17:12, Nicolas Pitre wrote:
> On Thu, 3 Jan 2019, Stefan Agner wrote:
> 
>> Convert the conditional infix to a postfix to make sure this inline
>> assembly is unified syntax. Since gcc assumes non-unified syntax
>> when emitting ARM instructions, make sure to define the syntax as
>> unified.
>>
>> This allows to use LLVM's integrated assembler.
>>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>> ---
>> Changes since v1:
>> - Explicitly use unified syntax for inline assembly
>>
>>
>>  arch/arm/include/asm/uaccess.h | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
>> index 6390a40f16e7..a50f9b4e2574 100644
>> --- a/arch/arm/include/asm/uaccess.h
>> +++ b/arch/arm/include/asm/uaccess.h
>> @@ -86,7 +86,8 @@ static inline void set_fs(mm_segment_t fs)
>>  #define __range_ok(addr, size) ({ \
>>  	unsigned long flag, roksum; \
>>  	__chk_user_ptr(addr);	\
>> -	__asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
>> +	__asm__(".syntax unified\n" \
>> +		"adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \
> 
> Instead of sprinkling ".syntax unified" around, you could consider 
> including <asm/unified.h> when needed.

This seems not to help in this case. When I include <asm/unified.h> at
the beginning of uaccess.h GCC still seems to emit ".syntax unified".

I guess this is since we are dealing with inline assembly. As far as I
understand its really gcc which emits a ".syntax divided" by default
when compiling ARM mode. There is an option "-masm-syntax-unified" which
according to the gcc man page should do what we need, but it seems
broken, see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88648

I agree this patch is not particularly pretty, but it is the only
solution I found to make this inline assembly work with gcc and Clang.

--
Stefan
diff mbox series

Patch

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 6390a40f16e7..a50f9b4e2574 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -86,7 +86,8 @@  static inline void set_fs(mm_segment_t fs)
 #define __range_ok(addr, size) ({ \
 	unsigned long flag, roksum; \
 	__chk_user_ptr(addr);	\
-	__asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
+	__asm__(".syntax unified\n" \
+		"adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \
 		: "=&r" (flag), "=&r" (roksum) \
 		: "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
 		: "cc"); \