From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>
Cc: Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 0/3] KVM: s390: Some gaccess cleanup
Date: Fri, 26 Nov 2021 17:45:46 +0100 [thread overview]
Message-ID: <20211126164549.7046-1-scgl@linux.ibm.com> (raw)
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
next reply other threads:[~2021-11-26 16:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-26 16:45 Janis Schoetterl-Glausch [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211126164549.7046-1-scgl@linux.ibm.com \
--to=scgl@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox