For nested guests where HFGITR_EL2.nGCSSTR_EL1 is clear or when there are
L2 GCS data check exceptions we need to forward the exception to the guest.
Add handling to do so.

Signed-off-by: Mark Brown <[email protected]>
---
 arch/arm64/kvm/handle_exit.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 54aedf93c78b..9db350891793 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -304,12 +304,24 @@ static int handle_svc(struct kvm_vcpu *vcpu)
        return 1;
 }
 
+/*
+ * We might get GCS exceptions that need to be forwarded to the
+ * hypervisor when a nested guest has HFGITR_EL2.nGCSSTR_EL1 clear, or
+ * for a GCS data check exception for a L2 guest.
+ */
 static int kvm_handle_gcs(struct kvm_vcpu *vcpu)
 {
-       /* We don't expect GCS, so treat it with contempt */
-       if (kvm_has_feat(vcpu->kvm, ID_AA64PFR1_EL1, GCS, IMP))
-               WARN_ON_ONCE(1);
+       if (!kvm_has_gcs(vcpu->kvm)) {
+               kvm_inject_undefined(vcpu);
+               return 1;
+       }
 
+       if (is_nested_ctxt(vcpu)) {
+               kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu));
+               return 1;
+       }
+
+       WARN_ON_ONCE(1);
        kvm_inject_undefined(vcpu);
        return 1;
 }

-- 
2.47.3


Reply via email to