From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: xen-devel@lists.xenproject.org,
"Romain Caritey" <Romain.Caritey@microchip.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger@xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Baptiste Le Duc" <baptiste.le-duc@vates.tech>
Subject: Re: [PATCH v4 03/42] xen/riscv: introduce csr_volatile_read64()
Date: Wed, 25 Nov 2026 09:48:04 +0100 [thread overview]
Message-ID: <9e48d67a-42fb-46e4-92b1-fb6fcc2bab18@gmail.com> (raw)
In-Reply-To: <09ed219f-5b4f-45f3-944a-b65c446d3274@suse.com>
On 11/18/26 11:57 AM, Jan Beulich wrote:
> On 18.11.2026 11:49, Jan Beulich wrote:
>> On 18.11.2026 10:50, Baptiste Le Duc wrote:
>>>> On RV32 a 64-bit CSR is accessed as two halves, <csr> and <csr>H. Reading
>>>> the halves with two separate instructions isn't always safe: for a CSR
>>>> which hardware increments, a carry from the low half into the high one can
>>>> happen in between, so a plain pair of reads can produce a value the CSR
>>>> never held. Therefore the high half is re-read and the sequence retried if
>>>> it changed in the meantime.
>>>>
>>>> Only CSRs which change under Xen's feet need that, hence the name. The
>>>> majority can be read with a plain pair of csr_read()s, so no helper for
>>>> those is introduced here as there would be no user for it.
>>>>
>>>> Use it for CSR_TIME, which is exactly such a counter, and widen cycles_t to
>>>> uint64_t. Otherwise get_cycles() would still truncate the time counter to
>>>> 32 bits on RV32.
>>>>
>>>> No functional change on RV64.
>>>>
>>>> Fixes: a541ddadec0a ("xen/riscv: introduce time.h")
>>>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>>>> ---
>>>> Changes in v4:
>>>> - Take the CSR name without the CSR_ prefix, so that the macro parameter
>>>> is used as an operand of ## only (MISRA C Rule 20.12).
>>>> - Drop the (void) of the ...H constant on RV64.
>>>> - Initialise hi_ in its declaration.
>>>
>>> Jan gave his Reviewed-by on v3. It is gone in v4. Dropping it may be
>>> fine given the macro rework, but please say so in the changelog :)
>>>
>>>> [ ... 45 lines skipped ... ]
>>>> #else
>>>> #define csr_write64(name, val) csr_write(CSR_ ## name, val)
>>>> +
>>>> +#define csr_volatile_read64(name) csr_read(CSR_ ## name)
>>>
>>> Nit: On v3 Jan suggested "#define csr_volatile_read64 csr_read64", and you
>>> answered you would then move csr_read64() into this patch. In v4
>>> csr_read64() still only comes with "xen/riscv: implement vCPU context
>>> switching".
>>>
>>> On RV64 I think it would read better like that:
>>> #define csr_read64(name) csr_read(CSR_ ## name)
>>> #define csr_volatile_read64(name) csr_read64(name)
>>
>> #define csr_read64(name) csr_read(CSR_ ## name)
>> #define csr_volatile_read64 csr_read64
>>
>> i.e. matching what I suggested earlier. Otherwise what is passed into
>> csr_volatile_read64() would be macro-expanded before further
>> expanding csr_read64(), thus prepending CSR_ only to the result of
>> that expansion. (In the common case there'll be no difference, but
>> things can go wrong if some unexpected new #define appears.)
>
> Oh, and - happy to fold this in while committing (perhaps with an adjustment
> to subject and description), if you agree. With that
> Acked-by: Jan Beulich <jbeulich@suse.com>
Sorry, for the so long response.
I will be happy if it could be done while committing.
Thanks.
~ Oleksii
next prev parent reply other threads:[~2026-11-25 8:48 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1794562488.git.oleksii.kurochko@gmail.com>
2026-11-13 15:48 ` [PATCH v4 01/42] xen/riscv: add helper to check APLIC MSI mode Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 02/42] xen/riscv: address violation of MISRA C Rule 20.12 in csr_write64() Oleksii Kurochko
2026-11-18 9:50 ` Baptiste Le Duc
2026-11-18 10:51 ` Jan Beulich
2026-11-13 15:48 ` [PATCH v4 03/42] xen/riscv: introduce csr_volatile_read64() Oleksii Kurochko
2026-11-18 9:50 ` Baptiste Le Duc
2026-11-18 10:49 ` Jan Beulich
2026-11-18 10:57 ` Jan Beulich
2026-11-25 8:48 ` Oleksii Kurochko [this message]
2026-11-13 15:48 ` [PATCH v4 04/42] xen/riscv: define the IPRIO field of the APLIC target register Oleksii Kurochko
2026-11-27 15:23 ` Baptiste Le Duc
2026-12-02 8:27 ` Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 05/42] xen/riscv: build the target hart index via aplic_hart_index() Oleksii Kurochko
2026-11-27 16:00 ` Baptiste Le Duc
2026-11-30 8:40 ` Jan Beulich
2026-11-30 9:25 ` Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 06/42] xen/riscv: introduce CPU_NONE Oleksii Kurochko
2026-11-27 16:08 ` Baptiste Le Duc
2026-11-30 8:41 ` Jan Beulich
2026-11-13 15:48 ` [PATCH v4 07/42] xen/riscv: introduce device-agnostic MMIO emulation dispatch Oleksii Kurochko
2026-11-27 16:42 ` Baptiste Le Duc
2026-11-13 15:48 ` [PATCH v4 08/42] xen/riscv: distinguish h/w and virtual vINTC sources Oleksii Kurochko
2026-12-01 12:54 ` Baptiste Le Duc
2026-11-13 15:48 ` [PATCH v4 09/42] xen/riscv: implement virtual APLIC MMIO emulation Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 10/42] xen/riscv: leave the h/w source of an IRQ routed to a guest inactive Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 11/42] xen/riscv: implement vCPU context switching Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 12/42] xen/riscv: save and restore vsiselect on vCPU context switch Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 13/42] xen/riscv: introduce vintc_ctxt_switch_{from,to}() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 14/42] xen/riscv: extend exception tables with type and data fields Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 15/42] xen/riscv: add guest page fault handling stub Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 16/42] xen/riscv: implement trap redirection to a guest Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 17/42] xen/riscv: detect Shtvala Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 18/42] xen/riscv: resolve the faulting guest physical address Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 19/42] xen/riscv: add guest memory read helper Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 20/42] xen/riscv: add helpers for decoding a trapped load or store Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 21/42] xen/riscv: add guest load emulation for trapped MMIO accesses Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 22/42] xen/riscv: add guest store " Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 23/42] xen/riscv: set the guest's XLEN explicitly in hstatus.VSXL Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 24/42] xen/riscv: implement continue_new_vcpu() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 25/42] xen/riscv: add basic VGEIN management for AIA guests Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 26/42] xen/riscv: map IMSIC interrupt file for vCPUs Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 27/42] xen/riscv: introduce vaplic_reconfigure_target() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 28/42] xen/riscv: introduce IMSIC h/w interrupt file attaching to vcpu Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 29/42] xen/riscv: wake up a descheduled vCPU on a guest external interrupt Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 30/42] xen/riscv: implement APLIC-IMSIC-hart sync barrier for vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 31/42] xen/riscv: introduce imsic_migrate_vcpu() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 32/42] xen/riscv: remap interrupts to new IMSIC VS-file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 33/42] xen/riscv: save and clear the old IMSIC VS-file on vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 34/42] xen/riscv: restore register state in the new IMSIC VS-file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 35/42] xen/riscv: move a vCPU's guest interrupt file on its way to the guest Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 36/42] xen/riscv: send MSIs to a vCPU's guest interrupt file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 37/42] xen/riscv: sync with IMSIC VS-file injections on vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 38/42] xen/riscv: emulate the vAPLIC genmsi register Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 39/42] xen/riscv: emulate vAPLIC sourcecfg[], setie[] and domaincfg.IE Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 40/42] xen/riscv: emulate target[] of virtual vAPLIC sources Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 41/42] xen/riscv: emulate the pending bits and MSIs " Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 42/42] xen/riscv: drive the line of a virtual vAPLIC source Oleksii Kurochko
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=9e48d67a-42fb-46e4-92b1-fb6fcc2bab18@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=Romain.Caritey@microchip.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=baptiste.le-duc@vates.tech \
--cc=connojdavis@gmail.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.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.