linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xing Li <lixing@loongson.cn>
To: Ralf Baechle <ralf@linux-mips.org>,
	Paul Burton <paulburton@kernel.org>,
	James Hogan <jhogan@kernel.org>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system
Date: Mon, 13 Jan 2020 12:39:08 +0800	[thread overview]
Message-ID: <1578890348-2734-3-git-send-email-lixing@loongson.cn> (raw)
In-Reply-To: <1578890348-2734-1-git-send-email-lixing@loongson.cn>

Currently, the module_init of kvm_mips_init cannot force the kvm
modules insmod when startup system.

Add new feature CPU_MIPS_VZ in elf_hwcap to support KVM auto probe
when hardware virtualization supported.

Signed-off-by: Xing Li <lixing@loongson.cn>
---
 arch/mips/include/uapi/asm/hwcap.h | 1 +
 arch/mips/kernel/cpu-probe.c       | 4 +++-
 arch/mips/kvm/mips.c               | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/uapi/asm/hwcap.h b/arch/mips/include/uapi/asm/hwcap.h
index 1ade1da..9e66509 100644
--- a/arch/mips/include/uapi/asm/hwcap.h
+++ b/arch/mips/include/uapi/asm/hwcap.h
@@ -17,5 +17,6 @@
 #define HWCAP_LOONGSON_MMI  (1 << 11)
 #define HWCAP_LOONGSON_EXT  (1 << 12)
 #define HWCAP_LOONGSON_EXT2 (1 << 13)
+#define HWCAP_MIPS_VZ       (1 << 14)
 
 #endif /* _UAPI_ASM_HWCAP_H */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index c543326..b305269 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -2242,8 +2242,10 @@ void cpu_probe(void)
 	if (cpu_has_loongson_ext2)
 		elf_hwcap |= HWCAP_LOONGSON_EXT2;
 
-	if (cpu_has_vz)
+	if (cpu_has_vz) {
 		cpu_probe_vz(c);
+		elf_hwcap |= HWCAP_MIPS_VZ;
+	}
 
 	cpu_probe_vmbits(c);
 
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 1109924..1da5df3 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -19,6 +19,7 @@
 #include <linux/sched/signal.h>
 #include <linux/fs.h>
 #include <linux/memblock.h>
+#include <linux/cpufeature.h>
 
 #include <asm/fpu.h>
 #include <asm/page.h>
@@ -1742,7 +1743,7 @@ static void __exit kvm_mips_exit(void)
 	unregister_die_notifier(&kvm_mips_csr_die_notifier);
 }
 
-module_init(kvm_mips_init);
+module_cpu_feature_match(MIPS_VZ, kvm_mips_init);
 module_exit(kvm_mips_exit);
 
 EXPORT_TRACEPOINT_SYMBOL(kvm_exit);
-- 
2.1.0


      parent reply	other threads:[~2020-01-13  4:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13  4:39 [PATCH v2 1/3] KVM: MIPS: Change KVM_ENTRYHI_ASID to cpu_asid_mask(&current_cpu_data) Xing Li
2020-01-13  4:39 ` [PATCH v2 2/3] KVM: MIPS: Fixup VPN2_MASK definition over 32bits virtual address Xing Li
2020-01-13  4:39 ` Xing Li [this message]

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=1578890348-2734-3-git-send-email-lixing@loongson.cn \
    --to=lixing@loongson.cn \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=paulburton@kernel.org \
    --cc=ralf@linux-mips.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).