From: Oleksii <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
Alistair Francis <alistair.francis@wdc.com>,
Bob Eshleman <bobbyeshleman@gmail.com>,
Connor Davis <connojdavis@gmail.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 18/23] xen/riscv: add minimal stuff to processor.h to build full Xen
Date: Tue, 05 Mar 2024 18:34:50 +0100 [thread overview]
Message-ID: <35595505b2733f7200a62177338cc3ba98f6afaa.camel@gmail.com> (raw)
In-Reply-To: <bd916469-f764-4d2e-bce6-52e3ed5e74d1@suse.com>
On Tue, 2024-03-05 at 09:05 +0100, Jan Beulich wrote:
> On 26.02.2024 18:39, Oleksii Kurochko wrote:
> > --- /dev/null
> > +++ b/docs/misc/riscv/booting.txt
> > @@ -0,0 +1,8 @@
> > +System requirements
> > +===================
> > +
> > +The following extensions are expected to be supported by a system
> > on which
> > +Xen is run:
> > +- Zihintpause:
> > + On a system that doesn't have this extension, cpu_relax() should
> > be
> > + implemented properly. Otherwise, an illegal instruction
> > exception will arise.
>
> This decision wants justifying in the (presently once again empty)
> description.
>
> Furthermore - will there really be an illegal instruction exception
> otherwise?
> Isn't it the nature of hints that they are NOPs if not serving their
> designated
> purpose?
You are right, they are NOPs, so I will drop the part about an illegal
instruction exception.
> > --- a/xen/arch/riscv/arch.mk
> > +++ b/xen/arch/riscv/arch.mk
> > @@ -5,6 +5,12 @@ $(call cc-options-
> > add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> >
> > CFLAGS-$(CONFIG_RISCV_64) += -mabi=lp64
> >
> > +ifeq ($(CONFIG_RISCV_64),y)
> > +has_zihintpause = $(call as-insn,$(CC) -mabi=lp64 -
> > march=rv64i_zihintpause, "pause",_zihintpause,)
> > +else
> > +has_zihintpause = $(call as-insn,$(CC) -mabi=ilp32 -
> > march=rv32i_zihintpause, "pause",_zihintpause,)
> > +endif
>
> Considering that down the road likely more such tests will want
> adding, I think
> this wants further abstracting for the rv32/rv64 difference (ideally
> in a way
> that wouldn't make future RV128 wrongly and silently take the RV32
> branch).
> This would include eliminating the -mabi=lp64 redundancy with what's
> visible in
> context, perhaps by way of introducing a separate helper macro, e.g.
>
> riscv-abi-$(CONFIG_RISCV_32) := -mabi=ilp32
> riscv-abi-$(CONFIG_RISCV_64) := -mabi=lp64
>
> I further see nothing wrong with also using $(riscv-march-y) here.
> I.e.
> overall
>
> _zihintpause := $(call as-insn,$(CC) $(riscv-abi-y) $(riscv-march-
> y)_zihintpause,"pause",_zihintpause)
>
> (still with potential of abstracting further through another macro
> such
> that not every such construct would need to spell out the ABI and
> arch
> compiler options).
>
> Plus a macro named has_* imo can be expected to expand to y or n. I
> would
> suggest to simply drop the "has", thus ...
>
> > @@ -12,7 +18,7 @@ riscv-march-$(CONFIG_RISCV_ISA_C) :=
> > $(riscv-march-y)c
> > # into the upper half _or_ the lower half of the address space.
> > # -mcmodel=medlow would force Xen into the lower half.
> >
> > -CFLAGS += -march=$(riscv-march-y) -mstrict-align -mcmodel=medany
> > +CFLAGS += -march=$(riscv-march-y)$(has_zihintpause) -mstrict-align
> > -mcmodel=medany
>
> ... also making the use site look
>
> > --- 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,26 @@ struct cpu_user_regs
> > unsigned long pregs;
> > };
> >
> > +/* TODO: need to implement */
> > +#define cpu_to_core(cpu) (0)
> > +#define cpu_to_socket(cpu) (0)
>
> Nit: Like above in smp_processor_id() no need for parentheses here.
>
> > +static inline void cpu_relax(void)
> > +{
> > +#ifdef __riscv_zihintpause
> > + /*
> > + * Reduce instruction retirement.
> > + * This assumes the PC changes.
>
> What is this 2nd sentence about?
cpu_relax() function was copied from Linux kernel and this comment
exists there, but I couldn't find in zihintpause spec how it affects PC
/IP, so it seems to me it can be dropped.
My guess that the 2nd sentece was added because of the following words
from the spec:
The PAUSE instruction is a HINT that indicates the current hart’s
rate of instruction retirement should be temporarily reduced or
paused. The duration of its effect must be bounded and may be zero.
So it says reduced or pause, but still doesn't make sense as no matter
how long pause takes to complete, it will still advance PC.
>
> > + */
> > + __asm__ __volatile__ ( "pause" );
> > +#else
> > + /* Encoding of the pause instruction */
> > + __asm__ __volatile__ ( ".insn 0x100000F" );
>
> May I ask that you spell out the leading zero here, to make clear
> there
> aren't, by mistake, one to few zeroes in the middle?
I will add a leading zero. The encoding is correct, I've verified with
disassembler:
c: 0100000f pause
~ Oleksii
next prev parent reply other threads:[~2024-03-05 17:35 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 17:38 [PATCH v5 00/23] [PATCH v4 00/30] Enable build of full Xen for RISC-V Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 01/23] xen/riscv: disable unnecessary configs Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 02/23] xen/riscv: use some asm-generic headers Oleksii Kurochko
2024-02-27 7:35 ` Jan Beulich
2024-02-26 17:38 ` [PATCH v5 03/23] xen/riscv: introduce nospec.h Oleksii Kurochko
2024-02-27 7:38 ` Jan Beulich
2024-02-28 9:59 ` Oleksii
2024-02-29 13:49 ` Julien Grall
2024-02-29 14:01 ` Jan Beulich
2024-02-29 16:09 ` Oleksii
2024-02-29 16:27 ` Jan Beulich
2024-02-26 17:38 ` [PATCH v5 04/23] xen/asm-generic: introduce generic fls() and flsl() functions Oleksii Kurochko
2024-02-29 13:54 ` Julien Grall
2024-02-29 14:03 ` Jan Beulich
2024-02-29 14:08 ` Julien Grall
2024-02-29 16:17 ` Oleksii
2024-02-29 15:52 ` Jan Beulich
2024-02-29 16:25 ` Andrew Cooper
2024-03-01 9:15 ` Oleksii
2024-02-26 17:38 ` [PATCH v5 05/23] xen/asm-generic: introduce generic find first set bit functions Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 06/23] xen/asm-generic: introduce generic ffz() Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 07/23] xen/asm-generic: introduce generic hweight64() Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 08/23] xen/asm-generic: introduce generic non-atomic test_*bit() Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 09/23] xen/riscv: introduce bitops.h Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 10/23] xen/riscv: introduces acrquire, release and full barriers Oleksii Kurochko
2024-03-05 7:42 ` Jan Beulich
2024-02-26 17:38 ` [PATCH v5 11/23] xen/riscv: introduce cmpxchg.h Oleksii Kurochko
2024-03-06 14:56 ` Jan Beulich
2024-03-07 10:35 ` Oleksii
2024-03-07 10:46 ` Jan Beulich
2024-03-07 11:01 ` Oleksii
2024-03-07 11:11 ` Jan Beulich
2024-03-07 12:28 ` Oleksii
2024-02-26 17:38 ` [PATCH v5 12/23] xen/riscv: introduce io.h Oleksii Kurochko
2024-03-06 14:13 ` Jan Beulich
2024-03-07 13:01 ` Oleksii
2024-03-07 13:24 ` Jan Beulich
2024-03-07 13:44 ` Oleksii
2024-03-07 15:32 ` Jan Beulich
2024-03-07 16:21 ` Oleksii
2024-03-07 17:14 ` Jan Beulich
2024-03-07 20:49 ` Oleksii
2024-03-07 20:54 ` Oleksii
2024-03-08 7:26 ` Jan Beulich
2024-03-08 10:14 ` Oleksii
2024-03-08 11:49 ` Jan Beulich
2024-03-08 11:52 ` Jan Beulich
2024-03-08 12:17 ` Oleksii
2024-03-08 12:54 ` Jan Beulich
2024-03-08 7:18 ` Jan Beulich
2024-02-26 17:38 ` [PATCH v5 13/23] xen/riscv: introduce atomic.h Oleksii Kurochko
2024-03-06 15:31 ` Jan Beulich
2024-03-07 13:30 ` Oleksii
2024-03-07 15:40 ` Jan Beulich
2024-02-26 17:38 ` [PATCH v5 14/23] xen/riscv: introduce monitor.h Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 15/23] xen/riscv: add definition of __read_mostly Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 16/23] xen/riscv: add required things to current.h Oleksii Kurochko
2024-02-26 17:38 ` [PATCH v5 17/23] xen/riscv: add minimal stuff to page.h to build full Xen Oleksii Kurochko
2024-02-26 17:39 ` [PATCH v5 18/23] xen/riscv: add minimal stuff to processor.h " Oleksii Kurochko
2024-03-05 8:05 ` Jan Beulich
2024-03-05 17:34 ` Oleksii [this message]
2024-02-26 17:39 ` [PATCH v5 19/23] xen/riscv: add minimal stuff to mm.h " Oleksii Kurochko
2024-03-05 8:17 ` Jan Beulich
2024-03-05 16:46 ` Oleksii
2024-02-26 17:39 ` [PATCH v5 20/23] xen/riscv: introduce vm_event_*() functions Oleksii Kurochko
2024-02-26 17:39 ` [PATCH v5 21/23] xen/rirscv: add minimal amount of stubs to build full Xen Oleksii Kurochko
2024-03-05 8:40 ` Jan Beulich
2024-02-26 17:39 ` [PATCH v5 22/23] xen/riscv: enable full Xen build Oleksii Kurochko
2024-02-26 17:39 ` [PATCH v5 23/23] xen/README: add compiler and binutils versions for RISC-V64 Oleksii Kurochko
2024-02-27 7:55 ` Jan Beulich
2024-02-28 17:03 ` Oleksii
2024-02-28 22:58 ` Julien Grall
2024-02-28 23:11 ` Andrew Cooper
2024-02-29 17:00 ` Oleksii
2024-02-29 7:58 ` Jan Beulich
2024-02-29 10:23 ` Julien Grall
2024-02-29 11:56 ` Jan Beulich
2024-02-29 11:59 ` Jan Beulich
2024-02-29 12:05 ` Andrew Cooper
2024-02-29 12:17 ` Jan Beulich
2024-02-29 12:32 ` Julien Grall
2024-02-29 12:51 ` Jan Beulich
2024-02-29 13:44 ` Julien Grall
2024-02-29 14:07 ` Jan Beulich
2024-02-29 14:14 ` Julien Grall
2024-02-29 17:43 ` Stefano Stabellini
2024-02-29 12:27 ` Julien Grall
2024-02-29 16:54 ` Oleksii
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=35595505b2733f7200a62177338cc3ba98f6afaa.camel@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=bobbyeshleman@gmail.com \
--cc=connojdavis@gmail.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.