Skip to contentSkip to conversation

crypto: arm64/poly1305 - move data to rodata section (47d9625)

herbertx/cryptodev Herbert Xu 3 participants 3 messages Aug 3, 2024 – Aug 5, 2024 2 messages not in the archive Crypto API

lore
Share & tools
lore

Herbert Xu

author maintainer
#2 lore raw
In reply to a message not in the archive
Quoted 10 lines · Andy Polyakov

Formally speaking this is error prone, because there is no guarantee that linker will be able to resolve it as argument to adr instruction above. I mean since the address is resolved with adr instruction alone, there is a limit on how far the label can be from the instruction in question. On a practical level, if/since it's compiled as part of a kernel module, it won't be a problem, because the module won't be large enough to break the limit, but it **is** a problem in general case.

But why would objtool attempt to disassemble it? Does it actually attempt to disassemble unreferenced spaces between functions? Note that the .Lzeros label doesn't make it into .o file, so there won't be anything in the symbol table to discover as potential entry point...

Signature · 5 lines
Reply to this email directly or view it on GitHub:
https://github.com/herbertx/cryptodev/commit/47d96252099a7184b4bad852fcfa3c233c1d2f71#r144978326
You are receiving this because you authored the thread.

Message ID: <herbertx/cryptodev/commit/47d96252099a7184b4bad852fcfa3c233c1d2f71/[email protected]>

Adding the original Cc list.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw

Hi Andy,

Quoted 15 lines

-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Saturday, August 3, 2024 8:40 AM
To: herbertx/cryptodev <[email protected] om>
Cc: herbertx/cryptodev <[email protected]>; Author <[email protected]>; Justin He <[email protected]>; David S. Miller <[email protected]>; Catalin Marinas <[email protected]>; [email protected]; Will Deacon <[email protected]>; [email protected]; [email protected]; Ard Biesheuvel <[email protected]>; Andy Polyakov <[email protected]>
Subject: Re: [herbertx/cryptodev] crypto: arm64/poly1305 - move data to rodata section (47d9625)

Quoted 7 lines
Quoted 1 line · Andy Polyakov

Formally speaking this is error prone, because there is no guarantee that linker

will be able to resolve it as argument to adr instruction above. I mean since the address is resolved with adr instruction alone, there is a limit on how far the label can be from the instruction in question. On a practical level, if/since it's compiled as part of a kernel module, it won't be a problem, because the module won't be large enough to break the limit, but it **is** a problem in general case.

Thanks,
Can this problem be resolved by changing "adr" to "adrp"?

Quoted 5 lines
Quoted 2 lines

But why would objtool attempt to disassemble it? Does it actually attempt to

disassemble unreferenced spaces between functions? Note that the .Lzeros label doesn't make it into .o file, so there won't be anything in the symbol table to discover as potential entry point..

There is a similar patch (1253cab8a352) for x86. I guess that objtool/stacktool can be improved in this regard.

--
Cheers,
Justin (Jia He)

#4 lore raw

Hi,

Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Saturday, August 3, 2024 8:40 AM
To: herbertx/cryptodev <[email protected] om>
Cc: herbertx/cryptodev <[email protected]>; Author <[email protected]>; Justin He <[email protected]>; David S. Miller <[email protected]>; Catalin Marinas <[email protected]>; [email protected]; Will Deacon <[email protected]>; [email protected]; [email protected]; Ard Biesheuvel <[email protected]>; Andy Polyakov <[email protected]>
Subject: Re: [herbertx/cryptodev] crypto: arm64/poly1305 - move data to rodata section (47d9625)

On Fri, Aug 02, 2024 at 08:09:10AM -0700, Andy Polyakov wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Formally speaking this is error prone, because there is no guarantee that linker

will be able to resolve it as argument to adr instruction above. I mean since the address is resolved with adr instruction alone, there is a limit on how far the label can be from the instruction in question. On a practical level, if/since it's compiled as part of a kernel module, it won't be a problem, because the module won't be large enough to break the limit, but it **is** a problem in general case.

Thanks,
Can this problem be resolved by changing "adr" to "adrp"?

Not by adrp alone, it has to be complemented with addition. I mean addrp gives you the label's page address and you need to add the offset within the page.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

But why would objtool attempt to disassemble it? Does it actually attempt to

disassemble unreferenced spaces between functions? Note that the .Lzeros label doesn't make it into .o file, so there won't be anything in the symbol table to discover as potential entry point..

There is a similar patch (1253cab8a352) for x86. I guess that objtool/stacktool can be improved in this regard.

objtool is weird and arguably inconsistent. It does look at the symbol table(*), and detects the return instructions(**), yet insists on disassemble-ability of the whole .text segment... Oh well...

Cheers.

(*) For example it refuses to generated ORC metadata for the following snippet

.text
foo: ret

It insists on foo being complemented with '.type foo,@function' as well as meaningful .size.

(**) Since it does mark the region[s] past 'ret' as type:(und)