Skip to content

Commit c5f64c9

Browse files
davidhildenbrandClaudio Imbrenda
authored andcommitted
KVM: s390: vsie: stop using page->index
Let's stop using page->index, and instead use a field inside "struct vsie_page" to hold that value. We have plenty of space left in there. This is one part of stopping using "struct page" when working with vsie pages. We place the "page_to_virt(page)" strategically, so the next cleanups requires less churn. Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com> Tested-by: Christoph Schlameuss <schlameuss@linux.ibm.com> Message-ID: <20250107154344.1003072-3-david@redhat.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
1 parent 5f230f4 commit c5f64c9

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

arch/s390/kvm/vsie.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ struct vsie_page {
4646
gpa_t gvrd_gpa; /* 0x0240 */
4747
gpa_t riccbd_gpa; /* 0x0248 */
4848
gpa_t sdnx_gpa; /* 0x0250 */
49-
__u8 reserved[0x0700 - 0x0258]; /* 0x0258 */
49+
/*
50+
* guest address of the original SCB. Remains set for free vsie
51+
* pages, so we can properly look them up in our addr_to_page
52+
* radix tree.
53+
*/
54+
gpa_t scb_gpa; /* 0x0258 */
55+
__u8 reserved[0x0700 - 0x0260]; /* 0x0260 */
5056
struct kvm_s390_crypto_cb crycb; /* 0x0700 */
5157
__u8 fac[S390_ARCH_FAC_LIST_SIZE_BYTE]; /* 0x0800 */
5258
};
@@ -1362,9 +1368,10 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
13621368
page = radix_tree_lookup(&kvm->arch.vsie.addr_to_page, addr >> 9);
13631369
rcu_read_unlock();
13641370
if (page) {
1371+
vsie_page = page_to_virt(page);
13651372
if (page_ref_inc_return(page) == 2) {
1366-
if (page->index == addr)
1367-
return page_to_virt(page);
1373+
if (vsie_page->scb_gpa == addr)
1374+
return vsie_page;
13681375
/*
13691376
* We raced with someone reusing + putting this vsie
13701377
* page before we grabbed it.
@@ -1386,36 +1393,37 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
13861393
mutex_unlock(&kvm->arch.vsie.mutex);
13871394
return ERR_PTR(-ENOMEM);
13881395
}
1396+
vsie_page = page_to_virt(page);
13891397
page_ref_inc(page);
13901398
kvm->arch.vsie.pages[kvm->arch.vsie.page_count] = page;
13911399
kvm->arch.vsie.page_count++;
13921400
} else {
13931401
/* reuse an existing entry that belongs to nobody */
13941402
while (true) {
13951403
page = kvm->arch.vsie.pages[kvm->arch.vsie.next];
1404+
vsie_page = page_to_virt(page);
13961405
if (page_ref_inc_return(page) == 2)
13971406
break;
13981407
page_ref_dec(page);
13991408
kvm->arch.vsie.next++;
14001409
kvm->arch.vsie.next %= nr_vcpus;
14011410
}
1402-
if (page->index != ULONG_MAX)
1411+
if (vsie_page->scb_gpa != ULONG_MAX)
14031412
radix_tree_delete(&kvm->arch.vsie.addr_to_page,
1404-
page->index >> 9);
1413+
vsie_page->scb_gpa >> 9);
14051414
}
14061415
/* Mark it as invalid until it resides in the tree. */
1407-
page->index = ULONG_MAX;
1416+
vsie_page->scb_gpa = ULONG_MAX;
14081417

14091418
/* Double use of the same address or allocation failure. */
14101419
if (radix_tree_insert(&kvm->arch.vsie.addr_to_page, addr >> 9, page)) {
14111420
page_ref_dec(page);
14121421
mutex_unlock(&kvm->arch.vsie.mutex);
14131422
return NULL;
14141423
}
1415-
page->index = addr;
1424+
vsie_page->scb_gpa = addr;
14161425
mutex_unlock(&kvm->arch.vsie.mutex);
14171426

1418-
vsie_page = page_to_virt(page);
14191427
memset(&vsie_page->scb_s, 0, sizeof(struct kvm_s390_sie_block));
14201428
release_gmap_shadow(vsie_page);
14211429
vsie_page->fault_addr = 0;
@@ -1507,9 +1515,9 @@ void kvm_s390_vsie_destroy(struct kvm *kvm)
15071515
vsie_page = page_to_virt(page);
15081516
release_gmap_shadow(vsie_page);
15091517
/* free the radix tree entry */
1510-
if (page->index != ULONG_MAX)
1518+
if (vsie_page->scb_gpa != ULONG_MAX)
15111519
radix_tree_delete(&kvm->arch.vsie.addr_to_page,
1512-
page->index >> 9);
1520+
vsie_page->scb_gpa >> 9);
15131521
__free_page(page);
15141522
}
15151523
kvm->arch.vsie.page_count = 0;

0 commit comments

Comments
 (0)