Skip to content

Commit a049cf7

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/misc-5.16 into kvmarm-master/next
* kvm-arm64/misc-5.16: : . : - Allow KVM to be disabled from the command-line : - Clean up CONFIG_KVM vs CONFIG_HAVE_KVM : . KVM: arm64: Depend on HAVE_KVM instead of OF KVM: arm64: Unconditionally include generic KVM's Kconfig KVM: arm64: Allow KVM to be disabled from the command line Signed-off-by: Marc Zyngier <[email protected]>
2 parents 15f9017 + e26bb75 commit a049cf7

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,8 @@
23652365
kvm-arm.mode=
23662366
[KVM,ARM] Select one of KVM/arm64's modes of operation.
23672367

2368+
none: Forcefully disable KVM.
2369+
23682370
nvhe: Standard nVHE-based mode, without support for
23692371
protected guests.
23702372

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ config ARM64
186186
select HAVE_GCC_PLUGINS
187187
select HAVE_HW_BREAKPOINT if PERF_EVENTS
188188
select HAVE_IRQ_TIME_ACCOUNTING
189+
select HAVE_KVM
189190
select HAVE_NMI
190191
select HAVE_PATA_PLATFORM
191192
select HAVE_PERF_EVENTS

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
enum kvm_mode {
5959
KVM_MODE_DEFAULT,
6060
KVM_MODE_PROTECTED,
61+
KVM_MODE_NONE,
6162
};
6263
enum kvm_mode kvm_get_mode(void);
6364

arch/arm64/kvm/Kconfig

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55

66
source "virt/lib/Kconfig"
7+
source "virt/kvm/Kconfig"
78

89
menuconfig VIRTUALIZATION
910
bool "Virtualization"
@@ -19,7 +20,7 @@ if VIRTUALIZATION
1920

2021
menuconfig KVM
2122
bool "Kernel-based Virtual Machine (KVM) support"
22-
depends on OF
23+
depends on HAVE_KVM
2324
select MMU_NOTIFIER
2425
select PREEMPT_NOTIFIERS
2526
select HAVE_KVM_CPU_RELAX_INTERCEPT
@@ -43,19 +44,14 @@ menuconfig KVM
4344

4445
If unsure, say N.
4546

46-
if KVM
47-
48-
source "virt/kvm/Kconfig"
49-
5047
config NVHE_EL2_DEBUG
5148
bool "Debug mode for non-VHE EL2 object"
49+
depends on KVM
5250
help
5351
Say Y here to enable the debug mode for the non-VHE KVM EL2 object.
5452
Failure reports will BUG() in the hypervisor. This is intended for
5553
local EL2 hypervisor development.
5654

5755
If unsure, say N.
5856

59-
endif # KVM
60-
6157
endif # VIRTUALIZATION

arch/arm64/kvm/arm.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,11 @@ int kvm_arch_init(void *opaque)
20872087
return -ENODEV;
20882088
}
20892089

2090+
if (kvm_get_mode() == KVM_MODE_NONE) {
2091+
kvm_info("KVM disabled from command line\n");
2092+
return -ENODEV;
2093+
}
2094+
20902095
in_hyp_mode = is_kernel_in_hyp_mode();
20912096

20922097
if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) ||
@@ -2160,8 +2165,15 @@ static int __init early_kvm_mode_cfg(char *arg)
21602165
return 0;
21612166
}
21622167

2163-
if (strcmp(arg, "nvhe") == 0 && !WARN_ON(is_kernel_in_hyp_mode()))
2168+
if (strcmp(arg, "nvhe") == 0 && !WARN_ON(is_kernel_in_hyp_mode())) {
2169+
kvm_mode = KVM_MODE_DEFAULT;
21642170
return 0;
2171+
}
2172+
2173+
if (strcmp(arg, "none") == 0) {
2174+
kvm_mode = KVM_MODE_NONE;
2175+
return 0;
2176+
}
21652177

21662178
return -EINVAL;
21672179
}

0 commit comments

Comments
 (0)