All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Janosch Frank <frankja@linux.ibm.com>, qemu-devel@nongnu.org
Cc: borntraeger@de.ibm.com, qemu-s390x@nongnu.org, cohuck@redhat.com
Subject: Re: [PATCH v8] s390x: protvirt: SCLP interpretation
Date: Tue, 10 Mar 2020 10:01:35 +0100	[thread overview]
Message-ID: <3378680f-3dd0-1a82-68aa-c47854e2fe02@redhat.com> (raw)
In-Reply-To: <20200310084245.30954-1-frankja@linux.ibm.com>

On 10.03.20 09:42, Janosch Frank wrote:
> SCLP for a protected guest is done over the SIDAD, so we need to use
> the s390_cpu_pv_mem_* functions to access the SIDAD instead of guest
> memory when reading/writing SCBs.
> 
> To not confuse the sclp emulation, we set 0x4000 as the SCCB address,
> since the function that injects the sclp external interrupt would
> reject a zero sccb address.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  hw/s390x/sclp.c         | 30 ++++++++++++++++++++++++++++++
>  include/hw/s390x/sclp.h |  2 ++
>  target/s390x/kvm.c      | 24 +++++++++++++++++++-----
>  3 files changed, 51 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index af0bfbc2ec..15dd15099c 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -193,6 +193,36 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
>      }
>  }
>  
> +/*
> +* We only need the address to have something valid for the
> +* service_interrupt call.
> +*/
> +#define SCLP_PV_DUMMY_ADDR 0x4000
> +int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
> +                                uint32_t code)
> +{
> +    SCLPDevice *sclp = get_sclp_device();
> +    SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
> +    SCCB work_sccb;
> +    hwaddr sccb_len = sizeof(SCCB);
> +
> +    /*
> +     * Only a very limited amount of calls is permitted by the
> +     * Ultravisor and we support all of them, so we don't check for
> +     * them. All other specification exceptions are also interpreted
> +     * by the Ultravisor and hence never cause an exit we need to
> +     * handle.
> +     *
> +     * Setting the CC is also done by the Ultravisor.
> +     */
> +    s390_cpu_pv_mem_read(env_archcpu(env), 0, &work_sccb, sccb_len);
> +    sclp_c->execute(sclp, &work_sccb, code);
> +    s390_cpu_pv_mem_write(env_archcpu(env), 0, &work_sccb,
> +                          be16_to_cpu(work_sccb.h.length));
> +    sclp_c->service_interrupt(sclp, SCLP_PV_DUMMY_ADDR);
> +    return 0;
> +}
> +
>  int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
>  {
>      SCLPDevice *sclp = get_sclp_device();
> diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
> index c54413b78c..c0a3faa37d 100644
> --- a/include/hw/s390x/sclp.h
> +++ b/include/hw/s390x/sclp.h
> @@ -217,5 +217,7 @@ void s390_sclp_init(void);
>  void sclp_service_interrupt(uint32_t sccb);
>  void raise_irq_cpu_hotplug(void);
>  int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code);
> +int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
> +                                uint32_t code);
>  
>  #endif
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index 295ed12a38..78e1b34ad5 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -1226,12 +1226,26 @@ static void kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
>      sccb = env->regs[ipbh0 & 0xf];
>      code = env->regs[(ipbh0 & 0xf0) >> 4];
>  
> -    r = sclp_service_call(env, sccb, code);
> -    if (r < 0) {
> -        kvm_s390_program_interrupt(cpu, -r);
> -        return;
> +    switch (run->s390_sieic.icptcode) {
> +    case ICPT_PV_INSTR_NOTIFICATION:
> +        g_assert(env->pv);
> +        /* The notification intercepts are currently handled by KVM */
> +        error_report("unexpected SCLP PV notification\n");
> +        exit(1);
> +        break;
> +    case ICPT_PV_INSTR:
> +        g_assert(env->pv);
> +        sclp_service_call_protected(env, sccb, code);
> +        break;
> +    case ICPT_INSTRUCTION:
> +        g_assert(!env->pv);
> +        r = sclp_service_call(env, sccb, code);
> +        if (r < 0) {
> +            kvm_s390_program_interrupt(cpu, -r);
> +            return;
> +        }
> +        setcc(cpu, r);
>      }
> -    setcc(cpu, r);
>  }
>  
>  static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2020-03-10  9:03 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 11:21 [PATCH v7 00/15] s390x: Protected Virtualization support Janosch Frank
2020-03-09 11:21 ` [PATCH v7 01/15] Sync pv Janosch Frank
2020-03-09 11:21 ` [PATCH v7 02/15] s390x: protvirt: Support unpack facility Janosch Frank
2020-03-09 13:37   ` David Hildenbrand
2020-03-09 14:40     ` Christian Borntraeger
2020-03-09 14:42       ` David Hildenbrand
2020-03-10  9:27       ` Christian Borntraeger
2020-03-09 15:42     ` Janosch Frank
2020-03-09 15:48       ` David Hildenbrand
2020-03-10  8:32     ` [PATCH v8 1/2] s390x: ipl: Consolidate iplb validity check into one function Janosch Frank
2020-03-10  8:32       ` [PATCH v8 2/2] s390x: protvirt: Support unpack facility Janosch Frank
2020-03-10  9:00         ` David Hildenbrand
2020-03-10  9:23           ` Janosch Frank
2020-03-10  9:28             ` David Hildenbrand
2020-03-10  9:24           ` Christian Borntraeger
2020-03-10  8:40       ` [PATCH v8 1/2] s390x: ipl: Consolidate iplb validity check into one function David Hildenbrand
2020-03-10  9:05       ` Christian Borntraeger
2020-03-10  9:09         ` [PATCH v8] " Janosch Frank
2020-03-10  9:11           ` Christian Borntraeger
2020-03-10  9:20             ` David Hildenbrand
2020-03-10  9:21           ` Christian Borntraeger
2020-03-09 14:28   ` [PATCH v7 02/15] s390x: protvirt: Support unpack facility Viktor Mihajlovski
2020-03-09 14:46     ` Janosch Frank
2020-03-09 11:21 ` [PATCH v7 03/15] s390x: protvirt: Add migration blocker Janosch Frank
2020-03-09 13:41   ` David Hildenbrand
2020-03-09 13:51     ` Janosch Frank
2020-03-09 14:15       ` David Hildenbrand
2020-03-09 11:21 ` [PATCH v7 04/15] s390x: protvirt: Inhibit balloon when switching to protected mode Janosch Frank
2020-03-09 13:42   ` David Hildenbrand
2020-03-09 14:00     ` Janosch Frank
2020-03-09 11:21 ` [PATCH v7 05/15] s390x: protvirt: KVM intercept changes Janosch Frank
2020-03-09 11:21 ` [PATCH v7 06/15] s390x: Add SIDA memory ops Janosch Frank
2020-03-09 11:21 ` [PATCH v7 07/15] s390x: protvirt: Move STSI data over SIDAD Janosch Frank
2020-03-09 11:21 ` [PATCH v7 08/15] s390x: protvirt: SCLP interpretation Janosch Frank
2020-03-09 15:27   ` David Hildenbrand
2020-03-09 16:05     ` Janosch Frank
2020-03-10  8:42     ` [PATCH v8] " Janosch Frank
2020-03-10  9:01       ` David Hildenbrand [this message]
2020-03-09 11:22 ` [PATCH v7 09/15] s390x: protvirt: Set guest IPL PSW Janosch Frank
2020-03-09 11:22 ` [PATCH v7 10/15] s390x: protvirt: Move diag 308 data over SIDA Janosch Frank
2020-03-09 11:22 ` [PATCH v7 11/15] s390x: protvirt: Disable address checks for PV guest IO emulation Janosch Frank
2020-03-09 11:22 ` [PATCH v7 12/15] s390x: protvirt: Move IO control structures over SIDA Janosch Frank
2020-03-09 11:22 ` [PATCH v7 13/15] s390x: protvirt: Handle SIGP store status correctly Janosch Frank
2020-03-09 11:22 ` [PATCH v7 14/15] docs: Add protvirt docs Janosch Frank
2020-03-09 11:22 ` [PATCH v7 15/15] s390x: Add unpack facility feature to GA1 Janosch Frank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3378680f-3dd0-1a82-68aa-c47854e2fe02@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.