Skip to content

Commit 9e7325a

Browse files
committed
KVM: s390: Refactor kvm_is_error_gpa() into kvm_is_gpa_in_memslot()
Rename kvm_is_error_gpa() to kvm_is_gpa_in_memslot() and invert the polarity accordingly in order to (a) free up kvm_is_error_gpa() to match with kvm_is_error_{hva,page}(), and (b) to make it more obvious that the helper is doing a memslot lookup, i.e. not simply checking for INVALID_GPA. No functional change intended. Link: https://lore.kernel.org/r/20240215152916.1158-9-paul@xen.org Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 406c109 commit 9e7325a

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

arch/s390/kvm/diag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int __diag_page_ref_service(struct kvm_vcpu *vcpu)
102102
parm.token_addr & 7 || parm.zarch != 0x8000000000000000ULL)
103103
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
104104

105-
if (kvm_is_error_gpa(vcpu->kvm, parm.token_addr))
105+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, parm.token_addr))
106106
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
107107

108108
vcpu->arch.pfault_token = parm.token_addr;

arch/s390/kvm/gaccess.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
664664
case ASCE_TYPE_REGION1: {
665665
union region1_table_entry rfte;
666666

667-
if (kvm_is_error_gpa(vcpu->kvm, ptr))
667+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr))
668668
return PGM_ADDRESSING;
669669
if (deref_table(vcpu->kvm, ptr, &rfte.val))
670670
return -EFAULT;
@@ -682,7 +682,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
682682
case ASCE_TYPE_REGION2: {
683683
union region2_table_entry rste;
684684

685-
if (kvm_is_error_gpa(vcpu->kvm, ptr))
685+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr))
686686
return PGM_ADDRESSING;
687687
if (deref_table(vcpu->kvm, ptr, &rste.val))
688688
return -EFAULT;
@@ -700,7 +700,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
700700
case ASCE_TYPE_REGION3: {
701701
union region3_table_entry rtte;
702702

703-
if (kvm_is_error_gpa(vcpu->kvm, ptr))
703+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr))
704704
return PGM_ADDRESSING;
705705
if (deref_table(vcpu->kvm, ptr, &rtte.val))
706706
return -EFAULT;
@@ -728,7 +728,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
728728
case ASCE_TYPE_SEGMENT: {
729729
union segment_table_entry ste;
730730

731-
if (kvm_is_error_gpa(vcpu->kvm, ptr))
731+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr))
732732
return PGM_ADDRESSING;
733733
if (deref_table(vcpu->kvm, ptr, &ste.val))
734734
return -EFAULT;
@@ -748,7 +748,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
748748
ptr = ste.fc0.pto * (PAGE_SIZE / 2) + vaddr.px * 8;
749749
}
750750
}
751-
if (kvm_is_error_gpa(vcpu->kvm, ptr))
751+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr))
752752
return PGM_ADDRESSING;
753753
if (deref_table(vcpu->kvm, ptr, &pte.val))
754754
return -EFAULT;
@@ -770,7 +770,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
770770
*prot = PROT_TYPE_IEP;
771771
return PGM_PROTECTION;
772772
}
773-
if (kvm_is_error_gpa(vcpu->kvm, raddr.addr))
773+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, raddr.addr))
774774
return PGM_ADDRESSING;
775775
*gpa = raddr.addr;
776776
return 0;
@@ -957,7 +957,7 @@ static int guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
957957
return rc;
958958
} else {
959959
gpa = kvm_s390_real_to_abs(vcpu, ga);
960-
if (kvm_is_error_gpa(vcpu->kvm, gpa)) {
960+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, gpa)) {
961961
rc = PGM_ADDRESSING;
962962
prot = PROT_NONE;
963963
}

arch/s390/kvm/kvm-s390.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,7 +2878,7 @@ static int kvm_s390_vm_mem_op_abs(struct kvm *kvm, struct kvm_s390_mem_op *mop)
28782878

28792879
srcu_idx = srcu_read_lock(&kvm->srcu);
28802880

2881-
if (kvm_is_error_gpa(kvm, mop->gaddr)) {
2881+
if (!kvm_is_gpa_in_memslot(kvm, mop->gaddr)) {
28822882
r = PGM_ADDRESSING;
28832883
goto out_unlock;
28842884
}
@@ -2940,7 +2940,7 @@ static int kvm_s390_vm_mem_op_cmpxchg(struct kvm *kvm, struct kvm_s390_mem_op *m
29402940

29412941
srcu_idx = srcu_read_lock(&kvm->srcu);
29422942

2943-
if (kvm_is_error_gpa(kvm, mop->gaddr)) {
2943+
if (!kvm_is_gpa_in_memslot(kvm, mop->gaddr)) {
29442944
r = PGM_ADDRESSING;
29452945
goto out_unlock;
29462946
}

arch/s390/kvm/priv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)
149149
* first page, since address is 8k aligned and memory pieces are always
150150
* at least 1MB aligned and have at least a size of 1MB.
151151
*/
152-
if (kvm_is_error_gpa(vcpu->kvm, address))
152+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, address))
153153
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
154154

155155
kvm_s390_set_prefix(vcpu, address);
@@ -464,7 +464,7 @@ static int handle_test_block(struct kvm_vcpu *vcpu)
464464
return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
465465
addr = kvm_s390_real_to_abs(vcpu, addr);
466466

467-
if (kvm_is_error_gpa(vcpu->kvm, addr))
467+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, addr))
468468
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
469469
/*
470470
* We don't expect errors on modern systems, and do not care

arch/s390/kvm/sigp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu,
172172
* first page, since address is 8k aligned and memory pieces are always
173173
* at least 1MB aligned and have at least a size of 1MB.
174174
*/
175-
if (kvm_is_error_gpa(vcpu->kvm, irq.u.prefix.address)) {
175+
if (!kvm_is_gpa_in_memslot(vcpu->kvm, irq.u.prefix.address)) {
176176
*reg &= 0xffffffff00000000UL;
177177
*reg |= SIGP_STATUS_INVALID_PARAMETER;
178178
return SIGP_CC_STATUS_STORED;

include/linux/kvm_host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,11 +1779,11 @@ static inline hpa_t pfn_to_hpa(kvm_pfn_t pfn)
17791779
return (hpa_t)pfn << PAGE_SHIFT;
17801780
}
17811781

1782-
static inline bool kvm_is_error_gpa(struct kvm *kvm, gpa_t gpa)
1782+
static inline bool kvm_is_gpa_in_memslot(struct kvm *kvm, gpa_t gpa)
17831783
{
17841784
unsigned long hva = gfn_to_hva(kvm, gpa_to_gfn(gpa));
17851785

1786-
return kvm_is_error_hva(hva);
1786+
return !kvm_is_error_hva(hva);
17871787
}
17881788

17891789
static inline void kvm_gpc_mark_dirty_in_slot(struct gfn_to_pfn_cache *gpc)

0 commit comments

Comments
 (0)