About -fasan-shadow-offset option

2022-11-16 Thread tao.z...@amlogic.com
Dear gcc:

I am developing a address sanitiser tools for u-boot. Basically refers 
compile options from kernel side. But there is a problem that I must set 
-fasan-shadow-offset with a pre-calculated value. Otherwise GCC compiler will 
use 0x10 as default value for shadow offset and caused boot failed 
because this value is too large.
The problem is uboot do not have a fixed memory layout as kernel. Basically 
it will relocate to end of DDR size and running at that memory space. Usually 
memory map for uboot is virt=phys and there are lots of drivers do not do 
address translate for dma based on this mapping. But ddr size are different on 
each platform. So it's hard to handle shadow offset at this scenario.
My point is that can gcc add an option like -fasan-shadow-symbol=, here 
 is a global variable and implementors can configure it's value based on 
platforms ddr size/malloc buffer size during initialize stage and this variable 
can be used for shadow address calculation during runtime. This may be more 
fitable compared than a fixed value during compile stage.  And is there any 
other options to help my problem?
Waiting for your response asap.
 Thanks.



Thanks!
B.R.
tao.z...@amlogic.com
 
Address: Building E5, 2555 Xiupu Road, Pudong District, Shanghai, China
公司地址:上海市浦东新区秀浦路2555号漕河泾康桥商务绿洲E5栋



Re: Re: About -fasan-shadow-offset option

2022-11-25 Thread tao.z...@amlogic.com
Dear Martin Liška

Thanks for your research. I have resolved this problem by pass a ddrsize 
paramters when build and cacluate the offset used by -fasan-shadow-offset 
according that parameter. 



Thanks!
B.R.
tao.z...@amlogic.com
 
Address: Building E5, 2555 Xiupu Road, Pudong District, Shanghai, China
公司地址:上海市浦东新区秀浦路2555号漕河泾康桥商务绿洲E5栋

 
发件人: Martin Liška
发送时间: 2022-11-26 00:23
收件人: tao.z...@amlogic.com; gcc
抄送: Jakub Jelinek
主题: Re: About -fasan-shadow-offset option
 
[ EXTERNAL EMAIL ]
 
On 11/16/22 10:01, tao.z...@amlogic.com wrote:
> Dear gcc:
> 
 
Hello.
 
Based on quick discussion with Jakub, we believe fasan-shadow-symbol= would 
be a non-trivial amount of work
and we rather suggest doing a per-system build with investigated 
-fasan-shadow-offset.
 
Cheers,
Martin
 
> I am developing a address sanitiser tools for u-boot. Basically refers 
> compile options from kernel side. But there is a problem that I must set 
> -fasan-shadow-offset with a pre-calculated value. Otherwise GCC compiler will 
> use 0x10 as default value for shadow offset and caused boot failed 
> because this value is too large.
> The problem is uboot do not have a fixed memory layout as kernel. 
> Basically it will relocate to end of DDR size and running at that memory 
> space. Usually memory map for uboot is virt=phys and there are lots of 
> drivers do not do address translate for dma based on this mapping. But ddr 
> size are different on each platform. So it's hard to handle shadow offset at 
> this scenario.
> My point is that can gcc add an option like -fasan-shadow-symbol=, 
> here  is a global variable and implementors can configure it's value 
> based on platforms ddr size/malloc buffer size during initialize stage and 
> this variable can be used for shadow address calculation during runtime. This 
> may be more fitable compared than a fixed value during compile stage.  And is 
> there any other options to help my problem?
> Waiting for your response asap.
>  Thanks.
> 
> 
> 
> Thanks!
> B.R.
> tao.z...@amlogic.com
>  
> Address: Building E5, 2555 Xiupu Road, Pudong District, Shanghai, China
> 公司地址:上海市浦东新区秀浦路2555号漕河泾康桥商务绿洲E5栋
>