Thread (13 messages) 13 messages, 5 authors, 2021-08-19

Re: [PATCH 1/2] KVM: s390: gaccess: Cleanup access to guest frames

From: Janosch Frank <frankja@linux.ibm.com>
Date: 2021-08-19 14:12:00
Also in: kvm, lkml

On 8/19/21 3:53 PM, Janis Schoetterl-Glausch wrote:
On 8/18/21 10:06 AM, Janosch Frank wrote:
quoted
On 8/18/21 9:54 AM, David Hildenbrand wrote:
quoted
On 16.08.21 17:07, Janis Schoetterl-Glausch wrote:
quoted
Introduce a helper function for guest frame access.
Rewrite the calculation of the gpa and the length of the segment
to be more readable.

Signed-off-by: Janis Schoetterl-Glausch <redacted>
[...]
quoted
quoted
-	unsigned long _len, gpa;
+	unsigned long gpa;
+	unsigned int seg;
  	int rc = 0;
  
  	while (len && !rc) {
  		gpa = kvm_s390_real_to_abs(vcpu, gra);
-		_len = min(PAGE_SIZE - (gpa & ~PAGE_MASK), len);
-		if (mode)
-			rc = write_guest_abs(vcpu, gpa, data, _len);
-		else
-			rc = read_guest_abs(vcpu, gpa, data, _len);
-		len -= _len;
-		gra += _len;
-		data += _len;
+		seg = min(PAGE_SIZE - offset_in_page(gpa), len);
What does "seg" mean? I certainly know when "len" means -- which is also 
what the function eats.
What does "_len" mean especially in contrast to "len"?

"seg" is used in the common kvm guest access functions so it's at least
consistent although I share the sentiment that it's not a great name for
the length we access inside the page.

Originally I suggested "len_in_page" if you have a better name I'd
expect we'll both be happy to discuss it :-)
fragment_len ? 
Sounds good to me
quoted
quoted
quoted
+		rc = access_guest_frame(vcpu->kvm, mode, gpa, data, seg);
+		len -= seg;
+		gra += seg;
+		data += seg;
  	}
  	return rc;
  }
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help