Skip to content

Commit 03b1198

Browse files
committed
Merge tag 'loongarch-kvm-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson into HEAD
LoongArch KVM changes for v6.17 1. Simplify some KVM routines. 2. Enhance in-kernel irqchip emulation. 3. Add stat information with kernel irqchip. 4. Add tracepoints for CPUCFG and CSR emulation exits.
2 parents 314b40b + 36d09b9 commit 03b1198

File tree

8 files changed

+132
-545
lines changed

8 files changed

+132
-545
lines changed

arch/loongarch/include/asm/kvm_host.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ struct kvm_vm_stat {
5050
struct kvm_vm_stat_generic generic;
5151
u64 pages;
5252
u64 hugepages;
53-
u64 ipi_read_exits;
54-
u64 ipi_write_exits;
55-
u64 eiointc_read_exits;
56-
u64 eiointc_write_exits;
57-
u64 pch_pic_read_exits;
58-
u64 pch_pic_write_exits;
5953
};
6054

6155
struct kvm_vcpu_stat {
@@ -65,6 +59,12 @@ struct kvm_vcpu_stat {
6559
u64 cpucfg_exits;
6660
u64 signal_exits;
6761
u64 hypercall_exits;
62+
u64 ipi_read_exits;
63+
u64 ipi_write_exits;
64+
u64 eiointc_read_exits;
65+
u64 eiointc_write_exits;
66+
u64 pch_pic_read_exits;
67+
u64 pch_pic_write_exits;
6868
};
6969

7070
#define KVM_MEM_HUGEPAGE_CAPABLE (1UL << 0)

arch/loongarch/kvm/exit.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,11 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
289289
er = EMULATE_FAIL;
290290
switch (((inst.word >> 24) & 0xff)) {
291291
case 0x0: /* CPUCFG GSPR */
292+
trace_kvm_exit_cpucfg(vcpu, KVM_TRACE_EXIT_CPUCFG);
292293
er = kvm_emu_cpucfg(vcpu, inst);
293294
break;
294295
case 0x4: /* CSR{RD,WR,XCHG} GSPR */
296+
trace_kvm_exit_csr(vcpu, KVM_TRACE_EXIT_CSR);
295297
er = kvm_handle_csr(vcpu, inst);
296298
break;
297299
case 0x6: /* Cache, Idle and IOCSR GSPR */
@@ -821,32 +823,25 @@ static int kvm_handle_lbt_disabled(struct kvm_vcpu *vcpu, int ecode)
821823
return RESUME_GUEST;
822824
}
823825

824-
static int kvm_send_pv_ipi(struct kvm_vcpu *vcpu)
826+
static void kvm_send_pv_ipi(struct kvm_vcpu *vcpu)
825827
{
826-
unsigned int min, cpu, i;
827-
unsigned long ipi_bitmap;
828+
unsigned int min, cpu;
828829
struct kvm_vcpu *dest;
830+
DECLARE_BITMAP(ipi_bitmap, BITS_PER_LONG * 2) = {
831+
kvm_read_reg(vcpu, LOONGARCH_GPR_A1),
832+
kvm_read_reg(vcpu, LOONGARCH_GPR_A2)
833+
};
829834

830835
min = kvm_read_reg(vcpu, LOONGARCH_GPR_A3);
831-
for (i = 0; i < 2; i++, min += BITS_PER_LONG) {
832-
ipi_bitmap = kvm_read_reg(vcpu, LOONGARCH_GPR_A1 + i);
833-
if (!ipi_bitmap)
836+
for_each_set_bit(cpu, ipi_bitmap, BITS_PER_LONG * 2) {
837+
dest = kvm_get_vcpu_by_cpuid(vcpu->kvm, cpu + min);
838+
if (!dest)
834839
continue;
835840

836-
cpu = find_first_bit((void *)&ipi_bitmap, BITS_PER_LONG);
837-
while (cpu < BITS_PER_LONG) {
838-
dest = kvm_get_vcpu_by_cpuid(vcpu->kvm, cpu + min);
839-
cpu = find_next_bit((void *)&ipi_bitmap, BITS_PER_LONG, cpu + 1);
840-
if (!dest)
841-
continue;
842-
843-
/* Send SWI0 to dest vcpu to emulate IPI interrupt */
844-
kvm_queue_irq(dest, INT_SWI0);
845-
kvm_vcpu_kick(dest);
846-
}
841+
/* Send SWI0 to dest vcpu to emulate IPI interrupt */
842+
kvm_queue_irq(dest, INT_SWI0);
843+
kvm_vcpu_kick(dest);
847844
}
848-
849-
return 0;
850845
}
851846

852847
/*

0 commit comments

Comments
 (0)