Skip to content

Commit

Permalink
s390/uv: add destroy page call
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Janosch Frank authored and Vasily Gorbik committed Sep 14, 2020
1 parent e670e64 commit 1a80b54
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions arch/s390/include/asm/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions arch/s390/kernel/uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/mm/gmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1a80b54

Please sign in to comment.