[PATCH v1 17/27] xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h.

Oleksii Kurochko posted 27 patches 4 weeks ago
[PATCH v1 17/27] xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h.
Posted by Oleksii Kurochko 4 weeks ago
These definitions are required for correct decoding of APLIC MMIO
accesses and target configuration, and will be used by both the
physical and virtual APLIC implementations.

No functional change is intended by this patch; it only centralises
hardware definitions that were previously missing.

Co-developed-by: Romain Caritey <Romain.Caritey@microchip.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/arch/riscv/include/asm/aplic.h | 35 ++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/asm/aplic.h
index 55cd4a128de7..7e9161d98ceb 100644
--- a/xen/arch/riscv/include/asm/aplic.h
+++ b/xen/arch/riscv/include/asm/aplic.h
@@ -17,6 +17,11 @@
 
 #define APLIC_NUM_REGS 32
 
+#define APLIC_REG_OFFSET_MASK   0x3FFF
+#define APLIC_TARGET_IPRIO_MASK 0xFF
+#define APLIC_TARGET_GUEST_IDX_SHIFT 12
+#define APLIC_TARGET_EIID_MASK  0x7FF
+
 #define APLIC_DOMAINCFG_IE      BIT(8, U)
 #define APLIC_DOMAINCFG_DM      BIT(2, U)
 
@@ -27,6 +32,36 @@
 #define APLIC_SOURCECFG_SM_LEVEL_HIGH   0x6
 #define APLIC_SOURCECFG_SM_LEVEL_LOW    0x7
 
+#define APLIC_DOMAINCFG         0x0000
+#define APLIC_SOURCECFG_BASE    0x0004
+#define APLIC_SOURCECFG_LAST    0x0FFC
+
+#define APLIC_SMSICFGADDR       0x1BC8
+#define APLIC_SMSICFGADDRH      0x1BCC
+
+#define APLIC_SETIP_BASE        0x1C00
+#define APLIC_SETIP_LAST        0x1C7C
+#define APLIC_SETIPNUM          0x1CDC
+
+#define APLIC_CLRIP_BASE        0x1D00
+#define APLIC_CLRIP_LAST        0x1D7C
+#define APLIC_CLRIPNUM          0x1DDC
+
+#define APLIC_SETIE_BASE        0x1E00
+#define APLIC_SETIE_LAST        0x1E7C
+#define APLIC_SETIENUM          0x1EDC
+
+#define APLIC_CLRIE_BASE        0x1F00
+#define APLIC_CLRIE_LAST        0x1F7C
+#define APLIC_CLRIENUM          0x1FDC
+
+#define APLIC_SETIPNUM_LE       0x2000
+
+#define APLIC_GENMSI            0x3000
+
+#define APLIC_TARGET_BASE       0x3004
+#define APLIC_TARGET_LAST       0x3FFC
+
 #define APLIC_TARGET_HART_IDX_SHIFT 18
 
 struct aplic_regs {
-- 
2.53.0
Re: [PATCH v1 17/27] xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h.
Posted by Jan Beulich 5 days, 14 hours ago
On 10.03.2026 18:08, Oleksii Kurochko wrote:
> These definitions are required for correct decoding of APLIC MMIO
> accesses and target configuration, and will be used by both the
> physical and virtual APLIC implementations.
> 
> No functional change is intended by this patch; it only centralises
> hardware definitions that were previously missing.
> 
> Co-developed-by: Romain Caritey <Romain.Caritey@microchip.com>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

I can commit this as is (with my ack added), but I'd like you to consider
again my remark elsewhere as to ...

> --- a/xen/arch/riscv/include/asm/aplic.h
> +++ b/xen/arch/riscv/include/asm/aplic.h
> @@ -17,6 +17,11 @@
>  
>  #define APLIC_NUM_REGS 32
>  
> +#define APLIC_REG_OFFSET_MASK   0x3FFF
> +#define APLIC_TARGET_IPRIO_MASK 0xFF
> +#define APLIC_TARGET_GUEST_IDX_SHIFT 12
> +#define APLIC_TARGET_EIID_MASK  0x7FF
> +
>  #define APLIC_DOMAINCFG_IE      BIT(8, U)
>  #define APLIC_DOMAINCFG_DM      BIT(2, U)
>  
> @@ -27,6 +32,36 @@
>  #define APLIC_SOURCECFG_SM_LEVEL_HIGH   0x6
>  #define APLIC_SOURCECFG_SM_LEVEL_LOW    0x7
>  
> +#define APLIC_DOMAINCFG         0x0000
> +#define APLIC_SOURCECFG_BASE    0x0004
> +#define APLIC_SOURCECFG_LAST    0x0FFC
> +
> +#define APLIC_SMSICFGADDR       0x1BC8
> +#define APLIC_SMSICFGADDRH      0x1BCC
> +
> +#define APLIC_SETIP_BASE        0x1C00
> +#define APLIC_SETIP_LAST        0x1C7C
> +#define APLIC_SETIPNUM          0x1CDC
> +
> +#define APLIC_CLRIP_BASE        0x1D00
> +#define APLIC_CLRIP_LAST        0x1D7C
> +#define APLIC_CLRIPNUM          0x1DDC
> +
> +#define APLIC_SETIE_BASE        0x1E00
> +#define APLIC_SETIE_LAST        0x1E7C
> +#define APLIC_SETIENUM          0x1EDC
> +
> +#define APLIC_CLRIE_BASE        0x1F00
> +#define APLIC_CLRIE_LAST        0x1F7C
> +#define APLIC_CLRIENUM          0x1FDC
> +
> +#define APLIC_SETIPNUM_LE       0x2000
> +
> +#define APLIC_GENMSI            0x3000
> +
> +#define APLIC_TARGET_BASE       0x3004
> +#define APLIC_TARGET_LAST       0x3FFC

... the case of hex digits vs the need to have L (and hence U) suffixes in
upper case for Misra's sake. Those suffixes are easier to spot as such when
the hex digits use lower case. Then even for un-suffixed numbers lower case
is preferable imo, for overall consistency.

Jan