From: Andrew Jones <andrew.jones@linux.dev>
To: "Clément Léger" <cleger@rivosinc.com>
Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <apatel@ventanamicro.com>,
Atish Patra <atishp@rivosinc.com>
Subject: Re: [kvm-unit-tests PATCH v4 2/5] riscv: use asm-offsets to generate SBI_EXT_HSM values
Date: Tue, 7 Jan 2025 18:27:00 +0100 [thread overview]
Message-ID: <20250107-feb21efc4c0815bd3ed7b173@orel> (raw)
In-Reply-To: <20241125162200.1630845-3-cleger@rivosinc.com>
On Mon, Nov 25, 2024 at 05:21:51PM +0100, Clément Léger wrote:
> Replace hardcoded values with generated ones using asm-offset. This
> allows to directly use ASM_SBI_EXT_HSM and ASM_SBI_EXT_HSM_START in
ASM_SBI_EXT_HSM_HART_STOP
> assembly.
>
> Signed-off-by: Clément Léger <cleger@rivosinc.com>
> ---
> riscv/Makefile | 2 +-
> riscv/sbi-asm.S | 6 ++++--
> riscv/asm-offsets-test.c | 12 ++++++++++++
> riscv/.gitignore | 1 +
> 4 files changed, 18 insertions(+), 3 deletions(-)
> create mode 100644 riscv/asm-offsets-test.c
> create mode 100644 riscv/.gitignore
>
> diff --git a/riscv/Makefile b/riscv/Makefile
> index 28b04156..a01ff8a3 100644
> --- a/riscv/Makefile
> +++ b/riscv/Makefile
> @@ -86,7 +86,7 @@ CFLAGS += -ffreestanding
> CFLAGS += -O2
> CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib -I $(SRCDIR)/riscv
>
> -asm-offsets = lib/riscv/asm-offsets.h
> +asm-offsets = lib/riscv/asm-offsets.h riscv/asm-offsets-test.h
> include $(SRCDIR)/scripts/asm-offsets.mak
>
> %.aux.o: $(SRCDIR)/lib/auxinfo.c
> diff --git a/riscv/sbi-asm.S b/riscv/sbi-asm.S
> index 923c2cec..193d9606 100644
> --- a/riscv/sbi-asm.S
> +++ b/riscv/sbi-asm.S
> @@ -7,6 +7,8 @@
> #define __ASSEMBLY__
> #include <asm/asm.h>
> #include <asm/csr.h>
> +#include <asm/asm-offsets.h>
> +#include <generated/asm-offsets-test.h>
>
> #include "sbi-tests.h"
>
> @@ -58,8 +60,8 @@ sbi_hsm_check:
> 7: lb t0, 0(t1)
> pause
> beqz t0, 7b
> - li a7, 0x48534d /* SBI_EXT_HSM */
> - li a6, 1 /* SBI_EXT_HSM_HART_STOP */
> + li a7, ASM_SBI_EXT_HSM
> + li a6, ASM_SBI_EXT_HSM_HART_STOP
> ecall
> 8: pause
> j 8b
> diff --git a/riscv/asm-offsets-test.c b/riscv/asm-offsets-test.c
> new file mode 100644
> index 00000000..116fe497
> --- /dev/null
> +++ b/riscv/asm-offsets-test.c
> @@ -0,0 +1,12 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include <kbuild.h>
> +#include <asm/sbi.h>
> +#include "sbi-tests.h"
> +
> +int main(void)
> +{
> + DEFINE(ASM_SBI_EXT_HSM, SBI_EXT_HSM);
> + DEFINE(ASM_SBI_EXT_HSM_HART_STOP, SBI_EXT_HSM_HART_STOP);
> +
> + return 0;
> +}
> diff --git a/riscv/.gitignore b/riscv/.gitignore
> new file mode 100644
> index 00000000..91713581
> --- /dev/null
> +++ b/riscv/.gitignore
> @@ -0,0 +1 @@
> +/asm-offsets-test.[hs]
> --
> 2.45.2
>
I like this and I should probably rework stuff to replace all the _IDX
macros in riscv/sbi-tests.h. I think we should call it sbi-asm-offsets.c,
though, and then change the Makefile and .gitignore changes to refer to
riscv/*-asm-offsets.h. That would allow us to keep test-specific asm-
offsets separate and avoid the name "asm-offsets-test" or similar which,
to me, conveys it's for testing asm-offsets.
Thanks,
drew
next prev parent reply other threads:[~2025-01-07 17:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 16:21 [kvm-unit-tests PATCH v4 0/5] riscv: add SBI SSE extension tests Clément Léger
2024-11-25 16:21 ` [kvm-unit-tests PATCH v4 1/5] kbuild: allow multiple asm-offsets file to be generated Clément Léger
2025-01-07 17:14 ` Andrew Jones
2024-11-25 16:21 ` [kvm-unit-tests PATCH v4 2/5] riscv: use asm-offsets to generate SBI_EXT_HSM values Clément Léger
2025-01-07 17:27 ` Andrew Jones [this message]
2025-01-07 17:33 ` Clément Léger
2024-11-25 16:21 ` [kvm-unit-tests PATCH v4 3/5] riscv: Add "-deps" handling for tests Clément Léger
2024-11-25 16:21 ` [kvm-unit-tests PATCH v4 4/5] riscv: lib: Add SBI SSE extension definitions Clément Léger
2025-01-08 13:03 ` Andrew Jones
2025-01-08 18:34 ` Atish Kumar Patra
2024-11-25 16:21 ` [kvm-unit-tests PATCH v4 5/5] riscv: sbi: Add SSE extension tests Clément Léger
2025-01-13 17:19 ` Andrew Jones
2025-01-13 17:22 ` Andrew Jones
2025-01-14 11:59 ` Andrew Jones
2025-02-13 9:27 ` Clément Léger
2025-01-06 10:11 ` [kvm-unit-tests PATCH v4 0/5] riscv: add SBI " Clément Léger
2025-01-06 13:55 ` Andrew Jones
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=20250107-feb21efc4c0815bd3ed7b173@orel \
--to=andrew.jones@linux.dev \
--cc=ajones@ventanamicro.com \
--cc=apatel@ventanamicro.com \
--cc=atishp@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
/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