Arm: Enable GICv3 for AArch32
v4 cover Arm: Enable GICv3 for AArch32
Hi All,
Please find the following patches to enable GICv3 for AArch32. This is a pre-requisite to support Xen on Cortex-R52 (AArch32-v8R system)
Let me know your thoughts.
Changes from -
v1 :-
1. Updated in the changelog for each of the patches.
v2 :-
1. Dropped "xen/Arm: GICv3: Move the macros to compute the affnity level to arm64/arm32". The reason being aff3 does not exist on arm32. And aff0..2 is the same between arm32, AArch32 and AArch64.
2. Introduce a new patch "xen/Arm: GICv3: Adapt access to VMPIDR register for AArch32".
3. For the new registers introduced, we have defined the arm32 name and then an alias.
4. Use 'AArch32' across all the patches.
5. Dropped the 'R-b' and 'Ack' in "[XEN v3 08/12] xen/Arm: GICv3: Define ICH_AP0R<n> and ICH_AP1R<n> for AArch32".
v3 :-
1. "xen/Arm: GICv3: Use ULL instead of UL for 64bits" has been dropped. The change has been merged with "xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32".
2. I have marked the patches which have been Rb + Ack vs Rb only.
3. Dropped Rb from "xen/Arm: GICv3: Enable GICv3 for AArch32"
Ayan Kumar Halder (11):
xen/Arm: vGICv3: Sysreg emulation is applicable for AArch64 only (Rb + Ack) xen/Arm: GICv3: Do not calculate affinity level 3 for AArch32 (Rb) xen/Arm: vreg: Support vreg_reg64_* helpers on AArch32 (Rb + Ack) xen/Arm: vGICv3: Adapt emulation of GICR_TYPER for AArch32 (Rb) xen/Arm: GICv3: Fix GICR_{PENDBASER, PROPBASER} emulation on 32-bit
host (Rb + Ack)
xen/Arm: vGICv3: Fix emulation of ICC_SGI1R on AArch32 (Rb + Ack) xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
xen/Arm: GICv3: Define ICH_AP0R<n> and ICH_AP1R<n> for AArch32 xen/Arm: GICv3: Define remaining GIC registers for AArch32 xen/Arm: GICv3: Define macros to read/write 64 bit
xen/Arm: GICv3: Enable GICv3 for AArch32
SUPPORT.md | 7 ++ xen/arch/arm/Kconfig | 9 +- xen/arch/arm/gic-v3.c | 153 ++++++++++++----------- xen/arch/arm/include/asm/arm32/io.h | 20 +++ xen/arch/arm/include/asm/arm32/sysregs.h | 19 +++ xen/arch/arm/include/asm/arm64/io.h | 2 + xen/arch/arm/include/asm/arm64/sysregs.h | 5 + xen/arch/arm/include/asm/cpregs.h | 136 ++++++++++++++++++++ xen/arch/arm/include/asm/cpufeature.h | 1 + xen/arch/arm/include/asm/gic_v3_defs.h | 24 ++-- xen/arch/arm/include/asm/vreg.h | 86 +++---------- xen/arch/arm/vgic-v3.c | 22 +++- 12 files changed, 324 insertions(+), 160 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/11 xen/Arm: vGICv3: Sysreg emulation is applicable for AArch64 only
Sysreg emulation is 64-bit specific, so guard the calls to vgic_v3_emulate_sysreg() as well as the function itself with "#ifdef CONFIG_ARM_64".
---
Changes from -
v1 - 1. Updated the commit message.
v2 - 1. Updated the commit message (removed the reference to Arm ARM as it is not required).
v3 - No changes. Added Rb and Ack.
xen/arch/arm/vgic-v3.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/arm/vgic-v3.c +4 -0
@@ -1519,6 +1519,7 @@ static bool vgic_v3_emulate_sgi1r(struct cpu_user_regs *regs, uint64_t *r, } } +#ifdef CONFIG_ARM_64 static bool vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_sysreg sysreg = hsr.sysreg;
@@ -1539,6 +1540,7 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) return false; } } +#endif static bool vgic_v3_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) {
@@ -1562,8 +1564,10 @@ static bool vgic_v3_emulate_reg(struct cpu_user_regs *regs, union hsr hsr) {switch (hsr.ec) { +#ifdef CONFIG_ARM_64 case HSR_EC_SYSREG :return vgic_v3_emulate_sysreg (regs, hsr); +#endif case HSR_EC_CP15_64 :return vgic_v3_emulate_cp64 (regs, hsr);default :
Signature · 1 line
2.17.1
PATCH v4 2/11 xen/Arm: GICv3: Do not calculate affinity level 3 for AArch32
In reply to Ayan Kumar HalderRefer ARM DDI 0487I.a ID081822, G8-9817, G8.2.169 Affinity level 3 is not present in AArch32.
Also, refer ARM DDI 0406C.d ID040418, B4-1644, B4.1.106, Affinity level 3 is not present in Armv7 (ie arm32). Thus, any access to affinity level 3 needs to be guarded within "ifdef CONFIG_ARM_64".
---
Changes from -
v1 - NA (as it is a new patch)
v2 - NA (as it is a new patch)
v3 - Modified the title. Added Rb.
xen/arch/arm/gic-v3.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
xen/arch/arm/gic-v3.c +12 -3
@@ -527,7 +527,10 @@ static void gicv3_set_pending_state(struct irq_desc *irqd, bool pending)static inline uint64_t gicv3_mpidr_to_affinity (int cpu) {uint64_t mpidr =cpu_logical_map (cpu); -return (MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<32 | + return ( +#ifdef CONFIG_ARM_64 +MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<32 | +#endifMPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 |MPIDR_AFFINITY_LEVEL (mpidr,1 ) <<8 | MPIDR_AFFINITY_LEVEL(mpidr, 0));
@@ -720,7 +723,10 @@ static int __init gicv3_populate_rdist(void)* Convert affinity to a 32bit value that can be matched to GICR_TYPER * bits [63:32] */ - aff = (MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<24 | + aff = ( +#ifdef CONFIG_ARM_64 +MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<24 | +#endifMPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 |MPIDR_AFFINITY_LEVEL (mpidr,1 ) <<8 | MPIDR_AFFINITY_LEVEL(mpidr, 0));
@@ -972,7 +978,10 @@ static void gicv3_send_sgi_list(enum gic_sgi sgi, const cpumask_t *cpumask)* Prepare affinity path of the cluster for which SGI is generated * along with SGI number */ - val = (MPIDR_AFFINITY_LEVEL(cluster_id, 3) << 48 | + val = ( +#ifdef CONFIG_ARM_64 + MPIDR_AFFINITY_LEVEL(cluster_id, 3) << 48 | +#endif MPIDR_AFFINITY_LEVEL(cluster_id, 2) << 32 | sgi << 24 | MPIDR_AFFINITY_LEVEL(cluster_id, 1) << 16 |
Signature · 1 line
2.17.1
PATCH v4 3/11 xen/Arm: vreg: Support vreg_reg64_* helpers on AArch32
In reply to Ayan Kumar HalderIn some situations (e.g. GICR_TYPER), the hypervior may need to emulate 64bit registers in AArch32 mode. In such situations, the hypervisor may need to read/modify the lower or upper 32 bits of the 64 bit register.
In AArch32, 'unsigned long' is 32 bits. Thus, we cannot use it for 64 bit registers.
While we could replace 'unsigned long' by 'uint64_t', it is not entirely clear whether a 32-bit compiler would not allocate register for the upper 32-bit. Therefore fold vreg_reg_* helper in the size specific one and use the appropriate type based on the size requested.
---
Changes from -
v1 - 1. Remove vreg_reg_extract(), vreg_reg_update(), vreg_reg_setbits() and vreg_reg_clearbits(). Moved the implementation to vreg_reg##sz##_*. 'mask' and 'val' is now using uint##sz##_t.
v2 - 1. Use 'unsigned int' for 'shift' variable.
2. Updated the commit message.
v3 - 1. No changes. Added Rb and Ack.
xen/arch/arm/include/asm/vreg.h | 86 ++++++++------------------------- 1 file changed, 19 insertions(+), 67 deletions(-)
xen/arch/arm/include/asm/vreg.h +19 -67
@@ -89,106 +89,58 @@ static inline bool vreg_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr* The check on the size supported by the register has to be done by * the caller of vreg_regN_*. * -* vreg_reg_* should never be called directly. Instead use the vreg_regN_* -* according to size of the emulated register -* * Note that the alignment fault will always be taken in the guest * (see B3.12.7 DDI0406.b). */ -static inline register_t vreg_reg_extract (unsigned long reg, -unsigned int offset, -enum dabt_size size) -{ - reg >>=8 * offset; - reg &=VREG_REG_MASK (size); - -return reg; -} - -static inline void vreg_reg_update (unsigned long *reg,register_t val, -unsigned int offset, -enum dabt_size size) -{ -unsigned long mask =VREG_REG_MASK (size); -int shift = offset *8 ; - - *reg &= ~(mask << shift); - *reg |= ((unsigned long )val & mask) << shift; -} - -static inline void vreg_reg_setbits (unsigned long *reg,register_t bits, -unsigned int offset, -enum dabt_size size) -{ -unsigned long mask =VREG_REG_MASK (size); -int shift = offset *8 ; - - *reg |= ((unsigned long )bits & mask) << shift; -} - -static inline void vreg_reg_clearbits (unsigned long *reg,register_t bits, -unsigned int offset, -enum dabt_size size) -{ -unsigned long mask =VREG_REG_MASK (size); -int shift = offset *8 ; - - *reg &= ~(((unsigned long )bits & mask) << shift); -}/* N-bit register helpers */ #define VREG_REG_HELPERS (sz, offmask) \ static inline register_t vreg_reg##sz##_extract(uint##sz##_t reg, \ const mmio_info_t *info)\ { \ - return vreg_reg_extract(reg, info->gpa & (offmask), \ - info->dabt.size); \ + unsigned int offset = info->gpa & (offmask); \ + \ + reg >>= 8 * offset; \ + reg &= VREG_REG_MASK(info->dabt.size); \ + \ + return reg; \ } \ \ static inline void vreg_reg##sz##_update(uint##sz##_t *reg, \ register_t val, \ const mmio_info_t *info) \ { \ - unsigned long tmp = *reg; \ + unsigned int offset = info->gpa & (offmask); \ + uint##sz##_t mask = VREG_REG_MASK(info->dabt.size); \ + unsigned int shift = offset * 8; \ \ - vreg_reg_update(&tmp, val, info->gpa & (offmask), \ - info->dabt.size); \ - \ - *reg = tmp; \ + *reg &= ~(mask << shift); \ + *reg |= ((uint##sz##_t)val & mask) << shift; \ } \ \ static inline void vreg_reg##sz##_setbits(uint##sz##_t *reg, \ register_t bits, \ const mmio_info_t *info) \ { \ - unsigned long tmp = *reg; \ - \ - vreg_reg_setbits(&tmp, bits, info->gpa & (offmask), \ - info->dabt.size); \ + unsigned int offset = info->gpa & (offmask); \ + uint##sz##_t mask = VREG_REG_MASK(info->dabt.size); \ + unsigned int shift = offset * 8; \ \ - *reg = tmp; \ + *reg |= ((uint##sz##_t)bits & mask) << shift; \ } \ \ static inline void vreg_reg##sz##_clearbits(uint##sz##_t *reg, \ register_t bits, \ const mmio_info_t *info) \ { \ - unsigned long tmp = *reg; \ - \ - vreg_reg_clearbits(&tmp, bits, info->gpa & (offmask), \ - info->dabt.size); \ + unsigned int offset = info->gpa & (offmask); \ + uint##sz##_t mask = VREG_REG_MASK(info->dabt.size); \ + unsigned int shift = offset * 8; \ \ - *reg = tmp; \ + *reg &= ~(((uint##sz##_t)bits & mask) << shift); \ } -/* -* 64 bits registers are only supported on platform with 64-bit long. -* This is also allow us to optimize the 32 bit case by using -* unsigned long rather than uint64_t -*/ -#if BITS_PER_LONG ==64 VREG_REG_HELPERS (64 ,0x7 ); -#endif VREG_REG_HELPERS (32 ,0x3 );#undef VREG_REG_HELPERS
Signature · 1 line
2.17.1
PATCH v4 4/11 xen/Arm: vGICv3: Adapt emulation of GICR_TYPER for AArch32
In reply to Ayan Kumar HalderRefer ARM DDI 0487I.a ID081822, G8-9650, G8.2.113 Aff3 does not exist on AArch32.
Also, refer ARM DDI 0406C.d ID040418, B4-1644, B4.1.106 Aff3 does not exist on Armv7 (ie arm32).
Thus, access to aff3 has been protected with "#ifdef CONFIG_ARM_64". Also, v->arch.vmpidr is a 32 bit register on AArch32. So, we have assigned it to 'uint64_t vmpidr' to perform the shifts.
---
Changes from :-
v1 - Assigned v->arch.vmpidr to "uint64_t vmpdir". Then, we can use MPIDR_AFFINITY_LEVEL macros to extract the affinity value.
v2 - 1. "MPIDR_AFFINITY_LEVEL(vmpidr, 3)" is contained within "#ifdef CONFIG_ARM_64".
2. Updated commit message.
v3 - 1. Added an inline comment to explain type widening for v->arch.vmpidr.
2. Updated the commit message. Added Rb.
xen/arch/arm/vgic-v3.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
xen/arch/arm/vgic-v3.c +12 -4
@@ -191,12 +191,20 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info,case VREG64 (GICR_TYPER ): {uint64_t typer, aff; +/* +* This is to enable shifts greater than 32 bits which would have +* otherwise caused overflow (as v->arch.vmpidr is 32 bit on AArch32). +*/ +uint64_t vmpidr = v->arch.vmpidr;if ( !vgic_reg64_check_access (dabt) ) goto bad_width; - aff = (MPIDR_AFFINITY_LEVEL (v->arch.vmpidr,3 ) <<56 | -MPIDR_AFFINITY_LEVEL (v->arch.vmpidr,2 ) <<48 | -MPIDR_AFFINITY_LEVEL (v->arch.vmpidr,1 ) <<40 | -MPIDR_AFFINITY_LEVEL (v->arch.vmpidr,0 ) <<32 ); + aff = ( +#ifdef CONFIG_ARM_64 +MPIDR_AFFINITY_LEVEL (vmpidr,3 ) <<56 | +#endif +MPIDR_AFFINITY_LEVEL (vmpidr,2 ) <<48 | +MPIDR_AFFINITY_LEVEL (vmpidr,1 ) <<40 | + MPIDR_AFFINITY_LEVEL(vmpidr, 0) << 32); typer = aff;/* We use the VCPU ID as the redistributor ID in bits[23:8] */ typer |= v->vcpu_id <<GICR_TYPER_PROC_NUM_SHIFT ;
Signature · 1 line
2.17.1
PATCH v4 5/11 xen/Arm: GICv3: Fix GICR_{PENDBASER, PROPBASER} emulation on 32-bit host
In reply to Ayan Kumar Halder'unsigned long long' is defined as 64 bit across both AArch32 and AArch64. So, use 'ULL' for 64 bit word instead of UL which is 32 bits for AArch32. GICR_PENDBASER and GICR_PROPBASER both are 64 bit registers.
---
Changes from -
v1 - 1. Extract the bug fix for incorrect bit clearing (GICR_PENDBASER_PTZ) into a separate patch fix.
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
v2 - No changes.
v3 - No changes.
xen/arch/arm/include/asm/gic_v3_defs.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
xen/arch/arm/include/asm/gic_v3_defs.h +8 -8
@@ -134,15 +134,15 @@#define GICR_PROPBASER_OUTER_CACHEABILITY_SHIFT 56#define GICR_PROPBASER_OUTER_CACHEABILITY_MASK \ - (7UL << GICR_PROPBASER_OUTER_CACHEABILITY_SHIFT) + (7ULL << GICR_PROPBASER_OUTER_CACHEABILITY_SHIFT)#define GICR_PROPBASER_SHAREABILITY_SHIFT 10#define GICR_PROPBASER_SHAREABILITY_MASK \ - (3UL << GICR_PROPBASER_SHAREABILITY_SHIFT) + (3ULL << GICR_PROPBASER_SHAREABILITY_SHIFT)#define GICR_PROPBASER_INNER_CACHEABILITY_SHIFT 7#define GICR_PROPBASER_INNER_CACHEABILITY_MASK \ - (7UL << GICR_PROPBASER_INNER_CACHEABILITY_SHIFT) + (7ULL << GICR_PROPBASER_INNER_CACHEABILITY_SHIFT)#define GICR_PROPBASER_RES0_MASK \ - (GENMASK(63, 59) | GENMASK(55, 52) | GENMASK(6, 5)) + (GENMASK_ULL(63, 59) | GENMASK_ULL(55, 52) | GENMASK_ULL(6, 5))#define GICR_PENDBASER_SHAREABILITY_SHIFT 10#define GICR_PENDBASER_INNER_CACHEABILITY_SHIFT 7
@@ -152,11 +152,11 @@#define GICR_PENDBASER_INNER_CACHEABILITY_MASK \ (7UL << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT)#define GICR_PENDBASER_OUTER_CACHEABILITY_MASK \ - (7UL << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT) -#define GICR_PENDBASER_PTZ BIT(62, UL) + (7ULL << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT) +#define GICR_PENDBASER_PTZ BIT(62, ULL)#define GICR_PENDBASER_RES0_MASK \ - (BIT(63, UL) | GENMASK(61, 59) | GENMASK(55, 52) | \ - GENMASK(15, 12) | GENMASK(6, 0)) + (BIT(63, ULL) | GENMASK_ULL(61, 59) | GENMASK_ULL(55, 52) | \ + GENMASK_ULL(15, 12) | GENMASK_ULL(6, 0))#define DEFAULT_PMR_VALUE 0xff
Signature · 1 line
2.17.1
PATCH v4 6/11 xen/Arm: vGICv3: Fix emulation of ICC_SGI1R on AArch32
In reply to Ayan Kumar HalderRefer Arm IHI 0069H ID020922, 12.5.23, ICC_SGI1R is a 64 bit register on AArch32 systems. Thus, the function needs to change to reflect this. The reason being 'register_t' is defined as 'u32' on AArch32.
---
Changes from :-
v1 - 1. Updated the commit message.
v2 - 1. No changes.
v3 - 1. No changes.
xen/arch/arm/vgic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/vgic-v3.c +1 -1
@@ -1483,7 +1483,7 @@ write_reserved:return 1 ; } -static bool vgic_v3_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v3_to_sgi (struct vcpu *v,uint64_t sgir) {int virq;int irqmode;
Signature · 1 line
2.17.1
PATCH v4 8/11 xen/Arm: GICv3: Define ICH_AP0R<n> and ICH_AP1R<n> for AArch32
In reply to Ayan Kumar HalderAdapt save_aprn_regs()/restore_aprn_regs() for AArch32.
For which we have defined the following registers:-
1. Interrupt Controller Hyp Active Priorities Group0 Registers 0-3
2. Interrupt Controller Hyp Active Priorities Group1 Registers 0-3
---
Changes from :-
v1 - 1. Moved coproc register definition to asm/cpregs.h.
v2 - 1. Defined register alias.
2. Style issues.
3. Dropped R-b and Ack.
v3 - 1. Style issues.
xen/arch/arm/include/asm/cpregs.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
xen/arch/arm/include/asm/cpregs.h +28 -0
@@ -261,6 +261,26 @@#define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0/* Hyp. Vector Base Address Register */ +/* +* CP15 CR12: Interrupt Controller Hyp Active Priorities Group 0 Registers, +* n = 0 - 3 +*/ +#define __AP0Rx (x) ___CP32(p15, 4, c12, c8, x) +#define ICH_AP0R0 __AP0Rx(0) +#define ICH_AP0R1 __AP0Rx(1) +#define ICH_AP0R2 __AP0Rx(2) +#define ICH_AP0R3 __AP0Rx(3) + +/* +* CP15 CR12: Interrupt Controller Hyp Active Priorities Group 1 Registers, +* n = 0 - 3 +*/ +#define __AP1Rx (x) ___CP32(p15, 4, c12, c9, x) +#define ICH_AP1R0 __AP1Rx(0) +#define ICH_AP1R1 __AP1Rx(1) +#define ICH_AP1R2 __AP1Rx(2) +#define ICH_AP1R3 __AP1Rx(3) +/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ #define __LR0 (x) ___CP32(p15, 4, c12, c12, x)#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)
@@ -361,6 +381,14 @@#define HCR_EL2 HCR#define HPFAR_EL2 HPFAR#define HSTR_EL2 HSTR +#define ICH_AP0R0_EL2 ICH_AP0R0 +#define ICH_AP0R1_EL2 ICH_AP0R1 +#define ICH_AP0R2_EL2 ICH_AP0R2 +#define ICH_AP0R3_EL2 ICH_AP0R3 +#define ICH_AP1R0_EL2 ICH_AP1R0 +#define ICH_AP1R1_EL2 ICH_AP1R1 +#define ICH_AP1R2_EL2 ICH_AP1R2 +#define ICH_AP1R3_EL2 ICH_AP1R3#define ICH_LR0_EL2 ICH_LR0#define ICH_LR1_EL2 ICH_LR1#define ICH_LR2_EL2 ICH_LR2
Signature · 1 line
2.17.1
PATCH v4 7/11 xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
In reply to Ayan Kumar HalderRefer "Arm IHI 0069H ID020922", 12.4.6, Interrupt Controller List Registers
AArch64 System register ICH_LR<n>_EL2 bits [31:0] are architecturally mapped to AArch32 System register ICH_LR<n>[31:0].
AArch64 System register ICH_LR<n>_EL2 bits [63:32] are architecturally mapped to AArch32 System register ICH_LRC<n>[31:0].
Defined ICH_LR<0...15>_EL2 and ICH_LRC<0...15>_EL2 for AArch32. For AArch32, the link register is stored as :- (((uint64_t) ICH_LRC<0...15>_EL2) << 32) | ICH_LR<0...15>_EL2
Also, ICR_LR macros need to be modified as ULL is 64 bits for AArch32 and AArch64.
---
Changes from :-
v1 - 1. Moved the coproc register definitions to asm/cpregs.h.
2. Use GENMASK(31, 0) to represent 0xFFFFFFFF
3. Use READ_CP32()/WRITE_CP32() instead of READ_SYSREG()/WRITE_SYSREG().
4. Multi-line macro definitions should be enclosed within ({ }).
v2 - 1. Use WRITE_SYSREG_LR(V, R) to make it consistent with before.
2. Defined the register alias.
3. Style issues.
v3 - 1. Addressed style issues.
xen/arch/arm/gic-v3.c | 132 +++++++++++------------ xen/arch/arm/include/asm/arm32/sysregs.h | 19 ++++ xen/arch/arm/include/asm/arm64/sysregs.h | 5 + xen/arch/arm/include/asm/cpregs.h | 76 +++++++++++++ xen/arch/arm/include/asm/gic_v3_defs.h | 8 +- 5 files changed, 170 insertions(+), 70 deletions(-)
xen/arch/arm/gic-v3.c +66 -66
@@ -73,37 +73,37 @@ static inline void gicv3_save_lrs(struct vcpu *v)switch ( gicv3_info.nr_lrs ) {case 16 : - v->arch.gic.v3.lr[15 ] =READ_SYSREG (ICH_LR15_EL2 ); + v->arch.gic.v3.lr[15 ] =READ_SYSREG_LR (15 );case 15 : - v->arch.gic.v3.lr[14 ] =READ_SYSREG (ICH_LR14_EL2 ); + v->arch.gic.v3.lr[14 ] =READ_SYSREG_LR (14 );case 14 : - v->arch.gic.v3.lr[13 ] =READ_SYSREG (ICH_LR13_EL2 ); + v->arch.gic.v3.lr[13 ] =READ_SYSREG_LR (13 );case 13 : - v->arch.gic.v3.lr[12 ] =READ_SYSREG (ICH_LR12_EL2 ); + v->arch.gic.v3.lr[12 ] =READ_SYSREG_LR (12 );case 12 : - v->arch.gic.v3.lr[11 ] =READ_SYSREG (ICH_LR11_EL2 ); + v->arch.gic.v3.lr[11 ] =READ_SYSREG_LR (11 );case 11 : - v->arch.gic.v3.lr[10 ] =READ_SYSREG (ICH_LR10_EL2 ); + v->arch.gic.v3.lr[10 ] =READ_SYSREG_LR (10 );case 10 : - v->arch.gic.v3.lr[9 ] =READ_SYSREG (ICH_LR9_EL2 ); + v->arch.gic.v3.lr[9 ] =READ_SYSREG_LR (9 );case 9 : - v->arch.gic.v3.lr[8 ] =READ_SYSREG (ICH_LR8_EL2 ); + v->arch.gic.v3.lr[8 ] =READ_SYSREG_LR (8 );case 8 : - v->arch.gic.v3.lr[7 ] =READ_SYSREG (ICH_LR7_EL2 ); + v->arch.gic.v3.lr[7 ] =READ_SYSREG_LR (7 );case 7 : - v->arch.gic.v3.lr[6 ] =READ_SYSREG (ICH_LR6_EL2 ); + v->arch.gic.v3.lr[6 ] =READ_SYSREG_LR (6 );case 6 : - v->arch.gic.v3.lr[5 ] =READ_SYSREG (ICH_LR5_EL2 ); + v->arch.gic.v3.lr[5 ] =READ_SYSREG_LR (5 );case 5 : - v->arch.gic.v3.lr[4 ] =READ_SYSREG (ICH_LR4_EL2 ); + v->arch.gic.v3.lr[4 ] =READ_SYSREG_LR (4 );case 4 : - v->arch.gic.v3.lr[3 ] =READ_SYSREG (ICH_LR3_EL2 ); + v->arch.gic.v3.lr[3 ] =READ_SYSREG_LR (3 );case 3 : - v->arch.gic.v3.lr[2 ] =READ_SYSREG (ICH_LR2_EL2 ); + v->arch.gic.v3.lr[2 ] =READ_SYSREG_LR (2 );case 2 : - v->arch.gic.v3.lr[1 ] =READ_SYSREG (ICH_LR1_EL2 ); + v->arch.gic.v3.lr[1 ] =READ_SYSREG_LR (1 );case 1 : - v->arch.gic.v3.lr[0 ] =READ_SYSREG (ICH_LR0_EL2 ); + v->arch.gic.v3.lr[0 ] =READ_SYSREG_LR (0 );break ;default :BUG ();
@@ -120,37 +120,37 @@ static inline void gicv3_restore_lrs(const struct vcpu *v)switch ( gicv3_info.nr_lrs ) {case 16 : -WRITE_SYSREG (v->arch.gic.v3.lr[15 ],ICH_LR15_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[15 ],15 );case 15 : -WRITE_SYSREG (v->arch.gic.v3.lr[14 ],ICH_LR14_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[14 ],14 );case 14 : -WRITE_SYSREG (v->arch.gic.v3.lr[13 ],ICH_LR13_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[13 ],13 );case 13 : -WRITE_SYSREG (v->arch.gic.v3.lr[12 ],ICH_LR12_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[12 ],12 );case 12 : -WRITE_SYSREG (v->arch.gic.v3.lr[11 ],ICH_LR11_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[11 ],11 );case 11 : -WRITE_SYSREG (v->arch.gic.v3.lr[10 ],ICH_LR10_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[10 ],10 );case 10 : -WRITE_SYSREG (v->arch.gic.v3.lr[9 ],ICH_LR9_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[9 ],9 );case 9 : -WRITE_SYSREG (v->arch.gic.v3.lr[8 ],ICH_LR8_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[8 ],8 );case 8 : -WRITE_SYSREG (v->arch.gic.v3.lr[7 ],ICH_LR7_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[7 ],7 );case 7 : -WRITE_SYSREG (v->arch.gic.v3.lr[6 ],ICH_LR6_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[6 ],6 );case 6 : -WRITE_SYSREG (v->arch.gic.v3.lr[5 ],ICH_LR5_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[5 ],5 );case 5 : -WRITE_SYSREG (v->arch.gic.v3.lr[4 ],ICH_LR4_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[4 ],4 );case 4 : -WRITE_SYSREG (v->arch.gic.v3.lr[3 ],ICH_LR3_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[3 ],3 );case 3 : -WRITE_SYSREG (v->arch.gic.v3.lr[2 ],ICH_LR2_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[2 ],2 );case 2 : -WRITE_SYSREG (v->arch.gic.v3.lr[1 ],ICH_LR1_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[1 ],1 );case 1 : -WRITE_SYSREG (v->arch.gic.v3.lr[0 ],ICH_LR0_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[0 ],0 );break ;default :BUG ();
@@ -161,22 +161,22 @@ static uint64_t gicv3_ich_read_lr(int lr) {switch ( lr ) { -case 0 :return READ_SYSREG (ICH_LR0_EL2 ); -case 1 :return READ_SYSREG (ICH_LR1_EL2 ); -case 2 :return READ_SYSREG (ICH_LR2_EL2 ); -case 3 :return READ_SYSREG (ICH_LR3_EL2 ); -case 4 :return READ_SYSREG (ICH_LR4_EL2 ); -case 5 :return READ_SYSREG (ICH_LR5_EL2 ); -case 6 :return READ_SYSREG (ICH_LR6_EL2 ); -case 7 :return READ_SYSREG (ICH_LR7_EL2 ); -case 8 :return READ_SYSREG (ICH_LR8_EL2 ); -case 9 :return READ_SYSREG (ICH_LR9_EL2 ); -case 10 :return READ_SYSREG (ICH_LR10_EL2 ); -case 11 :return READ_SYSREG (ICH_LR11_EL2 ); -case 12 :return READ_SYSREG (ICH_LR12_EL2 ); -case 13 :return READ_SYSREG (ICH_LR13_EL2 ); -case 14 :return READ_SYSREG (ICH_LR14_EL2 ); -case 15 :return READ_SYSREG (ICH_LR15_EL2 ); +case 0 :return READ_SYSREG_LR (0 ); +case 1 :return READ_SYSREG_LR (1 ); +case 2 :return READ_SYSREG_LR (2 ); +case 3 :return READ_SYSREG_LR (3 ); +case 4 :return READ_SYSREG_LR (4 ); +case 5 :return READ_SYSREG_LR (5 ); +case 6 :return READ_SYSREG_LR (6 ); +case 7 :return READ_SYSREG_LR (7 ); +case 8 :return READ_SYSREG_LR (8 ); +case 9 :return READ_SYSREG_LR (9 ); +case 10 :return READ_SYSREG_LR (10 ); +case 11 :return READ_SYSREG_LR (11 ); +case 12 :return READ_SYSREG_LR (12 ); +case 13 :return READ_SYSREG_LR (13 ); +case 14 :return READ_SYSREG_LR (14 ); +case 15 :return READ_SYSREG_LR (15 );default :BUG (); }
@@ -187,52 +187,52 @@ static void gicv3_ich_write_lr(int lr, uint64_t val)switch ( lr ) {case 0 : -WRITE_SYSREG (val,ICH_LR0_EL2 ); +WRITE_SYSREG_LR (val,0 );break ;case 1 : -WRITE_SYSREG (val,ICH_LR1_EL2 ); +WRITE_SYSREG_LR (val,1 );break ;case 2 : -WRITE_SYSREG (val,ICH_LR2_EL2 ); +WRITE_SYSREG_LR (val,2 );break ;case 3 : -WRITE_SYSREG (val,ICH_LR3_EL2 ); +WRITE_SYSREG_LR (val,3 );break ;case 4 : -WRITE_SYSREG (val,ICH_LR4_EL2 ); +WRITE_SYSREG_LR (val,4 );break ;case 5 : -WRITE_SYSREG (val,ICH_LR5_EL2 ); +WRITE_SYSREG_LR (val,5 );break ;case 6 : -WRITE_SYSREG (val,ICH_LR6_EL2 ); +WRITE_SYSREG_LR (val,6 );break ;case 7 : -WRITE_SYSREG (val,ICH_LR7_EL2 ); +WRITE_SYSREG_LR (val,7 );break ;case 8 : -WRITE_SYSREG (val,ICH_LR8_EL2 ); +WRITE_SYSREG_LR (val,8 );break ;case 9 : -WRITE_SYSREG (val,ICH_LR9_EL2 ); +WRITE_SYSREG_LR (val,9 );break ;case 10 : -WRITE_SYSREG (val,ICH_LR10_EL2 ); +WRITE_SYSREG_LR (val,10 );break ;case 11 : -WRITE_SYSREG (val,ICH_LR11_EL2 ); +WRITE_SYSREG_LR (val,11 );break ;case 12 : -WRITE_SYSREG (val,ICH_LR12_EL2 ); +WRITE_SYSREG_LR (val,12 );break ;case 13 : -WRITE_SYSREG (val,ICH_LR13_EL2 ); +WRITE_SYSREG_LR (val,13 );break ;case 14 : -WRITE_SYSREG (val,ICH_LR14_EL2 ); +WRITE_SYSREG_LR (val,14 );break ;case 15 : -WRITE_SYSREG (val,ICH_LR15_EL2 ); +WRITE_SYSREG_LR (val,15 );break ;default :return ;
@@ -417,12 +417,12 @@ static void gicv3_dump_state(const struct vcpu *v)if ( v == current ) {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" HW_LR[%d]=%lx\n" , i,gicv3_ich_read_lr (i)); +printk (" HW_LR[%d]=%" PRIx64"\n" , i,gicv3_ich_read_lr (i)); }else {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%lx\n" , i, v->arch.gic.v3.lr[i]); +printk (" VCPU_LR[%d]=%" PRIx64"\n" , i, v->arch.gic.v3.lr[i]); } }
xen/arch/arm/include/asm/arm32/sysregs.h +19 -0
@@ -62,6 +62,25 @@ #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define ICH_LRC_REG (index) ICH_LRC ## index ## _EL2 + +#define READ_SYSREG_LR (index) ({ \ + uint64_t _val; \ + uint32_t _lrc = READ_CP32(ICH_LRC_REG(index)); \ + uint32_t _lr = READ_CP32(ICH_LR_REG(index)); \ + \ + _val = ((uint64_t) _lrc << 32) | _lr; \ + _val; \ +}) + +#define WRITE_SYSREG_LR (v, index) ({ \ + uint64_t _val = (v); \ + WRITE_CP32(_val & GENMASK(31, 0), ICH_LR_REG(index)); \ + WRITE_CP32(_val >> 32, ICH_LRC_REG(index)); \ +}) +/* MVFR2 is not defined on ARMv7 */ #define MVFR2_MAYBE_UNDEFINED
xen/arch/arm/include/asm/arm64/sysregs.h +5 -0
@@ -472,6 +472,11 @@#define READ_SYSREG (name) READ_SYSREG64(name)#define WRITE_SYSREG (v, name) WRITE_SYSREG64(v, name) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define WRITE_SYSREG_LR (v, index) WRITE_SYSREG(v, ICH_LR_REG(index)) +#define READ_SYSREG_LR (index) READ_SYSREG(ICH_LR_REG(index)) +#endif /* _ASM_ARM_ARM64_SYSREGS_H */ /*
xen/arch/arm/include/asm/cpregs.h +76 -0
94 lines not on this page · raw message
xen/arch/arm/include/asm/gic_v3_defs.h +4 -4
@@ -185,9 +185,9 @@#define ICH_LR_HW_SHIFT 61#define ICH_LR_GRP_MASK 0x1#define ICH_LR_GRP_SHIFT 60 -#define ICH_LR_MAINTENANCE_IRQ (1UL<<41) -#define ICH_LR_GRP1 (1UL<<60) -#define ICH_LR_HW (1UL<<61) +#define ICH_LR_MAINTENANCE_IRQ (1ULL << 41) +#define ICH_LR_GRP1 (1ULL << 60) +#define ICH_LR_HW (1ULL << 61)#define ICH_VTR_NRLRGS 0x3f#define ICH_VTR_PRIBITS_MASK 0x7
@@ -195,7 +195,7 @@#define ICH_SGI_IRQMODE_SHIFT 40#define ICH_SGI_IRQMODE_MASK 0x1 -#define ICH_SGI_TARGET_OTHERS 1UL +#define ICH_SGI_TARGET_OTHERS 1ULL#define ICH_SGI_TARGET_LIST 0#define ICH_SGI_IRQ_SHIFT 24#define ICH_SGI_IRQ_MASK 0xf
Signature · 1 line
2.17.1
PATCH v4 10/11 xen/Arm: GICv3: Define macros to read/write 64 bit
In reply to Ayan Kumar HalderOn AArch32, ldrd/strd instructions are not atomic when used to access MMIO. Furthermore, ldrd/strd instructions are not decoded by Arm when running as a guest to access emulated MMIO region.
Thus, we have defined readq_relaxed_non_atomic()/writeq_relaxed_non_atomic() which in turn calls readl_relaxed()/writel_relaxed() for the lower and upper 32 bits.
For AArch64, readq_relaxed_non_atomic()/writeq_relaxed_non_atomic() invokes readq_relaxed()/writeq_relaxed() respectively.
As GICv3 registers (GICD_IROUTER, GICR_TYPER) can be accessed in a non atomic manner, so we have used readq_relaxed_non_atomic()/writeq_relaxed_non_atomic().
---
Changes from :-
v1 - 1. Use ldrd/strd for readq_relaxed()/writeq_relaxed().
2. No need to use le64_to_cpu() as the returned byte order is already in cpu endianess.
v2 - 1. Replace {read/write}q_relaxed with {read/write}q_relaxed_non_atomic().
v3 - 1. Use inline function definitions for {read/write}q_relaxed_non_atomic().
2. For AArch64, {read/write}q_relaxed_non_atomic() should invoke {read/write}q_relaxed(). Thus, we can avoid any ifdef in gic-v3.c.
xen/arch/arm/gic-v3.c | 6 +++--- xen/arch/arm/include/asm/arm32/io.h | 20 ++++++++++++++++++++ xen/arch/arm/include/asm/arm64/io.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-)
xen/arch/arm/gic-v3.c +3 -3
@@ -651,7 +651,7 @@ static void __init gicv3_dist_init(void) affinity &= ~GICD_IROUTER_SPI_MODE_ANY ;for ( i =NR_GIC_LOCAL_IRQS ; i < nr_lines; i++ ) -writeq_relaxed (affinity,GICD +GICD_IROUTER + i *8 ); +writeq_relaxed_non_atomic (affinity,GICD +GICD_IROUTER + i *8 ); }static int gicv3_enable_redist (void )
@@ -745,7 +745,7 @@ static int __init gicv3_populate_rdist(void) } do { - typer = readq_relaxed(ptr + GICR_TYPER); + typer = readq_relaxed_non_atomic(ptr + GICR_TYPER); if ( (typer >> 32) == aff ) {
@@ -1265,7 +1265,7 @@ static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask) affinity &= ~GICD_IROUTER_SPI_MODE_ANY ;if ( desc->irq >=NR_GIC_LOCAL_IRQS ) -writeq_relaxed (affinity, (GICD +GICD_IROUTER + desc->irq *8 )); +writeq_relaxed_non_atomic (affinity, (GICD +GICD_IROUTER + desc->irq *8 ));spin_unlock (&gicv3.lock); }
xen/arch/arm/include/asm/arm32/io.h +20 -0
@@ -80,10 +80,30 @@ static inline u32 __raw_readl(const volatile void __iomem *addr) __raw_readw(c)); __r; })#define readl_relaxed (c) ({ u32 __r = le32_to_cpu((__force __le32) \ __raw_readl(c)); __r; }) +/* +* ldrd instructions are not decoded by Arm when running as a guest to access +* emulated MMIO region. Thus, readq_relaxed_non_atomic() invokes readl_relaxed() +* twice to read the lower and upper 32 bits. +*/ +static inline u64 readq_relaxed_non_atomic (const volatile void __iomem *addr) +{ +u64 val = (((u64 )readl_relaxed (addr +4 )) <<32 ) |readl_relaxed (addr); +return val; +}#define writeb_relaxed (v,c) __raw_writeb(v,c)#define writew_relaxed (v,c) __raw_writew((__force u16) cpu_to_le16(v),c)#define writel_relaxed (v,c) __raw_writel((__force u32) cpu_to_le32(v),c) +/* +* strd instructions are not decoded by Arm when running as a guest to access +* emulated MMIO region. Thus, writeq_relaxed_non_atomic() invokes writel_relaxed() +* twice to write the lower and upper 32 bits. +*/ +static inline void writeq_relaxed_non_atomic (u64 val,volatile void __iomem *addr) +{ +writel_relaxed ((u32 )val, addr); +writel_relaxed ((u32)(val >>32 ), addr +4 ); +}#define readb (c) ({ u8 __v = readb_relaxed(c); __iormb(); __v; })#define readw (c) ({ u16 __v = readw_relaxed(c); __iormb(); __v; })
xen/arch/arm/include/asm/arm64/io.h +2 -0
@@ -102,11 +102,13 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)#define readw_relaxed (c) ({ u16 __v = le16_to_cpu((__force __le16)__raw_readw(c)); __v; })#define readl_relaxed (c) ({ u32 __v = le32_to_cpu((__force __le32)__raw_readl(c)); __v; })#define readq_relaxed (c) ({ u64 __v = le64_to_cpu((__force __le64)__raw_readq(c)); __v; }) +#define readq_relaxed_non_atomic (c) readq_relaxed((c))#define writeb_relaxed (v,c) ((void)__raw_writeb((v),(c)))#define writew_relaxed (v,c) ((void)__raw_writew((__force u16)cpu_to_le16(v),(c)))#define writel_relaxed (v,c) ((void)__raw_writel((__force u32)cpu_to_le32(v),(c)))#define writeq_relaxed (v,c) ((void)__raw_writeq((__force u64)cpu_to_le64(v),(c))) +#define writeq_relaxed_non_atomic (v,c) writeq_relaxed((v),(c))/* * I/O memory access primitives. Reads are ordered relative to any
Signature · 1 line
2.17.1
PATCH v4 11/11 xen/Arm: GICv3: Enable GICv3 for AArch32
In reply to Ayan Kumar HalderOne can now use GICv3 on AArch32 systems. However, ITS is not supported. The reason being currently we are trying to validate GICv3 on an AArch32_v8R system. Refer ARM DDI 0568A.c ID110520, B1.3.1,
"A Generic Interrupt Controller (GIC) implemented with an Armv8-R PE must not implement LPI support."
By default GICv3 is disabled on AArch32 and enabled on AArch64.
Updated SUPPORT.md to state that GICv3 on Arm32 is not security supported.
---
Changed from :-
v1 - 1. Remove "ARM_64 || ARM_32" as it is always true.
2. Updated SUPPORT.md.
v2 - 1. GICv3 is enabled by default only on ARM_64.
2. Updated SUPPORT.md.
v3 - 1. GICv3 is not selected by ARM_64. Rather, it is optionally enabled.
2. GICv3 is disabled by default on ARM_32.
SUPPORT.md | 7 +++++++ xen/arch/arm/Kconfig | 9 +++++---- xen/arch/arm/include/asm/cpufeature.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-)
SUPPORT.md +7 -0
@@ -76,6 +76,13 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported +### ARM/GICv3 + +GICv3 is an interrupt controller specification designed by Arm. + + Status, Arm64: Security supported + Status, Arm32: Supported, not security supported + ### ARM/GICv3 ITS Extension to the GICv3 interrupt controller to support MSI.
xen/arch/arm/Kconfig +5 -4
@@ -41,16 +41,17 @@ config ARM_EFI config GICV3 bool "GICv3 driver" - depends on ARM_64 && !NEW_VGIC - default y + depends on !NEW_VGIC + default n if ARM_32 + default y if ARM_64 ---help--- Driver for the ARM Generic Interrupt Controller v3. - If unsure, say Y + If unsure, say N for ARM_32 and Y for ARM_64 config HAS_ITS bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED - depends on GICV3 && !NEW_VGIC + depends on GICV3 && !NEW_VGIC && !ARM_32 config HVM def_bool y
xen/arch/arm/include/asm/cpufeature.h +1 -0
@@ -33,6 +33,7 @@#define cpu_has_aarch32 (cpu_has_arm || cpu_has_thumb)#ifdef CONFIG_ARM_32 +#define cpu_has_gicv3 (boot_cpu_feature32(gic) >= 1)#define cpu_has_gentimer (boot_cpu_feature32(gentimer) == 1)/* * On Armv7, the value 0 is used to indicate that PMUv2 is not
Signature · 1 line
2.17.1
PATCH v4 9/11 xen/Arm: GICv3: Define remaining GIC registers for AArch32
In reply to Ayan Kumar HalderDefine missing assembly aliases for GIC registers on arm32, taking the ones defined already for arm64 as a base. Aliases are defined according to the GIC Architecture Specification ARM IHI 0069H.
Defined the following registers:-
1. Interrupt Controller Interrupt Priority Mask Register
2. Interrupt Controller System Register Enable register
3. Interrupt Controller Deactivate Interrupt Register
4. Interrupt Controller End Of Interrupt Register 1
5. Interrupt Controller Interrupt Acknowledge Register 1
6. Interrupt Controller Binary Point Register 1
7. Interrupt Controller Control Register
8. Interrupt Controller Interrupt Group 1 Enable register
9. Interrupt Controller Maintenance Interrupt State Register
10. Interrupt Controller End of Interrupt Status Register
11. Interrupt Controller Empty List Register Status Register
12. Interrupt Controller Virtual Machine Control Register
---
Changes from :-
v1 - 1. Moved coproc regs definition to asm/cpregs.h
v2 - 1. Defined register alias.
2. Style issues.
3. Defined ELSR, MISR, EISR to make it consistent with AArch64.
v3 - 1. Rectified some of the register names.
xen/arch/arm/include/asm/cpregs.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
xen/arch/arm/include/asm/cpregs.h +32 -0
@@ -163,6 +163,7 @@#define DACR p15,0,c3,c0,0/* Domain Access Control Register */ /* CP15 CR4: */ +#define ICC_PMR p15,0,c4,c6,0/* Interrupt Priority Mask Register */ /* CP15 CR5: Fault Status Registers */ #define DFSR p15,0,c5,c0,0/* Data Fault Status Register */
@@ -256,6 +257,7 @@/* CP15 CR12: */ #define ICC_SGI1R p15,0,c12/* Interrupt Controller SGI Group 1 */ +#define ICC_DIR p15,0,c12,c11,1/* Interrupt Controller Deactivate Interrupt Register */ #define ICC_ASGI1R p15,1,c12/* Interrupt Controller Alias SGI Group 1 Register */ #define ICC_SGI0R p15,2,c12/* Interrupt Controller SGI Group 0 */ #define VBAR p15,0,c12,c0,0/* Vector Base Address Register */
@@ -281,6 +283,20 @@#define ICH_AP1R2 __AP1Rx(2)#define ICH_AP1R3 __AP1Rx(3) +#define ICC_IAR1 p15,0,c12,c12,0/* Interrupt Controller Interrupt Acknowledge Register 1 */ +#define ICC_EOIR1 p15,0,c12,c12,1/* Interrupt Controller End Of Interrupt Register 1 */ +#define ICC_BPR1 p15,0,c12,c12,3/* Interrupt Controller Binary Point Register 1 */ +#define ICC_CTLR p15,0,c12,c12,4/* Interrupt Controller Control Register */ +#define ICC_SRE p15,0,c12,c12,5/* Interrupt Controller System Register Enable register */ +#define ICC_IGRPEN1 p15,0,c12,c12,7/* Interrupt Controller Interrupt Group 1 Enable register */ +#define ICC_HSRE p15,4,c12,c9,5/* Interrupt Controller Hyp System Register Enable register */ +#define ICH_HCR p15,4,c12,c11,0/* Interrupt Controller Hyp Control Register */ +#define ICH_VTR p15,4,c12,c11,1/* Interrupt Controller VGIC Type Register */ +#define ICH_MISR p15,4,c12,c11,2/* Interrupt Controller Maintenance Interrupt State Register */ +#define ICH_EISR p15,4,c12,c11,3/* Interrupt Controller End of Interrupt Status Register */ +#define ICH_ELRSR p15,4,c12,c11,5/* Interrupt Controller Empty List Register Status Register */ +#define ICH_VMCR p15,4,c12,c11,7/* Interrupt Controller Virtual Machine Control Register */ +/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ #define __LR0 (x) ___CP32(p15, 4, c12, c12, x)#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)
@@ -381,6 +397,15 @@#define HCR_EL2 HCR#define HPFAR_EL2 HPFAR#define HSTR_EL2 HSTR +#define ICC_BPR1_EL1 ICC_BPR1 +#define ICC_CTLR_EL1 ICC_CTLR +#define ICC_DIR_EL1 ICC_DIR +#define ICC_EOIR1_EL1 ICC_EOIR1 +#define ICC_IGRPEN1_EL1 ICC_IGRPEN1 +#define ICC_PMR_EL1 ICC_PMR +#define ICC_SGI1R_EL1 ICC_SGI1R +#define ICC_SRE_EL1 ICC_SRE +#define ICC_SRE_EL2 ICC_HSRE#define ICH_AP0R0_EL2 ICH_AP0R0#define ICH_AP0R1_EL2 ICH_AP0R1#define ICH_AP0R2_EL2 ICH_AP0R2
@@ -389,6 +414,10 @@#define ICH_AP1R1_EL2 ICH_AP1R1#define ICH_AP1R2_EL2 ICH_AP1R2#define ICH_AP1R3_EL2 ICH_AP1R3 +#define ICH_EISR_EL2 ICH_EISR +#define ICH_ELRSR_EL2 ICH_ELRSR +#define ICH_HCR_EL2 ICH_HCR +#define ICC_IAR1_EL1 ICC_IAR1#define ICH_LR0_EL2 ICH_LR0#define ICH_LR1_EL2 ICH_LR1#define ICH_LR2_EL2 ICH_LR2
@@ -421,6 +450,9 @@#define ICH_LRC13_EL2 ICH_LRC13#define ICH_LRC14_EL2 ICH_LRC14#define ICH_LRC15_EL2 ICH_LRC15 +#define ICH_MISR_EL2 ICH_MISR +#define ICH_VMCR_EL2 ICH_VMCR +#define ICH_VTR_EL2 ICH_VTR#define ID_AFR0_EL1 ID_AFR0#define ID_DFR0_EL1 ID_DFR0#define ID_DFR1_EL1 ID_DFR1
Signature · 1 line
2.17.1
Re: [XEN v4 07/11] xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
In reply to Ayan Kumar HalderHi Ayan,
Quoted 9 lines · Ayan Kumar Halder
Refer "Arm IHI 0069H ID020922", 12.4.6, Interrupt Controller List Registers
AArch64 System register ICH_LR<n>_EL2 bits [31:0] are architecturally mapped to AArch32 System register ICH_LR<n>[31:0].
AArch64 System register ICH_LR<n>_EL2 bits [63:32] are architecturally mapped to AArch32 System register ICH_LRC<n>[31:0].
Quoted 8 lines
Defined ICH_LR<0...15>_EL2 and ICH_LRC<0...15>_EL2 for AArch32. For AArch32, the link register is stored as :- (((
uint64_t) ICH_LRC<0...15>_EL2) << 32) | ICH_LR<0...15>_EL2Also,
ICR_LRmacros need to be modified as ULL is 64 bits for AArch32 and AArch64.Signed-off-by Ayan Kumar Halder <[email protected]>
with two remarks (this is up to maintainers as these are rather cosmetic changes).
Quoted 242 lines
---
Changes from :-
v1 - 1. Moved the coproc register definitions toasm/cpregs.h.
2. UseGENMASK(31, 0)to represent0xFFFFFFFF
3. Use READ_CP32()/WRITE_CP32() instead of READ_SYSREG()/WRITE_SYSREG().
4. Multi-line macro definitions should be enclosed within ({ }).v2 - 1. Use
WRITE_SYSREG_LR(V, R)to make it consistent with before.
2. Defined the register alias.
3. Style issues.v3 - 1. Addressed style issues.
xen/arch/arm/gic-v3.c | 132 +++++++++++------------ xen/arch/arm/include/asm/arm32/sysregs.h | 19 ++++ xen/arch/arm/include/asm/arm64/sysregs.h | 5 + xen/arch/arm/include/asm/cpregs.h | 76 +++++++++++++ xen/arch/arm/include/asm/gic_v3_defs.h | 8 +- 5 files changed, 170 insertions(+), 70 deletions(-)xen/arch/arm/gic-v3.c +64
-64@@ -73,37 +73,37 @@ static inline void gicv3_save_lrs(struct vcpu *v)switch ( gicv3_info.nr_lrs ) {case 16 : - v->arch.gic.v3.lr[15 ] =READ_SYSREG (ICH_LR15_EL2 ); + v->arch.gic.v3.lr[15 ] =READ_SYSREG_LR (15 );case 15 : - v->arch.gic.v3.lr[14 ] =READ_SYSREG (ICH_LR14_EL2 ); + v->arch.gic.v3.lr[14 ] =READ_SYSREG_LR (14 );case 14 : - v->arch.gic.v3.lr[13 ] =READ_SYSREG (ICH_LR13_EL2 ); + v->arch.gic.v3.lr[13 ] =READ_SYSREG_LR (13 );case 13 : - v->arch.gic.v3.lr[12 ] =READ_SYSREG (ICH_LR12_EL2 ); + v->arch.gic.v3.lr[12 ] =READ_SYSREG_LR (12 );case 12 : - v->arch.gic.v3.lr[11 ] =READ_SYSREG (ICH_LR11_EL2 ); + v->arch.gic.v3.lr[11 ] =READ_SYSREG_LR (11 );case 11 : - v->arch.gic.v3.lr[10 ] =READ_SYSREG (ICH_LR10_EL2 ); + v->arch.gic.v3.lr[10 ] =READ_SYSREG_LR (10 );case 10 : - v->arch.gic.v3.lr[9 ] =READ_SYSREG (ICH_LR9_EL2 ); + v->arch.gic.v3.lr[9 ] =READ_SYSREG_LR (9 );case 9 : - v->arch.gic.v3.lr[8 ] =READ_SYSREG (ICH_LR8_EL2 ); + v->arch.gic.v3.lr[8 ] =READ_SYSREG_LR (8 );case 8 : - v->arch.gic.v3.lr[7 ] =READ_SYSREG (ICH_LR7_EL2 ); + v->arch.gic.v3.lr[7 ] =READ_SYSREG_LR (7 );case 7 : - v->arch.gic.v3.lr[6 ] =READ_SYSREG (ICH_LR6_EL2 ); + v->arch.gic.v3.lr[6 ] =READ_SYSREG_LR (6 );case 6 : - v->arch.gic.v3.lr[5 ] =READ_SYSREG (ICH_LR5_EL2 ); + v->arch.gic.v3.lr[5 ] =READ_SYSREG_LR (5 );case 5 : - v->arch.gic.v3.lr[4 ] =READ_SYSREG (ICH_LR4_EL2 ); + v->arch.gic.v3.lr[4 ] =READ_SYSREG_LR (4 );case 4 : - v->arch.gic.v3.lr[3 ] =READ_SYSREG (ICH_LR3_EL2 ); + v->arch.gic.v3.lr[3 ] =READ_SYSREG_LR (3 );case 3 : - v->arch.gic.v3.lr[2 ] =READ_SYSREG (ICH_LR2_EL2 ); + v->arch.gic.v3.lr[2 ] =READ_SYSREG_LR (2 );case 2 : - v->arch.gic.v3.lr[1 ] =READ_SYSREG (ICH_LR1_EL2 ); + v->arch.gic.v3.lr[1 ] =READ_SYSREG_LR (1 );case 1 : - v->arch.gic.v3.lr[0 ] =READ_SYSREG (ICH_LR0_EL2 ); + v->arch.gic.v3.lr[0 ] =READ_SYSREG_LR (0 );break ;default :BUG ();@@ -120,37 +120,37 @@ static inline void gicv3_restore_lrs(const struct vcpu *v)switch ( gicv3_info.nr_lrs ) {case 16 : -WRITE_SYSREG (v->arch.gic.v3.lr[15 ],ICH_LR15_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[15 ],15 );case 15 : -WRITE_SYSREG (v->arch.gic.v3.lr[14 ],ICH_LR14_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[14 ],14 );case 14 : -WRITE_SYSREG (v->arch.gic.v3.lr[13 ],ICH_LR13_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[13 ],13 );case 13 : -WRITE_SYSREG (v->arch.gic.v3.lr[12 ],ICH_LR12_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[12 ],12 );case 12 : -WRITE_SYSREG (v->arch.gic.v3.lr[11 ],ICH_LR11_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[11 ],11 );case 11 : -WRITE_SYSREG (v->arch.gic.v3.lr[10 ],ICH_LR10_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[10 ],10 );case 10 : -WRITE_SYSREG (v->arch.gic.v3.lr[9 ],ICH_LR9_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[9 ],9 );case 9 : -WRITE_SYSREG (v->arch.gic.v3.lr[8 ],ICH_LR8_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[8 ],8 );case 8 : -WRITE_SYSREG (v->arch.gic.v3.lr[7 ],ICH_LR7_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[7 ],7 );case 7 : -WRITE_SYSREG (v->arch.gic.v3.lr[6 ],ICH_LR6_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[6 ],6 );case 6 : -WRITE_SYSREG (v->arch.gic.v3.lr[5 ],ICH_LR5_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[5 ],5 );case 5 : -WRITE_SYSREG (v->arch.gic.v3.lr[4 ],ICH_LR4_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[4 ],4 );case 4 : -WRITE_SYSREG (v->arch.gic.v3.lr[3 ],ICH_LR3_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[3 ],3 );case 3 : -WRITE_SYSREG (v->arch.gic.v3.lr[2 ],ICH_LR2_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[2 ],2 );case 2 : -WRITE_SYSREG (v->arch.gic.v3.lr[1 ],ICH_LR1_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[1 ],1 );case 1 : -WRITE_SYSREG (v->arch.gic.v3.lr[0 ],ICH_LR0_EL2 ); +WRITE_SYSREG_LR (v->arch.gic.v3.lr[0 ],0 );break ;default :BUG ();@@ -161,22 +161,22 @@ static uint64_t gicv3_ich_read_lr(int lr) {switch ( lr ) { -case 0 :return READ_SYSREG (ICH_LR0_EL2 ); -case 1 :return READ_SYSREG (ICH_LR1_EL2 ); -case 2 :return READ_SYSREG (ICH_LR2_EL2 ); -case 3 :return READ_SYSREG (ICH_LR3_EL2 ); -case 4 :return READ_SYSREG (ICH_LR4_EL2 ); -case 5 :return READ_SYSREG (ICH_LR5_EL2 ); -case 6 :return READ_SYSREG (ICH_LR6_EL2 ); -case 7 :return READ_SYSREG (ICH_LR7_EL2 ); -case 8 :return READ_SYSREG (ICH_LR8_EL2 ); -case 9 :return READ_SYSREG (ICH_LR9_EL2 ); -case 10 :return READ_SYSREG (ICH_LR10_EL2 ); -case 11 :return READ_SYSREG (ICH_LR11_EL2 ); -case 12 :return READ_SYSREG (ICH_LR12_EL2 ); -case 13 :return READ_SYSREG (ICH_LR13_EL2 ); -case 14 :return READ_SYSREG (ICH_LR14_EL2 ); -case 15 :return READ_SYSREG (ICH_LR15_EL2 ); +case 0 :return READ_SYSREG_LR (0 ); +case 1 :return READ_SYSREG_LR (1 ); +case 2 :return READ_SYSREG_LR (2 ); +case 3 :return READ_SYSREG_LR (3 ); +case 4 :return READ_SYSREG_LR (4 ); +case 5 :return READ_SYSREG_LR (5 ); +case 6 :return READ_SYSREG_LR (6 ); +case 7 :return READ_SYSREG_LR (7 ); +case 8 :return READ_SYSREG_LR (8 ); +case 9 :return READ_SYSREG_LR (9 ); +case 10 :return READ_SYSREG_LR (10 ); +case 11 :return READ_SYSREG_LR (11 ); +case 12 :return READ_SYSREG_LR (12 ); +case 13 :return READ_SYSREG_LR (13 ); +case 14 :return READ_SYSREG_LR (14 ); +case 15 :return READ_SYSREG_LR (15 );default :BUG (); }@@ -187,52 +187,52 @@ static void gicv3_ich_write_lr(int lr, uint64_t val)switch ( lr ) {case 0 : -WRITE_SYSREG (val,ICH_LR0_EL2 ); +WRITE_SYSREG_LR (val,0 );break ;case 1 : -WRITE_SYSREG (val,ICH_LR1_EL2 ); +WRITE_SYSREG_LR (val,1 );break ;case 2 : -WRITE_SYSREG (val,ICH_LR2_EL2 ); +WRITE_SYSREG_LR (val,2 );break ;case 3 : -WRITE_SYSREG (val,ICH_LR3_EL2 ); +WRITE_SYSREG_LR (val,3 );break ;case 4 : -WRITE_SYSREG (val,ICH_LR4_EL2 ); +WRITE_SYSREG_LR (val,4 );break ;case 5 : -WRITE_SYSREG (val,ICH_LR5_EL2 ); +WRITE_SYSREG_LR (val,5 );break ;case 6 : -WRITE_SYSREG (val,ICH_LR6_EL2 ); +WRITE_SYSREG_LR (val,6 );break ;case 7 : -WRITE_SYSREG (val,ICH_LR7_EL2 ); +WRITE_SYSREG_LR (val,7 );break ;case 8 : -WRITE_SYSREG (val,ICH_LR8_EL2 ); +WRITE_SYSREG_LR (val,8 );break ;case 9 : -WRITE_SYSREG (val,ICH_LR9_EL2 ); +WRITE_SYSREG_LR (val,9 );break ;case 10 : -WRITE_SYSREG (val,ICH_LR10_EL2 ); +WRITE_SYSREG_LR (val,10 );break ;case 11 : -WRITE_SYSREG (val,ICH_LR11_EL2 ); +WRITE_SYSREG_LR (val,11 );break ;case 12 : -WRITE_SYSREG (val,ICH_LR12_EL2 ); +WRITE_SYSREG_LR (val,12 );break ;case 13 : -WRITE_SYSREG (val,ICH_LR13_EL2 ); +WRITE_SYSREG_LR (val,13 );break ;case 14 : -WRITE_SYSREG (val,ICH_LR14_EL2 ); +WRITE_SYSREG_LR (val,14 );break ;case 15 : -WRITE_SYSREG (val,ICH_LR15_EL2 ); +WRITE_SYSREG_LR (val,15 );break ;default :return ;
xen/arch/arm/gic-v3.c static void gicv3_dump_state(const struct vcpu *v) · line 420
Quoted 5 lines
xen/arch/arm/gic-v3.c +1
-1@@ -417,12 +417,12 @@ static void gicv3_dump_state(const struct vcpu *v)if ( v == current ) {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" HW_LR[%d]=%lx\n" , i,gicv3_ich_read_lr (i)); +printk (" HW_LR[%d]=%" PRIx64"\n" , i,gicv3_ich_read_lr (i));
1. We do not usually add spaces between " and PRIx.
Quoted 60 lines
xen/arch/arm/gic-v3.c +1
-1}else {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%lx\n" , i, v->arch.gic.v3.lr[i]); +printk (" VCPU_LR[%d]=%" PRIx64"\n" , i, v->arch.gic.v3.lr[i]); } }xen/arch/arm/include/asm/arm32/sysregs.h +19
-0@@ -62,6 +62,25 @@ #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define ICH_LRC_REG (index) ICH_LRC ## index ## _EL2 + +#define READ_SYSREG_LR (index) ({ \ + uint64_t _val; \ + uint32_t _lrc = READ_CP32(ICH_LRC_REG(index)); \ + uint32_t _lr = READ_CP32(ICH_LR_REG(index)); \ + \ + _val = ((uint64_t) _lrc << 32) | _lr; \ + _val; \ +}) + +#define WRITE_SYSREG_LR (v, index) ({ \ + uint64_t _val = (v); \ + WRITE_CP32(_val & GENMASK(31, 0), ICH_LR_REG(index)); \ + WRITE_CP32(_val >> 32, ICH_LRC_REG(index)); \ +}) +/* MVFR2 is not defined on ARMv7 */ #define MVFR2_MAYBE_UNDEFINED xen/arch/arm/include/asm/arm64/sysregs.h +5
-0@@ -472,6 +472,11 @@#define READ_SYSREG (name) READ_SYSREG64(name)#define WRITE_SYSREG (v, name) WRITE_SYSREG64(v, name) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define WRITE_SYSREG_LR (v, index) WRITE_SYSREG(v, ICH_LR_REG(index)) +#define READ_SYSREG_LR (index) READ_SYSREG(ICH_LR_REG(index)) +#endif /* _ASM_ARM_ARM64_SYSREGS_H */ /* xen/arch/arm/include/asm/cpregs.h +0
-0
xen/arch/arm/include/asm/cpregs.h line 11
Quoted 4 lines
xen/arch/arm/include/asm/cpregs.h +1
-0@@ -8,6 +8,8 @@* support 32-bit guests. */ +#define ___CP32 (coproc, opc1, crn, crm, opc2) coproc, opc1, crn, crm, opc2
2. As you are using ___CP32 much later in this file, it could be moved...
xen/arch/arm/include/asm/cpregs.h line 262
Quoted 7 lines
xen/arch/arm/include/asm/cpregs.h +1
-0+#define __HSR_CPREG_c0 0#define __HSR_CPREG_c1 1#define __HSR_CPREG_c2 2@@ -259,6 +261,48 @@#define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0/* Hyp. Vector Base Address Register */
...here, before first use. The remark I gave in v3 was that the definition should occur before use, but it does not mean placing the macro at the top of the file.
Quoted 112 lines
xen/arch/arm/include/asm/cpregs.h +74
-0+/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ +#define __LR0 (x) ___CP32(p15, 4, c12, c12, x) +#define __LR8 (x) ___CP32(p15, 4, c12, c13, x) + +#define ICH_LR0 __LR0(0) +#define ICH_LR1 __LR0(1) +#define ICH_LR2 __LR0(2) +#define ICH_LR3 __LR0(3) +#define ICH_LR4 __LR0(4) +#define ICH_LR5 __LR0(5) +#define ICH_LR6 __LR0(6) +#define ICH_LR7 __LR0(7) +#define ICH_LR8 __LR8(0) +#define ICH_LR9 __LR8(1) +#define ICH_LR10 __LR8(2) +#define ICH_LR11 __LR8(3) +#define ICH_LR12 __LR8(4) +#define ICH_LR13 __LR8(5) +#define ICH_LR14 __LR8(6) +#define ICH_LR15 __LR8(7) + +/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ +#define __LRC0 (x) ___CP32(p15, 4, c12, c14, x) +#define __LRC8 (x) ___CP32(p15, 4, c12, c15, x) + +#define ICH_LRC0 __LRC0(0) +#define ICH_LRC1 __LRC0(1) +#define ICH_LRC2 __LRC0(2) +#define ICH_LRC3 __LRC0(3) +#define ICH_LRC4 __LRC0(4) +#define ICH_LRC5 __LRC0(5) +#define ICH_LRC6 __LRC0(6) +#define ICH_LRC7 __LRC0(7) +#define ICH_LRC8 __LRC8(0) +#define ICH_LRC9 __LRC8(1) +#define ICH_LRC10 __LRC8(2) +#define ICH_LRC11 __LRC8(3) +#define ICH_LRC12 __LRC8(4) +#define ICH_LRC13 __LRC8(5) +#define ICH_LRC14 __LRC8(6) +#define ICH_LRC15 __LRC8(7) +/* CP15 CR13: */ #define FCSEIDR p15,0,c13,c0,0/* FCSE Process ID Register */ #define CONTEXTIDR p15,0,c13,c0,1/* Context ID Register */ @@ -317,6 +361,38 @@#define HCR_EL2 HCR#define HPFAR_EL2 HPFAR#define HSTR_EL2 HSTR +#define ICH_LR0_EL2 ICH_LR0 +#define ICH_LR1_EL2 ICH_LR1 +#define ICH_LR2_EL2 ICH_LR2 +#define ICH_LR3_EL2 ICH_LR3 +#define ICH_LR4_EL2 ICH_LR4 +#define ICH_LR5_EL2 ICH_LR5 +#define ICH_LR6_EL2 ICH_LR6 +#define ICH_LR7_EL2 ICH_LR7 +#define ICH_LR8_EL2 ICH_LR8 +#define ICH_LR9_EL2 ICH_LR9 +#define ICH_LR10_EL2 ICH_LR10 +#define ICH_LR11_EL2 ICH_LR11 +#define ICH_LR12_EL2 ICH_LR12 +#define ICH_LR13_EL2 ICH_LR13 +#define ICH_LR14_EL2 ICH_LR14 +#define ICH_LR15_EL2 ICH_LR15 +#define ICH_LRC0_EL2 ICH_LRC0 +#define ICH_LRC1_EL2 ICH_LRC1 +#define ICH_LRC2_EL2 ICH_LRC2 +#define ICH_LRC3_EL2 ICH_LRC3 +#define ICH_LRC4_EL2 ICH_LRC4 +#define ICH_LRC5_EL2 ICH_LRC5 +#define ICH_LRC6_EL2 ICH_LRC6 +#define ICH_LRC7_EL2 ICH_LRC7 +#define ICH_LRC8_EL2 ICH_LRC8 +#define ICH_LRC9_EL2 ICH_LRC9 +#define ICH_LRC10_EL2 ICH_LRC10 +#define ICH_LRC11_EL2 ICH_LRC11 +#define ICH_LRC12_EL2 ICH_LRC12 +#define ICH_LRC13_EL2 ICH_LRC13 +#define ICH_LRC14_EL2 ICH_LRC14 +#define ICH_LRC15_EL2 ICH_LRC15#define ID_AFR0_EL1 ID_AFR0#define ID_DFR0_EL1 ID_DFR0#define ID_DFR1_EL1 ID_DFR1xen/arch/arm/include/asm/gic_v3_defs.h +4
-5@@ -185,9 +185,9 @@#define ICH_LR_HW_SHIFT 61#define ICH_LR_GRP_MASK 0x1#define ICH_LR_GRP_SHIFT 60 -#define ICH_LR_MAINTENANCE_IRQ (1UL<<41) -#define ICH_LR_GRP1 (1UL<<60) -#define ICH_LR_HW (1UL<<61) +#define ICH_LR_MAINTENANCE_IRQ (1ULL << 41) +#define ICH_LR_GRP1 (1ULL << 60) +#define ICH_LR_HW (1ULL << 61)#define ICH_VTR_NRLRGS 0x3f#define ICH_VTR_PRIBITS_MASK 0x7@@ -195,7 +195,7 @@#define ICH_SGI_IRQMODE_SHIFT 40#define ICH_SGI_IRQMODE_MASK 0x1 -#define ICH_SGI_TARGET_OTHERS 1UL +#define ICH_SGI_TARGET_OTHERS 1ULL#define ICH_SGI_TARGET_LIST 0#define ICH_SGI_IRQ_SHIFT 24#define ICH_SGI_IRQ_MASK 0xf --
Quoted 3 lines
2.17.1
~Michal
Re: [XEN v4 08/11] xen/Arm: GICv3: Define ICH_AP0R<n> and ICH_AP1R<n> for AArch32
In reply to Ayan Kumar HalderHi Ayan,
Quoted 7 lines · Ayan Kumar Halder
Adapt save_aprn_regs()/restore_aprn_regs() for AArch32.
For which we have defined the following registers:-
1. Interrupt Controller Hyp Active Priorities Group0 Registers 0-3
2. Interrupt Controller Hyp Active Priorities Group1 Registers 0-3Signed-off-by Ayan Kumar Halder <[email protected]>
~Michal
Re: [XEN v4 09/11] xen/Arm: GICv3: Define remaining GIC registers for AArch32
In reply to Ayan Kumar HalderHi Ayan,
Quoted 18 lines · Ayan Kumar Halder
Define missing assembly aliases for GIC registers on arm32, taking the ones defined already for arm64 as a base. Aliases are defined according to the GIC Architecture Specification ARM IHI 0069H.
Defined the following registers:-
1. Interrupt Controller Interrupt Priority Mask Register
2. Interrupt Controller System Register Enable register
3. Interrupt Controller Deactivate Interrupt Register
4. Interrupt Controller End Of Interrupt Register 1
5. Interrupt Controller Interrupt Acknowledge Register 1
6. Interrupt Controller Binary Point Register 1
7. Interrupt Controller Control Register
8. Interrupt Controller Interrupt Group 1 Enable register
9. Interrupt Controller Maintenance Interrupt State Register
10. Interrupt Controller End of Interrupt Status Register
11. Interrupt Controller Empty List Register Status Register
12. Interrupt Controller Virtual Machine Control Register
Quoted 1 line
Signed-off-by Ayan Kumar Halder <[email protected]>
with one remark...
Quoted 27 lines
---
Changes from :-
v1 - 1. Moved coproc regs definition toasm/cpregs.hv2 - 1. Defined register alias.
2. Style issues.
3. Defined ELSR, MISR, EISR to make it consistent with AArch64.v3 - 1. Rectified some of the register names.
xen/arch/arm/include/asm/cpregs.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)xen/arch/arm/include/asm/cpregs.h +1
-0@@ -163,6 +163,7 @@#define DACR p15,0,c3,c0,0/* Domain Access Control Register */ /* CP15 CR4: */ +#define ICC_PMR p15,0,c4,c6,0/* Interrupt Priority Mask Register */ /* CP15 CR5: Fault Status Registers */ #define DFSR p15,0,c5,c0,0/* Data Fault Status Register */
xen/arch/arm/include/asm/cpregs.h line 260
Quoted 4 lines
xen/arch/arm/include/asm/cpregs.h +1
-0@@ -256,6 +257,7 @@/* CP15 CR12: */ #define ICC_SGI1R p15,0,c12/* Interrupt Controller SGI Group 1 */ +#define ICC_DIR p15,0,c12,c11,1/* Interrupt Controller Deactivate Interrupt Register */
Shouldn't ICC_DIR be placed after VBAR?
Quoted 52 lines
xen/arch/arm/include/asm/cpregs.h +27
-0#define ICC_ASGI1R p15,1,c12/* Interrupt Controller Alias SGI Group 1 Register */ #define ICC_SGI0R p15,2,c12/* Interrupt Controller SGI Group 0 */ #define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ @@ -281,6 +283,20 @@#define ICH_AP1R2 __AP1Rx(2)#define ICH_AP1R3 __AP1Rx(3) +#define ICC_IAR1 p15,0,c12,c12,0/* Interrupt Controller Interrupt Acknowledge Register 1 */ +#define ICC_EOIR1 p15,0,c12,c12,1/* Interrupt Controller End Of Interrupt Register 1 */ +#define ICC_BPR1 p15,0,c12,c12,3/* Interrupt Controller Binary Point Register 1 */ +#define ICC_CTLR p15,0,c12,c12,4/* Interrupt Controller Control Register */ +#define ICC_SRE p15,0,c12,c12,5/* Interrupt Controller System Register Enable register */ +#define ICC_IGRPEN1 p15,0,c12,c12,7/* Interrupt Controller Interrupt Group 1 Enable register */ +#define ICC_HSRE p15,4,c12,c9,5/* Interrupt Controller Hyp System Register Enable register */ +#define ICH_HCR p15,4,c12,c11,0/* Interrupt Controller Hyp Control Register */ +#define ICH_VTR p15,4,c12,c11,1/* Interrupt Controller VGIC Type Register */ +#define ICH_MISR p15,4,c12,c11,2/* Interrupt Controller Maintenance Interrupt State Register */ +#define ICH_EISR p15,4,c12,c11,3/* Interrupt Controller End of Interrupt Status Register */ +#define ICH_ELRSR p15,4,c12,c11,5/* Interrupt Controller Empty List Register Status Register */ +#define ICH_VMCR p15,4,c12,c11,7/* Interrupt Controller Virtual Machine Control Register */ +/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ #define __LR0 (x) ___CP32(p15, 4, c12, c12, x)#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)@@ -381,6 +397,15 @@#define HCR_EL2 HCR#define HPFAR_EL2 HPFAR#define HSTR_EL2 HSTR +#define ICC_BPR1_EL1 ICC_BPR1 +#define ICC_CTLR_EL1 ICC_CTLR +#define ICC_DIR_EL1 ICC_DIR +#define ICC_EOIR1_EL1 ICC_EOIR1 +#define ICC_IGRPEN1_EL1 ICC_IGRPEN1 +#define ICC_PMR_EL1 ICC_PMR +#define ICC_SGI1R_EL1 ICC_SGI1R +#define ICC_SRE_EL1 ICC_SRE +#define ICC_SRE_EL2 ICC_HSRE#define ICH_AP0R0_EL2 ICH_AP0R0#define ICH_AP0R1_EL2 ICH_AP0R1#define ICH_AP0R2_EL2 ICH_AP0R2@@ -389,6 +414,10 @@#define ICH_AP1R1_EL2 ICH_AP1R1#define ICH_AP1R2_EL2 ICH_AP1R2#define ICH_AP1R3_EL2 ICH_AP1R3 +#define ICH_EISR_EL2 ICH_EISR +#define ICH_ELRSR_EL2 ICH_ELRSR +#define ICH_HCR_EL2 ICH_HCR +#define ICC_IAR1_EL1 ICC_IAR1#define ICH_LR0_EL2 ICH_LR0#define ICH_LR1_EL2 ICH_LR1#define ICH_LR2_EL2 ICH_LR2
xen/arch/arm/include/asm/cpregs.h line 458
Quoted 9 lines
xen/arch/arm/include/asm/cpregs.h +3
-0@@ -421,6 +450,9 @@#define ICH_LRC13_EL2 ICH_LRC13#define ICH_LRC14_EL2 ICH_LRC14#define ICH_LRC15_EL2 ICH_LRC15 +#define ICH_MISR_EL2 ICH_MISR +#define ICH_VMCR_EL2 ICH_VMCR +#define ICH_VTR_EL2 ICH_VTR#define ID_AFR0_EL1 ID_AFR0#define ID_DFR0_EL1 ID_DFR0#define ID_DFR1_EL1 ID_DFR1
~Michal
Re: [XEN v4 11/11] xen/Arm: GICv3: Enable GICv3 for AArch32
In reply to Ayan Kumar HalderHi Ayan,
Quoted 11 lines · Ayan Kumar Halder
One can now use GICv3 on AArch32 systems. However, ITS is not supported. The reason being currently we are trying to validate GICv3 on an
AArch32_v8Rsystem. Refer ARM DDI0568A.cID110520, B1.3.1,
"A Generic Interrupt Controller (GIC) implemented with an Armv8-R PE must not implement LPI support."By default GICv3 is disabled on AArch32 and enabled on AArch64.
Updated SUPPORT.md to state that GICv3 on Arm32 is not security supported.
Signed-off-by Ayan Kumar Halder <[email protected]>
~Michal
Re: [XEN v4 02/11] xen/Arm: GICv3: Do not calculate affinity level 3 for AArch32
In reply to Ayan Kumar HalderHi,
Quoted 9 lines · Ayan Kumar Halder
Refer ARM DDI 0487I.a ID081822, G8-9817, G8.2.169 Affinity level 3 is not present in AArch32.
Also, refer ARM DDI 0406C.d ID040418, B4-1644, B4.1.106, Affinity level 3 is not present in Armv7 (ie arm32). Thus, any access to affinity level 3 needs to be guarded within "ifdefCONFIG_ARM_64".Signed-off-by Ayan Kumar Halder <[email protected]>Reviewed-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 04/11] xen/Arm: vGICv3: Adapt emulation of GICR_TYPER for AArch32
In reply to Ayan Kumar HalderHi Ayan,
Quoted 11 lines · Ayan Kumar Halder
Refer ARM DDI 0487I.a ID081822, G8-9650, G8.2.113 Aff3 does not exist on AArch32.
Also, refer ARM DDI 0406C.d ID040418, B4-1644, B4.1.106 Aff3 does not exist on Armv7 (ie arm32).Thus, access to aff3 has been protected with "#ifdef
CONFIG_ARM_64". Also,v->arch.vmpidris a 32 bit register on AArch32. So, we have assigned it to 'uint64_tvmpidr' to perform the shifts.Signed-off-by Ayan Kumar Halder <[email protected]>Reviewed-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 07/11] xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
In reply to Michal OrzelHi,
Quoted 7 lines · Michal Orzel
xen/arch/arm/gic-v3.c static void gicv3_dump_state(const struct vcpu *v) · line 420
Quoted 6 lines
xen/arch/arm/gic-v3.c +1
-1@@ -417,12 +417,12 @@ static void gicv3_dump_state(const struct vcpu *v)if ( v == current ) {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" HW_LR[%d]=%lx\n" , i,gicv3_ich_read_lr (i)); +printk (" HW_LR[%d]=%" PRIx64"\n" , i,gicv3_ich_read_lr (i));1. We do not usually add spaces between " and PRIx.
I don't have a strong preference on this one.
Quoted 64 lines
Quoted 64 lines
xen/arch/arm/gic-v3.c +1
-1}else {for ( i =0 ; i < gicv3_info.nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%lx\n" , i, v->arch.gic.v3.lr[i]); +printk (" VCPU_LR[%d]=%" PRIx64"\n" , i, v->arch.gic.v3.lr[i]); } }xen/arch/arm/include/asm/arm32/sysregs.h +19
-0@@ -62,6 +62,25 @@ #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define ICH_LRC_REG (index) ICH_LRC ## index ## _EL2 + +#define READ_SYSREG_LR (index) ({ \ + uint64_t _val; \ + uint32_t _lrc = READ_CP32(ICH_LRC_REG(index)); \ + uint32_t _lr = READ_CP32(ICH_LR_REG(index)); \ + \ + _val = ((uint64_t) _lrc << 32) | _lr; \ + _val; \ +}) + +#define WRITE_SYSREG_LR (v, index) ({ \ + uint64_t _val = (v); \ + WRITE_CP32(_val & GENMASK(31, 0), ICH_LR_REG(index)); \ + WRITE_CP32(_val >> 32, ICH_LRC_REG(index)); \ +}) +/* MVFR2 is not defined on ARMv7 */ #define MVFR2_MAYBE_UNDEFINED xen/arch/arm/include/asm/arm64/sysregs.h +5
-0@@ -472,6 +472,11 @@#define READ_SYSREG (name) READ_SYSREG64(name)#define WRITE_SYSREG (v, name) WRITE_SYSREG64(v, name) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define WRITE_SYSREG_LR (v, index) WRITE_SYSREG(v, ICH_LR_REG(index)) +#define READ_SYSREG_LR (index) READ_SYSREG(ICH_LR_REG(index)) +#endif /* _ASM_ARM_ARM64_SYSREGS_H */ /* xen/arch/arm/include/asm/cpregs.h +0
-0@@ -8,6 +8,8 @@* support 32-bit guests. */
Quoted 2 lines
xen/arch/arm/include/asm/cpregs.h line 11
Quoted 1 line
xen/arch/arm/include/asm/cpregs.h +1
-0+#define ___CP32 (coproc, opc1, crn, crm, opc2) coproc, opc1, crn, crm, opc22. As you are using
___CP32much later in this file, it could be moved...
__CP32() is already defined in arm32/sysregs.h which includes cpregs.h. We should not define __CP32() twice and the only reason the compiler doesn't complain is because the definition is the same
So one of the two needs to be dropped. Also, I think __CP32(), __CP64(), CP32() and CP64() should be defined together because they are all related.
However...
Quoted 12 lines
xen/arch/arm/include/asm/cpregs.h line 262
Quoted 7 lines
xen/arch/arm/include/asm/cpregs.h +1
-0+#define __HSR_CPREG_c0 0#define __HSR_CPREG_c1 1#define __HSR_CPREG_c2 2@@ -259,6 +261,48 @@#define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0/* Hyp. Vector Base Address Register */ ...here, before first use. The remark I gave in v3 was that the definition should occur before use, but it does not mean placing the macro at the top of the file.
Quoted 1 line
Quoted 3 lines
xen/arch/arm/include/asm/cpregs.h line 266
Quoted 3 lines
xen/arch/arm/include/asm/cpregs.h +3
-0+/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ +#define __LR0 (x) ___CP32(p15, 4, c12, c12, x) +#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)
... I don't understand why you need to use __CP32 here and everywhere else in this header. In fact I have replaced in my tree all the __CP32(foo) with foo and it still compiles.
So can you explain why they are necessary?
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 07/11] xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
Quoted 1 line · Julien Grall
Hi,
Hi Julien,
Quoted 12 lines · Michal Orzel
Quoted 9 lines
xen/arch/arm/gic-v3.c static void gicv3_dump_state(const struct vcpu · line 422
Quoted 8 lines
xen/arch/arm/gic-v3.c +1
-1@@ -417,12 +417,12 @@ static void gicv3_dump_state(const struct vcpu *v) if ( v == current ) { for ( i = 0; i < gicv3_info.nr_lrs; i++ ) - printk(" HW_LR[%d]=%lx\n", i, gicv3_ich_read_lr(i)); + printk(" HW_LR[%d]=%" PRIx64 "\n", i,gicv3_ich_read_lr (i));1. We do not usually add spaces between " and PRIx.
Quoted 1 line
I don't have a strong preference on this one.
ok, I will then keep it as it is.
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
(quoted diff) +0
-0}else
{
for ( i = 0; i < gicv3_info.nr_lrs; i++ )
-printk(" VCPU_LR[%d]=%lx\n", i, v->arch.gic.v3.lr[i]); +printk(" VCPU_LR[%d]=%" PRIx64 "\n", i, v->arch.gic.v3.lr[i]);
}
}xen/arch/arm/include/asm/arm32/sysregs.h +19
-0@@ -62,6 +62,25 @@ #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define ICH_LRC_REG (index) ICH_LRC ## index ## _EL2 + +#define READ_SYSREG_LR (index) ({ \ + uint64_t _val; \ + uint32_t _lrc = READ_CP32(ICH_LRC_REG(index)); \ + uint32_t _lr = READ_CP32(ICH_LR_REG(index)); \ + \ + _val = ((uint64_t) _lrc << 32) | _lr; \ + _val; \ +}) + +#define WRITE_SYSREG_LR (v, index) ({ \ + uint64_t _val = (v); \ + WRITE_CP32(_val & GENMASK(31, 0), ICH_LR_REG(index)); \ + WRITE_CP32(_val >> 32, ICH_LRC_REG(index)); \ +}) + /* MVFR2 is not defined on ARMv7 */ #define MVFR2_MAYBE_UNDEFINEDxen/arch/arm/include/asm/arm64/sysregs.h +5
-0@@ -472,6 +472,11 @@ #define READ_SYSREG(name) READ_SYSREG64(name) #define WRITE_SYSREG(v, name) WRITE_SYSREG64(v, name) +/* Wrappers for accessing interrupt controller list registers. */ +#define ICH_LR_REG (index) ICH_LR ## index ## _EL2 +#define WRITE_SYSREG_LR (v, index) WRITE_SYSREG(v, ICH_LR_REG(index)) +#define READ_SYSREG_LR (index) READ_SYSREG(ICH_LR_REG(index)) + #endif /* _ASM_ARM_ARM64_SYSREGS_H */ /*xen/arch/arm/include/asm/cpregs.h +0
-0@@ -8,6 +8,8 @@* support 32-bit guests. */
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
xen/arch/arm/include/asm/cpregs.h +1
-0+#define ___CP32 (coproc, opc1, crn, crm, opc2) coproc, opc1, crn,crm, opc2
2. As you are using
___CP32much later in this file, it could be moved...
__CP32()is already defined inarm32/sysregs.hwhich includescpregs.h. We should not define__CP32()twice and the only reason the compiler doesn't complain is because the definition is the same
The definition is different :-
In xen/arch/arm/include/asm/arm32/sysregs.h
"#define __CP32(r, coproc, opc1, crn, crm, opc2) coproc, opc1, r, crn, crm, opc2" (Note:- it takes 6 arguments)
And what I have defined in xen/arch/arm/include/asm/cpregs.h:-
#define ___CP32(coproc, opc1, crn, crm, opc2) coproc, opc1, crn, crm, opc2 (It takes 5 arguments, also note it has 3 underscores before CP32).
Quoted 17 lines
So one of the two needs to be dropped. Also, I think
__CP32(),__CP64(),CP32()andCP64()should be defined together because they are all related.However...
Quoted 12 lines
xen/arch/arm/include/asm/cpregs.h line 262
Quoted 7 lines
+
#define __HSR_CPREG_c0 0
#define __HSR_CPREG_c1 1
#define __HSR_CPREG_c2 2xen/arch/arm/include/asm/cpregs.h +0
-0@@ -259,6 +261,48 @@ #define VBAR p15,0,c12,c0,0 /* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0 /* Hyp. Vector Base Address Register */...here, before first use. The remark I gave in v3 was that the definition should occur before use, but it does not mean placing the macro at the top of the file.
Quoted 1 line
Quoted 5 lines
Quoted 3 lines
xen/arch/arm/include/asm/cpregs.h line 266
Quoted 3 lines
xen/arch/arm/include/asm/cpregs.h +3
-0+/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ +#define __LR0 (x) ___CP32(p15, 4, c12, c12, x) +#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)... I don't understand why you need to use
__CP32here and everywhere else in this header. In fact I have replaced in my tree all the__CP32(foo)with foo and it still compiles.
I think you mean ___CP32 here (3 underscores).
Quoted 2 lines
So can you explain why they are necessary?
Actually, they are not necessary. I will remove ___CP32 definition in the v5 patch.
Sorry, I was blindly influenced by the definition of __CP32. :( But, there it was needed.
Would you also review 8/11, 9/11, 10/11 and 10/11 before I re-spin a new series ? They have been reviewed by Michal (with some minor comments which I can address in v5).
- Ayan
Quoted 3 lines
Cheers,
Re: [XEN v4 10/11] xen/Arm: GICv3: Define macros to read/write 64 bit
In reply to Ayan Kumar HalderHi,
Quoted 10 lines · Ayan Kumar Halder
On AArch32, ldrd/strd instructions are not atomic when used to access MMIO. Furthermore, ldrd/strd instructions are not decoded by Arm when running as a guest to access emulated MMIO region.
Thus, we have defined readq_relaxed_non_atomic()/writeq_relaxed_non_atomic() which in turn calls readl_relaxed()/writel_relaxed() for the lower and upper 32 bits.
For AArch64, readq_relaxed_non_atomic()/writeq_relaxed_non_atomic() invokes readq_relaxed()/writeq_relaxed() respectively.
As GICv3 registers (GICD_IROUTER,GICR_TYPER) can be accessed in a non atomic manner, so we have used readq_relaxed_non_atomic()/writeq_relaxed_non_atomic().
I had another look at the code and I think there needs some clarification necessary because the accesses to IROUTER is non-obvious.
Quoted 25 lines
Signed-off-by Ayan Kumar Halder <[email protected]>---
Changes from :-
v1 - 1. Use ldrd/strd for readq_relaxed()/writeq_relaxed().
2. No need to usele64_to_cpu()as the returned byte order is already in cpu endianess.v2 - 1. Replace {read/write}q_relaxed with {read/write}q_relaxed_non_atomic().
v3 - 1. Use inline function definitions for {read/write}q_relaxed_non_atomic().
2. For AArch64, {read/write}q_relaxed_non_atomic() should invoke {read/write}q_relaxed(). Thus, we can avoid any ifdef ingic-v3.c.xen/arch/arm/gic-v3.c | 6 +++--- xen/arch/arm/include/asm/arm32/io.h | 20 ++++++++++++++++++++ xen/arch/arm/include/asm/arm64/io.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-)xen/arch/arm/gic-v3.c +0
-0
xen/arch/arm/gic-v3.c static void __init gicv3_dist_init(void) · line 654
Quoted 5 lines
xen/arch/arm/gic-v3.c +1
-1@@ -651,7 +651,7 @@ static void __init gicv3_dist_init(void) affinity &= ~GICD_IROUTER_SPI_MODE_ANY ;for ( i =NR_GIC_LOCAL_IRQS ; i < nr_lines; i++ ) -writeq_relaxed (affinity,GICD +GICD_IROUTER + i *8 ); +writeq_relaxed_non_atomic (affinity,GICD +GICD_IROUTER + i *8 );
Using non atomic here makes sense because AFAIU the interrupt will be disabled. Therefore the GIC should not use the register.
xen/arch/arm/gic-v3.c static int __init gicv3_populate_rdist(void) · line 748
Quoted 9 lines
xen/arch/arm/gic-v3.c +1
-1}static int gicv3_enable_redist (void )@@ -745,7 +745,7 @@ static int __init gicv3_populate_rdist(void) } do { - typer = readq_relaxed(ptr + GICR_TYPER); + typer = readq_relaxed_non_atomic(ptr + GICR_TYPER);
This non-atomic read is OK because GICR_TYPER is read-only.
xen/arch/arm/gic-v3.c static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask) · line 1268
Quoted 9 lines
xen/arch/arm/gic-v3.c +1
-1if ( (typer >>32 ) == aff ) {@@ -1265,7 +1265,7 @@ static void gicv3_irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask) affinity &= ~GICD_IROUTER_SPI_MODE_ANY ;if ( desc->irq >=NR_GIC_LOCAL_IRQS ) -writeq_relaxed (affinity, (GICD +GICD_IROUTER + desc->irq *8 )); +writeq_relaxed_non_atomic (affinity, (GICD +GICD_IROUTER + desc->irq *8 ));
This can be called with interrupt enabled. So a non-atomic access means the GIC will see a transient value when only one of two 32-bit will be updated.
In practice this is fine because only Aff3 is so far defined in the top 32-bits. So effectively, they will be RESS0 and never change.
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 11/11] xen/Arm: GICv3: Enable GICv3 for AArch32
In reply to Ayan Kumar HalderHi,
Quoted 55 lines · Ayan Kumar Halder
One can now use GICv3 on AArch32 systems. However, ITS is not supported. The reason being currently we are trying to validate GICv3 on an
AArch32_v8Rsystem. Refer ARM DDI0568A.cID110520, B1.3.1,
"A Generic Interrupt Controller (GIC) implemented with an Armv8-R PE must not implement LPI support."By default GICv3 is disabled on AArch32 and enabled on AArch64.
Updated SUPPORT.md to state that GICv3 on Arm32 is not security supported.
Signed-off-by Ayan Kumar Halder <[email protected]>---
Changed from :-
v1 - 1. Remove "ARM_64||ARM_32" as it is always true.
2. Updated SUPPORT.md.v2 - 1. GICv3 is enabled by default only on
ARM_64.
2. Updated SUPPORT.md.v3 - 1. GICv3 is not selected by
ARM_64. Rather, it is optionally enabled.
2. GICv3 is disabled by default onARM_32.SUPPORT.md | 7 +++++++ xen/arch/arm/Kconfig | 9 +++++---- xen/arch/arm/include/asm/cpufeature.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-)SUPPORT.md +7
-0@@ -76,6 +76,13 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported +### ARM/GICv3 + +GICv3 is an interrupt controller specification designed by Arm. + + Status, Arm64: Security supported + Status, Arm32: Supported, not security supported + ### ARM/GICv3 ITS Extension to the GICv3 interrupt controller to support MSI.xen/arch/arm/Kconfig +0
-0@@ -41,16 +41,17 @@ config ARM_EFI config GICV3 bool "GICv3 driver"
xen/arch/arm/Kconfig config ARM_EFI · line 50
Quoted 10 lines
xen/arch/arm/Kconfig +4
-3- depends on ARM_64 && !NEW_VGIC - default y + depends on !NEW_VGIC + default n if ARM_32 + default y if ARM_64 ---help--- Driver for the ARM Generic Interrupt Controller v3. - If unsure, say Y + If unsure, say N for ARM_32 and Y for ARM_64
s/ARM_32/32-bit Arm/
s/ARM_64/64-bit Arm/
Or you could use the following wording (used on x86 in similar circumstances):
"If unsure, use the default setting."
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 07/11] xen/Arm: GICv3: Define ICH_LR<n>_EL2 on AArch32
In reply to Ayan Kumar HalderHi,
Quoted 10 lines · Ayan Kumar Halder
The definition is different :-
In
xen/arch/arm/include/asm/arm32/sysregs.h"#define
__CP32(r, coproc, opc1, crn, crm, opc2)coproc, opc1, r, crn,
crm, opc2" (Note:- it takes 6 arguments)And what I have defined in xen/arch/arm/include/asm/cpregs.h:-
#define
___CP32(coproc, opc1, crn, crm, opc2)coproc, opc1, crn, crm, opc2 (It takes 5 arguments, also note it has 3 underscores before CP32).
Ah... I missed the 3rd underscore. That's one more reason to not define such macro.
[...]
Quoted 1 line
Would you also review 8/11, 9/11, 10/11 and 10/11 before I re-spin a new series ?
Patch #8, #9 needs ___CP32 to be removed.
Patch #10, some of the use needs to be clarified
Patch #11 have a minor comment
Please note that I'm reviewing these patches in between my main work and it can take a while to go through them in detail. So please wait a few days before asking for reply.
Cheers,
Signature · 1 line
Julien Grall
Re: [XEN v4 09/11] xen/Arm: GICv3: Define remaining GIC registers for AArch32
In reply to Michal OrzelQuoted 49 lines · Michal Orzel
Hi Ayan,
Quoted 18 lines · Ayan Kumar Halder
Define missing assembly aliases for GIC registers on arm32, taking the ones defined already for arm64 as a base. Aliases are defined according to the GIC Architecture Specification ARM IHI 0069H.
Defined the following registers:-
1. Interrupt Controller Interrupt Priority Mask Register
2. Interrupt Controller System Register Enable register
3. Interrupt Controller Deactivate Interrupt Register
4. Interrupt Controller End Of Interrupt Register 1
5. Interrupt Controller Interrupt Acknowledge Register 1
6. Interrupt Controller Binary Point Register 1
7. Interrupt Controller Control Register
8. Interrupt Controller Interrupt Group 1 Enable register
9. Interrupt Controller Maintenance Interrupt State Register
10. Interrupt Controller End of Interrupt Status Register
11. Interrupt Controller Empty List Register Status Register
12. Interrupt Controller Virtual Machine Control RegisterQuoted 1 line
Signed-off-by Ayan Kumar Halder <[email protected]>Reviewed-by Michal Orzel <[email protected]>with one remark...
Quoted 24 lines
---
Changes from :-
v1 - 1. Moved coproc regs definition toasm/cpregs.hv2 - 1. Defined register alias.
2. Style issues.
3. Defined ELSR, MISR, EISR to make it consistent with AArch64.v3 - 1. Rectified some of the register names.
xen/arch/arm/include/asm/cpregs.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)xen/arch/arm/include/asm/cpregs.h +1
-0@@ -163,6 +163,7 @@#define DACR p15,0,c3,c0,0/* Domain Access Control Register */ /* CP15 CR4: */ +#define ICC_PMR p15,0,c4,c6,0/* Interrupt Priority Mask Register */
Quoted 8 lines
xen/arch/arm/include/asm/cpregs.h line 260
Quoted 7 lines
xen/arch/arm/include/asm/cpregs.h +1
-0/* CP15 CR5: Fault Status Registers */ #define DFSR p15,0,c5,c0,0/* Data Fault Status Register */ @@ -256,6 +257,7 @@/* CP15 CR12: */ #define ICC_SGI1R p15,0,c12/* Interrupt Controller SGI Group 1 */ +#define ICC_DIR p15,0,c12,c11,1/* Interrupt Controller Deactivate Interrupt Register */ Shouldn't
ICC_DIRbe placed after VBAR?
I have moved ICC_DIR after VBAR in my v5 patch.
Actually, this ordering is not very clear to me.
It defines the following ordering "Coprocessor-> CRn-> Opcode 1-> CRm-> Opcode 2"
So "p15, 0, c12 ...." should come before "p15,1,c12 ...".
However, if I see in the file for examples where "crm, opc2" is not present, the order does not seem to make sense.
For eg
#define TTBCR p15,0,c2,c0,2 /* Translation Table Base Control Register */
#define TTBCR2 p15,0,c2,c0,3 /* Translation Table Base Control Register 2 */
#define TTBR0 p15,0,c2 /* Translation Table Base Reg. 0 */
#define TTBR1 p15,1,c2 /* Translation Table Base Reg. 1 */
#define HTTBR p15,4,c2 /* Hyp. Translation Table Base Register */
#define TTBR0_32 p15,0,c2,c0,0 /* 32-bit access to TTBR0 */ <<<------ does not seem in correct position , it should have been at the top #define TTBR1_32 p15,0,c2,c0,1 /* 32-bit access to TTBR1 */ <<<------- does not seem in correct position , it should have been between TTBR0_32 and TTBCR
- Ayan
Quoted 63 lines
Quoted 53 lines
xen/arch/arm/include/asm/cpregs.h +27
-0#define ICC_ASGI1R p15,1,c12/* Interrupt Controller Alias SGI Group 1 Register */ #define ICC_SGI0R p15,2,c12/* Interrupt Controller SGI Group 0 */ #define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ @@ -281,6 +283,20 @@#define ICH_AP1R2 __AP1Rx(2)#define ICH_AP1R3 __AP1Rx(3) +#define ICC_IAR1 p15,0,c12,c12,0/* Interrupt Controller Interrupt Acknowledge Register 1 */ +#define ICC_EOIR1 p15,0,c12,c12,1/* Interrupt Controller End Of Interrupt Register 1 */ +#define ICC_BPR1 p15,0,c12,c12,3/* Interrupt Controller Binary Point Register 1 */ +#define ICC_CTLR p15,0,c12,c12,4/* Interrupt Controller Control Register */ +#define ICC_SRE p15,0,c12,c12,5/* Interrupt Controller System Register Enable register */ +#define ICC_IGRPEN1 p15,0,c12,c12,7/* Interrupt Controller Interrupt Group 1 Enable register */ +#define ICC_HSRE p15,4,c12,c9,5/* Interrupt Controller Hyp System Register Enable register */ +#define ICH_HCR p15,4,c12,c11,0/* Interrupt Controller Hyp Control Register */ +#define ICH_VTR p15,4,c12,c11,1/* Interrupt Controller VGIC Type Register */ +#define ICH_MISR p15,4,c12,c11,2/* Interrupt Controller Maintenance Interrupt State Register */ +#define ICH_EISR p15,4,c12,c11,3/* Interrupt Controller End of Interrupt Status Register */ +#define ICH_ELRSR p15,4,c12,c11,5/* Interrupt Controller Empty List Register Status Register */ +#define ICH_VMCR p15,4,c12,c11,7/* Interrupt Controller Virtual Machine Control Register */ +/* CP15 CR12: Interrupt Controller List Registers, n = 0 - 15 */ #define __LR0 (x) ___CP32(p15, 4, c12, c12, x)#define __LR8 (x) ___CP32(p15, 4, c12, c13, x)@@ -381,6 +397,15 @@#define HCR_EL2 HCR#define HPFAR_EL2 HPFAR#define HSTR_EL2 HSTR +#define ICC_BPR1_EL1 ICC_BPR1 +#define ICC_CTLR_EL1 ICC_CTLR +#define ICC_DIR_EL1 ICC_DIR +#define ICC_EOIR1_EL1 ICC_EOIR1 +#define ICC_IGRPEN1_EL1 ICC_IGRPEN1 +#define ICC_PMR_EL1 ICC_PMR +#define ICC_SGI1R_EL1 ICC_SGI1R +#define ICC_SRE_EL1 ICC_SRE +#define ICC_SRE_EL2 ICC_HSRE#define ICH_AP0R0_EL2 ICH_AP0R0#define ICH_AP0R1_EL2 ICH_AP0R1#define ICH_AP0R2_EL2 ICH_AP0R2@@ -389,6 +414,10 @@#define ICH_AP1R1_EL2 ICH_AP1R1#define ICH_AP1R2_EL2 ICH_AP1R2#define ICH_AP1R3_EL2 ICH_AP1R3 +#define ICH_EISR_EL2 ICH_EISR +#define ICH_ELRSR_EL2 ICH_ELRSR +#define ICH_HCR_EL2 ICH_HCR +#define ICC_IAR1_EL1 ICC_IAR1#define ICH_LR0_EL2 ICH_LR0#define ICH_LR1_EL2 ICH_LR1#define ICH_LR2_EL2 ICH_LR2xen/arch/arm/include/asm/cpregs.h line 458
Quoted 9 lines
xen/arch/arm/include/asm/cpregs.h +3
-0@@ -421,6 +450,9 @@#define ICH_LRC13_EL2 ICH_LRC13#define ICH_LRC14_EL2 ICH_LRC14#define ICH_LRC15_EL2 ICH_LRC15 +#define ICH_MISR_EL2 ICH_MISR +#define ICH_VMCR_EL2 ICH_VMCR +#define ICH_VTR_EL2 ICH_VTR#define ID_AFR0_EL1 ID_AFR0#define ID_DFR0_EL1 ID_DFR0#define ID_DFR1_EL1 ID_DFR1~Michal