Re: [GIT PULL] Crypto Fixes for 5.15

From: Linus Torvalds
Date: Fri Oct 29 2021 - 13:39:59 EST


On Thu, Oct 28, 2021 at 9:14 PM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> This push fixes a build-time warning in x86/sm4.

Hmm..

> Tianjia Zhang (1):
> crypto: x86/sm4 - Fix invalid section entry size

So I do wonder why the crypto code asm tends to use such complex
".section" directives.

Almost everythign else in the kernel just uses

.section <name>,"a"

for data (and "ax" for text).

The crypto code uses that very subtle "M" flag which allows the linker
to merge data, but how much of a win is that added complexity? Now you
need to get the sizes exactly right, and you hit tooling issues.

Plus, I get the feeling that some people have just copied-and-pasted
those things, and don't necessarily realize just _how_ subtle 'M'
sections are.

How much of a data savings is it to have this complexity? Particularly
since I suspect most of the time these things end up being individual
modules, and never actually get linked together at all?

So I get this very strong feeling that the crypto code is doing
complicated and fragile things that cause tooling issues - and does so
for no good reason and no actual real-life upside.

I've pulled this, but I do suspect that all the fancy

.section .rodata.xyz, "aM", @progbits, abc

could just as well be

.section .rodata, "a"

instead, and you guys are only causing problems for yourself by trying
to be clever in pointless ways.

Linus