Re: [RFC 09/37] KVM: s390: protvirt: Implement on-demand pinning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24.10.19 13:40, Janosch Frank wrote:
From: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>

Pin the guest pages when they are first accessed, instead of all at
the same time when starting the guest.

Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
---
  arch/s390/include/asm/gmap.h |  1 +
  arch/s390/include/asm/uv.h   |  6 +++++
  arch/s390/kernel/uv.c        | 20 ++++++++++++++
  arch/s390/kvm/kvm-s390.c     |  2 ++
  arch/s390/kvm/pv.c           | 51 ++++++++++++++++++++++++++++++------
  5 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/gmap.h b/arch/s390/include/asm/gmap.h
index 99b3eedda26e..483f64427c0e 100644
--- a/arch/s390/include/asm/gmap.h
+++ b/arch/s390/include/asm/gmap.h
@@ -63,6 +63,7 @@ struct gmap {
  	struct gmap *parent;
  	unsigned long orig_asce;
  	unsigned long se_handle;
+	struct page **pinned_pages;
  	int edat_level;
  	bool removed;
  	bool initialized;
diff --git a/arch/s390/include/asm/uv.h b/arch/s390/include/asm/uv.h
index 99cdd2034503..9ce9363aee1c 100644
--- a/arch/s390/include/asm/uv.h
+++ b/arch/s390/include/asm/uv.h
@@ -298,6 +298,7 @@ static inline int uv_convert_from_secure(unsigned long paddr)
  	return -EINVAL;
  }
+int kvm_s390_pv_pin_page(struct gmap *gmap, unsigned long gpa);
  /*
   * Requests the Ultravisor to make a page accessible to a guest
   * (import). If it's brought in the first time, it will be cleared. If
@@ -317,6 +318,11 @@ static inline int uv_convert_to_secure(struct gmap *gmap, unsigned long gaddr)
  		.gaddr = gaddr
  	};
+ down_read(&gmap->mm->mmap_sem);
+	cc = kvm_s390_pv_pin_page(gmap, gaddr);
+	up_read(&gmap->mm->mmap_sem);
+	if (cc)
+		return cc;
  	cc = uv_call(0, (u64)&uvcb);

So, a theoretical question: Is any in-flight I/O from paging stopped when we try to pin the pages? I am no export on paging, but the comment from Christian ("you can actually fault in a page that is currently under paging I/O.") made me wonder.

Let's assume you could have parallel I/O on that page. You would do a uv_call() and convert the page to secure/unencrypted. The I/O can easily stumble over that (now inaccessible) page and report an error.

Or is any such race not possible because we are using get_user_pages_fast() vs. get_user_pages()? (then, I'd love to see a comment regarding that in the patch description)

--

Thanks,

David / dhildenb





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux