Skip to content

Commit 089401f

Browse files
SrikarJosyulachetan-rathore
authored andcommitted
fix(exerciser): avoid overwriting MSI control register
- update exerciser MSI generation to clear and set only ID/trigger bits, preserving reserved MSICTL bits - this change prevents accidental misconfiguration to the MSI-X vector index Signed-off-by: Srikar Josyula <srikar.josyula@arm.com> Change-Id: If7eba3b6f62f163b0300e81807ff1767c4ce5b57
1 parent e9963d9 commit 089401f

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

pal/baremetal/target/RDN2/include/platform_override_fvp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@
838838
#define FATAL_SHIFT 31
839839
#define ERROR_INJECT_BIT 17
840840

841+
#define MSICTL_ID_MASK ((1u << 11) - 1)
841842
#define MSI_GENERATION_MASK (1 << 31)
842843

843844
#define NO_SNOOP_START_MASK 0x20

pal/baremetal/target/RDN2/src/pal_exerciser.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@ uint32_t pal_exerciser_ops(EXERCISER_OPS Ops, uint64_t Param, uint32_t Bdf)
548548

549549
case GENERATE_MSI:
550550
/* Param is the msi_index */
551-
pal_mmio_write( Base + MSICTL ,(pal_mmio_read(Base + MSICTL) | (MSI_GENERATION_MASK) | (Param)));
551+
data = pal_mmio_read(Base + MSICTL);
552+
/* Clear the MSICTLID[10:0] and MSICTLTRG[31] bits while preserving the reserved bits */
553+
data &= ~(MSI_GENERATION_MASK | MSICTL_ID_MASK);
554+
data |= ((Param & MSICTL_ID_MASK) | MSI_GENERATION_MASK);
555+
pal_mmio_write(Base + MSICTL, data);
552556
return 0;
553557

554558
case GENERATE_L_INTR:

pal/baremetal/target/RDV3/include/platform_override_fvp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@
783783
#define ERROR_INJECT_BIT 17
784784
#define ERR_CODE_SHIFT 20
785785
#define FATAL_SHIFT 31
786+
#define MSICTL_ID_MASK ((1u << 11) - 1)
786787
#define MSI_GENERATION_MASK (1 << 31)
787788
#define NO_SNOOP_START_MASK 0x20
788789
#define NO_SNOOP_STOP_MASK 0xFFFFFFDF

pal/baremetal/target/RDV3/src/pal_exerciser.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,11 @@ uint32_t pal_exerciser_ops(EXERCISER_OPS Ops, uint64_t Param, uint32_t Bdf)
538538

539539
case GENERATE_MSI:
540540
/* Param is the msi_index */
541-
pal_mmio_write(Base + MSICTL, (pal_mmio_read(Base + MSICTL) |
542-
(MSI_GENERATION_MASK) | (Param)));
541+
data = pal_mmio_read(Base + MSICTL);
542+
/* Clear the MSICTLID[10:0] and MSICTLTRG[31] bits while preserving the reserved bits */
543+
data &= ~(MSI_GENERATION_MASK | MSICTL_ID_MASK);
544+
data |= ((Param & MSICTL_ID_MASK) | MSI_GENERATION_MASK);
545+
pal_mmio_write(Base + MSICTL, data);
543546
return 0;
544547

545548
case GENERATE_L_INTR:

pal/baremetal/target/RDV3CFG1/include/platform_override_fvp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@
719719
#define ERROR_INJECT_BIT 17
720720
#define ERR_CODE_SHIFT 20
721721
#define FATAL_SHIFT 31
722+
#define MSICTL_ID_MASK ((1u << 11) - 1)
722723
#define MSI_GENERATION_MASK (1 << 31)
723724
#define NO_SNOOP_START_MASK 0x20
724725
#define NO_SNOOP_STOP_MASK 0xFFFFFFDF

pal/baremetal/target/RDV3CFG1/src/pal_exerciser.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,11 @@ uint32_t pal_exerciser_ops(EXERCISER_OPS Ops, uint64_t Param, uint32_t Bdf)
538538

539539
case GENERATE_MSI:
540540
/* Param is the msi_index */
541-
pal_mmio_write(Base + MSICTL, (pal_mmio_read(Base + MSICTL) |
542-
(MSI_GENERATION_MASK) | (Param)));
541+
data = pal_mmio_read(Base + MSICTL);
542+
/* Clear the MSICTLID[10:0] and MSICTLTRG[31] bits while preserving the reserved bits */
543+
data &= ~(MSI_GENERATION_MASK | MSICTL_ID_MASK);
544+
data |= ((Param & MSICTL_ID_MASK) | MSI_GENERATION_MASK);
545+
pal_mmio_write(Base + MSICTL, data);
543546
return 0;
544547

545548
case GENERATE_L_INTR:

0 commit comments

Comments
 (0)