From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Xi Ruoyao <xry111@xry111.site>
Cc: Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
linux-crypto@vger.kernel.org, loongarch@lists.linux.dev,
Jinyang He <hejinyang@loongson.cn>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v4 1/4] LoongArch: vDSO: Wire up getrandom() vDSO implementation
Date: Wed, 28 Aug 2024 16:26:07 +0200 [thread overview]
Message-ID: <Zs8zf5SWLUVgbu1q@zx2c4.com> (raw)
In-Reply-To: <20240827132018.88854-2-xry111@xry111.site>
On Tue, Aug 27, 2024 at 09:20:14PM +0800, Xi Ruoyao wrote:
> diff --git a/arch/loongarch/vdso/vgetrandom-chacha.S b/arch/loongarch/vdso/vgetrandom-chacha.S
> new file mode 100644
> index 000000000000..2e42198f2faf
> --- /dev/null
> +++ b/arch/loongarch/vdso/vgetrandom-chacha.S
> @@ -0,0 +1,239 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2024 Xi Ruoyao <xry111@xry111.site>. All Rights Reserved.
> + */
> +
> +#include <asm/asm.h>
> +#include <asm/regdef.h>
> +#include <linux/linkage.h>
> +
> +.text
> +
> +/* Salsa20 quarter-round */
> +.macro QR a b c d
> + add.w \a, \a, \b
> + xor \d, \d, \a
> + rotri.w \d, \d, 16
> +
> + add.w \c, \c, \d
> + xor \b, \b, \c
> + rotri.w \b, \b, 20
> +
> + add.w \a, \a, \b
> + xor \d, \d, \a
> + rotri.w \d, \d, 24
> +
> + add.w \c, \c, \d
> + xor \b, \b, \c
> + rotri.w \b, \b, 25
> +.endm
> +
> +/*
> + * Very basic LoongArch implementation of ChaCha20. Produces a given positive
> + * number of blocks of output with a nonce of 0, taking an input key and
> + * 8-byte counter. Importantly does not spill to the stack. Its arguments
> + * are:
> + *
> + * a0: output bytes
> + * a1: 32-byte key input
> + * a2: 8-byte counter input/output
> + * a3: number of 64-byte blocks to write to output
> + */
> +SYM_FUNC_START(__arch_chacha20_blocks_nostack)
I can confirm this works:
$ loongarch64-unknown-linux-gnu-gcc -std=gnu99 -D_GNU_SOURCE= -idirafter tools/testing/selftests/../../../tools/include -idirafter tools/testing/selftests/../../../arch/loongarch/include -idirafter tools/testing/selftests/../../../include -D__ASSEMBLY__ -Wa,--noexecstack vdso_test_chacha.c tools/testing/selftests/../../../tools/arch/loongarch/vdso/vgetrandom-chacha.S -o tools/testing/selftests/vDSO/vdso_test_chacha -static
$ qemu-loongarch64 ./vdso_test_chacha
TAP version 13
1..1
ok 1 chacha: PASS
Just waiting now on a v5 as discussed and acks from the LoongArch maintainers on that v5.
Jason
next prev parent reply other threads:[~2024-08-28 14:26 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 13:20 [PATCH v4 0/4] LoongArch: Implement getrandom() in vDSO Xi Ruoyao
2024-08-27 13:20 ` [PATCH v4 1/4] LoongArch: vDSO: Wire up getrandom() vDSO implementation Xi Ruoyao
2024-08-27 13:36 ` Xi Ruoyao
2024-08-27 13:49 ` Jason A. Donenfeld
2024-08-27 14:26 ` Xi Ruoyao
2024-08-27 14:30 ` Jason A. Donenfeld
2024-08-27 15:07 ` Xi Ruoyao
2024-08-28 14:26 ` Jason A. Donenfeld [this message]
2024-08-28 14:33 ` Jason A. Donenfeld
2024-08-27 13:20 ` [PATCH v4 2/4] selftests/vDSO: Add --cflags for pkg-config command querying libsodium Xi Ruoyao
2024-08-27 13:54 ` Jason A. Donenfeld
2024-08-27 13:20 ` [PATCH v4 3/4] selftests/vDSO: Use KHDR_INCLUDES to locate UAPI headers for vdso_test_getrandom Xi Ruoyao
2024-08-27 13:58 ` Jason A. Donenfeld
2024-08-27 14:07 ` LEROY Christophe
2024-08-27 14:15 ` Jason A. Donenfeld
2024-08-27 14:41 ` Xi Ruoyao
2024-08-27 14:50 ` Christophe Leroy
2024-08-27 15:00 ` Jason A. Donenfeld
2024-08-27 15:05 ` Xi Ruoyao
2024-08-27 15:10 ` Jason A. Donenfeld
2024-08-27 15:28 ` Xi Ruoyao
2024-08-27 15:29 ` Jason A. Donenfeld
2024-08-28 11:36 ` Jason A. Donenfeld
2024-08-28 12:00 ` Xi Ruoyao
2024-08-27 15:12 ` Christophe Leroy
2024-08-27 13:20 ` [PATCH v4 4/4] selftests/vDSO: Enable vdso getrandom tests for LoongArch Xi Ruoyao
2024-08-27 14:00 ` Jason A. Donenfeld
2024-08-27 14:45 ` Xi Ruoyao
2024-08-27 13:51 ` [PATCH v4 0/4] LoongArch: Implement getrandom() in vDSO Jason A. Donenfeld
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=Zs8zf5SWLUVgbu1q@zx2c4.com \
--to=jason@zx2c4.com \
--cc=arnd@arndb.de \
--cc=chenhuacai@kernel.org \
--cc=hejinyang@loongson.cn \
--cc=kernel@xen0n.name \
--cc=linux-crypto@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=xry111@xry111.site \
--cc=yangtiezhu@loongson.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.