Skip to contentSkip to conversation

Documentation: Update the behaviour of "kvm-arm.mode"

PATCH Superseded Mostafa Saleh 2 participants 3 messages Oct 24, 2024 Documentation

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Documentation: Update the behaviour of "kvm-arm.mode"

Commit 5053c3f0519c ("KVM: arm64: Use hVHE in pKVM by default on CPUs with VHE support") modified the behaviour of "kvm-arm.mode=protected" without the updating the kernel parameters doc.

Update it to match the current implementation.

Also, update required architecture version for nested virtualization as suggested by Marc.

Cc Will Deacon <[email protected]>
Cc Marc Zyngier <[email protected]>

---
v2: Update nested value also

---
 Documentation/admin-guide/kernel-parameters.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -3
index 1518343bbe22..d5b771e5cb5b 100644
@@ -2740,12 +2740,16 @@
 			nvhe: Standard nVHE-based mode, without support for
 			      protected guests.
 
-			protected: nVHE-based mode with support for guests whose
+			protected: hVHE-based mode with support for guests whose
 				   state is kept private from the host.
+				   In case hVHE is not supported in hardware, it will
+				   boot with protected nVHE.
+				   nVHE protected mode can still be forced on VHE systems
+				   using "kvm_arm.mode=protected arm64_sw.hvhe=0 id_aa64mmfr1.vh=0"
 
 			nested: VHE-based mode with support for nested
-				virtualization. Requires at least ARMv8.3
-				hardware.
+				virtualization. Requires at least ARMv8.4
+				hardware (with FEAT_NV2).
 
 			Defaults to VHE/nVHE based on hardware support. Setting
 			mode to "protected" will disable kexec and hibernation
Signature · 1 line
2.47.0.105.g07ac214952-goog
#1 lore raw

Hi Mostafa,

Quoted 10 lines · Mostafa Saleh

Commit 5053c3f0519c ("KVM: arm64: Use hVHE in pKVM by default on CPUs with VHE support") modified the behaviour of "kvm-arm.mode=protected" without the updating the kernel parameters doc.

Update it to match the current implementation.

Also, update required architecture version for nested virtualization as suggested by Marc.

Quoted 7 lines
Cc Will Deacon <[email protected]>
Cc Marc Zyngier <[email protected]>

---
v2: Update nested value also

Thanks for that. However...

Quoted 9 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 1518343bbe22..d5b771e5cb5b 100644

Documentation/admin-guide/kernel-parameters.txt line 2748

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +5 -1
@@ -2740,12 +2740,16 @@
 			nvhe: Standard nVHE-based mode, without support for
 			      protected guests.
 
-			protected: nVHE-based mode with support for guests whose
+			protected: hVHE-based mode with support for guests whose
 				   state is kept private from the host.
+				   In case hVHE is not supported in hardware, it will
+				   boot with protected nVHE.
+				   nVHE protected mode can still be forced on VHE systems
+				   using "kvm_arm.mode=protected arm64_sw.hvhe=0 id_aa64mmfr1.vh=0"

I probably didn't explain myself very well. I would like to avoid mentioning hVHE at all, because this is pretty confusing (and really an implementation detail). Instead, we can talk about VHE/nVHE, which are real architectural features.

Also, I just realised that we can use your command-line magic for downgrading from VHE to nVHE in all cases, so I'd be suggesting something like this:

Documentation/admin-guide/kernel-parameters.txt +8 -4
index 1518343bbe223..2bb19f1331fed 100644
@@ -2740,8 +2740,9 @@
 			nvhe: Standard nVHE-based mode, without support for
 			      protected guests.
 
-			protected: nVHE-based mode with support for guests whose
-				   state is kept private from the host.
+			protected: Mode with support for guests whose state is
+				   kept private from the host, using VHE or
+				   nVHE depending on HW support.
 
 			nested: VHE-based mode with support for nested
 				virtualization. Requires at least ARMv8.3
@@ -2749,8 +2750,11 @@
 
 			Defaults to VHE/nVHE based on hardware support. Setting
 			mode to "protected" will disable kexec and hibernation
