* [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation
@ 2025-05-29 1:10 Bibo Mao
2025-05-29 1:10 ` [PATCH 1/5] LoongArch: KVM: Fix interrupt route update with eiointc Bibo Mao
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:10 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li; +Cc: kvm, loongarch, linux-kernel
This series fix two issue about kernel eiointc emulation, one is caused
by type forced assignment, the other is to use physical cpu with
interrupt route.
Also there is code cleanup with kernel eiointc emulation.
Bibo Mao (5):
LoongArch: KVM: Fix interrupt route update with eiointc
LoongArch: KVM: Check interrupt route from physical cpu with eiointc
LoongArch: KVM: Use standard bitops API with eiointc
LoongArch: KVM: Remove unused parameter len
LoongArch: KVM: Add stat information with kernel irqchip
arch/loongarch/include/asm/kvm_host.h | 9 +--
arch/loongarch/kvm/intc/eiointc.c | 98 ++++++++++++++-------------
arch/loongarch/kvm/intc/ipi.c | 28 ++------
arch/loongarch/kvm/intc/pch_pic.c | 4 +-
arch/loongarch/kvm/vcpu.c | 5 +-
5 files changed, 65 insertions(+), 79 deletions(-)
base-commit: feacb1774bd5eac6382990d0f6d1378dc01dd78f
--
2.39.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] LoongArch: KVM: Fix interrupt route update with eiointc
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
@ 2025-05-29 1:10 ` Bibo Mao
2025-05-29 1:10 ` [PATCH 2/5] LoongArch: KVM: Check interrupt route from physical cpu " Bibo Mao
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:10 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li
Cc: kvm, loongarch, linux-kernel, stable
With function eiointc_update_sw_coremap(), there is forced assignment
like val = *(u64 *)pvalue. Parameter pvalue may be pointer to char type
or others, there is problem with forced assignment with u64 type.
Here the detailed value is passed rather address pointer.
Cc: stable@vger.kernel.org
Fixes: 3956a52bc05b ("LoongArch: KVM: Add EIOINTC read and write functions")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/intc/eiointc.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index f39929d7bf8a..d2c521b0e923 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -66,10 +66,9 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
}
static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,
- int irq, void *pvalue, u32 len, bool notify)
+ int irq, u64 val, u32 len, bool notify)
{
int i, cpu;
- u64 val = *(u64 *)pvalue;
for (i = 0; i < len; i++) {
cpu = val & 0xff;
@@ -398,7 +397,7 @@ static int loongarch_eiointc_writeb(struct kvm_vcpu *vcpu,
irq = offset - EIOINTC_COREMAP_START;
index = irq;
s->coremap.reg_u8[index] = data;
- eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
+ eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
break;
default:
ret = -EINVAL;
@@ -484,7 +483,7 @@ static int loongarch_eiointc_writew(struct kvm_vcpu *vcpu,
irq = offset - EIOINTC_COREMAP_START;
index = irq >> 1;
s->coremap.reg_u16[index] = data;
- eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
+ eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
break;
default:
ret = -EINVAL;
@@ -570,7 +569,7 @@ static int loongarch_eiointc_writel(struct kvm_vcpu *vcpu,
irq = offset - EIOINTC_COREMAP_START;
index = irq >> 2;
s->coremap.reg_u32[index] = data;
- eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
+ eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
break;
default:
ret = -EINVAL;
@@ -656,7 +655,7 @@ static int loongarch_eiointc_writeq(struct kvm_vcpu *vcpu,
irq = offset - EIOINTC_COREMAP_START;
index = irq >> 3;
s->coremap.reg_u64[index] = data;
- eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
+ eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
break;
default:
ret = -EINVAL;
@@ -809,7 +808,7 @@ static int kvm_eiointc_ctrl_access(struct kvm_device *dev,
for (i = 0; i < (EIOINTC_IRQS / 4); i++) {
start_irq = i * 4;
eiointc_update_sw_coremap(s, start_irq,
- (void *)&s->coremap.reg_u32[i], sizeof(u32), false);
+ s->coremap.reg_u32[i], sizeof(u32), false);
}
break;
default:
--
2.39.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] LoongArch: KVM: Check interrupt route from physical cpu with eiointc
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
2025-05-29 1:10 ` [PATCH 1/5] LoongArch: KVM: Fix interrupt route update with eiointc Bibo Mao
@ 2025-05-29 1:10 ` Bibo Mao
2025-05-29 1:11 ` [PATCH 3/5] LoongArch: KVM: Use standard bitops API " Bibo Mao
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:10 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li
Cc: kvm, loongarch, linux-kernel, stable
With eiointc interrupt controller, physical cpu id is set for irq
route. However function kvm_get_vcpu() is used to get destination vCPU
when delivering irq. With API kvm_get_vcpu(), logical cpu is used.
With API kvm_get_vcpu_by_cpuid(), vCPU can be searched from physical
cpu id.
Cc: stable@vger.kernel.org
Fixes: 3956a52bc05b ("LoongArch: KVM: Add EIOINTC read and write functions")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/intc/eiointc.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index d2c521b0e923..0b648c56b0c3 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -9,7 +9,8 @@
static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
{
- int ipnum, cpu, irq_index, irq_mask, irq;
+ int ipnum, cpu, irq_index, irq_mask, irq, cpuid;
+ struct kvm_vcpu *vcpu;
for (irq = 0; irq < EIOINTC_IRQS; irq++) {
ipnum = s->ipmap.reg_u8[irq / 32];
@@ -20,7 +21,12 @@ static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
irq_index = irq / 32;
irq_mask = BIT(irq & 0x1f);
- cpu = s->coremap.reg_u8[irq];
+ cpuid = s->coremap.reg_u8[irq];
+ vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);
+ if (vcpu == NULL)
+ continue;
+
+ cpu = vcpu->vcpu_id;
if (!!(s->coreisr.reg_u32[cpu][irq_index] & irq_mask))
set_bit(irq, s->sw_coreisr[cpu][ipnum]);
else
@@ -68,17 +74,23 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,
int irq, u64 val, u32 len, bool notify)
{
- int i, cpu;
+ int i, cpu, cpuid;
+ struct kvm_vcpu *vcpu;
for (i = 0; i < len; i++) {
- cpu = val & 0xff;
+ cpuid = val & 0xff;
val = val >> 8;
if (!(s->status & BIT(EIOINTC_ENABLE_CPU_ENCODE))) {
- cpu = ffs(cpu) - 1;
- cpu = (cpu >= 4) ? 0 : cpu;
+ cpuid = ffs(cpuid) - 1;
+ cpuid = (cpuid >= 4) ? 0 : cpuid;
}
+ vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);
+ if (vcpu == NULL)
+ continue;
+
+ cpu = vcpu->vcpu_id;
if (s->sw_coremap[irq + i] == cpu)
continue;
--
2.39.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] LoongArch: KVM: Use standard bitops API with eiointc
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
2025-05-29 1:10 ` [PATCH 1/5] LoongArch: KVM: Fix interrupt route update with eiointc Bibo Mao
2025-05-29 1:10 ` [PATCH 2/5] LoongArch: KVM: Check interrupt route from physical cpu " Bibo Mao
@ 2025-05-29 1:11 ` Bibo Mao
2025-05-29 1:11 ` [PATCH 4/5] LoongArch: KVM: Remove unused parameter len Bibo Mao
2025-05-29 1:11 ` [PATCH 5/5] LoongArch: KVM: Add stat information with kernel irqchip Bibo Mao
4 siblings, 0 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:11 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li; +Cc: kvm, loongarch, linux-kernel
Standard bitops APIs such test_bit() is used here, rather than manually
calculate the offset and mask. Also use non-atomic API __set_bit()
and __clear_bit() rather than set_bit() and clear_bit(), since global
spinlock is held already.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/intc/eiointc.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 0b648c56b0c3..b3aa6e305a18 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -9,7 +9,7 @@
static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
{
- int ipnum, cpu, irq_index, irq_mask, irq, cpuid;
+ int ipnum, cpu, irq, cpuid;
struct kvm_vcpu *vcpu;
for (irq = 0; irq < EIOINTC_IRQS; irq++) {
@@ -18,8 +18,6 @@ static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
ipnum = count_trailing_zeros(ipnum);
ipnum = (ipnum >= 0 && ipnum < 4) ? ipnum : 0;
}
- irq_index = irq / 32;
- irq_mask = BIT(irq & 0x1f);
cpuid = s->coremap.reg_u8[irq];
vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);
@@ -27,16 +25,16 @@ static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
continue;
cpu = vcpu->vcpu_id;
- if (!!(s->coreisr.reg_u32[cpu][irq_index] & irq_mask))
- set_bit(irq, s->sw_coreisr[cpu][ipnum]);
+ if (test_bit(irq, (unsigned long *)s->coreisr.reg_u32[cpu]))
+ __set_bit(irq, s->sw_coreisr[cpu][ipnum]);
else
- clear_bit(irq, s->sw_coreisr[cpu][ipnum]);
+ __clear_bit(irq, s->sw_coreisr[cpu][ipnum]);
}
}
static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
{
- int ipnum, cpu, found, irq_index, irq_mask;
+ int ipnum, cpu, found;
struct kvm_vcpu *vcpu;
struct kvm_interrupt vcpu_irq;
@@ -48,19 +46,16 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
cpu = s->sw_coremap[irq];
vcpu = kvm_get_vcpu(s->kvm, cpu);
- irq_index = irq / 32;
- irq_mask = BIT(irq & 0x1f);
-
if (level) {
/* if not enable return false */
- if (((s->enable.reg_u32[irq_index]) & irq_mask) == 0)
+ if (!test_bit(irq, (unsigned long *)s->enable.reg_u32))
return;
- s->coreisr.reg_u32[cpu][irq_index] |= irq_mask;
+ __set_bit(irq, (unsigned long *)s->coreisr.reg_u32[cpu]);
found = find_first_bit(s->sw_coreisr[cpu][ipnum], EIOINTC_IRQS);
- set_bit(irq, s->sw_coreisr[cpu][ipnum]);
+ __set_bit(irq, s->sw_coreisr[cpu][ipnum]);
} else {
- s->coreisr.reg_u32[cpu][irq_index] &= ~irq_mask;
- clear_bit(irq, s->sw_coreisr[cpu][ipnum]);
+ __clear_bit(irq, (unsigned long *)s->coreisr.reg_u32[cpu]);
+ __clear_bit(irq, s->sw_coreisr[cpu][ipnum]);
found = find_first_bit(s->sw_coreisr[cpu][ipnum], EIOINTC_IRQS);
}
@@ -110,8 +105,8 @@ void eiointc_set_irq(struct loongarch_eiointc *s, int irq, int level)
unsigned long flags;
unsigned long *isr = (unsigned long *)s->isr.reg_u8;
- level ? set_bit(irq, isr) : clear_bit(irq, isr);
spin_lock_irqsave(&s->lock, flags);
+ level ? __set_bit(irq, isr) : __clear_bit(irq, isr);
eiointc_update_irq(s, irq, level);
spin_unlock_irqrestore(&s->lock, flags);
}
--
2.39.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] LoongArch: KVM: Remove unused parameter len
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
` (2 preceding siblings ...)
2025-05-29 1:11 ` [PATCH 3/5] LoongArch: KVM: Use standard bitops API " Bibo Mao
@ 2025-05-29 1:11 ` Bibo Mao
2025-05-29 1:11 ` [PATCH 5/5] LoongArch: KVM: Add stat information with kernel irqchip Bibo Mao
4 siblings, 0 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:11 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li; +Cc: kvm, loongarch, linux-kernel
Parameter len is unused in some functions with eiointc emulation
driver, remove it here.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/intc/eiointc.c | 32 +++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index b3aa6e305a18..41fe1e6e9d3b 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -131,7 +131,7 @@ static inline void eiointc_enable_irq(struct kvm_vcpu *vcpu,
}
static int loongarch_eiointc_readb(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,
- gpa_t addr, int len, void *val)
+ gpa_t addr, void *val)
{
int index, ret = 0;
u8 data = 0;
@@ -173,7 +173,7 @@ static int loongarch_eiointc_readb(struct kvm_vcpu *vcpu, struct loongarch_eioin
}
static int loongarch_eiointc_readw(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,
- gpa_t addr, int len, void *val)
+ gpa_t addr, void *val)
{
int index, ret = 0;
u16 data = 0;
@@ -215,7 +215,7 @@ static int loongarch_eiointc_readw(struct kvm_vcpu *vcpu, struct loongarch_eioin
}
static int loongarch_eiointc_readl(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,
- gpa_t addr, int len, void *val)
+ gpa_t addr, void *val)
{
int index, ret = 0;
u32 data = 0;
@@ -257,7 +257,7 @@ static int loongarch_eiointc_readl(struct kvm_vcpu *vcpu, struct loongarch_eioin
}
static int loongarch_eiointc_readq(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,
- gpa_t addr, int len, void *val)
+ gpa_t addr, void *val)
{
int index, ret = 0;
u64 data = 0;
@@ -315,16 +315,16 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
spin_lock_irqsave(&eiointc->lock, flags);
switch (len) {
case 1:
- ret = loongarch_eiointc_readb(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_readb(vcpu, eiointc, addr, val);
break;
case 2:
- ret = loongarch_eiointc_readw(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_readw(vcpu, eiointc, addr, val);
break;
case 4:
- ret = loongarch_eiointc_readl(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_readl(vcpu, eiointc, addr, val);
break;
case 8:
- ret = loongarch_eiointc_readq(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_readq(vcpu, eiointc, addr, val);
break;
default:
WARN_ONCE(1, "%s: Abnormal address access: addr 0x%llx, size %d\n",
@@ -337,7 +337,7 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
static int loongarch_eiointc_writeb(struct kvm_vcpu *vcpu,
struct loongarch_eiointc *s,
- gpa_t addr, int len, const void *val)
+ gpa_t addr, const void *val)
{
int index, irq, bits, ret = 0;
u8 cpu;
@@ -416,7 +416,7 @@ static int loongarch_eiointc_writeb(struct kvm_vcpu *vcpu,
static int loongarch_eiointc_writew(struct kvm_vcpu *vcpu,
struct loongarch_eiointc *s,
- gpa_t addr, int len, const void *val)
+ gpa_t addr, const void *val)
{
int i, index, irq, bits, ret = 0;
u8 cpu;
@@ -502,7 +502,7 @@ static int loongarch_eiointc_writew(struct kvm_vcpu *vcpu,
static int loongarch_eiointc_writel(struct kvm_vcpu *vcpu,
struct loongarch_eiointc *s,
- gpa_t addr, int len, const void *val)
+ gpa_t addr, const void *val)
{
int i, index, irq, bits, ret = 0;
u8 cpu;
@@ -588,7 +588,7 @@ static int loongarch_eiointc_writel(struct kvm_vcpu *vcpu,
static int loongarch_eiointc_writeq(struct kvm_vcpu *vcpu,
struct loongarch_eiointc *s,
- gpa_t addr, int len, const void *val)
+ gpa_t addr, const void *val)
{
int i, index, irq, bits, ret = 0;
u8 cpu;
@@ -689,16 +689,16 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
spin_lock_irqsave(&eiointc->lock, flags);
switch (len) {
case 1:
- ret = loongarch_eiointc_writeb(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_writeb(vcpu, eiointc, addr, val);
break;
case 2:
- ret = loongarch_eiointc_writew(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_writew(vcpu, eiointc, addr, val);
break;
case 4:
- ret = loongarch_eiointc_writel(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_writel(vcpu, eiointc, addr, val);
break;
case 8:
- ret = loongarch_eiointc_writeq(vcpu, eiointc, addr, len, val);
+ ret = loongarch_eiointc_writeq(vcpu, eiointc, addr, val);
break;
default:
WARN_ONCE(1, "%s: Abnormal address access: addr 0x%llx, size %d\n",
--
2.39.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] LoongArch: KVM: Add stat information with kernel irqchip
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
` (3 preceding siblings ...)
2025-05-29 1:11 ` [PATCH 4/5] LoongArch: KVM: Remove unused parameter len Bibo Mao
@ 2025-05-29 1:11 ` Bibo Mao
4 siblings, 0 replies; 6+ messages in thread
From: Bibo Mao @ 2025-05-29 1:11 UTC (permalink / raw)
To: Tianrui Zhao, Huacai Chen, Xianglai Li; +Cc: kvm, loongarch, linux-kernel
Move stat information about kernel irqchip from VM to vCPU, and add
entry with structure kvm_vcpu_stats_desc[], so that it can display
with directory /sys/kernel/debug/kvm.
Also unify stat information about eiointc_read_exits and
eiointc_write_exits into eiointc_emu_exits, to avoid two many entries
about stat information output.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/include/asm/kvm_host.h | 9 +++------
arch/loongarch/kvm/intc/eiointc.c | 4 ++--
arch/loongarch/kvm/intc/ipi.c | 28 ++++-----------------------
arch/loongarch/kvm/intc/pch_pic.c | 4 ++--
arch/loongarch/kvm/vcpu.c | 5 ++++-
5 files changed, 15 insertions(+), 35 deletions(-)
diff --git a/arch/loongarch/include/asm/kvm_host.h b/arch/loongarch/include/asm/kvm_host.h
index f457c2662e2f..959e8df44612 100644
--- a/arch/loongarch/include/asm/kvm_host.h
+++ b/arch/loongarch/include/asm/kvm_host.h
@@ -50,12 +50,6 @@ struct kvm_vm_stat {
struct kvm_vm_stat_generic generic;
u64 pages;
u64 hugepages;
- u64 ipi_read_exits;
- u64 ipi_write_exits;
- u64 eiointc_read_exits;
- u64 eiointc_write_exits;
- u64 pch_pic_read_exits;
- u64 pch_pic_write_exits;
};
struct kvm_vcpu_stat {
@@ -65,6 +59,9 @@ struct kvm_vcpu_stat {
u64 cpucfg_exits;
u64 signal_exits;
u64 hypercall_exits;
+ u64 ipi_emu_exits;
+ u64 eiointc_emu_exits;
+ u64 pch_pic_emu_exits;
};
#define KVM_MEM_HUGEPAGE_CAPABLE (1UL << 0)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 41fe1e6e9d3b..8f844828a308 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -311,7 +311,7 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
return -EINVAL;
}
- vcpu->kvm->stat.eiointc_read_exits++;
+ vcpu->stat.eiointc_emu_exits++;
spin_lock_irqsave(&eiointc->lock, flags);
switch (len) {
case 1:
@@ -685,7 +685,7 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
return -EINVAL;
}
- vcpu->kvm->stat.eiointc_write_exits++;
+ vcpu->stat.eiointc_emu_exits++;
spin_lock_irqsave(&eiointc->lock, flags);
switch (len) {
case 1:
diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c
index fe734dc062ed..b66f91209940 100644
--- a/arch/loongarch/kvm/intc/ipi.c
+++ b/arch/loongarch/kvm/intc/ipi.c
@@ -268,36 +268,16 @@ static int kvm_ipi_read(struct kvm_vcpu *vcpu,
struct kvm_io_device *dev,
gpa_t addr, int len, void *val)
{
- int ret;
- struct loongarch_ipi *ipi;
-
- ipi = vcpu->kvm->arch.ipi;
- if (!ipi) {
- kvm_err("%s: ipi irqchip not valid!\n", __func__);
- return -EINVAL;
- }
- ipi->kvm->stat.ipi_read_exits++;
- ret = loongarch_ipi_readl(vcpu, addr, len, val);
-
- return ret;
+ vcpu->stat.ipi_emu_exits++;
+ return loongarch_ipi_readl(vcpu, addr, len, val);
}
static int kvm_ipi_write(struct kvm_vcpu *vcpu,
struct kvm_io_device *dev,
gpa_t addr, int len, const void *val)
{
- int ret;
- struct loongarch_ipi *ipi;
-
- ipi = vcpu->kvm->arch.ipi;
- if (!ipi) {
- kvm_err("%s: ipi irqchip not valid!\n", __func__);
- return -EINVAL;
- }
- ipi->kvm->stat.ipi_write_exits++;
- ret = loongarch_ipi_writel(vcpu, addr, len, val);
-
- return ret;
+ vcpu->stat.ipi_emu_exits++;
+ return loongarch_ipi_writel(vcpu, addr, len, val);
}
static const struct kvm_io_device_ops kvm_ipi_ops = {
diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
index 08fce845f668..6dba2ec79c16 100644
--- a/arch/loongarch/kvm/intc/pch_pic.c
+++ b/arch/loongarch/kvm/intc/pch_pic.c
@@ -196,7 +196,7 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,
}
/* statistics of pch pic reading */
- vcpu->kvm->stat.pch_pic_read_exits++;
+ vcpu->stat.pch_pic_emu_exits++;
ret = loongarch_pch_pic_read(s, addr, len, val);
return ret;
@@ -303,7 +303,7 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,
}
/* statistics of pch pic writing */
- vcpu->kvm->stat.pch_pic_write_exits++;
+ vcpu->stat.pch_pic_emu_exits++;
ret = loongarch_pch_pic_write(s, addr, len, val);
return ret;
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 5af32ec62cb1..06397ae70811 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -20,7 +20,10 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
STATS_DESC_COUNTER(VCPU, idle_exits),
STATS_DESC_COUNTER(VCPU, cpucfg_exits),
STATS_DESC_COUNTER(VCPU, signal_exits),
- STATS_DESC_COUNTER(VCPU, hypercall_exits)
+ STATS_DESC_COUNTER(VCPU, hypercall_exits),
+ STATS_DESC_COUNTER(VCPU, ipi_emu_exits),
+ STATS_DESC_COUNTER(VCPU, eiointc_emu_exits),
+ STATS_DESC_COUNTER(VCPU, pch_pic_emu_exits)
};
const struct kvm_stats_header kvm_vcpu_stats_header = {
--
2.39.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-29 1:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 1:10 [PATCH 0/5] LoongArch: KVM: Enhancement about eiointc emulation Bibo Mao
2025-05-29 1:10 ` [PATCH 1/5] LoongArch: KVM: Fix interrupt route update with eiointc Bibo Mao
2025-05-29 1:10 ` [PATCH 2/5] LoongArch: KVM: Check interrupt route from physical cpu " Bibo Mao
2025-05-29 1:11 ` [PATCH 3/5] LoongArch: KVM: Use standard bitops API " Bibo Mao
2025-05-29 1:11 ` [PATCH 4/5] LoongArch: KVM: Remove unused parameter len Bibo Mao
2025-05-29 1:11 ` [PATCH 5/5] LoongArch: KVM: Add stat information with kernel irqchip Bibo Mao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).