Query: Regarding mtrack-speculation support in gcc latest version
Gaurav Kohli
gkohli@codeaurora.org
Tue Jan 7 11:32:00 GMT 2020
Hi Richard,
Thanks a lot, it is working now.
So for user space also, we have to work like Linux kernel only use
array_index_nospec in required places.
Is there any plan to automate this thing from compiler only?
Regards
Gaurav
On 1/6/2020 9:23 PM, Richard Earnshaw (lists) wrote:
> On 03/01/2020 13:08, Gaurav Kohli wrote:
>> Hi,
>>
>> I am trying latest gcc 9.1 version and executing below code with
>> option -mtrack-speculation -march=armv8.5-a
>>
>> #include<stdio.h>
>> #include<stdlib.h>
>> #define limit 10
>> int arr[limit] = {0};
>> void main() {
>>
>> int inp;
>> printf("enter inp\n");
>> scanf("%d\n",&inp);
>> if(inp < limit)
>> Â Â Â Â Â Â Â Â printf("val=%d\n",arr[inp]);
>> else
>> Â Â Â Â Â Â Â Â printf("crossing limit\n");
>> return;
>>
>> }
>>
>>
>> But in disassembly only csel is generating, no csdb is coming:
>>
>>   40069c:      9a9fd1ef       csel   x15, x15, xzr, le
>>   4006a0:      b9401fe1       ldr    w1, [sp, #28]
>>   4006a4:      b0000080       adrp   x0, 411000
>> <__libc_start_main@GLIBC_2.17>
>>   4006a8:      91012000       add    x0, x0, #0x48
>>   4006ac:      93407c21       sxtw   x1, w1
>>   4006b0:      b8617800       ldr    w0, [x0, x1, lsl #2]
>>   4006b4:      2a0003e1       mov    w1, w0
>>   4006b8:      90000000       adrp   x0, 400000 <_init-0x4a0>
>>   4006bc:      911f8000       add    x0, x0, #0x7e0
>>   4006c0:      910003ee       mov    x14, sp
>>   4006c4:      8a0f01ce       and    x14, x14, x15
>>   4006c8:      910001df       mov    sp, x14
>>   4006cc:      97ffff99       bl     400530 <printf@plt>
>>   4006d0:      f10003ff       cmp    sp, #0x0
>>   4006d4:      da9f03ef       csetm  x15, ne // ne = any
>>   4006d8:      1400000b       b      400704 <main+0xb8>
>>   4006dc:      9a9fc1ef       csel   x15, x15, xzr, gt
>>
>>
>> Can someone please point, when cdsb will come?
>>
>> Regards
>> Gaurav
>>
>
> As the manual says, -mtrack-speculation must be used in conjunction with
> __builtin_speculation_safe_copy to annotate memory accesses that might
> lead to potentially unsafe speculation. See the manual for more details.
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
More information about the Gcc-help
mailing list