* [PATCH v2 Resend 1/3] KVM: MIPS: Change KVM_ENTRYHI_ASID to cpu_asid_mask(¤t_cpu_data) @ 2020-03-13 3:14 Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 2/3] KVM: MIPS: Fixup VPN2_MASK definition over 32bits virtual address Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system Xing Li 0 siblings, 2 replies; 4+ messages in thread From: Xing Li @ 2020-03-13 3:14 UTC (permalink / raw) To: Thomas Bogendoerfer Cc: linux-mips, kvm, linux-kernel, maobibo, chenhc, jiaxun.yang The code in decode_config4 of arch/mips/kernel/cpu-probe.c asid_mask = MIPS_ENTRYHI_ASID; if (config4 & MIPS_CONF4_AE) asid_mask |= MIPS_ENTRYHI_ASIDX; set_cpu_asid_mask(c, asid_mask); set asid_mask to cpuinfo->asid_mask So KVM_ENTRYHI_ASID should change to cpu_asid_mask(¤t_cpu_data) for support 10bits ASID_MASK Signed-off-by: Xing Li <lixing@loongson.cn> --- arch/mips/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 41204a4..6be70d5 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -275,7 +275,7 @@ enum emulation_result { #define MIPS3_PG_FRAME 0x3fffffc0 #define VPN2_MASK 0xffffe000 -#define KVM_ENTRYHI_ASID MIPS_ENTRYHI_ASID +#define KVM_ENTRYHI_ASID cpu_asid_mask(¤t_cpu_data) #define TLB_IS_GLOBAL(x) ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G) #define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK) #define TLB_ASID(x) ((x).tlb_hi & KVM_ENTRYHI_ASID) -- 2.1.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 Resend 2/3] KVM: MIPS: Fixup VPN2_MASK definition over 32bits virtual address 2020-03-13 3:14 [PATCH v2 Resend 1/3] KVM: MIPS: Change KVM_ENTRYHI_ASID to cpu_asid_mask(¤t_cpu_data) Xing Li @ 2020-03-13 3:14 ` Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system Xing Li 1 sibling, 0 replies; 4+ messages in thread From: Xing Li @ 2020-03-13 3:14 UTC (permalink / raw) To: Thomas Bogendoerfer Cc: linux-mips, kvm, linux-kernel, maobibo, chenhc, jiaxun.yang If the cpu support more than 32bits vmbits, VPN2_MASK set to fixed 0xffffe000 will lead to wrong entryhi for _kvm_mips_host_tlb_inv The cpu_vmbits definition of 32bit in cpu-features.h is 31, so still use the old style for 32bits. Signed-off-by: Xing Li <lixing@loongson.cn> --- v2: Change VPN2_MASK definition according to Jiaxun Yang's comment arch/mips/include/asm/kvm_host.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 6be70d5..ef8e606 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -274,7 +274,11 @@ enum emulation_result { #define MIPS3_PG_SHIFT 6 #define MIPS3_PG_FRAME 0x3fffffc0 +#if defined(CONFIG_64BIT) +#define VPN2_MASK GENMASK(cpu_vmbits - 1, 13) +#else #define VPN2_MASK 0xffffe000 +#endif #define KVM_ENTRYHI_ASID cpu_asid_mask(¤t_cpu_data) #define TLB_IS_GLOBAL(x) ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G) #define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK) -- 2.1.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system 2020-03-13 3:14 [PATCH v2 Resend 1/3] KVM: MIPS: Change KVM_ENTRYHI_ASID to cpu_asid_mask(¤t_cpu_data) Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 2/3] KVM: MIPS: Fixup VPN2_MASK definition over 32bits virtual address Xing Li @ 2020-03-13 3:14 ` Xing Li 2020-03-13 6:38 ` Huacai Chen 1 sibling, 1 reply; 4+ messages in thread From: Xing Li @ 2020-03-13 3:14 UTC (permalink / raw) To: Thomas Bogendoerfer Cc: linux-mips, kvm, linux-kernel, maobibo, chenhc, jiaxun.yang 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system 2020-03-13 3:14 ` [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system Xing Li @ 2020-03-13 6:38 ` Huacai Chen 0 siblings, 0 replies; 4+ messages in thread From: Huacai Chen @ 2020-03-13 6:38 UTC (permalink / raw) To: Xing Li Cc: Thomas Bogendoerfer, open list:MIPS, kvm, LKML, maobibo, Jiaxun Yang Hi, Lixing, On Fri, Mar 13, 2020 at 11:14 AM Xing Li <lixing@loongson.cn> wrote: > > 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. I think this patch is not suitable, because: 1, KVM has VZ mode and TE mode, you only consider VZ mode? 2, As X86 does, you can use udev or modprobe.conf to autoprobe kvm module. Regards, Huacai > > 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-13 6:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-03-13 3:14 [PATCH v2 Resend 1/3] KVM: MIPS: Change KVM_ENTRYHI_ASID to cpu_asid_mask(¤t_cpu_data) Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 2/3] KVM: MIPS: Fixup VPN2_MASK definition over 32bits virtual address Xing Li 2020-03-13 3:14 ` [PATCH v2 Resend 3/3] KVM: MIPS: Support kvm modules autoprobed when startup system Xing Li 2020-03-13 6:38 ` Huacai Chen
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).