On 12/01/2023 09:36, Amit Daniel Kachhap wrote:
Inline assembly instruction as shown below is not recognized in Gcc
Nit: s/instruction/modifier/ (the issue is the "w" in "%w0" here, which is an operand modifier).
Also maybe the commit title could be more descriptive, "Fix inline assembly syntax" for instance.
Assembler and generates error,
asm volatile("adr %w0, #0" : "=r"(cap));
/tmp/cc49utqN.s: Assembler messages: /tmp/cc49utqN.s:1110: Error: operand mismatch -- `adr w0,#0' /tmp/cc49utqN.s:1110: Info: did you mean this? /tmp/cc49utqN.s:1110: Info: adr x0, #0x0 /tmp/cc49utqN.s:1088: Error: undefined symbol c30 used as an immediate value
Fix the above by using the syntax as below which is recognized in both Clang and GAS.
Nit: s/GAS/GCC/ - it is the compiler that generates plain assembly instructions from inline assembly statements, and here the issue is in this transformation, not in the assembly syntax itself. It is the assembler that complains, because GCC does understand %w0, but in a different way from Clang. Similarly just saying "GCC" instead of "GCC assembler" above would make more sense to me.
Kevin
asm volatile("adr %0, #0" : "=C"(cap));
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com
tools/testing/selftests/arm64/morello/bootstrap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/bootstrap.c b/tools/testing/selftests/arm64/morello/bootstrap.c index 6a91ba39dd83..75c636688c5b 100644 --- a/tools/testing/selftests/arm64/morello/bootstrap.c +++ b/tools/testing/selftests/arm64/morello/bootstrap.c @@ -138,12 +138,12 @@ TEST(test_c64) { uintcap_t cap;
- asm volatile("mov %w0, c30" : "=r"(cap));
- asm volatile("mov %0, c30" : "=C"(cap)); /* LSB is set on LR if we came from C64 */ ASSERT_TRUE(cap & 0x1) TH_LOG("we did not come from C64");
/* will write to Cn register in C64 and Xn in A64, clearing the tag */
- asm volatile("adr %w0, #0" : "=r"(cap));
- asm volatile("adr %0, #0" : "=C"(cap)); ASSERT_TRUE(cheri_tag_get(cap)) TH_LOG("not running in C64");
}