linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] KVM: s390: Some gaccess cleanup
@ 2021-11-26 16:45 Janis Schoetterl-Glausch
  2021-11-26 16:45 ` [PATCH v3 1/3] KVM: s390: gaccess: Refactor gpa and length calculation Janis Schoetterl-Glausch
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Janis Schoetterl-Glausch @ 2021-11-26 16:45 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank, Heiko Carstens, Vasily Gorbik
  Cc: Janis Schoetterl-Glausch, David Hildenbrand, Claudio Imbrenda,
	Alexander Gordeev, kvm, linux-s390, linux-kernel

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.
     
         Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
    +    Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
     
      ## 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.
     
         Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
    +    Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
     
      ## 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 <scgl@linux.ibm.com>
     
      ## 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.
     
         Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
    +    Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
     
      ## 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
-- 
2.32.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-12-07  9:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 16:45 [PATCH v3 0/3] KVM: s390: Some gaccess cleanup Janis Schoetterl-Glausch
2021-11-26 16:45 ` [PATCH v3 1/3] KVM: s390: gaccess: Refactor gpa and length calculation Janis Schoetterl-Glausch
2021-11-26 17:10   ` David Hildenbrand
2021-11-29  8:55   ` Claudio Imbrenda
2021-11-26 16:45 ` [PATCH v3 2/3] KVM: s390: gaccess: Refactor access address range check Janis Schoetterl-Glausch
2021-11-29  9:13   ` Claudio Imbrenda
2021-11-26 16:45 ` [PATCH v3 3/3] KVM: s390: gaccess: Cleanup access to guest pages Janis Schoetterl-Glausch
2021-11-26 17:09   ` David Hildenbrand
2021-11-29  8:59   ` Claudio Imbrenda
2021-11-29  9:17     ` Janis Schoetterl-Glausch
2021-12-07  9:27 ` [PATCH v3 0/3] KVM: s390: Some gaccess cleanup Janosch Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).