s390/uv: add destroy page call
authorJanosch Frank <frankja@linux.ibm.com>
Mon, 7 Sep 2020 12:46:59 +0000 (08:46 -0400)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 14 Sep 2020 09:38:35 +0000 (11:38 +0200)
We don't need to export pages if we destroy the VM configuration
afterwards anyway. Instead we can destroy the page which will zero it
and then make it accessible to the host.

Destroying is about twice as fast as the export.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Link: https://lore.kernel.org/kvm/20200907124700.10374-2-frankja@linux.ibm.com/
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/uv.h
arch/s390/kernel/uv.c
arch/s390/mm/gmap.c

index cff4b4c99b7551218ad0f5fed40ddccdd228ad96..0325fc0469b7b021613d1d1837b62b85378665f4 100644 (file)
@@ -33,6 +33,7 @@
 #define UVC_CMD_DESTROY_SEC_CPU                0x0121
 #define UVC_CMD_CONV_TO_SEC_STOR       0x0200
 #define UVC_CMD_CONV_FROM_SEC_STOR     0x0201
+#define UVC_CMD_DESTR_SEC_STOR         0x0202
 #define UVC_CMD_SET_SEC_CONF_PARAMS    0x0300
 #define UVC_CMD_UNPACK_IMG             0x0301
 #define UVC_CMD_VERIFY_IMG             0x0302
@@ -344,6 +345,7 @@ static inline int is_prot_virt_host(void)
 }
 
 int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb);
+int uv_destroy_page(unsigned long paddr);
 int uv_convert_from_secure(unsigned long paddr);
 int gmap_convert_to_secure(struct gmap *gmap, unsigned long gaddr);
 
@@ -354,6 +356,11 @@ void adjust_to_uv_max(unsigned long *vmax);
 static inline void setup_uv(void) {}
 static inline void adjust_to_uv_max(unsigned long *vmax) {}
 
+static inline int uv_destroy_page(unsigned long paddr)
+{
+       return 0;
+}
+
 static inline int uv_convert_from_secure(unsigned long paddr)
 {
        return 0;
index c296e5c8dbf97ab4fd793dd7a10c9618392034fe..d3399b8a9b2374a132d54801940787e0950eeba9 100644 (file)
@@ -118,6 +118,26 @@ static int uv_pin_shared(unsigned long paddr)
        return 0;
 }
 
+/*
+ * Requests the Ultravisor to destroy a guest page and make it
+ * accessible to the host. The destroy clears the page instead of
+ * exporting.
+ *
+ * @paddr: Absolute host address of page to be destroyed
+ */
+int uv_destroy_page(unsigned long paddr)
+{
+       struct uv_cb_cfs uvcb = {
+               .header.cmd = UVC_CMD_DESTR_SEC_STOR,
+               .header.len = sizeof(uvcb),
+               .paddr = paddr
+       };
+
+       if (uv_call(0, (u64)&uvcb))
+               return -EINVAL;
+       return 0;
+}
+
 /*
  * Requests the Ultravisor to encrypt a guest page and make it
  * accessible to the host for paging (export).
index 373542ca1113edc37b239f4e5c139a88310935c7..cfb0017f33a70444b6d8d0a636d35937489725b2 100644 (file)
@@ -2679,7 +2679,7 @@ static int __s390_reset_acc(pte_t *ptep, unsigned long addr,
        pte_t pte = READ_ONCE(*ptep);
 
        if (pte_present(pte))
-               WARN_ON_ONCE(uv_convert_from_secure(pte_val(pte) & PAGE_MASK));
+               WARN_ON_ONCE(uv_destroy_page(pte_val(pte) & PAGE_MASK));
        return 0;
 }