[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/15] s390x: protvirt: Add diag308 subcodes 8 - 10
From: |
Cornelia Huck |
Subject: |
Re: [PATCH 03/15] s390x: protvirt: Add diag308 subcodes 8 - 10 |
Date: |
Thu, 21 Nov 2019 13:47:30 +0100 |
On Wed, 20 Nov 2019 06:43:22 -0500
Janosch Frank <address@hidden> wrote:
> For diag308 subcodes 8 - 10 we have a new ipib of type 5. The ipib
> holds the address and length of the secure execution header, as well
> as a list of guest components.
>
> Each component is a block of memory, for example kernel or initrd,
> which needs to be decrypted by the Ultravisor in order to run a
> protected VM. The secure execution header instructs the Ultravisor on
> how to handle the protected VM and its components.
>
> Subcodes 8 and 9 are similiar to 5 and 6 and subcode 10 will finally
> start the protected guest.
>
> Subcodes 8-10 are not valid in protected mode, we have to do a subcode
> 3 and then the 8 and 10 combination for a protected reboot.
>
> Signed-off-by: Janosch Frank <address@hidden>
> ---
> hw/s390x/ipl.c | 48 ++++++++++++++++++++++++++++++++++++++++++---
> hw/s390x/ipl.h | 33 +++++++++++++++++++++++++++++++
> target/s390x/diag.c | 26 ++++++++++++++++++++++--
> 3 files changed, 102 insertions(+), 5 deletions(-)
>
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index ca544d64c5..a077926f36 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -529,15 +529,56 @@ static bool is_virtio_scsi_device(IplParameterBlock
> *iplb)
> return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_SCSI);
> }
>
> +int s390_ipl_pv_check_comp(IplParameterBlock *iplb)
s390_ipl_pv_check_components() ?
> +{
> + int i;
> + IPLBlockPV *ipib_pv = &iplb->pv;
> +
> + if (ipib_pv->num_comp == 0) {
> + return -EINVAL;
> + }
> +
> + for (i = 0; i < ipib_pv->num_comp; i++) {
> +
> + /* Addr must be 4k aligned */
> + if (ipib_pv->components[i].addr & ~TARGET_PAGE_MASK) {
> + return -EINVAL;
> + }
> +
> + /* Tweak prefix is monotonously increasing with each component */
> + if (i < ipib_pv->num_comp - 1 &&
> + ipib_pv->components[i].tweak_pref >
> + ipib_pv->components[i + 1].tweak_pref) {
> + return -EINVAL;
> + }
> + }
> + return 1;
> +}
> +
(...)
> @@ -185,4 +211,11 @@ static inline bool iplb_valid_fcp(IplParameterBlock
> *iplb)
> iplb->pbt == S390_IPL_TYPE_FCP;
> }
>
> +static inline bool iplb_valid_se(IplParameterBlock *iplb)
iplb_valid_pv() ?
> +{
> + return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_PV_LEN &&
> + iplb->pbt == S390_IPL_TYPE_PV;
> +}
> +
> +
> #endif
(...)
> @@ -105,6 +110,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1,
> uint64_t r3, uintptr_t ra)
> s390_ipl_reset_request(cs, S390_RESET_REIPL);
> break;
> case DIAG308_SET:
> + case DIAG308_PV_SET: /* Set SE parms */
PV parms?
('SE' makes me think of 'service element' :)
> if (diag308_parm_check(env, r1, addr, ra, false)) {
> return;
> }
> @@ -117,7 +123,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1,
> uint64_t r3, uintptr_t ra)
>
> cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len));
>
> - if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) {
> + if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb) &&
> + !(iplb_valid_se(iplb) && s390_ipl_pv_check_comp(iplb) >= 0)) {
> env->regs[r1 + 1] = DIAG_308_RC_INVALID;
> goto out;
> }
> @@ -128,10 +135,15 @@ out:
> g_free(iplb);
> return;
> case DIAG308_STORE:
> + case DIAG308_PV_STORE: /* Get SE parms */
Same here.
> if (diag308_parm_check(env, r1, addr, ra, true)) {
> return;
> }
> - iplb = s390_ipl_get_iplb();
> + if (subcode == DIAG308_PV_STORE) {
> + iplb = s390_ipl_get_iplb_secure();
> + } else {
> + iplb = s390_ipl_get_iplb();
> + }
> if (iplb) {
> cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len));
> env->regs[r1 + 1] = DIAG_308_RC_OK;
> @@ -139,6 +151,16 @@ out:
> env->regs[r1 + 1] = DIAG_308_RC_NO_CONF;
> }
> return;
> + break;
> + case DIAG308_PV_START: /* SE start */
Also here :)
> + iplb = s390_ipl_get_iplb_secure();
> + if (!iplb_valid_se(iplb)) {
> + env->regs[r1 + 1] = DIAG_308_RC_NO_PV_CONF;
> + return;
> + }
> +
> + s390_ipl_reset_request(cs, S390_RESET_PV);
> + break;
> default:
> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
> break;
Did not spot anything else.
- Re: [PATCH 04/15] Header sync protvirt, (continued)
[PATCH 01/15] s390x: Cleanup cpu resets, Janosch Frank, 2019/11/20
Re: [PATCH 01/15] s390x: Cleanup cpu resets, Thomas Huth, 2019/11/21
[PATCH 03/15] s390x: protvirt: Add diag308 subcodes 8 - 10, Janosch Frank, 2019/11/20
[PATCH 05/15] s390x: protvirt: Sync PV state, Janosch Frank, 2019/11/20
[PATCH 08/15] s390x: protvirt: KVM intercept changes, Janosch Frank, 2019/11/20