qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Huacai Chen <zltjiangshi@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Aleksandar Markovic" <aleksandar.qemu.devel@gmail.com>
Cc: Huacai Chen <chenhuacai@gmail.com>,
	Huacai Chen <chenhc@lemote.com>,
	Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>,
	qemu-devel@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: [PATCH for-5.1 V5 1/4] hw/mips: Implement the kvm_type() hook in MachineClass
Date: Tue, 23 Jun 2020 20:13:55 +0800	[thread overview]
Message-ID: <1592914438-30317-2-git-send-email-chenhc@lemote.com> (raw)
In-Reply-To: <1592914438-30317-1-git-send-email-chenhc@lemote.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.

Reviewed-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>
---
 target/mips/kvm.c      | 20 ++++++++++++++++++++
 target/mips/kvm_mips.h | 11 +++++++++++
 2 files changed, 31 insertions(+)

diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 96cfa10..373f582 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,21 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
 {
     abort();
 }
+
+int mips_kvm_type(MachineState *machine, const char *vm_type)
+{
+    int r;
+    KVMState *s = KVM_STATE(machine->accelerator);
+
+    r = kvm_check_extension(s, KVM_CAP_MIPS_VZ);
+    if (r > 0) {
+        return KVM_VM_MIPS_VZ;
+    }
+
+    r = kvm_check_extension(s, KVM_CAP_MIPS_TE);
+    if (r > 0) {
+        return KVM_VM_MIPS_TE;
+    }
+
+    return -1;
+}
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 */
-- 
2.7.0



  reply	other threads:[~2020-06-23 12:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 12:13 [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM) Huacai Chen
2020-06-23 12:13 ` Huacai Chen [this message]
2020-06-23 12:13 ` [PATCH for-5.1 V5 2/4] hw/intc: Add Loongson liointc support Huacai Chen
2020-06-23 14:02   ` Aleksandar Markovic
2020-06-23 14:50   ` Aleksandar Markovic
2020-06-24  1:23     ` Jiaxun Yang
2020-06-23 12:13 ` [PATCH for-5.1 V5 3/4] hw/mips: Add Loongson-3 machine support (with KVM) Huacai Chen
2020-06-23 13:19   ` Aleksandar Markovic
2020-06-23 13:46   ` Aleksandar Markovic
2020-06-24 11:26     ` Aleksandar Markovic
2020-06-26 10:30       ` Huacai Chen
2020-06-23 14:04   ` Aleksandar Markovic
2020-06-24  6:34     ` Huacai Chen
2020-06-23 12:13 ` [PATCH for-5.1 V5 4/4] MAINTAINERS: Add Loongson-3 maintainer and reviewer Huacai Chen
2020-06-23 13:50   ` Aleksandar Markovic
2020-06-24  6:32     ` Huacai Chen
2020-06-23 13:02 ` [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM) no-reply
2020-06-23 13:58   ` Aleksandar Markovic
2020-06-24  6:12     ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1592914438-30317-2-git-send-email-chenhc@lemote.com \
    --to=zltjiangshi@gmail.com \
    --cc=aleksandar.qemu.devel@gmail.com \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=aurelien@aurel32.net \
    --cc=chenhc@lemote.com \
    --cc=chenhuacai@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).