[PATCH] linux-user/riscv: Add new extensions to hwprobe

Robbin Ehn posted 1 patch 1 year, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/bc82203b72d7efb30f1b4a8f9eb3d94699799dc8.camel@rivosinc.com
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
[PATCH] linux-user/riscv: Add new extensions to hwprobe
Posted by Robbin Ehn 1 year, 3 months ago
This patch adds the new extensions in
linux 6.5 to the hwprobe syscall.

And fixes RVC check to OR with correct value.
The previous variable contains 0 therefore it
did work.

Signed-off-by: Robbin Ehn <rehn@rivosinc.com>
---
 linux-user/syscall.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9353268cc1..c46a0b1493 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9049,6 +9049,10 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
 #define RISCV_HWPROBE_KEY_IMA_EXT_0     4
 #define     RISCV_HWPROBE_IMA_FD       (1 << 0)
 #define     RISCV_HWPROBE_IMA_C        (1 << 1)
+#define     RISCV_HWPROBE_IMA_V        (1 << 2)
+#define     RISCV_HWPROBE_EXT_ZBA      (1 << 3)
+#define     RISCV_HWPROBE_EXT_ZBB      (1 << 4)
+#define     RISCV_HWPROBE_EXT_ZBS      (1 << 5)
 
 #define RISCV_HWPROBE_KEY_CPUPERF_0     5
 #define     RISCV_HWPROBE_MISALIGNED_UNKNOWN     (0 << 0)
@@ -9096,7 +9100,15 @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env,
                     riscv_has_ext(env, RVD) ?
                     RISCV_HWPROBE_IMA_FD : 0;
             value |= riscv_has_ext(env, RVC) ?
-                     RISCV_HWPROBE_IMA_C : pair->value;
+                     RISCV_HWPROBE_IMA_C : 0;
+            value |= riscv_has_ext(env, RVV) ?
+                     RISCV_HWPROBE_IMA_V : 0;
+            value |= cfg->ext_zba ?
+                     RISCV_HWPROBE_EXT_ZBA : 0;
+            value |= cfg->ext_zbb ?
+                     RISCV_HWPROBE_EXT_ZBB : 0;
+            value |= cfg->ext_zbs ?
+                     RISCV_HWPROBE_EXT_ZBS : 0;
             __put_user(value, &pair->value);
             break;
         case RISCV_HWPROBE_KEY_CPUPERF_0:
-- 
2.39.2
Re: [PATCH] linux-user/riscv: Add new extensions to hwprobe
Posted by Alistair Francis 1 year, 2 months ago
On Tue, Aug 29, 2023 at 12:58 AM Robbin Ehn <rehn@rivosinc.com> wrote:
>
> This patch adds the new extensions in
> linux 6.5 to the hwprobe syscall.
>
> And fixes RVC check to OR with correct value.
> The previous variable contains 0 therefore it
> did work.
>
> Signed-off-by: Robbin Ehn <rehn@rivosinc.com>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  linux-user/syscall.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 9353268cc1..c46a0b1493 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9049,6 +9049,10 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
>  #define RISCV_HWPROBE_KEY_IMA_EXT_0     4
>  #define     RISCV_HWPROBE_IMA_FD       (1 << 0)
>  #define     RISCV_HWPROBE_IMA_C        (1 << 1)
> +#define     RISCV_HWPROBE_IMA_V        (1 << 2)
> +#define     RISCV_HWPROBE_EXT_ZBA      (1 << 3)
> +#define     RISCV_HWPROBE_EXT_ZBB      (1 << 4)
> +#define     RISCV_HWPROBE_EXT_ZBS      (1 << 5)
>
>  #define RISCV_HWPROBE_KEY_CPUPERF_0     5
>  #define     RISCV_HWPROBE_MISALIGNED_UNKNOWN     (0 << 0)
> @@ -9096,7 +9100,15 @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env,
>                      riscv_has_ext(env, RVD) ?
>                      RISCV_HWPROBE_IMA_FD : 0;
>              value |= riscv_has_ext(env, RVC) ?
> -                     RISCV_HWPROBE_IMA_C : pair->value;
> +                     RISCV_HWPROBE_IMA_C : 0;
> +            value |= riscv_has_ext(env, RVV) ?
> +                     RISCV_HWPROBE_IMA_V : 0;
> +            value |= cfg->ext_zba ?
> +                     RISCV_HWPROBE_EXT_ZBA : 0;
> +            value |= cfg->ext_zbb ?
> +                     RISCV_HWPROBE_EXT_ZBB : 0;
> +            value |= cfg->ext_zbs ?
> +                     RISCV_HWPROBE_EXT_ZBS : 0;
>              __put_user(value, &pair->value);
>              break;
>          case RISCV_HWPROBE_KEY_CPUPERF_0:
> --
> 2.39.2
>
>
Re: [PATCH] linux-user/riscv: Add new extensions to hwprobe
Posted by Alistair Francis 1 year, 2 months ago
On Tue, Aug 29, 2023 at 12:58 AM Robbin Ehn <rehn@rivosinc.com> wrote:
>
> This patch adds the new extensions in
> linux 6.5 to the hwprobe syscall.
>
> And fixes RVC check to OR with correct value.
> The previous variable contains 0 therefore it
> did work.
>
> Signed-off-by: Robbin Ehn <rehn@rivosinc.com>

