Let kvm_msicfgaddr use the same format with mmsicfgaddr and smsicfgaddr.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
---
hw/intc/riscv_aplic.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
index e5714267c096..5964cde7e09e 100644
--- a/hw/intc/riscv_aplic.c
+++ b/hw/intc/riscv_aplic.c
@@ -181,8 +181,10 @@ void riscv_aplic_set_kvm_msicfgaddr(RISCVAPLICState *aplic, hwaddr addr)
{
#ifdef CONFIG_KVM
if (riscv_use_emulated_aplic(aplic->msimode)) {
+ addr >>= APLIC_xMSICFGADDR_PPN_SHIFT;
aplic->kvm_msicfgaddr = extract64(addr, 0, 32);
- aplic->kvm_msicfgaddrH = extract64(addr, 32, 32);
+ aplic->kvm_msicfgaddrH = extract64(addr, 32, 32) &
+ APLIC_xMSICFGADDRH_VALID_MASK;
}
#endif
}
@@ -403,12 +405,17 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic,
}
}
- if (aplic->mmode) {
- msicfgaddr = aplic_m->mmsicfgaddr;
- msicfgaddrH = aplic_m->mmsicfgaddrH;
+ if (aplic->kvm_splitmode) {
+ msicfgaddr = aplic->kvm_msicfgaddr;
+ msicfgaddrH = ((uint64_t)aplic->kvm_msicfgaddrH << 32);
} else {
- msicfgaddr = aplic_m->smsicfgaddr;
- msicfgaddrH = aplic_m->smsicfgaddrH;
+ if (aplic->mmode) {
+ msicfgaddr = aplic_m->mmsicfgaddr;
+ msicfgaddrH = aplic_m->mmsicfgaddrH;
+ } else {
+ msicfgaddr = aplic_m->smsicfgaddr;
+ msicfgaddrH = aplic_m->smsicfgaddrH;
+ }
}
lhxs = (msicfgaddrH >> APLIC_xMSICFGADDRH_LHXS_SHIFT) &
@@ -431,11 +438,6 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic,
addr |= (uint64_t)(guest_idx & APLIC_xMSICFGADDR_PPN_HART(lhxs));
addr <<= APLIC_xMSICFGADDR_PPN_SHIFT;
- if (aplic->kvm_splitmode) {
- addr |= aplic->kvm_msicfgaddr;
- addr |= ((uint64_t)aplic->kvm_msicfgaddrH << 32);
- }
-
address_space_stl_le(&address_space_memory, addr,
eiid, MEMTXATTRS_UNSPECIFIED, &result);
if (result != MEMTX_OK) {
--
2.17.1
On 2/23/25 11:57 PM, Yong-Xuan Wang wrote: > Let kvm_msicfgaddr use the same format with mmsicfgaddr and smsicfgaddr. > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > --- Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > hw/intc/riscv_aplic.c | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > > diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c > index e5714267c096..5964cde7e09e 100644 > --- a/hw/intc/riscv_aplic.c > +++ b/hw/intc/riscv_aplic.c > @@ -181,8 +181,10 @@ void riscv_aplic_set_kvm_msicfgaddr(RISCVAPLICState *aplic, hwaddr addr) > { > #ifdef CONFIG_KVM > if (riscv_use_emulated_aplic(aplic->msimode)) { > + addr >>= APLIC_xMSICFGADDR_PPN_SHIFT; > aplic->kvm_msicfgaddr = extract64(addr, 0, 32); > - aplic->kvm_msicfgaddrH = extract64(addr, 32, 32); > + aplic->kvm_msicfgaddrH = extract64(addr, 32, 32) & > + APLIC_xMSICFGADDRH_VALID_MASK; > } > #endif > } > @@ -403,12 +405,17 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic, > } > } > > - if (aplic->mmode) { > - msicfgaddr = aplic_m->mmsicfgaddr; > - msicfgaddrH = aplic_m->mmsicfgaddrH; > + if (aplic->kvm_splitmode) { > + msicfgaddr = aplic->kvm_msicfgaddr; > + msicfgaddrH = ((uint64_t)aplic->kvm_msicfgaddrH << 32); > } else { > - msicfgaddr = aplic_m->smsicfgaddr; > - msicfgaddrH = aplic_m->smsicfgaddrH; > + if (aplic->mmode) { > + msicfgaddr = aplic_m->mmsicfgaddr; > + msicfgaddrH = aplic_m->mmsicfgaddrH; > + } else { > + msicfgaddr = aplic_m->smsicfgaddr; > + msicfgaddrH = aplic_m->smsicfgaddrH; > + } > } > > lhxs = (msicfgaddrH >> APLIC_xMSICFGADDRH_LHXS_SHIFT) & > @@ -431,11 +438,6 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic, > addr |= (uint64_t)(guest_idx & APLIC_xMSICFGADDR_PPN_HART(lhxs)); > addr <<= APLIC_xMSICFGADDR_PPN_SHIFT; > > - if (aplic->kvm_splitmode) { > - addr |= aplic->kvm_msicfgaddr; > - addr |= ((uint64_t)aplic->kvm_msicfgaddrH << 32); > - } > - > address_space_stl_le(&address_space_memory, addr, > eiid, MEMTXATTRS_UNSPECIFIED, &result); > if (result != MEMTX_OK) {
© 2016 - 2025 Red Hat, Inc.