Skip to content

Commit 719d109

Browse files
Huacai ChenAMarkovic
authored andcommitted
hw/mips: Implement the kvm_type() hook in MachineClass
MIPS has two types of KVM: TE & VZ, and TE is the default type. Now we can't create a VZ guest in QEMU because it lacks the kvm_type() hook in MachineClass. This patch add the the kvm_type() hook to support both of the two types. [AM: Added "if defined" guards.] Reviewed-by: Aleksandar Markovic <[email protected]> Signed-off-by: Aleksandar Markovic <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Co-developed-by: Jiaxun Yang <[email protected]> Message-Id: <[email protected]>
1 parent 553cf5d commit 719d109

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

target/mips/kvm.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
#include "qemu/main-loop.h"
2222
#include "qemu/timer.h"
2323
#include "sysemu/kvm.h"
24+
#include "sysemu/kvm_int.h"
2425
#include "sysemu/runstate.h"
2526
#include "sysemu/cpus.h"
2627
#include "kvm_mips.h"
2728
#include "exec/memattrs.h"
29+
#include "hw/boards.h"
2830

2931
#define DEBUG_KVM 0
3032

@@ -1270,3 +1272,27 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
12701272
{
12711273
abort();
12721274
}
1275+
1276+
int mips_kvm_type(MachineState *machine, const char *vm_type)
1277+
{
1278+
#if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE)
1279+
int r;
1280+
KVMState *s = KVM_STATE(machine->accelerator);
1281+
#endif
1282+
1283+
#if defined(KVM_CAP_MIPS_VZ)
1284+
r = kvm_check_extension(s, KVM_CAP_MIPS_VZ);
1285+
if (r > 0) {
1286+
return KVM_VM_MIPS_VZ;
1287+
}
1288+
#endif
1289+
1290+
#if defined(KVM_CAP_MIPS_TE)
1291+
r = kvm_check_extension(s, KVM_CAP_MIPS_TE);
1292+
if (r > 0) {
1293+
return KVM_VM_MIPS_TE;
1294+
}
1295+
#endif
1296+
1297+
return -1;
1298+
}

target/mips/kvm_mips.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef KVM_MIPS_H
1313
#define KVM_MIPS_H
1414

15+
#include "cpu.h"
16+
1517
/**
1618
* kvm_mips_reset_vcpu:
1719
* @cpu: MIPSCPU
@@ -23,4 +25,13 @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu);
2325
int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level);
2426
int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level);
2527

28+
#ifdef CONFIG_KVM
29+
int mips_kvm_type(MachineState *machine, const char *vm_type);
30+
#else
31+
static inline int mips_kvm_type(MachineState *machine, const char *vm_type)
32+
{
33+
return 0;
34+
}
35+
#endif
36+
2637
#endif /* KVM_MIPS_H */

0 commit comments

Comments
 (0)