Acked-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  linux-user/syscall.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 9353268cc1..c46a0b1493 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9049,6 +9049,10 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
>  #define RISCV_HWPROBE_KEY_IMA_EXT_0     4
>  #define     RISCV_HWPROBE_IMA_FD       (1 << 0)
>  #define     RISCV_HWPROBE_IMA_C        (1 << 1)
> +#define     RISCV_HWPROBE_IMA_V        (1 << 2)
> +#define     RISCV_HWPROBE_EXT_ZBA      (1 << 3)
> +#define     RISCV_HWPROBE_EXT_ZBB      (1 << 4)
> +#define     RISCV_HWPROBE_EXT_ZBS      (1 << 5)
>
>  #define RISCV_HWPROBE_KEY_CPUPERF_0     5
>  #define     RISCV_HWPROBE_MISALIGNED_UNKNOWN     (0 << 0)
> @@ -9096,7 +9100,15 @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env,
>                      riscv_has_ext(env, RVD) ?
>                      RISCV_HWPROBE_IMA_FD : 0;
>              value |= riscv_has_ext(env, RVC) ?
> -                     RISCV_HWPROBE_IMA_C : pair->value;
> +                     RISCV_HWPROBE_IMA_C : 0;
> +            value |= riscv_has_ext(env, RVV) ?
> +                     RISCV_HWPROBE_IMA_V : 0;
> +            value |= cfg->ext_zba ?
> +                     RISCV_HWPROBE_EXT_ZBA : 0;
> +            value |= cfg->ext_zbb ?
> +                     RISCV_HWPROBE_EXT_ZBB : 0;
> +            value |= cfg->ext_zbs ?
> +                     RISCV_HWPROBE_EXT_ZBS : 0;
>              __put_user(value, &pair->value);
>              break;
>          case RISCV_HWPROBE_KEY_CPUPERF_0:
> --
> 2.39.2
>
>
Re: [PATCH] linux-user/riscv: Add new extensions to hwprobe
Posted by Richard Henderson 1 year, 3 months ago
On 8/28/23 07:56, Robbin Ehn wrote:
> This patch adds the new extensions in
> linux 6.5 to the hwprobe syscall.
> 
> And fixes RVC check to OR with correct value.
> The previous variable contains 0 therefore it
> did work.
> 
> Signed-off-by: Robbin Ehn<rehn@rivosinc.com>
> ---
>   linux-user/syscall.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)

Acked-by: Richard Henderson <richard.henderson@linaro.org>


r~