]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: s390: wrapper for KVM_BUG
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Thu, 23 Jan 2025 14:46:14 +0000 (15:46 +0100)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Fri, 31 Jan 2025 11:03:52 +0000 (12:03 +0100)
Wrap the call to KVM_BUG; this reduces code duplication and improves
readability.

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20250123144627.312456-3-imbrenda@linux.ibm.com
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-ID: <20250123144627.312456-3-imbrenda@linux.ibm.com>

arch/s390/kvm/kvm-s390.c

index d8080c27d45bda85e59f8d5c4104d7f05b2a0e2a..ecbdd7d41230afc1e1d5f15e39c25bd8956a9e1e 100644 (file)
@@ -4766,6 +4766,13 @@ static int vcpu_post_run_addressing_exception(struct kvm_vcpu *vcpu)
        return kvm_s390_inject_prog_irq(vcpu, &pgm_info);
 }
 
+static void kvm_s390_assert_primary_as(struct kvm_vcpu *vcpu)
+{
+       KVM_BUG(current->thread.gmap_teid.as != PSW_BITS_AS_PRIMARY, vcpu->kvm,
+               "Unexpected program interrupt 0x%x, TEID 0x%016lx",
+               current->thread.gmap_int_code, current->thread.gmap_teid.val);
+}
+
 static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)
 {
        unsigned int flags = 0;
@@ -4781,9 +4788,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)
                vcpu->stat.exit_null++;
                break;
        case PGM_NON_SECURE_STORAGE_ACCESS:
-               KVM_BUG(current->thread.gmap_teid.as != PSW_BITS_AS_PRIMARY, vcpu->kvm,
-                       "Unexpected program interrupt 0x%x, TEID 0x%016lx",
-                       current->thread.gmap_int_code, current->thread.gmap_teid.val);
+               kvm_s390_assert_primary_as(vcpu);
                /*
                 * This is normal operation; a page belonging to a protected
                 * guest has not been imported yet. Try to import the page into
@@ -4794,9 +4799,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)
                break;
        case PGM_SECURE_STORAGE_ACCESS:
        case PGM_SECURE_STORAGE_VIOLATION:
-               KVM_BUG(current->thread.gmap_teid.as != PSW_BITS_AS_PRIMARY, vcpu->kvm,
-                       "Unexpected program interrupt 0x%x, TEID 0x%016lx",
-                       current->thread.gmap_int_code, current->thread.gmap_teid.val);
+               kvm_s390_assert_primary_as(vcpu);
                /*
                 * This can happen after a reboot with asynchronous teardown;
                 * the new guest (normal or protected) will run on top of the
@@ -4825,9 +4828,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)
        case PGM_REGION_FIRST_TRANS:
        case PGM_REGION_SECOND_TRANS:
        case PGM_REGION_THIRD_TRANS:
-               KVM_BUG(current->thread.gmap_teid.as != PSW_BITS_AS_PRIMARY, vcpu->kvm,
-                       "Unexpected program interrupt 0x%x, TEID 0x%016lx",
-                       current->thread.gmap_int_code, current->thread.gmap_teid.val);
+               kvm_s390_assert_primary_as(vcpu);
                if (vcpu->arch.gmap->pfault_enabled) {
                        rc = gmap_fault(vcpu->arch.gmap, gaddr, flags | FAULT_FLAG_RETRY_NOWAIT);
                        if (rc == -EFAULT)