[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/15] s390x: protvirt: Support unpack facility
From: |
Cornelia Huck |
Subject: |
Re: [PATCH 06/15] s390x: protvirt: Support unpack facility |
Date: |
Wed, 20 Nov 2019 14:43:27 +0100 |
On Wed, 20 Nov 2019 06:43:25 -0500
Janosch Frank <address@hidden> wrote:
> When a guest has saved a ipib of type 5 and call diagnose308 with
> subcode 10, we have to setup the protected processing environment via
> Ultravisor calls. The calls are done by KVM and are exposed via an API.
>
> The following steps are necessary:
> 1. Create a VM (register it with the Ultravisor)
> 2. Create secure CPUs for all of our current cpus
> 3. Forward the secure header to the Ultravisor (has all information on
> how to decrypt the image and VM information)
> 4. Protect image pages from the host and decrypt them
> 5. Verify the image integrity
>
> Only after step 5 a protected VM is allowed to run.
>
> Signed-off-by: Janosch Frank <address@hidden>
> ---
> hw/s390x/Makefile.objs | 1 +
> hw/s390x/ipl.c | 33 ++++++++
> hw/s390x/ipl.h | 2 +
> hw/s390x/pv.c | 118 ++++++++++++++++++++++++++++
> hw/s390x/pv.h | 26 ++++++
> hw/s390x/s390-virtio-ccw.c | 45 ++++++++---
> target/s390x/cpu_features_def.inc.h | 1 +
> 7 files changed, 216 insertions(+), 10 deletions(-)
> create mode 100644 hw/s390x/pv.c
> create mode 100644 hw/s390x/pv.h
>
> diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
> index 94e57113d8..568bab9711 100644
> --- a/hw/s390x/Makefile.objs
> +++ b/hw/s390x/Makefile.objs
> @@ -31,6 +31,7 @@ obj-y += tod-qemu.o
> obj-$(CONFIG_KVM) += tod-kvm.o
> obj-$(CONFIG_KVM) += s390-skeys-kvm.o
> obj-$(CONFIG_KVM) += s390-stattrib-kvm.o s390-mchk.o
> +obj-$(CONFIG_KVM) += pv.o
As this is kvm only...
> obj-y += s390-ccw.o
> obj-y += ap-device.o
> obj-y += ap-bridge.o
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index a077926f36..50501fcd27 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -33,6 +33,7 @@
> #include "qemu/cutils.h"
> #include "qemu/option.h"
> #include "exec/exec-all.h"
> +#include "pv.h"
>
> #define KERN_IMAGE_START 0x010000UL
> #define LINUX_MAGIC_ADDR 0x010008UL
> @@ -668,6 +669,38 @@ static void s390_ipl_prepare_qipl(S390CPU *cpu)
> cpu_physical_memory_unmap(addr, len, 1, len);
> }
>
> +int s390_ipl_prepare_pv_header(void)
> +{
> + int rc;
> + IplParameterBlock *iplb = s390_ipl_get_iplb_secure();
> + IPLBlockPV *ipib_pv = &iplb->pv;
> + void *hdr = g_malloc(ipib_pv->pv_header_len);
> +
> + cpu_physical_memory_read(ipib_pv->pv_header_addr, hdr,
> + ipib_pv->pv_header_len);
> + rc = s390_pv_set_sec_parms((uint64_t)hdr,
> + ipib_pv->pv_header_len);
> + g_free(hdr);
> + return rc;
> +}
> +
> +int s390_ipl_pv_unpack(void)
> +{
> + int i, rc;
> + IplParameterBlock *iplb = s390_ipl_get_iplb_secure();
> + IPLBlockPV *ipib_pv = &iplb->pv;
> +
> + for (i = 0; i < ipib_pv->num_comp; i++) {
> + rc = s390_pv_unpack(ipib_pv->components[i].addr,
> + TARGET_PAGE_ALIGN(ipib_pv->components[i].size),
> + ipib_pv->components[i].tweak_pref);
...you probably need a stub version of the pv functions as well, right?
> + if (rc) {
> + return rc;
> + }
> + }
> + return rc;
> +}
> +
> void s390_ipl_prepare_cpu(S390CPU *cpu)
> {
> S390IPLState *ipl = get_ipl_device();
- Re: [PATCH 05/15] s390x: protvirt: Sync PV state, (continued)
[PATCH 06/15] s390x: protvirt: Support unpack facility, Janosch Frank, 2019/11/20
Re: [PATCH 06/15] s390x: protvirt: Support unpack facility, Cornelia Huck, 2019/11/22
Re: [PATCH 06/15] s390x: protvirt: Support unpack facility, Thomas Huth, 2019/11/28