RISC-V: Enable cbo.zero in usermode
Subsystems (3)
v2 cover RISC-V: Enable cbo.zero in usermode
In order for usermode to issue cbo.zero, it needs privilege granted to issue the extension instruction (patch 2) and to know that the extension is available and its block size (patch 3). Patch 1 could be separate from this series (it just fixes up some error messages), patches 4-5 convert the hwprobe selftest to a statically-linked, TAP test and patch 6 adds a new hwprobe test for the new information as well as testing CBO instructions can or cannot be issued as appropriate.
Thanks,
drew
v2:
- fixed build of the vector selftest
- changed this-cpu wrappers to just cpu wrappers and then pass smp_processor_id() at the callsite
- added comment to EXT_KEY macro
- picked up a couple r-b's
Andrew Jones (6):
RISC-V: Make zicbom/zicboz errors consistent
RISC-V: Enable cbo.zero in usermode
RISC-V: hwprobe: Expose Zicboz extension and its block size
RISC-V: selftests: Statically link hwprobe test
RISC-V: selftests: Convert hwprobe test to kselftest API
RISC-V: selftests: Add CBO tests
Documentation/riscv/hwprobe.rst | 6 + arch/riscv/include/asm/cpufeature.h | 2 + arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 2 + arch/riscv/kernel/cpufeature.c | 10 +- arch/riscv/kernel/setup.c | 4 + arch/riscv/kernel/smpboot.c | 4 + arch/riscv/kernel/sys_riscv.c | 46 +++-- .../testing/selftests/riscv/hwprobe/Makefile | 9 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 64 +++---- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 14 files changed, 280 insertions(+), 63 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.h
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 1/6 RISC-V: Make zicbom/zicboz errors consistent
commit c818fea83de4 ("riscv: say disabling zicbom if no or bad riscv,cbom-block-size found") improved the error messages for zicbom but zicboz was missed since its patches were in flight at the same time. Get 'em now.
--- arch/riscv/kernel/cpufeature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/cpufeature.c +2 -2
@@ -87,10 +87,10 @@ static bool riscv_isa_extension_check(int id)return true;case RISCV_ISA_EXT_ZICBOZ :if (!riscv_cboz_block_size) { -pr_err ("Zicboz detected in ISA string, but no cboz-block-size found\n" ); +pr_err ("Zicboz detected in ISA string, disabling as no cboz-block-size found\n" );return false; }else if (!is_power_of_2 (riscv_cboz_block_size)) { -pr_err ("cboz-block-size present, but is not a power-of-2\n" ); +pr_err ("Zicboz disabled as cboz-block-size present, but is not a power-of-2\n" );return false; }return true;
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 2/6 RISC-V: Enable cbo.zero in usermode
In reply to Andrew JonesWhen Zicboz is present, enable its instruction (cbo.zero) in usermode by setting its respective senvcfg bit. We don't bother trying to set this bit per-task, which would also require an interface for tasks to request enabling and/or disabling. Instead, permanently set the bit for each hart which has the extension when bringing it online.
--- arch/riscv/include/asm/cpufeature.h | 2 ++ arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++++++++++++++++ arch/riscv/kernel/cpufeature.c | 6 ++++++ arch/riscv/kernel/setup.c | 4 ++++ arch/riscv/kernel/smpboot.c | 4 ++++ 6 files changed, 33 insertions(+)
arch/riscv/include/asm/cpufeature.h +2 -0
@@ -30,4 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);/* Per-cpu ISA extensions. */ extern struct riscv_isainfo hart_isa[NR_CPUS ]; +void riscv_user_isa_enable (void ); +#endif
arch/riscv/include/asm/csr.h +1 -0
@@ -273,6 +273,7 @@#define CSR_SIE 0x104#define CSR_STVEC 0x105#define CSR_SCOUNTEREN 0x106 +#define CSR_SENVCFG 0x10a#define CSR_SSCRATCH 0x140#define CSR_SEPC 0x141#define CSR_SCAUSE 0x142
arch/riscv/include/asm/hwcap.h +16 -0
@@ -66,6 +66,7 @@#ifndef __ASSEMBLY__#include <linux/jump_label.h> +#include <asm/cpufeature.h> unsigned long riscv_get_elf_hwcap (void );
@@ -130,6 +131,21 @@ riscv_has_extension_unlikely(const unsigned long ext)return true; } +static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_likely (ext)) +return true; + +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +} + +static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_unlikely (ext)) +return true; + +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +}#endif #endif /* _ASM_RISCV_HWCAP_H */
arch/riscv/kernel/cpufeature.c +6 -0
@@ -391,6 +391,12 @@ unsigned long riscv_get_elf_hwcap(void)return hwcap; } +void riscv_user_isa_enable (void ) +{ +if (riscv_cpu_has_extension_unlikely (smp_processor_id (),RISCV_ISA_EXT_ZICBOZ )) +csr_set (CSR_SENVCFG ,ENVCFG_CBZE ); +} +#ifdef CONFIG_RISCV_ALTERNATIVE /* * Alternative patch sites consider 48 bits when determining when to patch
arch/riscv/kernel/setup.c +4 -0
@@ -25,6 +25,7 @@#include <asm/acpi.h> #include <asm/alternative.h> #include <asm/cacheflush.h> +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/early_ioremap.h> #include <asm/pgtable.h>
@@ -308,9 +309,12 @@ void __init setup_arch(char **cmdline_p)riscv_fill_hwcap ();init_rt_signal_env ();apply_boot_alternatives (); +if (IS_ENABLED (CONFIG_RISCV_ISA_ZICBOM ) &&riscv_isa_extension_available (NULL ,ZICBOM ))riscv_noncoherent_supported (); + +riscv_user_isa_enable (); }static int __init topology_init (void )
arch/riscv/kernel/smpboot.c +4 -0
@@ -25,6 +25,8 @@#include <linux/of.h> #include <linux/sched/task_stack.h> #include <linux/sched/mm.h> + +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/irq.h> #include <asm/mmu_context.h>
@@ -252,6 +254,8 @@ asmlinkage __visible void smp_callin(void) elf_hwcap &= ~COMPAT_HWCAP_ISA_V ; } +riscv_user_isa_enable (); +/* * Remote TLB flushes are ignored while the CPU is offline, so emit * a local TLB flush right now just in case.
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 53 lines · Andrew Jones
When Zicboz is present, enable its instruction (cbo.zero) in usermode by setting its respective senvcfg bit. We don't bother trying to set this bit per-task, which would also require an interface for tasks to request enabling and/or disabling. Instead, permanently set the bit for each hart which has the extension when bringing it online.
Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/include/asm/cpufeature.h | 2 ++ arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++++++++++++++++ arch/riscv/kernel/cpufeature.c | 6 ++++++ arch/riscv/kernel/setup.c | 4 ++++ arch/riscv/kernel/smpboot.c | 4 ++++ 6 files changed, 33 insertions(+)arch/riscv/include/asm/cpufeature.h +2
-0@@ -30,4 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);/* Per-cpu ISA extensions. */ extern struct riscv_isainfo hart_isa[NR_CPUS ]; +void riscv_user_isa_enable (void ); +#endif arch/riscv/include/asm/csr.h +1
-0@@ -273,6 +273,7 @@#define CSR_SIE 0x104#define CSR_STVEC 0x105#define CSR_SCOUNTEREN 0x106 +#define CSR_SENVCFG 0x10a#define CSR_SSCRATCH 0x140#define CSR_SEPC 0x141#define CSR_SCAUSE 0x142arch/riscv/include/asm/hwcap.h +1
-0@@ -66,6 +66,7 @@#ifndef __ASSEMBLY__#include <linux/jump_label.h> +#include <asm/cpufeature.h> unsigned long riscv_get_elf_hwcap (void );
arch/riscv/include/asm/hwcap.h riscv_has_extension_unlikely(const unsigned long ext) · line 137
Quoted 7 lines
arch/riscv/include/asm/hwcap.h +4
-0@@ -130,6 +131,21 @@ riscv_has_extension_unlikely(const unsigned long ext)return true; } +static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_likely (ext)) +return true;
It'd have been nice to put the explanation for this into the commit message I think, but w/e. Do it if there's a v3 I guess.
Thanks,
Conor.
Quoted 86 lines
arch/riscv/include/asm/hwcap.h +11
-0+ +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +} + +static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_unlikely (ext)) +return true; + +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +}#endif #endif /* _ASM_RISCV_HWCAP_H */ arch/riscv/kernel/cpufeature.c +6
-0@@ -391,6 +391,12 @@ unsigned long riscv_get_elf_hwcap(void)return hwcap; } +void riscv_user_isa_enable (void ) +{ +if (riscv_cpu_has_extension_unlikely (smp_processor_id (),RISCV_ISA_EXT_ZICBOZ )) +csr_set (CSR_SENVCFG ,ENVCFG_CBZE ); +} +#ifdef CONFIG_RISCV_ALTERNATIVE /* * Alternative patch sites consider 48 bits when determining when to patch arch/riscv/kernel/setup.c +4
-0@@ -25,6 +25,7 @@#include <asm/acpi.h> #include <asm/alternative.h> #include <asm/cacheflush.h> +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/early_ioremap.h> #include <asm/pgtable.h> @@ -308,9 +309,12 @@ void __init setup_arch(char **cmdline_p)riscv_fill_hwcap ();init_rt_signal_env ();apply_boot_alternatives (); +if (IS_ENABLED (CONFIG_RISCV_ISA_ZICBOM ) &&riscv_isa_extension_available (NULL ,ZICBOM ))riscv_noncoherent_supported (); + +riscv_user_isa_enable (); }static int __init topology_init (void )arch/riscv/kernel/smpboot.c +4
-0@@ -25,6 +25,8 @@#include <linux/of.h> #include <linux/sched/task_stack.h> #include <linux/sched/mm.h> + +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/irq.h> #include <asm/mmu_context.h> @@ -252,6 +254,8 @@ asmlinkage __visible void smp_callin(void) elf_hwcap &= ~COMPAT_HWCAP_ISA_V ; } +riscv_user_isa_enable (); +/* * Remote TLB flushes are ignored while the CPU is offline, so emit * a local TLB flush right now just in case. Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 57 lines · Conor Dooley
Quoted 56 lines · Andrew Jones
When Zicboz is present, enable its instruction (cbo.zero) in usermode by setting its respective senvcfg bit. We don't bother trying to set this bit per-task, which would also require an interface for tasks to request enabling and/or disabling. Instead, permanently set the bit for each hart which has the extension when bringing it online.
Signed-off-by Andrew Jones <[email protected]>--- arch/riscv/include/asm/cpufeature.h | 2 ++ arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++++++++++++++++ arch/riscv/kernel/cpufeature.c | 6 ++++++ arch/riscv/kernel/setup.c | 4 ++++ arch/riscv/kernel/smpboot.c | 4 ++++ 6 files changed, 33 insertions(+)arch/riscv/include/asm/cpufeature.h +2
-0@@ -30,4 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);/* Per-cpu ISA extensions. */ extern struct riscv_isainfo hart_isa[NR_CPUS ]; +void riscv_user_isa_enable (void ); +#endif arch/riscv/include/asm/csr.h +1
-0@@ -273,6 +273,7 @@#define CSR_SIE 0x104#define CSR_STVEC 0x105#define CSR_SCOUNTEREN 0x106 +#define CSR_SENVCFG 0x10a#define CSR_SSCRATCH 0x140#define CSR_SEPC 0x141#define CSR_SCAUSE 0x142arch/riscv/include/asm/hwcap.h +1
-0@@ -66,6 +66,7 @@#ifndef __ASSEMBLY__#include <linux/jump_label.h> +#include <asm/cpufeature.h> unsigned long riscv_get_elf_hwcap (void );@@ -130,6 +131,21 @@ riscv_has_extension_unlikely(const unsigned long ext)return true; }
Quoted 7 lines
arch/riscv/include/asm/hwcap.h riscv_has_extension_unlikely(const unsigned long ext) · line 137
Quoted 4 lines
arch/riscv/include/asm/hwcap.h +4
-0+static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_likely (ext)) +return true;It'd have been nice to put the explanation for this into the commit message I think, but w/e. Do it if there's a v3 I guess.
Do you mean the "why gate on the alternative config" explanation? If so, I can certainly do that for v3.
Quoted 2 lines
Reviewed-by Conor Dooley <[email protected]>
Thanks,
drew
Quoted 86 lines
Thanks,
Conor.Quoted 82 lines
arch/riscv/include/asm/hwcap.h +11
-0+ +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +} + +static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_unlikely (ext)) +return true; + +return __riscv_isa_extension_available (hart_isa[cpu].isa, ext); +}#endif #endif /* _ASM_RISCV_HWCAP_H */ arch/riscv/kernel/cpufeature.c +6
-0@@ -391,6 +391,12 @@ unsigned long riscv_get_elf_hwcap(void)return hwcap; } +void riscv_user_isa_enable (void ) +{ +if (riscv_cpu_has_extension_unlikely (smp_processor_id (),RISCV_ISA_EXT_ZICBOZ )) +csr_set (CSR_SENVCFG ,ENVCFG_CBZE ); +} +#ifdef CONFIG_RISCV_ALTERNATIVE /* * Alternative patch sites consider 48 bits when determining when to patch arch/riscv/kernel/setup.c +4
-0@@ -25,6 +25,7 @@#include <asm/acpi.h> #include <asm/alternative.h> #include <asm/cacheflush.h> +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/early_ioremap.h> #include <asm/pgtable.h> @@ -308,9 +309,12 @@ void __init setup_arch(char **cmdline_p)riscv_fill_hwcap ();init_rt_signal_env ();apply_boot_alternatives (); +if (IS_ENABLED (CONFIG_RISCV_ISA_ZICBOM ) &&riscv_isa_extension_available (NULL ,ZICBOM ))riscv_noncoherent_supported (); + +riscv_user_isa_enable (); }static int __init topology_init (void )arch/riscv/kernel/smpboot.c +4
-0@@ -25,6 +25,8 @@#include <linux/of.h> #include <linux/sched/task_stack.h> #include <linux/sched/mm.h> + +#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/irq.h> #include <asm/mmu_context.h> @@ -252,6 +254,8 @@ asmlinkage __visible void smp_callin(void) elf_hwcap &= ~COMPAT_HWCAP_ISA_V ; } +riscv_user_isa_enable (); +/* * Remote TLB flushes are ignored while the CPU is offline, so emit * a local TLB flush right now just in case. Signature · 1 line
2.41.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 15 lines · Andrew Jones
Quoted 6 lines · Conor Dooley
Quoted 4 lines · Andrew Jones
arch/riscv/include/asm/hwcap.h +0
-0@@ -130,6 +131,21 @@ riscv_has_extension_unlikely(const unsigned long ext)return true; }Quoted 7 lines
arch/riscv/include/asm/hwcap.h riscv_has_extension_unlikely(const unsigned long ext) · line 137
Quoted 4 lines
arch/riscv/include/asm/hwcap.h +4
-0+static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext) +{ +if (IS_ENABLED (CONFIG_RISCV_ALTERNATIVE ) &&riscv_has_extension_likely (ext)) +return true;It'd have been nice to put the explanation for this into the commit message I think, but w/e. Do it if there's a v3 I guess.
Quoted 2 lines
Do you mean the "why gate on the alternative config" explanation? If so, I can certainly do that for v3.
Yeah, should maybe have specified, sorry.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 3/6 RISC-V: hwprobe: Expose Zicboz extension and its block size
In reply to Andrew JonesExpose Zicboz through hwprobe and also provide a key to extract its respective block size. Opportunistically add a macro and apply it to current extensions in order to avoid duplicating code.
--- Documentation/riscv/hwprobe.rst | 6 ++++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 2 ++ arch/riscv/kernel/sys_riscv.c | 46 +++++++++++++++++++-------- 4 files changed, 41 insertions(+), 15 deletions(-)
Documentation/riscv/hwprobe.rst +6 -0
@@ -77,6 +77,9 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined in version 1.0 of the Bit-Manipulation ISA extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZICBOZ`: The Zicboz extension is supported, as + ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
@@ -97,3 +100,6 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are not supported at all and will generate a misaligned address fault. + +* :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which + represents the size of the Zicboz block in bytes.
arch/riscv/include/asm/hwprobe.h +1 -1
@@ -8,6 +8,6 @@#include <uapi/asm/hwprobe.h> -#define RISCV_HWPROBE_MAX_KEY 5 +#define RISCV_HWPROBE_MAX_KEY 6#endif
arch/riscv/include/uapi/asm/hwprobe.h +2 -0
@@ -29,6 +29,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZBA (1 << 3)#define RISCV_HWPROBE_EXT_ZBB (1 << 4)#define RISCV_HWPROBE_EXT_ZBS (1 << 5) +#define RISCV_HWPROBE_EXT_ZICBOZ (1 << 6)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
@@ -36,6 +37,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_MISALIGNED_FAST (3 << 0)#define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0)#define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) +#define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ #endif
arch/riscv/kernel/sys_riscv.c +32 -14
64 lines not on this page · raw message
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 3/6] RISC-V: hwprobe: Expose Zicboz extension and its block size
Quoted 90 lines · Andrew Jones
Expose Zicboz through hwprobe and also provide a key to extract its respective block size. Opportunistically add a macro and apply it to current extensions in order to avoid duplicating code.
Signed-off-by Andrew Jones <[email protected]>Reviewed-by Evan Green <[email protected]>--- Documentation/riscv/hwprobe.rst | 6 ++++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 2 ++ arch/riscv/kernel/sys_riscv.c | 46 +++++++++++++++++++-------- 4 files changed, 41 insertions(+), 15 deletions(-)Documentation/riscv/hwprobe.rst +6
-0@@ -77,6 +77,9 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined in version 1.0 of the Bit-Manipulation ISA extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZICBOZ`: The Zicboz extension is supported, as + ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.@@ -97,3 +100,6 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are not supported at all and will generate a misaligned address fault. + +* :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which + represents the size of the Zicboz block in bytes.arch/riscv/include/asm/hwprobe.h +1
-1@@ -8,6 +8,6 @@#include <uapi/asm/hwprobe.h> -#define RISCV_HWPROBE_MAX_KEY 5 +#define RISCV_HWPROBE_MAX_KEY 6#endif arch/riscv/include/uapi/asm/hwprobe.h +2
-0@@ -29,6 +29,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZBA (1 << 3)#define RISCV_HWPROBE_EXT_ZBB (1 << 4)#define RISCV_HWPROBE_EXT_ZBS (1 << 5) +#define RISCV_HWPROBE_EXT_ZICBOZ (1 << 6)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)@@ -36,6 +37,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_MISALIGNED_FAST (3 << 0)#define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0)#define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) +#define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ #endif arch/riscv/kernel/sys_riscv.c +2
-14@@ -145,26 +145,38 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define EXT_KEY (ext) \ + do { \
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 159
Quoted 10 lines
arch/riscv/kernel/sys_riscv.c +10
-0+ if (__riscv_isa_extension_available(isainfo->isa, RISCV_ISA_EXT_##ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##ext; \ + } while (false) + +/* +* Only use EXT_KEY() for extensions which can be exposed to userspace, +* regardless of the kernel's configuration, as no other checks, besides +* presence in the hart_isa bitmap, are made.
Thanks for adding the comment.
Thanks,
Conor.
Quoted 44 lines
arch/riscv/kernel/sys_riscv.c +20
-0+*/ +EXT_KEY (ZBA ); +EXT_KEY (ZBB ); +EXT_KEY (ZBS ); +EXT_KEY (ZICBOZ ); +#undef EXT_KEY }/* Now turn off reporting features if any CPU is missing it. */ pair->value &= ~missing; } +static bool hwprobe_ext0_has (const struct cpumask *cpus,unsigned long ext) +{ +struct riscv_hwprobe pair; + +hwprobe_isa_ext0 (&pair, cpus); +return (pair.value & ext); +} +static u64 hwprobe_misaligned (const struct cpumask *cpus) {int cpu;@@ -215,6 +227,12 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair, pair->value =hwprobe_misaligned (cpus);break ; +case RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE : + pair->value =0 ; +if (hwprobe_ext0_has (cpus,RISCV_HWPROBE_EXT_ZICBOZ )) + pair->value = riscv_cboz_block_size; +break ; +/* * For forward compatibility, unknown keys don't fail the whole * call, but get their element key set to -1 and value set to 0 Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 4/6 RISC-V: selftests: Statically link hwprobe test
In reply to Andrew JonesStatically linking makes it more convenient to copy the test to a minimal busybox environment.
--- tools/testing/selftests/riscv/hwprobe/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/riscv/hwprobe/Makefile +1 -1
@@ -7,4 +7,4 @@ TEST_GEN_PROGS := hwprobe include ../../lib.mk $(OUTPUT)/hwprobe: hwprobe.c sys_hwprobe.S - $(CC) -o$@ $(CFLAGS) $(LDFLAGS) $^ + $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 5/6 RISC-V: selftests: Convert hwprobe test to kselftest API
In reply to Andrew JonesReturning (exiting with) negative exit codes isn't user friendly, because the user must output the exit code with the shell, convert it from its unsigned 8-bit value back to the negative value, and then look up where that comes from in the code (which may be multiple places). Use the kselftests TAP interface, instead.
--- .../testing/selftests/riscv/hwprobe/hwprobe.c | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-)
tools/testing/selftests/riscv/hwprobe/hwprobe.c +20 -34
@@ -2,6 +2,8 @@#include <stddef.h> #include <asm/hwprobe.h> +#include "../../kselftest.h" +/* * Rather than relying on having a new enough libc to define this, just do it * ourselves. This way we don't need to be coupled to a new-enough libc to
@@ -16,6 +18,9 @@ int main(int argc, char **argv)unsigned long cpus;long out; +ksft_print_header (); +ksft_set_plan (5 ); +/* Fake the CPU_SET ops. */ cpus =-1 ;
@@ -25,13 +30,16 @@ int main(int argc, char **argv)*/ for (long i =0 ; i <8 ; i++) pairs[i].key = i; + out =riscv_hwprobe (pairs,8 ,1 , &cpus,0 );if (out !=0 ) -return -1 ; +ksft_exit_fail_msg ("hwprobe() failed with %ld\n" , out); +for (long i =0 ; i <4 ; ++i) {/* Fail if the kernel claims not to recognize a base key. */ if ((i <4 ) && (pairs[i].key != i)) -return -2 ; +ksft_exit_fail_msg ("Failed to recognize base key: key != i, " +"key=%ld, i=%ld\n" , pairs[i].key, i);if (pairs[i].key !=RISCV_HWPROBE_KEY_BASE_BEHAVIOR )continue ;
@@ -39,52 +47,30 @@ int main(int argc, char **argv)if (pairs[i].value &RISCV_HWPROBE_BASE_BEHAVIOR_IMA )continue ; -return -3 ; +ksft_exit_fail_msg ("Unexpected pair: (%ld, %ld)\n" , pairs[i].key, pairs[i].value); } -/* -* This should also work with a NULL CPU set, but should not work -* with an improperly supplied CPU set. -*/ out =riscv_hwprobe (pairs,8 ,0 ,0 ,0 ); -if (out !=0 ) -return -4 ; +ksft_test_result (out ==0 ,"NULL CPU set\n" ); out =riscv_hwprobe (pairs,8 ,0 , &cpus,0 ); -if (out ==0 ) -return -5 ; +ksft_test_result (out !=0 ,"Bad CPU set\n" ); out =riscv_hwprobe (pairs,8 ,1 ,0 ,0 ); -if (out ==0 ) -return -6 ; +ksft_test_result (out !=0 ,"NULL CPU set with non-zero count\n" ); -/* -* Check that keys work by providing one that we know exists, and -* checking to make sure the resultig pair is what we asked for. -*/ pairs[0 ].key =RISCV_HWPROBE_KEY_BASE_BEHAVIOR ; out =riscv_hwprobe (pairs,1 ,1 , &cpus,0 ); -if (out !=0 ) -return -7 ; -if (pairs[0 ].key !=RISCV_HWPROBE_KEY_BASE_BEHAVIOR ) -return -8 ; +ksft_test_result (out ==0 && pairs[0 ].key ==RISCV_HWPROBE_KEY_BASE_BEHAVIOR , +"Existing key is maintained\n" ); -/* -* Check that an unknown key gets overwritten with -1, -* but doesn't block elements after it. -*/ pairs[0 ].key =0x5555 ; pairs[1 ].key =1 ; pairs[1 ].value =0xAAAA ; out =riscv_hwprobe (pairs,2 ,0 ,0 ,0 ); -if (out !=0 ) -return -9 ; - -if (pairs[0 ].key !=-1 ) -return -10 ; - -if ((pairs[1 ].key !=1 ) || (pairs[1 ].value ==0xAAAA )) -return -11 ; +ksft_test_result (out ==0 && pairs[0 ].key ==-1 && + pairs[1 ].key ==1 && pairs[1 ].value !=0xAAAA , +"Unknown key overwritten with -1 and doesn't block other elements\n" ); -return 0 ; +ksft_finished (); }
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 6/6 RISC-V: selftests: Add CBO tests
In reply to Andrew JonesAdd hwprobe test for Zicboz and its block size. Also, when Zicboz is present, test that cbo.zero may be issued and works. Additionally test that the Zicbom instructions cause SIGILL and also that cbo.zero causes SIGILL when Zicboz is not present. Pinning the test to a subset of cpus with taskset will also restrict the hwprobe calls to that set.
--- .../testing/selftests/riscv/hwprobe/Makefile | 7 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 12 +- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 4 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.h
tools/testing/selftests/riscv/hwprobe/Makefile +6 -1
@@ -2,9 +2,14 @@ # Copyright (C) 2021 ARM Limited # Originally tools/testing/arm64/abi/Makefile -TEST_GEN_PROGS := hwprobe +CFLAGS += -I$(top_srcdir)/tools/include + +TEST_GEN_PROGS := hwprobe cbo include ../../lib.mk $(OUTPUT)/hwprobe: hwprobe.c sys_hwprobe.S $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^ + +$(OUTPUT)/cbo: cbo.c sys_hwprobe.S + $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
tools/testing/selftests/riscv/hwprobe/cbo.c new file +162 -0
162 lines not on this page · raw message
tools/testing/selftests/riscv/hwprobe/hwprobe.c +1 -11
@@ -1,17 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only -#include <stddef.h> -#include <asm/hwprobe.h> - +#include "hwprobe.h" #include "../../kselftest.h" -/* -* Rather than relying on having a new enough libc to define this, just do it -* ourselves. This way we don't need to be coupled to a new-enough libc to -* contain the call. -*/ -long riscv_hwprobe (struct riscv_hwprobe *pairs,size_t pair_count, -size_t cpu_count,unsigned long *cpus,unsigned int flags); -int main (int argc,char **argv) {struct riscv_hwprobe pairs[8 ];
tools/testing/selftests/riscv/hwprobe/hwprobe.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef SELFTEST_RISCV_HWPROBE_H +#define SELFTEST_RISCV_HWPROBE_H +#include <stddef.h> +#include <asm/hwprobe.h> + +/* +* Rather than relying on having a new enough libc to define this, just do it +* ourselves. This way we don't need to be coupled to a new-enough libc to +* contain the call. +*/ +long riscv_hwprobe (struct riscv_hwprobe *pairs,size_t pair_count, +size_t cpu_count,unsigned long *cpus,unsigned int flags); + +#endif
Signature · 7 lines
2.41.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
RE: [PATCH v2 6/6] RISC-V: selftests: Add CBO tests
Hi,
Quoted 113 lines
-----Original Message-----
From: linux-riscv <[email protected]> On Behalf Of Andrew Jones
Sent: Thursday, August 31, 2023 12:50 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 6/6] RISC-V: selftests: Add CBO testsAdd hwprobe test for Zicboz and its block size. Also, when Zicboz is present, test that cbo.zero may be issued and works. Additionally test that the Zicbom instructions cause SIGILL and also that cbo.zero causes SIGILL when Zicboz is not present. Pinning the test to a subset of cpus with taskset will also restrict the hwprobe calls to that set.
Signed-off-by Andrew Jones <[email protected]>--- .../testing/selftests/riscv/hwprobe/Makefile | 7 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 12 +- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 4 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.htools/testing/selftests/riscv/hwprobe/Makefile +6
-1@@ -2,9 +2,14 @@ # Copyright (C) 2021 ARM Limited # Originally tools/testing/arm64/abi/Makefile -TEST_GEN_PROGS := hwprobe +CFLAGS += -I$(top_srcdir)/tools/include + +TEST_GEN_PROGS := hwprobe cbo include ../../lib.mk $(OUTPUT)/hwprobe: hwprobe.c sys_hwprobe.S $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^ + +$(OUTPUT)/cbo: cbo.c sys_hwprobe.S + $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^tools/testing/selftests/riscv/hwprobe/cbo.c new file +26
-0@@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2023 Ventana Micro Systems Inc. +* +* Run with 'taskset -c <cpu-list> cbo' to only execute hwprobe on a +* subset of cpus, as well as only executing the tests on those cpus. +*/ +#define _GNU_SOURCE +#include <stdbool.h> +#include <stdint.h> +#include <sched.h> +#include <signal.h> +#include <assert.h> +#include <linux/compiler.h> +#include <asm/ucontext.h> + +#include "hwprobe.h" +#include "../../kselftest.h" + +static char mem[4096 ]__aligned(4096) = { [0 ...4095 ] =0xa5 }; + +static bool illegal_insn; + +static void sigill_handler (int sig,siginfo_t *info,void *context) +{ + unsigned long *regs = (unsigned long *)&((ucontext_t *)context)-Quoted 1 line
uc_mcontext;tools/testing/selftests/riscv/hwprobe/cbo.c new file +32
-0+uint32_t insn = *(uint32_t *)regs[0 ]; + +assert (insn >>20 == regs[11 ] && + (insn & ((1 <<20 ) -1 )) == (10 <<15 |2 <<12 |0 <<7 |15 )); + + illegal_insn = true; + regs[0 ] +=4 ; +} + +static void cbo_insn (int fn,char *base) +{ + asmvolatile ( +"mv a0, %0\n" +"li a1, %1\n" +".4byte %1 << 20 | 10 << 15 | 2 << 12 | 0 << 7 | 15\n" + : :"r" (base),"i" (fn) :"a0" ,"a1" ,"memory" ); +} + +static void cbo_inval (char *base) {cbo_insn (0 , base); } +static void cbo_clean (char *base) {cbo_insn (1 , base); } +static void cbo_flush (char *base) {cbo_insn (2 , base); } +static void cbo_zero (char *base) {cbo_insn (4 , base); } + +static void test_no_zicbom (void ) +{ + illegal_insn = false; +cbo_clean (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.clean\n" ); + + illegal_insn = false; +cbo_flush (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.flush\n" );
tools/testing/selftests/riscv/hwprobe/cbo.c line 68
Quoted 10 lines
tools/testing/selftests/riscv/hwprobe/cbo.c new file +10
-0+ + illegal_insn = false; +cbo_inval (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.inval\n" ); +} + +static void test_no_zicboz (void ) +{ + illegal_insn = false; +cbo_clean (&mem[0 ]);
Seems we need to call cbo_zero() instead of cbo_clean().
BRs,
Xiao
Quoted 3 lines
tools/testing/selftests/riscv/hwprobe/cbo.c new file +3
-0+ksft_test_result (illegal_insn,"No cbo.zero\n" ); +} +
[...]
Quoted 6 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 6/6] RISC-V: selftests: Add CBO tests
Quoted 119 lines · Xiao W
Hi,
Quoted 117 lines
-----Original Message-----
From: linux-riscv <[email protected]> On Behalf Of Andrew Jones
Sent: Thursday, August 31, 2023 12:50 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 6/6] RISC-V: selftests: Add CBO testsAdd hwprobe test for Zicboz and its block size. Also, when Zicboz is present, test that cbo.zero may be issued and works. Additionally test that the Zicbom instructions cause SIGILL and also that cbo.zero causes SIGILL when Zicboz is not present. Pinning the test to a subset of cpus with taskset will also restrict the hwprobe calls to that set.
Signed-off-by Andrew Jones <[email protected]>--- .../testing/selftests/riscv/hwprobe/Makefile | 7 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 12 +- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 4 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.htools/testing/selftests/riscv/hwprobe/Makefile +6
-1@@ -2,9 +2,14 @@ # Copyright (C) 2021 ARM Limited # Originally tools/testing/arm64/abi/Makefile -TEST_GEN_PROGS := hwprobe +CFLAGS += -I$(top_srcdir)/tools/include + +TEST_GEN_PROGS := hwprobe cbo include ../../lib.mk $(OUTPUT)/hwprobe: hwprobe.c sys_hwprobe.S $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^ + +$(OUTPUT)/cbo: cbo.c sys_hwprobe.S + $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^tools/testing/selftests/riscv/hwprobe/cbo.c new file +26
-0@@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2023 Ventana Micro Systems Inc. +* +* Run with 'taskset -c <cpu-list> cbo' to only execute hwprobe on a +* subset of cpus, as well as only executing the tests on those cpus. +*/ +#define _GNU_SOURCE +#include <stdbool.h> +#include <stdint.h> +#include <sched.h> +#include <signal.h> +#include <assert.h> +#include <linux/compiler.h> +#include <asm/ucontext.h> + +#include "hwprobe.h" +#include "../../kselftest.h" + +static char mem[4096 ]__aligned(4096) = { [0 ...4095 ] =0xa5 }; + +static bool illegal_insn; + +static void sigill_handler (int sig,siginfo_t *info,void *context) +{ + unsigned long *regs = (unsigned long *)&((ucontext_t *)context)-Quoted 1 line
uc_mcontext;tools/testing/selftests/riscv/hwprobe/cbo.c new file +36
-0+uint32_t insn = *(uint32_t *)regs[0 ]; + +assert (insn >>20 == regs[11 ] && + (insn & ((1 <<20 ) -1 )) == (10 <<15 |2 <<12 |0 <<7 |15 )); + + illegal_insn = true; + regs[0 ] +=4 ; +} + +static void cbo_insn (int fn,char *base) +{ + asmvolatile ( +"mv a0, %0\n" +"li a1, %1\n" +".4byte %1 << 20 | 10 << 15 | 2 << 12 | 0 << 7 | 15\n" + : :"r" (base),"i" (fn) :"a0" ,"a1" ,"memory" ); +} + +static void cbo_inval (char *base) {cbo_insn (0 , base); } +static void cbo_clean (char *base) {cbo_insn (1 , base); } +static void cbo_flush (char *base) {cbo_insn (2 , base); } +static void cbo_zero (char *base) {cbo_insn (4 , base); } + +static void test_no_zicbom (void ) +{ + illegal_insn = false; +cbo_clean (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.clean\n" ); + + illegal_insn = false; +cbo_flush (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.flush\n" ); + + illegal_insn = false; +cbo_inval (&mem[0 ]); +ksft_test_result (illegal_insn,"No cbo.inval\n" );
Quoted 8 lines
tools/testing/selftests/riscv/hwprobe/cbo.c line 68
Quoted 6 lines
tools/testing/selftests/riscv/hwprobe/cbo.c new file +6
-0+} + +static void test_no_zicboz (void ) +{ + illegal_insn = false; +cbo_clean (&mem[0 ]);Seems we need to call
cbo_zero()instead ofcbo_clean().
Nice catch, Xiao. Copy+paste mistake... Will fix for v3.
Thanks,
drew
Quoted 14 lines
BRs,
XiaoQuoted 3 lines
tools/testing/selftests/riscv/hwprobe/cbo.c new file +3
-0+ksft_test_result (illegal_insn,"No cbo.zero\n" ); +} +[...]
Quoted 6 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 8 lines · Andrew Jones
In order for usermode to issue cbo.zero, it needs privilege granted to issue the extension instruction (patch 2) and to know that the extension is available and its block size (patch 3). Patch 1 could be separate from this series (it just fixes up some error messages), patches 4-5 convert the hwprobe selftest to a statically-linked, TAP test and patch 6 adds a new hwprobe test for the new information as well as testing CBO instructions can or cannot be issued as appropriate.
Quoted 5 lines
Thanks,
drewv2:
- fixed build of the vector selftest
for-next also needs commit 25696067202f ("selftests: riscv: Fix compilation error with vstate_exec_nolibc.c") in order for the vector selftest to build.
Thanks,
drew
Quoted 22 lines
- changed this-cpu wrappers to just cpu wrappers and then pass
smp_processor_id()at the callsite
- added comment toEXT_KEYmacro
- picked up a couple r-b'sAndrew Jones (6):
RISC-V: Make zicbom/zicboz errors consistent
RISC-V: Enable cbo.zero in usermode
RISC-V: hwprobe: Expose Zicboz extension and its block size
RISC-V: selftests: Statically link hwprobe test
RISC-V: selftests: Convert hwprobe test to kselftest API
RISC-V: selftests: Add CBO testsDocumentation/riscv/hwprobe.rst | 6 + arch/riscv/include/asm/cpufeature.h | 2 + arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 2 + arch/riscv/kernel/cpufeature.c | 10 +- arch/riscv/kernel/setup.c | 4 + arch/riscv/kernel/smpboot.c | 4 +
Quoted 12 lines
arch/riscv/kernel/sys_riscv.c | 46 +++-- .../testing/selftests/riscv/hwprobe/Makefile | 9 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 64 +++---- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 14 files changed, 280 insertions(+), 63 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.hSignature · 1 line
2.41.0
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Palmer Dabbelt
maintainerQuoted 12 lines · On Wed, 30 Aug 2023 09:52:46 PDT (-0700), [email protected] wrote:
Quoted 11 lines · Andrew Jones
In order for usermode to issue cbo.zero, it needs privilege granted to issue the extension instruction (patch 2) and to know that the extension is available and its block size (patch 3). Patch 1 could be separate from this series (it just fixes up some error messages), patches 4-5 convert the hwprobe selftest to a statically-linked, TAP test and patch 6 adds a new hwprobe test for the new information as well as testing CBO instructions can or cannot be issued as appropriate.
Thanks,
drew
Quoted 6 lines
Quoted 2 lines
v2:
- fixed build of the vector selftestfor-next also needs commit
25696067202f("selftests: riscv: Fix compilation error withvstate_exec_nolibc.c") in order for the vector selftest to build.
Thanks. I'm going to hold off on this one for this week's PR and then pick it up for next week, assuming no other issues crop up.
Quoted 37 lines
Thanks,
drewQuoted 34 lines
- changed this-cpu wrappers to just cpu wrappers and then pass
smp_processor_id()at the callsite
- added comment toEXT_KEYmacro
- picked up a couple r-b'sAndrew Jones (6):
RISC-V: Make zicbom/zicboz errors consistent
RISC-V: Enable cbo.zero in usermode
RISC-V: hwprobe: Expose Zicboz extension and its block size
RISC-V: selftests: Statically link hwprobe test
RISC-V: selftests: Convert hwprobe test to kselftest API
RISC-V: selftests: Add CBO testsDocumentation/riscv/hwprobe.rst | 6 + arch/riscv/include/asm/cpufeature.h | 2 + arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 16 ++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 2 + arch/riscv/kernel/cpufeature.c | 10 +- arch/riscv/kernel/setup.c | 4 + arch/riscv/kernel/smpboot.c | 4 + arch/riscv/kernel/sys_riscv.c | 46 +++-- .../testing/selftests/riscv/hwprobe/Makefile | 9 +- tools/testing/selftests/riscv/hwprobe/cbo.c | 162 ++++++++++++++++++ .../testing/selftests/riscv/hwprobe/hwprobe.c | 64 +++---- .../testing/selftests/riscv/hwprobe/hwprobe.h | 15 ++ 14 files changed, 280 insertions(+), 63 deletions(-) create mode 100644 tools/testing/selftests/riscv/hwprobe/cbo.c create mode 100644 tools/testing/selftests/riscv/hwprobe/hwprobe.h--
2.41.0
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv