All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason J. Herne" <jjherne@linux.ibm.com>
To: Eric Farman <farman@linux.ibm.com>
Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
	pasic@linux.ibm.com, alifm@linux.ibm.com, borntraeger@de.ibm.com
Subject: Re: [Qemu-devel] [qemu-s390x] [PATCH 15/15] s390-bios: Support booting from real dasd device
Date: Thu, 21 Feb 2019 08:22:42 -0500	[thread overview]
Message-ID: <28ce4238-43d0-502b-55c9-bc34cb9b69aa@linux.ibm.com> (raw)
In-Reply-To: <95cb3df5-89cb-0d28-5fb7-2cea5d139484@linux.ibm.com>

On 2/20/19 9:52 PM, Eric Farman wrote:
> 
> 
> On 01/29/2019 08:29 AM, Jason J. Herne wrote:
>> Allows guest to boot from a vfio configured real dasd device.
>>
>> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
>> ---
>>   docs/devel/s390-dasd-ipl.txt | 132 +++++++++++++++++++++++
>>   pc-bios/s390-ccw/Makefile    |   2 +-
>>   pc-bios/s390-ccw/dasd-ipl.c  | 249 +++++++++++++++++++++++++++++++++++++++++++
>>   pc-bios/s390-ccw/dasd-ipl.h  |  16 +++
>>   pc-bios/s390-ccw/main.c      |   4 +
>>   pc-bios/s390-ccw/s390-arch.h |  13 +++
>>   6 files changed, 415 insertions(+), 1 deletion(-)
>>   create mode 100644 docs/devel/s390-dasd-ipl.txt
>>   create mode 100644 pc-bios/s390-ccw/dasd-ipl.c
>>   create mode 100644 pc-bios/s390-ccw/dasd-ipl.h
> 
> ...snip...
> 
>> diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
>> new file mode 100644
>> index 0000000..b7ce6d9
>> --- /dev/null
>> +++ b/pc-bios/s390-ccw/dasd-ipl.c
>> @@ -0,0 +1,249 @@
> 
> ...snip...
> 
>> +static void ipl1_fixup(void)
>> +{
>> +    Ccw0 *ccwSeek = (Ccw0 *) 0x08;
>> +    Ccw0 *ccwSearchID = (Ccw0 *) 0x10;
>> +    Ccw0 *ccwSearchTic = (Ccw0 *) 0x18;
>> +    Ccw0 *ccwRead = (Ccw0 *) 0x20;
>> +    CcwSeekData *seekData = (CcwSeekData *) 0x30;
>> +    CcwSearchIdData *searchData = (CcwSearchIdData *) 0x38;
>> +
>> +    /* move IPL1 CCWs to make room for CCWs needed to locate record 2 */
>> +    memcpy(ccwRead, (void *)0x08, 16);
>> +
>> +    /* Disable chaining so we don't TIC to IPL2 channel program */
>> +    ccwRead->chain = 0x00;
>> +
>> +    ccwSeek->cmd_code = CCW_CMD_DASD_SEEK;
>> +    ccwSeek->cda = ptr2u32(seekData);
>> +    ccwSeek->chain = 1;
>> +    ccwSeek->count = sizeof(seekData);
> 
> This needs to be sizeof(*seekData)
> 

Good catch! Thanks. C can be such a pain sometimes. It should do what I WANT... not what I 
SAY :-).

>> +    seekData->reserved = 0x00;
>> +    seekData->cyl = 0x00;
>> +    seekData->head = 0x00;
>> +
>> +    ccwSearchID->cmd_code = CCW_CMD_DASD_SEARCH_ID_EQ;
>> +    ccwSearchID->cda = ptr2u32(searchData);
>> +    ccwSearchID->chain = 1;
>> +    ccwSearchID->count = sizeof(searchData);
> 
> sizeof(*searchData)
> 
> I notice that vfio sees the count for each of these as 8 bytes despite them being packed 
> structs of 6 or 5 bytes.
> 
>> +    searchData->cyl = 0;
>> +    searchData->head = 0;
>> +    searchData->record = 2;
>> +
>> +    /* Go back to Search CCW if correct record not yet found */
>> +    ccwSearchTic->cmd_code = CCW_CMD_TIC;
>> +    ccwSearchTic->cda = ptr2u32(ccwSearchID);
>> +}
>> +
>> +static void run_ipl1(SubChannelId schid)
>> + {
>> +    uint32_t startAddr = 0x08;
>> +
>> +    if (do_cio(schid, startAddr, CCW_FMT0)) {
>> +        panic("dasd-ipl: Failed to run IPL1 channel program");
>> +    }
>> +}
>> +
>> +static void run_ipl2(SubChannelId schid, uint32_t addr)
>> +{
>> +
>> +    if (run_dynamic_ccw_program(schid, addr)) {
>> +        panic("dasd-ipl: Failed to run IPL2 channel program");
>> +    }
>> +}
>> +
>> +static void lpsw(void *psw_addr)
>> +{
>> +    PSWLegacy *pswl = (PSWLegacy *) psw_addr;
>> +
>> +    pswl->mask |= PSW_MASK_EAMODE;   /* Force z-mode */
>> +    pswl->addr |= PSW_MASK_BAMODE;
>> +    asm volatile("  llgtr 0,0\n llgtr 1,1\n"     /* Some OS's expect to be */
>> +                 "  llgtr 2,2\n llgtr 3,3\n"     /* in 32-bit mode. Clear  */
>> +                 "  llgtr 4,4\n llgtr 5,5\n"     /* high part of regs to   */
>> +                 "  llgtr 6,6\n llgtr 7,7\n"     /* avoid messing up       */
>> +                 "  llgtr 8,8\n llgtr 9,9\n"     /* instructions that work */
>> +                 "  llgtr 10,10\n llgtr 11,11\n" /* in both addressing     */
>> +                 "  llgtr 12,12\n llgtr 13,13\n" /* modes, like servc.     */
>> +                 "  llgtr 14,14\n llgtr 15,15\n"
>> +                 "  lpsw %0\n"
>> +                 : : "Q" (*pswl) : "cc");
>> +}
>> +
>> +/*
>> + * Limitations in QEMU's CCW support complicate the IPL process. Details can
>> + * be found in docs/devel/s390-dasd-ipl.txt
>> + */
>> +void dasd_ipl(SubChannelId schid)
>> +{
>> +    uint32_t ipl2_addr;
>> +
>> +    /* Construct Read IPL CCW and run it to read IPL1 from boot disk */
>> +    make_readipl();
>> +    run_readipl(schid);
>> +    ipl2_addr = read_ipl2_addr();
>> +    check_ipl1();
>> +
>> +    /*
>> +     * Fixup IPL1 channel program to account for QEMU limitations, then run it
>> +     * to read IPL2 channel program from boot disk.
>> +     */
>> +    ipl1_fixup();
>> +    run_ipl1(schid);
>> +    check_ipl2(ipl2_addr);
>> +
>> +    /*
>> +     * Run IPL2 channel program to read operating system code from boot disk
>> +     * then transfer control to the guest operating system
>> +     */
>> +    run_ipl2(schid, ipl2_addr);
>> +    lpsw(0);
>> +}
>> diff --git a/pc-bios/s390-ccw/dasd-ipl.h b/pc-bios/s390-ccw/dasd-ipl.h
>> new file mode 100644
>> index 0000000..56bba82
>> --- /dev/null
>> +++ b/pc-bios/s390-ccw/dasd-ipl.h
>> @@ -0,0 +1,16 @@
>> +/*
>> + * S390 IPL (boot) from a real DASD device via vfio framework.
>> + *
>> + * Copyright (c) 2018 Jason J. Herne <jjherne@us.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2 or (at
>> + * your option) any later version. See the COPYING file in the top-level
>> + * directory.
>> + */
>> +
>> +#ifndef DASD_IPL_H
>> +#define DASD_IPL_H
>> +
>> +void dasd_ipl(SubChannelId schid);
>> +
>> +#endif /* DASD_IPL_H */
>> diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
>> index 5ee02c3..0a46339 100644
>> --- a/pc-bios/s390-ccw/main.c
>> +++ b/pc-bios/s390-ccw/main.c
>> @@ -13,6 +13,7 @@
>>   #include "s390-ccw.h"
>>   #include "cio.h"
>>   #include "virtio.h"
>> +#include "dasd-ipl.h"
>>   char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
>>   static SubChannelId blk_schid = { .one = 1 };
>> @@ -210,6 +211,9 @@ int main(void)
>>       cutype = cu_type(blk_schid) ;
>>       switch (cutype) {
>> +    case CU_TYPE_DASD_3990:
>> +        dasd_ipl(blk_schid); /* no return */
>> +        break;
>>       case CU_TYPE_VIRTIO:
>>           virtio_setup();
>>           zipl_load(); /* no return */
>> diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
>> index 47eaa04..0438d42 100644
>> --- a/pc-bios/s390-ccw/s390-arch.h
>> +++ b/pc-bios/s390-ccw/s390-arch.h
>> @@ -97,4 +97,17 @@ typedef struct LowCore {
>>   extern const LowCore *lowcore;
>> +static inline void set_prefix(uint32_t address)
>> +{
>> +    asm volatile("spx %0" : : "m" (address) : "memory");
>> +}
>> +
>> +static inline uint32_t store_prefix(void)
>> +{
>> +    uint32_t address;
>> +
>> +    asm volatile("stpx %0" : "=m" (address));
>> +    return address;
>> +}
>> +
>>   #endif
>>
> 


-- 
-- Jason J. Herne (jjherne@linux.ibm.com)


  reply	other threads:[~2019-02-21 13:23 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 13:29 [Qemu-devel] [PATCH 00/15] s390: vfio-ccw dasd ipl support Jason J. Herne
2019-01-29 13:29 ` [Qemu-devel] [PATCH 01/15] s390 vfio-ccw: Add bootindex property and IPLB data Jason J. Herne
2019-01-30 16:56   ` Cornelia Huck
2019-01-30 20:12     ` Jason J. Herne
2019-01-30 22:21   ` Farhan Ali
2019-02-08 16:07     ` Jason J. Herne
2019-01-31 18:20   ` Cornelia Huck
2019-02-04 10:26   ` Cornelia Huck
2019-02-13 13:41     ` Jason J. Herne
2019-02-13 14:52       ` Cornelia Huck
2019-02-06 11:30   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-02-08 16:04     ` Jason J. Herne
2019-02-11  8:15       ` Cornelia Huck
2019-02-11  8:39       ` Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 02/15] s390-bios: decouple cio setup from virtio Jason J. Herne
2019-01-30 22:23   ` Farhan Ali
2019-02-04 10:28   ` Cornelia Huck
2019-02-05  9:55   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 03/15] s390-bios: decouple common boot logic " Jason J. Herne
2019-01-30 22:27   ` Farhan Ali
2019-02-04 10:31   ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 04/15] s390-bios: Extend find_dev() for non-virtio devices Jason J. Herne
2019-02-04 10:33   ` Cornelia Huck
2019-02-11 16:38   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-02-13 13:59     ` Jason J. Herne
2019-03-04 19:23       ` Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 05/15] s390-bios: Factor finding boot device out of virtio code path Jason J. Herne
2019-01-31 13:44   ` Farhan Ali
2019-02-04 10:45   ` Cornelia Huck
2019-02-11 17:57     ` Jason J. Herne
2019-02-12  9:32       ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 06/15] s390-bios: Clean up cio.h Jason J. Herne
2019-01-31 14:23   ` Farhan Ali
2019-02-04 10:48   ` Cornelia Huck
2019-02-12 12:32     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 07/15] s390-bios: Decouple channel i/o logic from virtio Jason J. Herne
2019-01-31 14:38   ` Farhan Ali
2019-01-31 14:45     ` Jason J. Herne
2019-02-04 10:57   ` Cornelia Huck
2019-02-13 14:40     ` Jason J. Herne
2019-01-29 13:29 ` [Qemu-devel] [PATCH 08/15] s390-bios: Map low core memory Jason J. Herne
2019-02-12 12:47   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-02-18 15:40     ` Jason J. Herne
2019-02-18 15:49       ` Cornelia Huck
2019-02-18 16:52       ` Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 09/15] s390-bios: ptr2u32 and u32toptr Jason J. Herne
2019-02-04 11:03   ` Cornelia Huck
2019-02-12 12:50   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-01-29 13:29 ` [Qemu-devel] [PATCH 10/15] s390-bios: Support for running format-0/1 channel programs Jason J. Herne
2019-01-31 17:31   ` Farhan Ali
2019-02-04 11:13     ` Cornelia Huck
2019-02-04 19:29       ` Farhan Ali
2019-02-05 10:18         ` Cornelia Huck
2019-02-12 13:10           ` Halil Pasic
2019-02-27 13:35           ` Jason J. Herne
2019-02-27 14:07             ` Cornelia Huck
2019-02-27 13:32       ` Jason J. Herne
2019-02-27 14:06         ` Cornelia Huck
2019-02-04 11:24   ` Cornelia Huck
2019-02-21 18:01     ` Jason J. Herne
2019-02-22  8:35       ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 11/15] s390-bios: cio error handling Jason J. Herne
2019-02-04 11:41   ` Cornelia Huck
2019-02-28 15:59     ` Jason J. Herne
2019-02-28 16:11       ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 12/15] s390-bios: Refactor virtio to run channel programs via cio Jason J. Herne
2019-02-04 11:44   ` Cornelia Huck
2019-02-25 13:20     ` Jason J. Herne
2019-02-25 17:07       ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 13/15] s390-bios: Use control unit type to determine boot method Jason J. Herne
2019-02-04 11:46   ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 14/15] s390-bios: Add channel command codes/structs needed for dasd-ipl Jason J. Herne
2019-02-04 11:47   ` Cornelia Huck
2019-01-29 13:29 ` [Qemu-devel] [PATCH 15/15] s390-bios: Support booting from real dasd device Jason J. Herne
2019-01-31 18:23   ` Cornelia Huck
2019-02-04 12:02   ` Cornelia Huck
2019-02-19 14:57     ` Jason J. Herne
2019-02-21  2:52   ` [Qemu-devel] [qemu-s390x] " Eric Farman
2019-02-21 13:22     ` Jason J. Herne [this message]
2019-01-29 16:40 ` [Qemu-devel] [qemu-s390x] [PATCH 00/15] s390: vfio-ccw dasd ipl support Jason J. Herne
2019-01-31 18:10 ` [Qemu-devel] " no-reply

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=28ce4238-43d0-502b-55c9-bc34cb9b69aa@linux.ibm.com \
    --to=jjherne@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=pasic@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.