Message ID | c05291c698d37ac0d6d31602fe35b2accf2d518c.1710517542.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Enable build of full Xen for RISC-V | expand |
On 15.03.2024 19:06, Oleksii Kurochko wrote: > The cpu_relax() function, introduced in this commit, is anticipated to > support _zihintpause by the CPU. > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com> Looks like this can go in ahead of the other 14 patches? Jan
On Thu, 2024-03-21 at 14:26 +0100, Jan Beulich wrote: > On 15.03.2024 19:06, Oleksii Kurochko wrote: > > The cpu_relax() function, introduced in this commit, is anticipated > > to > > support _zihintpause by the CPU. > > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > Acked-by: Jan Beulich <jbeulich@suse.com> Thanks. > > Looks like this can go in ahead of the other 14 patches? Yes, it can. I'll rebase it ahead. ~ Oleksii
diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/include/asm/processor.h index 6db681d805..6846151717 100644 --- a/xen/arch/riscv/include/asm/processor.h +++ b/xen/arch/riscv/include/asm/processor.h @@ -12,6 +12,9 @@ #ifndef __ASSEMBLY__ +/* TODO: need to be implemeted */ +#define smp_processor_id() 0 + /* On stack VCPU state */ struct cpu_user_regs { @@ -53,6 +56,23 @@ struct cpu_user_regs unsigned long pregs; }; +/* TODO: need to implement */ +#define cpu_to_core(cpu) 0 +#define cpu_to_socket(cpu) 0 + +static inline void cpu_relax(void) +{ +#ifdef __riscv_zihintpause + /* Reduce instruction retirement. */ + __asm__ __volatile__ ( "pause" ); +#else + /* Encoding of the pause instruction */ + __asm__ __volatile__ ( ".insn 0x0100000F" ); +#endif + + barrier(); +} + static inline void wfi(void) { __asm__ __volatile__ ("wfi");
The cpu_relax() function, introduced in this commit, is anticipated to support _zihintpause by the CPU. Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> --- Changes in V6: - drop incorrect part in riscv/booting.txt and move the introduction of it to separate patch. - compiler check that __riscv_zihintpause exist was droped to separate patch. - minor fixes. - drop unnecessary comment. - update the commit message. --- Changes in V5: - Code style fixes. - drop introduced TOOLCHAIN_HAS_ZIHINTPAUSE and use as-insn instead and use as-insn istead. --- Changes in V4: - Change message -> subject in "Changes in V3" - Documentation about system requirement was added. In the future, it can be checked if the extension is supported by system __riscv_isa_extension_available() ( https://gitlab.com/xen-project/people/olkur/xen/-/commit/737998e89ed305eb92059300c374dfa53d2143fa ) - update cpu_relax() function to check if __riscv_zihintpause is supported by a toolchain - add conditional _zihintpause to -march if it is supported by a toolchain Changes in V3: - update the commit subject - rename get_processor_id to smp_processor_id - code style fixes - update the cpu_relax instruction: use pause instruction instead of div %0, %0, zero --- Changes in V2: - Nothing changed. Only rebase. --- xen/arch/riscv/include/asm/processor.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)