-			for the host. "nested" is experimental and should be
-			used with extreme caution.
+			for the host. To force nVHE on VHE hardware, add
+			"arm64_sw.hvhe=0 id_aa64mmfr1.vh=0" to the
+			command-line.
+			"nested" is experimental and should be used with
+			extreme caution.
 
 	kvm-arm.vgic_v3_group0_trap=
 			[KVM,ARM,EARLY] Trap guest accesses to GICv3 group-0

Documentation/admin-guide/kernel-parameters.txt line 2751

Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +2 -2
 			nested: VHE-based mode with support for nested
-				virtualization. Requires at least ARMv8.3
-				hardware.
+				virtualization. Requires at least ARMv8.4
+				hardware (with FEAT_NV2).

That part looks good!

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#2 lore raw
Quoted 36 lines · Marc Zyngier

Hi Mostafa,

Quoted 10 lines · Mostafa Saleh

Commit 5053c3f0519c ("KVM: arm64: Use hVHE in pKVM by default on CPUs with VHE support") modified the behaviour of "kvm-arm.mode=protected" without the updating the kernel parameters doc.

Update it to match the current implementation.

Also, update required architecture version for nested virtualization as suggested by Marc.

Quoted 7 lines
Cc Will Deacon <[email protected]>
Cc Marc Zyngier <[email protected]>

---
v2: Update nested value also

Thanks for that. However...

Quoted 12 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 1518343bbe22..d5b771e5cb5b 100644
@@ -2740,12 +2740,16 @@
 			nvhe: Standard nVHE-based mode, without support for
 			      protected guests.
 
Quoted 13 lines

Documentation/admin-guide/kernel-parameters.txt line 2748

Quoted 7 lines
Documentation/admin-guide/kernel-parameters.txt +5 -1
-			protected: nVHE-based mode with support for guests whose
+			protected: hVHE-based mode with support for guests whose
 				   state is kept private from the host.
+				   In case hVHE is not supported in hardware, it will
+				   boot with protected nVHE.
+				   nVHE protected mode can still be forced on VHE systems
+				   using "kvm_arm.mode=protected arm64_sw.hvhe=0 id_aa64mmfr1.vh=0"

I probably didn't explain myself very well. I would like to avoid mentioning hVHE at all, because this is pretty confusing (and really an implementation detail). Instead, we can talk about VHE/nVHE, which are real architectural features.

Agh, my bad, it makes more sense to talk in terms or architecture.

Quoted 46 lines

Also, I just realised that we can use your command-line magic for downgrading from VHE to nVHE in all cases, so I'd be suggesting something like this:

Documentation/admin-guide/kernel-parameters.txt +8 -4
index 1518343bbe223..2bb19f1331fed 100644
@@ -2740,8 +2740,9 @@
 			nvhe: Standard nVHE-based mode, without support for
 			      protected guests.
 
-			protected: nVHE-based mode with support for guests whose
-				   state is kept private from the host.
+			protected: Mode with support for guests whose state is
+				   kept private from the host, using VHE or
+				   nVHE depending on HW support.
 
 			nested: VHE-based mode with support for nested
 				virtualization. Requires at least ARMv8.3
@@ -2749,8 +2750,11 @@
 
 			Defaults to VHE/nVHE based on hardware support. Setting
 			mode to "protected" will disable kexec and hibernation
-			for the host. "nested" is experimental and should be
-			used with extreme caution.
+			for the host. To force nVHE on VHE hardware, add
+			"arm64_sw.hvhe=0 id_aa64mmfr1.vh=0" to the
+			command-line.
+			"nested" is experimental and should be used with
+			extreme caution.
 
 	kvm-arm.vgic_v3_group0_trap=
 			[KVM,ARM,EARLY] Trap guest accesses to GICv3 group-0

Documentation/admin-guide/kernel-parameters.txt line 2751

Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +2 -2
 			nested: VHE-based mode with support for nested
-				virtualization. Requires at least ARMv8.3
-				hardware.
+				virtualization. Requires at least ARMv8.4
+				hardware (with FEAT_NV2).

That part looks good!

Quoted 6 lines

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.

Thanks,
Mostafa