Re: [GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
On 11/06/2021 14:02, Srinath Parvathaneni via Gcc-patches wrote: Hi Richard, I have addressed all your review comments in https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571739.html in the following patch. The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-06-11 Srinath Parvathaneni PR target/99939 * gcc.target/arm/cmse/cmse-18.c: Add separate scan-assembler directives check for target is v8.1-m.main+mve or not before comparing the assembly output. * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-06-11 Srinath Parvathaneni PR target/99939 * config/arm/cmse_nonsecure_call.S: Add __ARM_FEATURE_MVE macro. * config/arm/t-arm: To link cmse.o and cmse_nonsecure_call.o on passing -mcmse option. OK. R. ### Attachment also inlined for ease of reply### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c index e1ff09257b7900982f49117d4cfc16f3bd79d76c..db7d975a90ea4bd1810aea03949ec1e8837e 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c @@ -8,4 +8,5 @@ void bar(f func, int a) func(a); } -/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..08e89bff6378f1f96950fc40f3ab3946bd433773 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* This test is executed only if the execution engine supports CMSE instructions. */ +/* { dg-options "--save-temps -mcmse -Wl,--section-start,.gnu.sgstubs=0x0040" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/cmse_nonsecure_call.S b/libgcc/config/arm/cmse_nonsecure_call.S index 146f3ed52e9c7e915e5dbd9b70624ec3bd7cd5b5..00830ade98ea650c328c709d5d308fbc96f7f21c 100644 --- a/libgcc/config/arm/cmse_nonsecure_call.S +++ b/libgcc/config/arm/cmse_nonsecure_call.S @@ -25,7 +25,7 @@ .syntax unified #ifdef __ARM_PCS_VFP -# if __ARM_FP & 0x8 +# if (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) .fpu fpv5-d16 # else .fpu fpv4-sp-d16 @@ -59,7 +59,7 @@ vmov s24, s25, r5, r5 vmov s26, s27, r5, r5 vmov s28, s29, r5, r5 vmov s30, s31, r5, r5 -#elif __ARM_FP & 0x08 +#elif (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) vmov.f64d9, d8 vmov.f64d10, d8 vmov.f64d11, d8 diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..c1553d4e5d80751b13dc2e9c9e36d5ebe82e5f8c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -3,18 +3,17 @@ LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \ _thumb1_case_uhi _thumb1_case_si _speculation_barrier HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - -HAVE_V81M:=$(findstring armv8.1-m.main,$(gcc_compile_bare)) ifeq ($(shell $(gcc_compile_bare) -E -mcmse - /dev/null 2>/dev/null; echo $$?),0) CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M + libgcc-objects += cmse.o cmse_nonsecure_call.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< + cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif -endif
[GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
Hi Richard, I have addressed all your review comments in https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571739.html in the following patch. The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-06-11 Srinath Parvathaneni PR target/99939 * gcc.target/arm/cmse/cmse-18.c: Add separate scan-assembler directives check for target is v8.1-m.main+mve or not before comparing the assembly output. * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-06-11 Srinath Parvathaneni PR target/99939 * config/arm/cmse_nonsecure_call.S: Add __ARM_FEATURE_MVE macro. * config/arm/t-arm: To link cmse.o and cmse_nonsecure_call.o on passing -mcmse option. ### Attachment also inlined for ease of reply### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c index e1ff09257b7900982f49117d4cfc16f3bd79d76c..db7d975a90ea4bd1810aea03949ec1e8837e 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c @@ -8,4 +8,5 @@ void bar(f func, int a) func(a); } -/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..08e89bff6378f1f96950fc40f3ab3946bd433773 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* This test is executed only if the execution engine supports CMSE instructions. */ +/* { dg-options "--save-temps -mcmse -Wl,--section-start,.gnu.sgstubs=0x0040" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/cmse_nonsecure_call.S b/libgcc/config/arm/cmse_nonsecure_call.S index 146f3ed52e9c7e915e5dbd9b70624ec3bd7cd5b5..00830ade98ea650c328c709d5d308fbc96f7f21c 100644 --- a/libgcc/config/arm/cmse_nonsecure_call.S +++ b/libgcc/config/arm/cmse_nonsecure_call.S @@ -25,7 +25,7 @@ .syntax unified #ifdef __ARM_PCS_VFP -# if __ARM_FP & 0x8 +# if (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) .fpu fpv5-d16 # else .fpu fpv4-sp-d16 @@ -59,7 +59,7 @@ vmov s24, s25, r5, r5 vmov s26, s27, r5, r5 vmov s28, s29, r5, r5 vmov s30, s31, r5, r5 -#elif __ARM_FP & 0x08 +#elif (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) vmov.f64d9, d8 vmov.f64d10, d8 vmov.f64d11, d8 diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..c1553d4e5d80751b13dc2e9c9e36d5ebe82e5f8c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -3,18 +3,17 @@ LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \ _thumb1_case_uhi _thumb1_case_si _speculation_barrier HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - /dev/null 2>/dev/null; echo $$?),0) CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M + libgcc-objects += cmse.o cmse_nonsecure_call.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< + cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif -endif diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c index e1ff09257b7900982f49117d4cfc16f3bd79d76c..db7d975a90ea4bd1810aea03949ec1e8837e 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c @@ -8,4 +8,5 @@ void bar(f func, int a) func(a); } -/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c
[GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
Hi Richard, I have addressed all your review comments in https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571739.html in the following patch. The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-06-11 Srinath Parvathaneni * gcc.target/arm/cmse/cmse-18.c: Add separate scan-assembler directives check for target is v8.1-m.main+mve or not before comparing the assembly output. * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-06-11 Srinath Parvathaneni * config/arm/cmse_nonsecure_call.S: Add __ARM_FEATURE_MVE macro. * config/arm/t-arm: To link cmse.o and cmse_nonsecure_call.o on passing -mcmse option. ### Attachment also inlined for ease of reply### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c index e1ff09257b7900982f49117d4cfc16f3bd79d76c..db7d975a90ea4bd1810aea03949ec1e8837e 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c @@ -8,4 +8,5 @@ void bar(f func, int a) func(a); } -/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..08e89bff6378f1f96950fc40f3ab3946bd433773 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* This test is executed only if the execution engine supports CMSE instructions. */ +/* { dg-options "--save-temps -mcmse -Wl,--section-start,.gnu.sgstubs=0x0040" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/cmse_nonsecure_call.S b/libgcc/config/arm/cmse_nonsecure_call.S index 146f3ed52e9c7e915e5dbd9b70624ec3bd7cd5b5..00830ade98ea650c328c709d5d308fbc96f7f21c 100644 --- a/libgcc/config/arm/cmse_nonsecure_call.S +++ b/libgcc/config/arm/cmse_nonsecure_call.S @@ -25,7 +25,7 @@ .syntax unified #ifdef __ARM_PCS_VFP -# if __ARM_FP & 0x8 +# if (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) .fpu fpv5-d16 # else .fpu fpv4-sp-d16 @@ -59,7 +59,7 @@ vmov s24, s25, r5, r5 vmov s26, s27, r5, r5 vmov s28, s29, r5, r5 vmov s30, s31, r5, r5 -#elif __ARM_FP & 0x08 +#elif (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) vmov.f64d9, d8 vmov.f64d10, d8 vmov.f64d11, d8 diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..c1553d4e5d80751b13dc2e9c9e36d5ebe82e5f8c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -3,18 +3,17 @@ LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \ _thumb1_case_uhi _thumb1_case_si _speculation_barrier HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - /dev/null 2>/dev/null; echo $$?),0) CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M + libgcc-objects += cmse.o cmse_nonsecure_call.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< + cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif -endif diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c index e1ff09257b7900982f49117d4cfc16f3bd79d76c..db7d975a90ea4bd1810aea03949ec1e8837e 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c @@ -8,4 +8,5 @@ void bar(f func, int a) func(a); } -/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */ +/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index
Re: [GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
On 01/06/2021 18:16, Srinath Parvathaneni via Gcc-patches wrote: Hi Richard, -Original Message- From: Richard Earnshaw Sent: 13 April 2021 14:55 To: Srinath Parvathaneni ; gcc- patc...@gcc.gnu.org Cc: Richard Earnshaw Subject: Re: [GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939). On 12/04/2021 14:04, Srinath Parvathaneni via Gcc-patches wrote: Hi, The current CMSE support in the multilib build for "-march=armv8.1- m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * config/arm/t-arm: Make changes to use cmse.c for all the armv8.1-m.main mulitlibs. ### Attachment also inlined for ease of reply ### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..7e2739e14792624adf5b428 0ca58 a5d8320acbf0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mcmse +-Wl,--section-start,.gnu.sgstubs=0x0019" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..949e2ee06653680211ff2dcf 0b55 a41a6aedc31c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -9,11 +9,12 @@ CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M -libgcc-objects += cmse.o cmse_nonsecure_call.o +libgcc-objects += cmse.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< +ifndef HAVE_V81M +libgcc-objects += cmse_nonsecure_call.o cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif So if I have two object files using CMSE and one is built with v8m, but the other with v8.1m, when I link them, the needed additional support for the v8m object file will be missing the library support. Wouldn't it be better to just build the cmse_nonsecure_call code unconditionally? It won't be called if it's not needed, but will be there if something does require it. I have modified the patch to build the cmse_nonsecure_call code unconditionally, I have attached the diff and cover letter in this email. Please let me know if it is ok for master? Regards, Srinath. R. gcc/testsuite/ChangeLog: 2021-06-01 Srinath Parvathaneni * gcc.target/arm/cmse/cmse-18.c: Modify Incomplete. I know you've modified it, but how? * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-06-01 Srinath Parvathaneni * config/arm/cmse_nonsecure_call.S: Modify to add __ARM_FEATURE_MVE macro check. "Add __ARM_FEATURE_MVE macro check." is sufficient (I know you've modified it). * config/arm/t-arm: Make changes to link cmse.o and cmse_nonsecure_call.o on finding -mcmse gcc options. Again, "Make changes to " is redundant. diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..7e2739e14792624adf5b4280ca58a5d8320acbf0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mcmse -Wl,--section-start,.gnu.sgstubs=0x0019" } */ Why does this need a different stubs address to all the other executable CMSE tests? Can't it use 0x0040 like them? R.
RE: [GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
Hi Richard, > -Original Message- > From: Richard Earnshaw > Sent: 13 April 2021 14:55 > To: Srinath Parvathaneni ; gcc- > patc...@gcc.gnu.org > Cc: Richard Earnshaw > Subject: Re: [GCC][Patch] arm: Fix the mve multilib for the broken cmse > support (pr99939). > > > > On 12/04/2021 14:04, Srinath Parvathaneni via Gcc-patches wrote: > > Hi, > > > > The current CMSE support in the multilib build for "-march=armv8.1- > m.main+mve -mfloat-abi=hard -mfpu=auto" > > is broken as specified in PR99939 and this patch fixes the issue. > > > > Regression tested on arm-none-eabi and found no regressions. > > > > Ok for master? and Ok for GCC-10 branch? > > > > Regards, > > Srinath. > > > > gcc/testsuite/ChangeLog: > > > > 2021-04-12 Srinath Parvathaneni > > > > PR target/99939 > > * gcc.target/arm/cmse/cmse-20.c: New test. > > > > libgcc/ChangeLog: > > > > 2021-04-12 Srinath Parvathaneni > > > > PR target/99939 > > * config/arm/t-arm: Make changes to use cmse.c for all the > > armv8.1-m.main mulitlibs. > > > > > > > > ### Attachment also inlined for ease of reply > ### > > > > > > diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c > > b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c > > new file mode 100644 > > index > > > ..7e2739e14792624adf5b428 > 0ca58 > > a5d8320acbf0 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c > > @@ -0,0 +1,28 @@ > > +/* { dg-do run } */ > > +/* { dg-additional-options "-mcmse > > +-Wl,--section-start,.gnu.sgstubs=0x0019" } */ > > + > > +#include > > +#include > > +#include > > + > > +void __attribute__((cmse_nonsecure_entry)) > > +secure_fun (int a, int *p) > > +{ > > + void *b = cmse_check_address_range ((void *)p, a, 1); > > + > > + if (b == NULL) > > + __builtin_abort (); > > + printf("%d", *((int *)b)); > > +} > > + > > +int > > +main (void) > > +{ > > + int *ptr; > > + int size = 1; > > + ptr = (int *) calloc (1, sizeof(int *)); > > + *ptr = 1315852292; > > + secure_fun (size, ptr); > > + free (ptr); > > + return 0; > > +} > > diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index > > > 3625a2590beec4e4e0e0881be9ad284c595c7190..949e2ee06653680211ff2dcf > 0b55 > > a41a6aedc31c 100644 > > --- a/libgcc/config/arm/t-arm > > +++ b/libgcc/config/arm/t-arm > > @@ -9,11 +9,12 @@ CMSE_OPTS:=-mcmse > > endif > > > > ifdef HAVE_CMSE > > -ifndef HAVE_V81M > > -libgcc-objects += cmse.o cmse_nonsecure_call.o > > +libgcc-objects += cmse.o > > > > cmse.o: $(srcdir)/config/arm/cmse.c > > $(gcc_compile) -c $(CMSE_OPTS) $< > > +ifndef HAVE_V81M > > +libgcc-objects += cmse_nonsecure_call.o > > cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S > >$(gcc_compile) -c $< > > endif > > > > So if I have two object files using CMSE and one is built with v8m, but the > other with v8.1m, when I link them, the needed additional support for the > v8m object file will be missing the library support. > > Wouldn't it be better to just build the cmse_nonsecure_call code > unconditionally? It won't be called if it's not needed, but will be there if > something does require it. I have modified the patch to build the cmse_nonsecure_call code unconditionally, I have attached the diff and cover letter in this email. Please let me know if it is ok for master? Regards, Srinath. > > R. Hi, The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-06-01 Srinath Parvathaneni * gcc.target/arm/cmse/cmse-18.c: Modify * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-06-01 Srinath Parvathaneni * config/arm/cmse_nonsecure_call.S: Modify to add __ARM_FEATURE_MVE macro check. * config/arm/t-arm: Make changes to link cmse.o and cmse_nonsecure_call.o on finding -mcmse gcc options. diff (2).patch Description: diff (2).patch
Re: [GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
On 12/04/2021 14:04, Srinath Parvathaneni via Gcc-patches wrote: Hi, The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * config/arm/t-arm: Make changes to use cmse.c for all the armv8.1-m.main mulitlibs. ### Attachment also inlined for ease of reply### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..7e2739e14792624adf5b4280ca58a5d8320acbf0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mcmse -Wl,--section-start,.gnu.sgstubs=0x0019" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..949e2ee06653680211ff2dcf0b55a41a6aedc31c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -9,11 +9,12 @@ CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M -libgcc-objects += cmse.o cmse_nonsecure_call.o +libgcc-objects += cmse.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< +ifndef HAVE_V81M +libgcc-objects += cmse_nonsecure_call.o cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif So if I have two object files using CMSE and one is built with v8m, but the other with v8.1m, when I link them, the needed additional support for the v8m object file will be missing the library support. Wouldn't it be better to just build the cmse_nonsecure_call code unconditionally? It won't be called if it's not needed, but will be there if something does require it. R.
[GCC][Patch] arm: Fix the mve multilib for the broken cmse support (pr99939).
Hi, The current CMSE support in the multilib build for "-march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto" is broken as specified in PR99939 and this patch fixes the issue. Regression tested on arm-none-eabi and found no regressions. Ok for master? and Ok for GCC-10 branch? Regards, Srinath. gcc/testsuite/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * gcc.target/arm/cmse/cmse-20.c: New test. libgcc/ChangeLog: 2021-04-12 Srinath Parvathaneni PR target/99939 * config/arm/t-arm: Make changes to use cmse.c for all the armv8.1-m.main mulitlibs. ### Attachment also inlined for ease of reply### diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..7e2739e14792624adf5b4280ca58a5d8320acbf0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mcmse -Wl,--section-start,.gnu.sgstubs=0x0019" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..949e2ee06653680211ff2dcf0b55a41a6aedc31c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -9,11 +9,12 @@ CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M -libgcc-objects += cmse.o cmse_nonsecure_call.o +libgcc-objects += cmse.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< +ifndef HAVE_V81M +libgcc-objects += cmse_nonsecure_call.o cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c new file mode 100644 index ..7e2739e14792624adf5b4280ca58a5d8320acbf0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-20.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mcmse -Wl,--section-start,.gnu.sgstubs=0x0019" } */ + +#include +#include +#include + +void __attribute__((cmse_nonsecure_entry)) +secure_fun (int a, int *p) +{ + void *b = cmse_check_address_range ((void *)p, a, 1); + + if (b == NULL) + __builtin_abort (); + printf("%d", *((int *)b)); +} + +int +main (void) +{ + int *ptr; + int size = 1; + ptr = (int *) calloc (1, sizeof(int *)); + *ptr = 1315852292; + secure_fun (size, ptr); + free (ptr); + return 0; +} diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a2590beec4e4e0e0881be9ad284c595c7190..949e2ee06653680211ff2dcf0b55a41a6aedc31c 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -9,11 +9,12 @@ CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M -libgcc-objects += cmse.o cmse_nonsecure_call.o +libgcc-objects += cmse.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< +ifndef HAVE_V81M +libgcc-objects += cmse_nonsecure_call.o cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif