From: Sami Tolvanen <samitolvanen@google.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Andy Polyakov <appro@cryptogams.org>,
Zhihang Shao <zhihang.shao.iscas@gmail.com>,
linux-crypto@vger.kernel.org, linux-riscv@lists.infradead.org,
herbert@gondor.apana.org.au, paul.walmsley@sifive.com,
alex@ghiti.fr, zhang.lyra@gmail.com
Subject: Re: [PATCH v4] crypto: riscv/poly1305 - import OpenSSL/CRYPTOGAMS implementation
Date: Thu, 26 Jun 2025 08:58:58 -0700 [thread overview]
Message-ID: <CABCJKudbdWThfL71L-ccCpCeVZBW7Yhf3JXo9FvaPboRVaXOyg@mail.gmail.com> (raw)
In-Reply-To: <20250625035446.GC8962@sol>
On Tue, Jun 24, 2025 at 8:56 PM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Tue, Jun 24, 2025 at 11:13:49AM +0200, Andy Polyakov wrote:
> > > > +.globl poly1305_init
> > > > +.type poly1305_init,\@function
> > > > +poly1305_init:
> > > > +#ifdef __riscv_zicfilp
> > > > + lpad 0
> > > > +#endif
> > >
> > > The 'lpad' instructions aren't present in the upstream CRYPTOGAMS source.
> >
> > They are.
>
> I now see the latest version does have them. However, the description of this
> patch explicitly states it was taken from CRYPTOGAMS commit
> 33fe84bc21219a16825459b37c825bf4580a0a7b. Which is of course the one I looked
> at, and it did not have them. So the patch description is wrong.
>
> > > If they are necessary, this addition needs to be documented.
> > >
> > > But they appear to be unnecessary.
> >
> > They are better be there if Control Flow Integrity is on. It's the same deal
> > as with endbranch instruction on Intel and hint #34 on ARM. It's possible
> > that the kernel never engages CFI for itself, in which case all the
> > mentioned instructions are executed as nop-s. But note that here they are
> > compiled conditionally, so that if you don't compile the kernel with
> > -march=..._zicfilp_..., then they won't be there.
>
> There appears to be no kernel-mode support for Zicfilp yet. This would be the
> very first occurrence of the lpad instruction in the kernel source.
Of course, if the kernel actually ends up calling these functions
indirectly at some point, lpad alone isn't sufficient, we would need
to use SYM_TYPED_FUNC_START to emit CFI type information for them. I
assume if RISC-V gains kernel-mode Zicfilp support later, we would
have an arch-specific override for the SYM_TYPED_FUNC_START macro that
includes the lpad instruction, similarly to arm64 and BTI.
Also, if the kernel decides to use type-based landing pad labels for
finer-grained CFI, "lpad 0" isn't going to work anyway. Perhaps it
would make sense to just drop the lpad instruction in kernel builds
for now to avoid confusion?
Sami
next prev parent reply other threads:[~2025-06-26 15:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 3:31 [PATCH v4] crypto: riscv/poly1305 - import OpenSSL/CRYPTOGAMS implementation Zhihang Shao
2025-06-24 3:50 ` Eric Biggers
2025-06-24 9:13 ` Andy Polyakov
2025-06-25 3:54 ` Eric Biggers
2025-06-25 9:38 ` Andy Polyakov
2025-06-26 15:58 ` Sami Tolvanen [this message]
2025-06-27 9:07 ` Andy Polyakov
2025-06-27 16:10 ` Sami Tolvanen
2025-06-27 21:51 ` Eric Biggers
2025-06-30 9:55 ` Andy Polyakov
2025-06-24 11:08 ` Andy Polyakov
2025-07-06 23:35 ` Eric Biggers
-- strict thread matches above, loose matches on Subject: below --
2025-07-20 9:10 Zhihang Shao
2025-07-20 17:22 ` Eric Biggers
2025-07-23 9:47 ` Andy Polyakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABCJKudbdWThfL71L-ccCpCeVZBW7Yhf3JXo9FvaPboRVaXOyg@mail.gmail.com \
--to=samitolvanen@google.com \
--cc=alex@ghiti.fr \
--cc=appro@cryptogams.org \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=paul.walmsley@sifive.com \
--cc=zhang.lyra@gmail.com \
--cc=zhihang.shao.iscas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).