diff mbox series

[v3] KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available()

Message ID 20220911214059.2767620-1-quic_eberman@quicinc.com (mailing list archive)
State New, archived
Headers show
Series [v3] KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available() | expand

Commit Message

Elliot Berman Sept. 11, 2022, 9:40 p.m. UTC
Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want
to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is
not available. This prevents "Protected KVM" cpu capability being
reported when Linux is booting in EL1 and would not have KVM enabled.
Reasonably though, we should warn if the command line is requesting a
KVM mode at all if KVM isn't actually available. Don't emit warning for
"kvm-arm.mode=none" since this would disable KVM anyway.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 arch/arm64/kvm/arm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)


base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9

Comments

kernel test robot Sept. 12, 2022, 12:44 a.m. UTC | #1
Hi Elliot,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 0982c8d859f8f7022b9fd44d421c7ec721bb41f9]

url:    https://github.com/intel-lab-lkp/linux/commits/Elliot-Berman/KVM-arm64-Ignore-kvm-arm-mode-if-is_hyp_mode_available/20220912-054253
base:   0982c8d859f8f7022b9fd44d421c7ec721bb41f9
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220912/202209120812.lW9MTQPf-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/2266c3455ccaa7b42a9a0be751e15a15899d99b8
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Elliot-Berman/KVM-arm64-Ignore-kvm-arm-mode-if-is_hyp_mode_available/20220912-054253
        git checkout 2266c3455ccaa7b42a9a0be751e15a15899d99b8
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash arch/arm64/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arm64/kvm/arm.c: In function 'early_kvm_mode_cfg':
>> arch/arm64/kvm/arm.c:2281:17: error: expected ';' before 'return'
    2281 |                 return 0;
         |                 ^~~~~~


vim +2281 arch/arm64/kvm/arm.c

  2268	
  2269	static int __init early_kvm_mode_cfg(char *arg)
  2270	{
  2271		if (!arg)
  2272			return -EINVAL;
  2273	
  2274		if (strcmp(arg, "none") == 0) {
  2275			kvm_mode = KVM_MODE_NONE;
  2276			return 0;
  2277		}
  2278	
  2279		if (!is_hyp_mode_available()) {
  2280			pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n")
> 2281			return 0;
  2282		}
  2283	
  2284		if (strcmp(arg, "protected") == 0) {
  2285			if (!is_kernel_in_hyp_mode())
  2286				kvm_mode = KVM_MODE_PROTECTED;
  2287			else
  2288				pr_warn_once("Protected KVM not available with VHE\n");
  2289	
  2290			return 0;
  2291		}
  2292	
  2293		if (strcmp(arg, "nvhe") == 0 && !WARN_ON(is_kernel_in_hyp_mode())) {
  2294			kvm_mode = KVM_MODE_DEFAULT;
  2295			return 0;
  2296		}
  2297	
  2298		return -EINVAL;
  2299	}
  2300	early_param("kvm-arm.mode", early_kvm_mode_cfg);
  2301
diff mbox series

Patch

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 8fe73ee5fa84..8e5d1c8502f5 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -2271,6 +2271,16 @@  static int __init early_kvm_mode_cfg(char *arg)
 	if (!arg)
 		return -EINVAL;
 
+	if (strcmp(arg, "none") == 0) {
+		kvm_mode = KVM_MODE_NONE;
+		return 0;
+	}
+
+	if (!is_hyp_mode_available()) {
+		pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n")
+		return 0;
+	}
+
 	if (strcmp(arg, "protected") == 0) {
 		if (!is_kernel_in_hyp_mode())
 			kvm_mode = KVM_MODE_PROTECTED;
@@ -2285,11 +2295,6 @@  static int __init early_kvm_mode_cfg(char *arg)
 		return 0;
 	}
 
-	if (strcmp(arg, "none") == 0) {
-		kvm_mode = KVM_MODE_NONE;
-		return 0;
-	}
-
 	return -EINVAL;
 }
 early_param("kvm-arm.mode", early_kvm_mode_cfg);