]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: Rationalise KVM banner output
authorMarc Zyngier <maz@kernel.org>
Thu, 21 Mar 2024 17:37:06 +0000 (17:37 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Mon, 1 Apr 2024 08:33:52 +0000 (01:33 -0700)
We are not very consistent when it comes to displaying which mode
we're in (VHE, {n,h}VHE, protected or not). For example, booting
in protected mode with hVHE results in:

[    0.969545] kvm [1]: Protected nVHE mode initialized successfully

which is mildly amusing considering that the machine is VHE only.

We already cleaned this up a bit with commit 1f3ca7023fe6 ("KVM:
arm64: print Hyp mode"), but that's still unsatisfactory.

Unify the three strings into one and use a mess of conditional
statements to sort it out (yes, it's a slow day).

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20240321173706.3280796-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/arm.c

index 3dee5490eea94dd08e4ff88cb79f41d5d60be139..c4a0a35e02c72866b87c8a3e827b87ed5303504e 100644 (file)
@@ -2597,14 +2597,11 @@ static __init int kvm_arm_init(void)
        if (err)
                goto out_hyp;
 
-       if (is_protected_kvm_enabled()) {
-               kvm_info("Protected nVHE mode initialized successfully\n");
-       } else if (in_hyp_mode) {
-               kvm_info("VHE mode initialized successfully\n");
-       } else {
-               char mode = cpus_have_final_cap(ARM64_KVM_HVHE) ? 'h' : 'n';
-               kvm_info("Hyp mode (%cVHE) initialized successfully\n", mode);
-       }
+       kvm_info("%s%sVHE mode initialized successfully\n",
+                in_hyp_mode ? "" : (is_protected_kvm_enabled() ?
+                                    "Protected " : "Hyp "),
+                in_hyp_mode ? "" : (cpus_have_final_cap(ARM64_KVM_HVHE) ?
+                                    "h" : "n"));
 
        /*
         * FIXME: Do something reasonable if kvm_init() fails after pKVM