[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/6] hw/mips: Implement the kvm_type() hook in MachineClass
From: |
Aleksandar Markovic |
Subject: |
[PULL 1/6] hw/mips: Implement the kvm_type() hook in MachineClass |
Date: |
Sat, 27 Jun 2020 21:51:38 +0200 |
From: Huacai Chen <zltjiangshi@gmail.com>
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 <aleksandar.qemu.devel@gmail.com>
Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Co-developed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-Id: <1592995531-32600-2-git-send-email-chenhc@lemote.com>
---
target/mips/kvm_mips.h | 11 +++++++++++
target/mips/kvm.c | 26 ++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/target/mips/kvm_mips.h b/target/mips/kvm_mips.h
index 1e40147..171d53d 100644
--- a/target/mips/kvm_mips.h
+++ b/target/mips/kvm_mips.h
@@ -12,6 +12,8 @@
#ifndef KVM_MIPS_H
#define KVM_MIPS_H
+#include "cpu.h"
+
/**
* kvm_mips_reset_vcpu:
* @cpu: MIPSCPU
@@ -23,4 +25,13 @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu);
int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level);
int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level);
+#ifdef CONFIG_KVM
+int mips_kvm_type(MachineState *machine, const char *vm_type);
+#else
+static inline int mips_kvm_type(MachineState *machine, const char *vm_type)
+{
+ return 0;
+}
+#endif
+
#endif /* KVM_MIPS_H */
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 96cfa10..72637a1 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -21,10 +21,12 @@
#include "qemu/main-loop.h"
#include "qemu/timer.h"
#include "sysemu/kvm.h"
+#include "sysemu/kvm_int.h"
#include "sysemu/runstate.h"
#include "sysemu/cpus.h"
#include "kvm_mips.h"
#include "exec/memattrs.h"
+#include "hw/boards.h"
#define DEBUG_KVM 0
@@ -1270,3 +1272,27 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
{
abort();
}
+
+int mips_kvm_type(MachineState *machine, const char *vm_type)
+{
+#if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE)
+ int r;
+ KVMState *s = KVM_STATE(machine->accelerator);
+#endif
+
+#if defined(KVM_CAP_MIPS_VZ)
+ r = kvm_check_extension(s, KVM_CAP_MIPS_VZ);
+ if (r > 0) {
+ return KVM_VM_MIPS_VZ;
+ }
+#endif
+
+#if defined(KVM_CAP_MIPS_TE)
+ r = kvm_check_extension(s, KVM_CAP_MIPS_TE);
+ if (r > 0) {
+ return KVM_VM_MIPS_TE;
+ }
+#endif
+
+ return -1;
+}
--
2.7.4
- [PULL 0/6] MIPS + TCG Continuous Benchmarking queue for June 27th, 2020, Aleksandar Markovic, 2020/06/27
- [PULL 1/6] hw/mips: Implement the kvm_type() hook in MachineClass,
Aleksandar Markovic <=
- [PULL 3/6] MAINTAINERS: Add Loongson-3 maintainer and reviewer, Aleksandar Markovic, 2020/06/27
- [PULL 4/6] scripts/performance: Add topN_perf.py script, Aleksandar Markovic, 2020/06/27
- [PULL 2/6] hw/intc: Add Loongson LIOINTC support, Aleksandar Markovic, 2020/06/27
- [PULL 6/6] MAINTAINERS: Add 'Performance Tools and Tests' subsection, Aleksandar Markovic, 2020/06/27
- [PULL 5/6] scripts/performance: Add topN_callgrind.py script, Aleksandar Markovic, 2020/06/27
- Re: [PULL 0/6] MIPS + TCG Continuous Benchmarking queue for June 27th, 2020, Peter Maydell, 2020/06/28