Skip to content

KVM: s390: Some gaccess cleanup

Janis Schoetterl-Glausch kvm linux-s390 lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 7 repliesIn review
  2. v22 of 3 patches 7 repliesSuperseded
  3. v12 patches 10 repliesSuperseded

Changes in v3 from the cover letter

minor changes only
typo fixes
whitespace
line reordering
picked up Reviewed-by's

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3KVM: s390: gaccess: Refactor gpa and length calculationarch/s390/kvm/gaccess.c+17 -152 replies
2/3KVM: s390: gaccess: Refactor access address range checkarch/s390/kvm/gaccess.c+69 -531 reply
3/3KVM: s390: gaccess: Cleanup access to guest pagesarch/s390/kvm/gaccess.c+16 -83 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchJanosch FrankDavid HildenbrandClaudio Imbrenda
1/3R-b R-b R-b
2/3R-b R-b
3/3R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/3] KVM: s390: Some gaccess cleanup

Cleanup s390 guest access code a bit, getting rid of some code duplication and improving readability.

v2 -> v3
minor changes only
typo fixes
whitespace
line reordering
picked up Reviewed-by's

v1 -> v2
separate patch for renamed variable
fragment_len instead of seg
expand comment of guest_range_to_gpas
fix nits

Janis Schoetterl-Glausch (3):
KVM: s390: gaccess: Refactor gpa and length calculation
KVM: s390: gaccess: Refactor access address range check
KVM: s390: gaccess: Cleanup access to guest pages

 arch/s390/kvm/gaccess.c | 158 +++++++++++++++++++++++-----------------
 1 file changed, 92 insertions(+), 66 deletions(-)

Range-diff against v2:
1: 60d050210198 ! 1: e5d7d2d7a4da KVM: s390: gaccess: Refactor gpa and length calculation
@@ Metadata
## Commit message ##
KVM: s390: gaccess: Refactor gpa and length calculation

- Improve readability be renaming the length variable and
+ Improve readability by renaming the length variable and
not calculating the offset manually.

+ Reviewed-by: Janosch Frank <[email protected]>

## arch/s390/kvm/gaccess.c ##
@@ arch/s390/kvm/gaccess.c: int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data,
@@ arch/s390/kvm/gaccess.c: int access_guest(struct kvm_vcpu *vcpu, unsigned long g
psw_t *psw = &vcpu->arch.sie_block->gpsw;
- unsigned long _len, nr_pages, gpa, idx;
+ unsigned long nr_pages, gpa, idx;
-+ unsigned int fragment_len;
unsigned long pages_array[2];
++ unsigned int fragment_len;
unsigned long *pages;
int need_ipte_lock;
+ union asce asce;
@@ arch/s390/kvm/gaccess.c: int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data,
ipte_lock(vcpu);
rc = guest_page_range(vcpu, ga, ar, pages, nr_pages, asce, mode);
2: 7080846c8c07 ! 2: 91cadb42cbbc KVM: s390: gaccess: Refactor access address range check
@@ Commit message
range.

+ Reviewed-by: Janosch Frank <[email protected]>

## arch/s390/kvm/gaccess.c ##
@@ arch/s390/kvm/gaccess.c: static int low_address_protection_enabled(struct kvm_vcpu *vcpu,
@@ arch/s390/kvm/gaccess.c: static int low_address_protection_enabled(struct kvm_vc
+ * a correct exception into the guest.
+ * The resulting gpas are stored into @gpas, unless it is NULL.
+ *
-+ * Note: All gpas except the first one start at the beginning of a page.
++ * Note: All fragments except the first one start at the beginning of a page.
+ * When deriving the boundaries of a fragment from a gpa, all but the last
+ * fragment end at the end of the page.
+ *
@@ arch/s390/kvm/gaccess.c: int access_guest(struct kvm_vcpu *vcpu, unsigned long g
{
psw_t *psw = &vcpu->arch.sie_block->gpsw;
- unsigned long nr_pages, gpa, idx;
+- unsigned long pages_array[2];
+ unsigned long nr_pages, idx;
++ unsigned long gpa_array[2];
unsigned int fragment_len;
-- unsigned long pages_array[2];
- unsigned long *pages;
-+ unsigned long gpa_array[2];
+ unsigned long *gpas;
int need_ipte_lock;
union asce asce;
3: c991cbdbfbd5 ! 3: f5000a22efcd KVM: s390: gaccess: Cleanup access to guest frames
@@ Metadata
Author: Janis Schoetterl-Glausch <[email protected]>

## Commit message ##
- KVM: s390: gaccess: Cleanup access to guest frames
+ KVM: s390: gaccess: Cleanup access to guest pages

Introduce a helper function for guest frame access.

+ Reviewed-by: Janosch Frank <[email protected]>

## arch/s390/kvm/gaccess.c ##
@@ arch/s390/kvm/gaccess.c: static int guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
@@ arch/s390/kvm/gaccess.c: static int guest_range_to_gpas(struct kvm_vcpu *vcpu, u
}

+static int access_guest_page(struct kvm *kvm, enum gacc_mode mode, gpa_t gpa,
-+ void *data, unsigned int len)
++ void *data, unsigned int len)
+{
+ const unsigned int offset = offset_in_page(gpa);
+ const gfn_t gfn = gpa_to_gfn(gpa);

base-commit: d25f27432f80a800a3592db128254c8140bd71bf

Signature · 1 line
2.32.0