Enable LoongArch kvm config and add the makefile to support build kvm
module.
Reviewed-by: Bibo Mao <[email protected]>
Reported-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Tianrui Zhao <[email protected]>
---
arch/loongarch/Kbuild | 1 +
arch/loongarch/Kconfig | 3 ++
arch/loongarch/configs/loongson3_defconfig | 2 +
arch/loongarch/kvm/Kconfig | 45 ++++++++++++++++++++++
arch/loongarch/kvm/Makefile | 22 +++++++++++
5 files changed, 73 insertions(+)
create mode 100644 arch/loongarch/kvm/Kconfig
create mode 100644 arch/loongarch/kvm/Makefile
diff --git a/arch/loongarch/Kbuild b/arch/loongarch/Kbuild
index b01f5cdb27..40be8a1696 100644
--- a/arch/loongarch/Kbuild
+++ b/arch/loongarch/Kbuild
@@ -2,6 +2,7 @@ obj-y += kernel/
obj-y += mm/
obj-y += net/
obj-y += vdso/
+obj-y += kvm/
# for cleaning
subdir- += boot
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index ecf282dee5..7f2f7ccc76 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -123,6 +123,7 @@ config LOONGARCH
select HAVE_KPROBES
select HAVE_KPROBES_ON_FTRACE
select HAVE_KRETPROBES
+ select HAVE_KVM
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_NMI
select HAVE_PCI
@@ -650,3 +651,5 @@ source "kernel/power/Kconfig"
source "drivers/acpi/Kconfig"
endmenu
+
+source "arch/loongarch/kvm/Kconfig"
diff --git a/arch/loongarch/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig
index d64849b4cb..7acb4ae7af 100644
--- a/arch/loongarch/configs/loongson3_defconfig
+++ b/arch/loongarch/configs/loongson3_defconfig
@@ -63,6 +63,8 @@ CONFIG_EFI_ZBOOT=y
CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER=y
CONFIG_EFI_CAPSULE_LOADER=m
CONFIG_EFI_TEST=m
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM=m
CONFIG_MODULES=y
CONFIG_MODULE_FORCE_LOAD=y
CONFIG_MODULE_UNLOAD=y
diff --git a/arch/loongarch/kvm/Kconfig b/arch/loongarch/kvm/Kconfig
new file mode 100644
index 0000000000..bf7d6e7cde
--- /dev/null
+++ b/arch/loongarch/kvm/Kconfig
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# KVM configuration
+#
+
+source "virt/kvm/Kconfig"
+
+menuconfig VIRTUALIZATION
+ bool "Virtualization"
+ help
+ Say Y here to get to see options for using your Linux host to run
+ other operating systems inside virtual machines (guests).
+ This option alone does not add any kernel code.
+
+ If you say N, all options in this submenu will be skipped and
+ disabled.
+
+if VIRTUALIZATION
+
+config AS_HAS_LVZ_EXTENSION
+ def_bool $(as-instr,hvcl 0)
+
+config KVM
+ tristate "Kernel-based Virtual Machine (KVM) support"
+ depends on HAVE_KVM
+ depends on AS_HAS_LVZ_EXTENSION
+ select MMU_NOTIFIER
+ select ANON_INODES
+ select PREEMPT_NOTIFIERS
+ select KVM_MMIO
+ select KVM_GENERIC_DIRTYLOG_READ_PROTECT
+ select KVM_GENERIC_HARDWARE_ENABLING
+ select KVM_XFER_TO_GUEST_WORK
+ select HAVE_KVM_DIRTY_RING_ACQ_REL
+ select HAVE_KVM_VCPU_ASYNC_IOCTL
+ select HAVE_KVM_EVENTFD
+ select SRCU
+ help
+ Support hosting virtualized guest machines using hardware
+ virtualization extensions. You will need a fairly processor
+ equipped with virtualization extensions.
+
+ If unsure, say N.
+
+endif # VIRTUALIZATION
diff --git a/arch/loongarch/kvm/Makefile b/arch/loongarch/kvm/Makefile
new file mode 100644
index 0000000000..2335e873a6
--- /dev/null
+++ b/arch/loongarch/kvm/Makefile
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for LOONGARCH KVM support
+#
+
+ccflags-y += -I $(srctree)/$(src)
+
+include $(srctree)/virt/kvm/Makefile.kvm
+
+obj-$(CONFIG_KVM) += kvm.o
+
+kvm-y += main.o
+kvm-y += vm.o
+kvm-y += vmid.o
+kvm-y += tlb.o
+kvm-y += mmu.o
+kvm-y += vcpu.o
+kvm-y += exit.o
+kvm-y += interrupt.o
+kvm-y += timer.o
+kvm-y += switch.o
+kvm-y += csr_ops.o
--
2.27.0
On Fri, Sep 8, 2023 at 9:49 AM bibo mao <[email protected]> wrote:
>
>
>
> 在 2023/9/8 09:40, Huacai Chen 写道:
> > On Fri, Sep 8, 2023 at 4:10 AM WANG Xuerui <[email protected]> wrote:
> >>
> >>
> >> On 8/31/23 16:30, Tianrui Zhao wrote:
> >>> Enable LoongArch kvm config and add the makefile to support build kvm
> >>> module.
> >>>
> >>> Reviewed-by: Bibo Mao <[email protected]>
> >>> Reported-by: kernel test robot <[email protected]>
> >>> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >>> Signed-off-by: Tianrui Zhao <[email protected]>
> >>> ---
> >>> arch/loongarch/Kbuild | 1 +
> >>> arch/loongarch/Kconfig | 3 ++
> >>> arch/loongarch/configs/loongson3_defconfig | 2 +
> >>> arch/loongarch/kvm/Kconfig | 45 ++++++++++++++++++++++
> >>> arch/loongarch/kvm/Makefile | 22 +++++++++++
> >>> 5 files changed, 73 insertions(+)
> >>> create mode 100644 arch/loongarch/kvm/Kconfig
> >>> create mode 100644 arch/loongarch/kvm/Makefile
> >>>
> >>> diff --git a/arch/loongarch/Kbuild b/arch/loongarch/Kbuild
> >>> index b01f5cdb27..40be8a1696 100644
> >>> --- a/arch/loongarch/Kbuild
> >>> +++ b/arch/loongarch/Kbuild
> >>> @@ -2,6 +2,7 @@ obj-y += kernel/
> >>> obj-y += mm/
> >>> obj-y += net/
> >>> obj-y += vdso/
> >>> +obj-y += kvm/
> >> Do we want to keep the list alphabetically sorted here?
> > kvm directory can be at last, but I'm afraid that it should be
> >
> > ifdef CONFIG_KVM
> > obj-y += kvm/
> > endif
> Agree, how about this like other architectures.
> obj-$(CONFIG_KVM) += kvm/
This is better, I agree and it can be at last because it is in a
different format from others.
> >
> > If such a guard is unnecessary, then I agree to use alphabetical order.
> Is there any document about "alphabetical order"? I check Kbuild in other
> directories, it is not sorted by alphabetical order.
Yes, there is no hard limit, but alphabetical order is better in some
cases, e.g., avoid duplicate lines.
Huacai
>
> $ cat arch/riscv/Kbuild
> obj-y += kernel/ mm/ net/
> obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
> obj-y += errata/
> obj-$(CONFIG_KVM) += kvm/
> obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += purgatory/
> # for cleaning
> subdir- += boot
>
> $ cat arch/arm64/Kbuild
> obj-y += kernel/ mm/ net/
> obj-$(CONFIG_KVM) += kvm/
> obj-$(CONFIG_XEN) += xen/
> obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/
> obj-$(CONFIG_CRYPTO) += crypto/
>
> # for cleaning
> subdir- += boot
>
>
> Regards
> Bibo Mao
> >
> > Huacai
> >
> >>>
> >>> # for cleaning
> >>> subdir- += boot
> >>> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
> >>> index ecf282dee5..7f2f7ccc76 100644
> >>> --- a/arch/loongarch/Kconfig
> >>> +++ b/arch/loongarch/Kconfig
> >>> @@ -123,6 +123,7 @@ config LOONGARCH
> >>> select HAVE_KPROBES
> >>> select HAVE_KPROBES_ON_FTRACE
> >>> select HAVE_KRETPROBES
> >>> + select HAVE_KVM
> >>> select HAVE_MOD_ARCH_SPECIFIC
> >>> select HAVE_NMI
> >>> select HAVE_PCI
> >>> @@ -650,3 +651,5 @@ source "kernel/power/Kconfig"
> >>> source "drivers/acpi/Kconfig"
> >>>
> >>> endmenu
> >>> +
> >>> +source "arch/loongarch/kvm/Kconfig"
> >>> diff --git a/arch/loongarch/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig
> >>> index d64849b4cb..7acb4ae7af 100644
> >>> --- a/arch/loongarch/configs/loongson3_defconfig
> >>> +++ b/arch/loongarch/configs/loongson3_defconfig
> >>> @@ -63,6 +63,8 @@ CONFIG_EFI_ZBOOT=y
> >>> CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER=y
> >>> CONFIG_EFI_CAPSULE_LOADER=m
> >>> CONFIG_EFI_TEST=m
> >>> +CONFIG_VIRTUALIZATION=y
> >>> +CONFIG_KVM=m
> >>> CONFIG_MODULES=y
> >>> CONFIG_MODULE_FORCE_LOAD=y
> >>> CONFIG_MODULE_UNLOAD=y
> >>> diff --git a/arch/loongarch/kvm/Kconfig b/arch/loongarch/kvm/Kconfig
> >>> new file mode 100644
> >>> index 0000000000..bf7d6e7cde
> >>> --- /dev/null
> >>> +++ b/arch/loongarch/kvm/Kconfig
> >>> @@ -0,0 +1,45 @@
> >>> +# SPDX-License-Identifier: GPL-2.0
> >>> +#
> >>> +# KVM configuration
> >>> +#
> >>> +
> >>> +source "virt/kvm/Kconfig"
> >>> +
> >>> +menuconfig VIRTUALIZATION
> >>> + bool "Virtualization"
> >>> + help
> >>> + Say Y here to get to see options for using your Linux host to run
> >>> + other operating systems inside virtual machines (guests).
> >>> + This option alone does not add any kernel code.
> >>> +
> >>> + If you say N, all options in this submenu will be skipped and
> >>> + disabled.
> >>> +
> >>> +if VIRTUALIZATION
> >>> +
> >>> +config AS_HAS_LVZ_EXTENSION
> >>> + def_bool $(as-instr,hvcl 0)
> >>> +
> >>> +config KVM
> >>> + tristate "Kernel-based Virtual Machine (KVM) support"
> >>> + depends on HAVE_KVM
> >>> + depends on AS_HAS_LVZ_EXTENSION
> >>> + select MMU_NOTIFIER
> >>> + select ANON_INODES
> >>> + select PREEMPT_NOTIFIERS
> >>> + select KVM_MMIO
> >>> + select KVM_GENERIC_DIRTYLOG_READ_PROTECT
> >>> + select KVM_GENERIC_HARDWARE_ENABLING
> >>> + select KVM_XFER_TO_GUEST_WORK
> >>> + select HAVE_KVM_DIRTY_RING_ACQ_REL
> >>> + select HAVE_KVM_VCPU_ASYNC_IOCTL
> >>> + select HAVE_KVM_EVENTFD
> >>> + select SRCU
> >> Make the list of selects also alphabetically sorted?
> >>> + help
> >>> + Support hosting virtualized guest machines using hardware
> >>> + virtualization extensions. You will need a fairly processor
> >>> + equipped with virtualization extensions.
> >>
> >> The word "fairly" seems extraneous here, and can be simply dropped.
> >>
> >> (I suppose you forgot to delete it after tweaking the original sentence,
> >> that came from arch/x86/kvm: "You will need a fairly recent processor
> >> ..." -- all LoongArch processors are recent!)
> >>
> >>> +
> >>> + If unsure, say N.
> >>> +
> >>> +endif # VIRTUALIZATION
> >>> diff --git a/arch/loongarch/kvm/Makefile b/arch/loongarch/kvm/Makefile
> >>> new file mode 100644
> >>> index 0000000000..2335e873a6
> >>> --- /dev/null
> >>> +++ b/arch/loongarch/kvm/Makefile
> >>> @@ -0,0 +1,22 @@
> >>> +# SPDX-License-Identifier: GPL-2.0
> >>> +#
> >>> +# Makefile for LOONGARCH KVM support
> >> "LoongArch" -- you may want to check the entire patch series for such
> >> ALL-CAPS references to LoongArch in natural language paragraphs, they
> >> all want to be spelled "LoongArch".
> >>> +#
> >>> +
> >>> +ccflags-y += -I $(srctree)/$(src)
> >>> +
> >>> +include $(srctree)/virt/kvm/Makefile.kvm
> >>> +
> >>> +obj-$(CONFIG_KVM) += kvm.o
> >>> +
> >>> +kvm-y += main.o
> >>> +kvm-y += vm.o
> >>> +kvm-y += vmid.o
> >>> +kvm-y += tlb.o
> >>> +kvm-y += mmu.o
> >>> +kvm-y += vcpu.o
> >>> +kvm-y += exit.o
> >>> +kvm-y += interrupt.o
> >>> +kvm-y += timer.o
> >>> +kvm-y += switch.o
> >>> +kvm-y += csr_ops.o
> >> I'd suggest sorting this list too to better avoid editing conflicts in
> >> the future.
> >>
> >> --
> >> WANG "xen0n" Xuerui
> >>
> >> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
> >>
> >>
>
>
在 2023/9/8 09:40, Huacai Chen 写道:
> On Fri, Sep 8, 2023 at 4:10 AM WANG Xuerui <[email protected]> wrote:
>>
>>
>> On 8/31/23 16:30, Tianrui Zhao wrote:
>>> Enable LoongArch kvm config and add the makefile to support build kvm
>>> module.
>>>
>>> Reviewed-by: Bibo Mao <[email protected]>
>>> Reported-by: kernel test robot <[email protected]>
>>> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>>> Signed-off-by: Tianrui Zhao <[email protected]>
>>> ---
>>> arch/loongarch/Kbuild | 1 +
>>> arch/loongarch/Kconfig | 3 ++
>>> arch/loongarch/configs/loongson3_defconfig | 2 +
>>> arch/loongarch/kvm/Kconfig | 45 ++++++++++++++++++++++
>>> arch/loongarch/kvm/Makefile | 22 +++++++++++
>>> 5 files changed, 73 insertions(+)
>>> create mode 100644 arch/loongarch/kvm/Kconfig
>>> create mode 100644 arch/loongarch/kvm/Makefile
>>>
>>> diff --git a/arch/loongarch/Kbuild b/arch/loongarch/Kbuild
>>> index b01f5cdb27..40be8a1696 100644
>>> --- a/arch/loongarch/Kbuild
>>> +++ b/arch/loongarch/Kbuild
>>> @@ -2,6 +2,7 @@ obj-y += kernel/
>>> obj-y += mm/
>>> obj-y += net/
>>> obj-y += vdso/
>>> +obj-y += kvm/
>> Do we want to keep the list alphabetically sorted here?
> kvm directory can be at last, but I'm afraid that it should be
>
> ifdef CONFIG_KVM
> obj-y += kvm/
> endif
Agree, how about this like other architectures.
obj-$(CONFIG_KVM) += kvm/
>
> If such a guard is unnecessary, then I agree to use alphabetical order.
Is there any document about "alphabetical order"? I check Kbuild in other
directories, it is not sorted by alphabetical order.
$ cat arch/riscv/Kbuild
obj-y += kernel/ mm/ net/
obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
obj-y += errata/
obj-$(CONFIG_KVM) += kvm/
obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += purgatory/
# for cleaning
subdir- += boot
$ cat arch/arm64/Kbuild
obj-y += kernel/ mm/ net/
obj-$(CONFIG_KVM) += kvm/
obj-$(CONFIG_XEN) += xen/
obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/
obj-$(CONFIG_CRYPTO) += crypto/
# for cleaning
subdir- += boot
Regards
Bibo Mao
>
> Huacai
>
>>>
>>> # for cleaning
>>> subdir- += boot
>>> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
>>> index ecf282dee5..7f2f7ccc76 100644
>>> --- a/arch/loongarch/Kconfig
>>> +++ b/arch/loongarch/Kconfig
>>> @@ -123,6 +123,7 @@ config LOONGARCH
>>> select HAVE_KPROBES
>>> select HAVE_KPROBES_ON_FTRACE
>>> select HAVE_KRETPROBES
>>> + select HAVE_KVM
>>> select HAVE_MOD_ARCH_SPECIFIC
>>> select HAVE_NMI
>>> select HAVE_PCI
>>> @@ -650,3 +651,5 @@ source "kernel/power/Kconfig"
>>> source "drivers/acpi/Kconfig"
>>>
>>> endmenu
>>> +
>>> +source "arch/loongarch/kvm/Kconfig"
>>> diff --git a/arch/loongarch/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig
>>> index d64849b4cb..7acb4ae7af 100644
>>> --- a/arch/loongarch/configs/loongson3_defconfig
>>> +++ b/arch/loongarch/configs/loongson3_defconfig
>>> @@ -63,6 +63,8 @@ CONFIG_EFI_ZBOOT=y
>>> CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER=y
>>> CONFIG_EFI_CAPSULE_LOADER=m
>>> CONFIG_EFI_TEST=m
>>> +CONFIG_VIRTUALIZATION=y
>>> +CONFIG_KVM=m
>>> CONFIG_MODULES=y
>>> CONFIG_MODULE_FORCE_LOAD=y
>>> CONFIG_MODULE_UNLOAD=y
>>> diff --git a/arch/loongarch/kvm/Kconfig b/arch/loongarch/kvm/Kconfig
>>> new file mode 100644
>>> index 0000000000..bf7d6e7cde
>>> --- /dev/null
>>> +++ b/arch/loongarch/kvm/Kconfig
>>> @@ -0,0 +1,45 @@
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +#
>>> +# KVM configuration
>>> +#
>>> +
>>> +source "virt/kvm/Kconfig"
>>> +
>>> +menuconfig VIRTUALIZATION
>>> + bool "Virtualization"
>>> + help
>>> + Say Y here to get to see options for using your Linux host to run
>>> + other operating systems inside virtual machines (guests).
>>> + This option alone does not add any kernel code.
>>> +
>>> + If you say N, all options in this submenu will be skipped and
>>> + disabled.
>>> +
>>> +if VIRTUALIZATION
>>> +
>>> +config AS_HAS_LVZ_EXTENSION
>>> + def_bool $(as-instr,hvcl 0)
>>> +
>>> +config KVM
>>> + tristate "Kernel-based Virtual Machine (KVM) support"
>>> + depends on HAVE_KVM
>>> + depends on AS_HAS_LVZ_EXTENSION
>>> + select MMU_NOTIFIER
>>> + select ANON_INODES
>>> + select PREEMPT_NOTIFIERS
>>> + select KVM_MMIO
>>> + select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>>> + select KVM_GENERIC_HARDWARE_ENABLING
>>> + select KVM_XFER_TO_GUEST_WORK
>>> + select HAVE_KVM_DIRTY_RING_ACQ_REL
>>> + select HAVE_KVM_VCPU_ASYNC_IOCTL
>>> + select HAVE_KVM_EVENTFD
>>> + select SRCU
>> Make the list of selects also alphabetically sorted?
>>> + help
>>> + Support hosting virtualized guest machines using hardware
>>> + virtualization extensions. You will need a fairly processor
>>> + equipped with virtualization extensions.
>>
>> The word "fairly" seems extraneous here, and can be simply dropped.
>>
>> (I suppose you forgot to delete it after tweaking the original sentence,
>> that came from arch/x86/kvm: "You will need a fairly recent processor
>> ..." -- all LoongArch processors are recent!)
>>
>>> +
>>> + If unsure, say N.
>>> +
>>> +endif # VIRTUALIZATION
>>> diff --git a/arch/loongarch/kvm/Makefile b/arch/loongarch/kvm/Makefile
>>> new file mode 100644
>>> index 0000000000..2335e873a6
>>> --- /dev/null
>>> +++ b/arch/loongarch/kvm/Makefile
>>> @@ -0,0 +1,22 @@
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +#
>>> +# Makefile for LOONGARCH KVM support
>> "LoongArch" -- you may want to check the entire patch series for such
>> ALL-CAPS references to LoongArch in natural language paragraphs, they
>> all want to be spelled "LoongArch".
>>> +#
>>> +
>>> +ccflags-y += -I $(srctree)/$(src)
>>> +
>>> +include $(srctree)/virt/kvm/Makefile.kvm
>>> +
>>> +obj-$(CONFIG_KVM) += kvm.o
>>> +
>>> +kvm-y += main.o
>>> +kvm-y += vm.o
>>> +kvm-y += vmid.o
>>> +kvm-y += tlb.o
>>> +kvm-y += mmu.o
>>> +kvm-y += vcpu.o
>>> +kvm-y += exit.o
>>> +kvm-y += interrupt.o
>>> +kvm-y += timer.o
>>> +kvm-y += switch.o
>>> +kvm-y += csr_ops.o
>> I'd suggest sorting this list too to better avoid editing conflicts in
>> the future.
>>
>> --
>> WANG "xen0n" Xuerui
>>
>> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
>>
>>
在 2023/9/11 下午3:30, WANG Xuerui 写道:
> On 8/31/23 16:30, Tianrui Zhao wrote:
>> [snip]
>> +
>> +config AS_HAS_LVZ_EXTENSION
>> + def_bool $(as-instr,hvcl 0)
>
> Upon closer look it looks like this piece could use some improvement
> as well: while presence of "hvcl" indeed always implies full support
> for LVZ instructions, "hvcl" however isn't used anywhere in the
> series, so it's not trivially making sense. It may be better to test
> for an instruction actually going to be used like "gcsrrd". What do
> you think?
Thanks for your advice, and I think both "hvcl" and "gcsrrd"
instructions which are supported by binutils mean that the cpu support
LVZ extension, so I think they have the same meaning there.
Thanks
Tianrui Zhao
在 2023/9/8 上午4:10, WANG Xuerui 写道:
>
> On 8/31/23 16:30, Tianrui Zhao wrote:
>> Enable LoongArch kvm config and add the makefile to support build kvm
>> module.
>>
>> Reviewed-by: Bibo Mao <[email protected]>
>> Reported-by: kernel test robot <[email protected]>
>> Link:
>> https://lore.kernel.org/oe-kbuild-all/[email protected]/
>> Signed-off-by: Tianrui Zhao <[email protected]>
>> ---
>> arch/loongarch/Kbuild | 1 +
>> arch/loongarch/Kconfig | 3 ++
>> arch/loongarch/configs/loongson3_defconfig | 2 +
>> arch/loongarch/kvm/Kconfig | 45 ++++++++++++++++++++++
>> arch/loongarch/kvm/Makefile | 22 +++++++++++
>> 5 files changed, 73 insertions(+)
>> create mode 100644 arch/loongarch/kvm/Kconfig
>> create mode 100644 arch/loongarch/kvm/Makefile
>>
>> diff --git a/arch/loongarch/Kbuild b/arch/loongarch/Kbuild
>> index b01f5cdb27..40be8a1696 100644
>> --- a/arch/loongarch/Kbuild
>> +++ b/arch/loongarch/Kbuild
>> @@ -2,6 +2,7 @@ obj-y += kernel/
>> obj-y += mm/
>> obj-y += net/
>> obj-y += vdso/
>> +obj-y += kvm/
> Do we want to keep the list alphabetically sorted here?
It could be resorted by alphabetical.
>> # for cleaning
>> subdir- += boot
>> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
>> index ecf282dee5..7f2f7ccc76 100644
>> --- a/arch/loongarch/Kconfig
>> +++ b/arch/loongarch/Kconfig
>> @@ -123,6 +123,7 @@ config LOONGARCH
>> select HAVE_KPROBES
>> select HAVE_KPROBES_ON_FTRACE
>> select HAVE_KRETPROBES
>> + select HAVE_KVM
>> select HAVE_MOD_ARCH_SPECIFIC
>> select HAVE_NMI
>> select HAVE_PCI
>> @@ -650,3 +651,5 @@ source "kernel/power/Kconfig"
>> source "drivers/acpi/Kconfig"
>> endmenu
>> +
>> +source "arch/loongarch/kvm/Kconfig"
>> diff --git a/arch/loongarch/configs/loongson3_defconfig
>> b/arch/loongarch/configs/loongson3_defconfig
>> index d64849b4cb..7acb4ae7af 100644
>> --- a/arch/loongarch/configs/loongson3_defconfig
>> +++ b/arch/loongarch/configs/loongson3_defconfig
>> @@ -63,6 +63,8 @@ CONFIG_EFI_ZBOOT=y
>> CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER=y
>> CONFIG_EFI_CAPSULE_LOADER=m
>> CONFIG_EFI_TEST=m
>> +CONFIG_VIRTUALIZATION=y
>> +CONFIG_KVM=m
>> CONFIG_MODULES=y
>> CONFIG_MODULE_FORCE_LOAD=y
>> CONFIG_MODULE_UNLOAD=y
>> diff --git a/arch/loongarch/kvm/Kconfig b/arch/loongarch/kvm/Kconfig
>> new file mode 100644
>> index 0000000000..bf7d6e7cde
>> --- /dev/null
>> +++ b/arch/loongarch/kvm/Kconfig
>> @@ -0,0 +1,45 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +#
>> +# KVM configuration
>> +#
>> +
>> +source "virt/kvm/Kconfig"
>> +
>> +menuconfig VIRTUALIZATION
>> + bool "Virtualization"
>> + help
>> + Say Y here to get to see options for using your Linux host to run
>> + other operating systems inside virtual machines (guests).
>> + This option alone does not add any kernel code.
>> +
>> + If you say N, all options in this submenu will be skipped and
>> + disabled.
>> +
>> +if VIRTUALIZATION
>> +
>> +config AS_HAS_LVZ_EXTENSION
>> + def_bool $(as-instr,hvcl 0)
>> +
>> +config KVM
>> + tristate "Kernel-based Virtual Machine (KVM) support"
>> + depends on HAVE_KVM
>> + depends on AS_HAS_LVZ_EXTENSION
>> + select MMU_NOTIFIER
>> + select ANON_INODES
>> + select PREEMPT_NOTIFIERS
>> + select KVM_MMIO
>> + select KVM_GENERIC_DIRTYLOG_READ_PROTECT
>> + select KVM_GENERIC_HARDWARE_ENABLING
>> + select KVM_XFER_TO_GUEST_WORK
>> + select HAVE_KVM_DIRTY_RING_ACQ_REL
>> + select HAVE_KVM_VCPU_ASYNC_IOCTL
>> + select HAVE_KVM_EVENTFD
>> + select SRCU
> Make the list of selects also alphabetically sorted?
It also could be resorted by alphabetical.
>> + help
>> + Support hosting virtualized guest machines using hardware
>> + virtualization extensions. You will need a fairly processor
>> + equipped with virtualization extensions.
>
> The word "fairly" seems extraneous here, and can be simply dropped.
Thanks, I will remove this "fairly" word.
>
> (I suppose you forgot to delete it after tweaking the original
> sentence, that came from arch/x86/kvm: "You will need a fairly recent
> processor ..." -- all LoongArch processors are recent!)
>
>> +
>> + If unsure, say N.
>> +
>> +endif # VIRTUALIZATION
>> diff --git a/arch/loongarch/kvm/Makefile b/arch/loongarch/kvm/Makefile
>> new file mode 100644
>> index 0000000000..2335e873a6
>> --- /dev/null
>> +++ b/arch/loongarch/kvm/Makefile
>> @@ -0,0 +1,22 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +#
>> +# Makefile for LOONGARCH KVM support
> "LoongArch" -- you may want to check the entire patch series for such
> ALL-CAPS references to LoongArch in natural language paragraphs, they
> all want to be spelled "LoongArch".
Thanks, I will fix it.
>> +#
>> +
>> +ccflags-y += -I $(srctree)/$(src)
>> +
>> +include $(srctree)/virt/kvm/Makefile.kvm
>> +
>> +obj-$(CONFIG_KVM) += kvm.o
>> +
>> +kvm-y += main.o
>> +kvm-y += vm.o
>> +kvm-y += vmid.o
>> +kvm-y += tlb.o
>> +kvm-y += mmu.o
>> +kvm-y += vcpu.o
>> +kvm-y += exit.o
>> +kvm-y += interrupt.o
>> +kvm-y += timer.o
>> +kvm-y += switch.o
>> +kvm-y += csr_ops.o
> I'd suggest sorting this list too to better avoid editing conflicts in
> the future.
I will also resort them by alphabetical.
Thanks
Tianrui Zhao