arm64/sve: KVM: Treat guest SVE use as undefined instruction execution
authorDave Martin <[email protected]>
Tue, 31 Oct 2017 15:51:17 +0000 (15:51 +0000)
committerWill Deacon <[email protected]>
Fri, 3 Nov 2017 15:24:20 +0000 (15:24 +0000)
When trapping forbidden attempts by a guest to use SVE, we want the
guest to see a trap consistent with SVE not being implemented.

This patch injects an undefined instruction exception into the
guest in response to such an exception.

Signed-off-by: Dave Martin <[email protected]>
Reviewed-by: Alex BennĂ©e <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Acked-by: Christoffer Dall <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
arch/arm64/kvm/handle_exit.c

index 7debb74843a053bfdec33cb69326f3f3d0968297..b712479954692f3efd3844e490b412f71c3a96aa 100644 (file)
@@ -147,6 +147,13 @@ static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run)
        return 1;
 }
 
+static int handle_sve(struct kvm_vcpu *vcpu, struct kvm_run *run)
+{
+       /* Until SVE is supported for guests: */
+       kvm_inject_undefined(vcpu);
+       return 1;
+}
+
 static exit_handle_fn arm_exit_handlers[] = {
        [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
        [ESR_ELx_EC_WFx]        = kvm_handle_wfx,
@@ -160,6 +167,7 @@ static exit_handle_fn arm_exit_handlers[] = {
        [ESR_ELx_EC_HVC64]      = handle_hvc,
        [ESR_ELx_EC_SMC64]      = handle_smc,
        [ESR_ELx_EC_SYS64]      = kvm_handle_sys_reg,
+       [ESR_ELx_EC_SVE]        = handle_sve,
        [ESR_ELx_EC_IABT_LOW]   = kvm_handle_guest_abort,
        [ESR_ELx_EC_DABT_LOW]   = kvm_handle_guest_abort,
        [ESR_ELx_EC_SOFTSTP_LOW]= kvm_handle_guest_debug,