Skip to contentSkip to conversation

KVM: s390: Don't WARN on PV validities

PATCH In review Janosch Frank 3 participants 3 messages Jul 6, 2023 – Jul 10, 2023

Subsystems (3)
lore
Share & tools
lore

Janosch Frank

author maintainer
#0 lore raw

PATCH 1/1 KVM: s390: Don't WARN on PV validities

Validities usually indicate KVM errors and as such we want to print a message with a high priority to alert users that a validity occurred. With the introduction of Protected VMs it's become very easy to trigger validities via IOCTLs if the VM is in PV mode.

An optimal solution would be to return EINVALs to all IOCTLs that could result in such a situation. Unfortunately there are quite a lot of ways to trigger PV validities since the number of allowed SCB data combinations are very limited by FW in order to provide the guest's security.

Let's only log those validities to the KVM sysfs log and skip the WARN_ONCE(). This way we get a longish lasting log entry.

---

int -> ext:
* Fixed range
* Extended commit message

---
 arch/s390/kvm/intercept.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/s390/kvm/intercept.c +9 -3
index 954d39adf85c..f3c1220fd1e2 100644
@@ -97,9 +97,15 @@ static int handle_validity(struct kvm_vcpu *vcpu)
 	KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%pK)", viwhy,
 		  current->pid, vcpu->kvm);
 
-	/* do not warn on invalid runtime instrumentation mode */
-	WARN_ONCE(viwhy != 0x44, "kvm: unhandled validity intercept 0x%x\n",
-		  viwhy);
+	/*
+	 * Do not warn on:
+	 *  - invalid runtime instrumentation mode
+	 *  - PV related validities since they can be triggered by userspace
+	 *    PV validities are in the 0x2XXX range
+	 */
+	WARN_ONCE(viwhy != 0x44 &&
+		  ((viwhy < 0x2000) || (viwhy >= 0x3000)),
+		  "kvm: unhandled validity intercept 0x%x\n", viwhy);
 	return -EINVAL;
 }
 
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw

Am 06.07.23 um 16:53 schrieb Janosch Frank:

Quoted 11 lines

Validities usually indicate KVM errors and as such we want to print a message with a high priority to alert users that a validity occurred. With the introduction of Protected VMs it's become very easy to trigger validities via IOCTLs if the VM is in PV mode.

An optimal solution would be to return EINVALs to all IOCTLs that could result in such a situation. Unfortunately there are quite a lot of ways to trigger PV validities since the number of allowed SCB data combinations are very limited by FW in order to provide the guest's security.

Quoted 5 lines

Let's only log those validities to the KVM sysfs log and skip the WARN_ONCE(). This way we get a longish lasting log entry.

---

Quoted 32 lines

int -> ext:
* Fixed range
* Extended commit message

---
  arch/s390/kvm/intercept.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
arch/s390/kvm/intercept.c +9 -3
index 954d39adf85c..f3c1220fd1e2 100644
@@ -97,9 +97,15 @@ static int handle_validity(struct kvm_vcpu *vcpu)
  	KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%pK)", viwhy,
  		  current->pid, vcpu->kvm);
 
-	/* do not warn on invalid runtime instrumentation mode */
-	WARN_ONCE(viwhy != 0x44, "kvm: unhandled validity intercept 0x%x\n",
-		  viwhy);
+	/*
+	 * Do not warn on:
+	 *  - invalid runtime instrumentation mode
+	 *  - PV related validities since they can be triggered by userspace
+	 *    PV validities are in the 0x2XXX range
+	 */
+	WARN_ONCE(viwhy != 0x44 &&
+		  ((viwhy < 0x2000) || (viwhy >= 0x3000)),
+		  "kvm: unhandled validity intercept 0x%x\n", viwhy);
  	return -EINVAL;
  }
 
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Janosch Frank
Quoted 11 lines · On Thu, 6 Jul 2023 14:53:35 +0000 Janosch Frank <[email protected]> wrote:

Validities usually indicate KVM errors and as such we want to print a message with a high priority to alert users that a validity occurred. With the introduction of Protected VMs it's become very easy to trigger validities via IOCTLs if the VM is in PV mode.

An optimal solution would be to return EINVALs to all IOCTLs that could result in such a situation. Unfortunately there are quite a lot of ways to trigger PV validities since the number of allowed SCB data combinations are very limited by FW in order to provide the guest's security.

Quoted 4 lines

Let's only log those validities to the KVM sysfs log and skip the WARN_ONCE(). This way we get a longish lasting log entry.

Quoted 33 lines

---

int -> ext:
* Fixed range
* Extended commit message

---
 arch/s390/kvm/intercept.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/s390/kvm/intercept.c +9 -3
index 954d39adf85c..f3c1220fd1e2 100644
@@ -97,9 +97,15 @@ static int handle_validity(struct kvm_vcpu *vcpu)
 	KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%pK)", viwhy,
 		  current->pid, vcpu->kvm);
 
-	/* do not warn on invalid runtime instrumentation mode */
-	WARN_ONCE(viwhy != 0x44, "kvm: unhandled validity intercept 0x%x\n",
-		  viwhy);
+	/*
+	 * Do not warn on:
+	 *  - invalid runtime instrumentation mode
+	 *  - PV related validities since they can be triggered by userspace
+	 *    PV validities are in the 0x2XXX range
+	 */
+	WARN_ONCE(viwhy != 0x44 &&
+		  ((viwhy < 0x2000) || (viwhy >= 0x3000)),
+		  "kvm: unhandled validity intercept 0x%x\n", viwhy);
 	return -EINVAL;
 }