Message ID | b6328d9b5bbb9269066dc17d7c0fcb32fa935b2b.1700761381.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Enable build of full Xen for RISC-V | expand |
On 24.11.2023 11:30, Oleksii Kurochko wrote: > --- a/xen/arch/riscv/include/asm/current.h > +++ b/xen/arch/riscv/include/asm/current.h > @@ -3,6 +3,22 @@ > #ifndef __ASM_CURRENT_H > #define __ASM_CURRENT_H > > +#include <xen/percpu.h> > +#include <asm/processor.h> > + > +#ifndef __ASSEMBLY__ > + > +struct vcpu; I don't think you need this here? > +/* Which VCPU is "current" on this PCPU. */ > +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); > + > +#define current (this_cpu(curr_vcpu)) Nit: No need for the extra parentheses. > +#define set_current(vcpu) do { current = (vcpu); } while (0) > +#define get_cpu_current(cpu) (per_cpu(curr_vcpu, cpu)) Same here then. > +#define guest_cpu_user_regs() (0) 0 or NULL? Also perhaps better #define guest_cpu_user_regs() ({ BUG(); NULL; }) until it's properly implemented? > @@ -10,4 +26,8 @@ > unreachable(); \ > } while ( false ) > > +#define get_per_cpu_offset() __per_cpu_offset[get_processor_id()] I'd like to remind you that there's no get_processor_id() anymore. Jan
On Thu, 2023-12-14 at 16:55 +0100, Jan Beulich wrote: > On 24.11.2023 11:30, Oleksii Kurochko wrote: > > --- a/xen/arch/riscv/include/asm/current.h > > +++ b/xen/arch/riscv/include/asm/current.h > > @@ -3,6 +3,22 @@ > > #ifndef __ASM_CURRENT_H > > #define __ASM_CURRENT_H > > > > +#include <xen/percpu.h> > > +#include <asm/processor.h> > > + > > +#ifndef __ASSEMBLY__ > > + > > +struct vcpu; > > I don't think you need this here? Shouldn't forward declaration be for the case of curr_vcpu declaration in the next line ? > > > +/* Which VCPU is "current" on this PCPU. */ > > +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); > > + > > +#define current (this_cpu(curr_vcpu)) > > Nit: No need for the extra parentheses. Thanks. > > > +#define set_current(vcpu) do { current = (vcpu); } while (0) > > +#define get_cpu_current(cpu) (per_cpu(curr_vcpu, cpu)) > > Same here then. > > > +#define guest_cpu_user_regs() (0) > > 0 or NULL? Also perhaps better > > #define guest_cpu_user_regs() ({ BUG(); NULL; }) > > until it's properly implemented? Thanks. I'll use your definition. > > > @@ -10,4 +26,8 @@ > > unreachable(); \ > > } while ( false ) > > > > +#define get_per_cpu_offset() __per_cpu_offset[get_processor_id()] > > I'd like to remind you that there's no get_processor_id() anymore. Yeah, missed that. Thanks. ~ Oleksii
On 18.12.2023 11:39, Oleksii wrote: > On Thu, 2023-12-14 at 16:55 +0100, Jan Beulich wrote: >> On 24.11.2023 11:30, Oleksii Kurochko wrote: >>> --- a/xen/arch/riscv/include/asm/current.h >>> +++ b/xen/arch/riscv/include/asm/current.h >>> @@ -3,6 +3,22 @@ >>> #ifndef __ASM_CURRENT_H >>> #define __ASM_CURRENT_H >>> >>> +#include <xen/percpu.h> >>> +#include <asm/processor.h> >>> + >>> +#ifndef __ASSEMBLY__ >>> + >>> +struct vcpu; >> >> I don't think you need this here? > Shouldn't forward declaration be for the case of curr_vcpu declaration > in the next line ? I don't think so. In C forward decls are needed only when an otherwise undeclared type is used as type of a function parameter. (C++ is different in this regard.) Jan >>> +/* Which VCPU is "current" on this PCPU. */ >>> +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); >>> + >>> +#define current (this_cpu(curr_vcpu))
On Mon, 2023-12-18 at 12:28 +0100, Jan Beulich wrote: > On 18.12.2023 11:39, Oleksii wrote: > > On Thu, 2023-12-14 at 16:55 +0100, Jan Beulich wrote: > > > On 24.11.2023 11:30, Oleksii Kurochko wrote: > > > > --- a/xen/arch/riscv/include/asm/current.h > > > > +++ b/xen/arch/riscv/include/asm/current.h > > > > @@ -3,6 +3,22 @@ > > > > #ifndef __ASM_CURRENT_H > > > > #define __ASM_CURRENT_H > > > > > > > > +#include <xen/percpu.h> > > > > +#include <asm/processor.h> > > > > + > > > > +#ifndef __ASSEMBLY__ > > > > + > > > > +struct vcpu; > > > > > > I don't think you need this here? > > Shouldn't forward declaration be for the case of curr_vcpu > > declaration > > in the next line ? > > I don't think so. In C forward decls are needed only when an > otherwise > undeclared type is used as type of a function parameter. (C++ is > different > in this regard.) Thanks for clarifying; in this case, it can be dropped. ~ Oleksii > > > > +/* Which VCPU is "current" on this PCPU. */ > > > > +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); > > > > + > > > > +#define current (this_cpu(curr_vcpu)) >
diff --git a/xen/arch/riscv/include/asm/current.h b/xen/arch/riscv/include/asm/current.h index d84f15dc50..e105329bf3 100644 --- a/xen/arch/riscv/include/asm/current.h +++ b/xen/arch/riscv/include/asm/current.h @@ -3,6 +3,22 @@ #ifndef __ASM_CURRENT_H #define __ASM_CURRENT_H +#include <xen/percpu.h> +#include <asm/processor.h> + +#ifndef __ASSEMBLY__ + +struct vcpu; + +/* Which VCPU is "current" on this PCPU. */ +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); + +#define current (this_cpu(curr_vcpu)) +#define set_current(vcpu) do { current = (vcpu); } while (0) +#define get_cpu_current(cpu) (per_cpu(curr_vcpu, cpu)) + +#define guest_cpu_user_regs() (0) + #define switch_stack_and_jump(stack, fn) do { \ asm volatile ( \ "mv sp, %0\n" \ @@ -10,4 +26,8 @@ unreachable(); \ } while ( false ) +#define get_per_cpu_offset() __per_cpu_offset[get_processor_id()] + +#endif /* __ASSEMBLY__ */ + #endif /* __ASM_CURRENT_H */
Add minimal requied things to be able to build full Xen. Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> --- Changes in V2: - Nothing changed. Only rebase. --- xen/arch/riscv/include/asm/current.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)