From patchwork Tue May 17 14:46:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 9113751 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B81449F37F for ; Tue, 17 May 2016 15:17:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E354D20218 for ; Tue, 17 May 2016 15:17:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D50C6201BB for ; Tue, 17 May 2016 15:17:22 +0000 (UTC) Received: from localhost ([::1]:51048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2gkL-0006zM-Tj for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 May 2016 11:17:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2gGc-0006j6-Lq for qemu-devel@nongnu.org; Tue, 17 May 2016 10:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2gGT-00079K-Hq for qemu-devel@nongnu.org; Tue, 17 May 2016 10:46:37 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:37245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2gGT-00078i-7B for qemu-devel@nongnu.org; Tue, 17 May 2016 10:46:29 -0400 Received: from localhost by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 May 2016 15:46:27 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 May 2016 15:46:26 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: cornelia.huck@de.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id E05FD1B0804B for ; Tue, 17 May 2016 15:47:21 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u4HEkPqU1638770 for ; Tue, 17 May 2016 14:46:25 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u4HEkPvY026703 for ; Tue, 17 May 2016 08:46:25 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-125.boeblingen.de.ibm.com [9.152.224.125]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u4HEkM4u026518 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO); Tue, 17 May 2016 08:46:24 -0600 From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 17 May 2016 16:46:04 +0200 Message-Id: <1463496377-9729-8-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1463496377-9729-1-git-send-email-cornelia.huck@de.ibm.com> References: <1463496377-9729-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16051714-0025-0000-0000-000018373B48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.112 Subject: [Qemu-devel] [PULL 07/20] pc-bios/s390-ccw: Get device address via diag 308/6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Yarygin , agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alexander Yarygin To IPL from a device, pc-bios receives from qemu a device address via general register 7. The better way to do it is to use diag308/6 instruction which returns so called "IplParameterBlock". IplParameterBlock contains the device address for IPL and additional parameters that can be used by pc-bios. This patch allows pc-bios to get device address via diag308/6 and doesn't use gr7 passed boot information anymore. Signed-off-by: Alexander Yarygin Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/iplb.h | 79 +++++++++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 25 ++++++++------ pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/start.S | 2 -- 4 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 pc-bios/s390-ccw/iplb.h diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h new file mode 100644 index 0000000..1cf509f --- /dev/null +++ b/pc-bios/s390-ccw/iplb.h @@ -0,0 +1,79 @@ +/* + * QEMU S390 IPL Block + * + * Copyright 2015 IBM Corp. + * Author(s): Alexander Yarygin + * + * 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 IPLB_H +#define IPLB_H + +struct IplBlockCcw { + uint8_t reserved0[85]; + uint8_t ssid; + uint16_t devno; + uint8_t vm_flags; + uint8_t reserved3[3]; + uint32_t vm_parm_len; + uint8_t nss_name[8]; + uint8_t vm_parm[64]; + uint8_t reserved4[8]; +} __attribute__ ((packed)); +typedef struct IplBlockCcw IplBlockCcw; + +struct IplBlockFcp { + uint8_t reserved1[305 - 1]; + uint8_t opt; + uint8_t reserved2[3]; + uint16_t reserved3; + uint16_t devno; + uint8_t reserved4[4]; + uint64_t wwpn; + uint64_t lun; + uint32_t bootprog; + uint8_t reserved5[12]; + uint64_t br_lba; + uint32_t scp_data_len; + uint8_t reserved6[260]; + uint8_t scp_data[]; +} __attribute__ ((packed)); +typedef struct IplBlockFcp IplBlockFcp; + +struct IplParameterBlock { + uint32_t len; + uint8_t reserved0[3]; + uint8_t version; + uint32_t blk0_len; + uint8_t pbt; + uint8_t flags; + uint16_t reserved01; + uint8_t loadparm[8]; + union { + IplBlockCcw ccw; + IplBlockFcp fcp; + }; +} __attribute__ ((packed)); +typedef struct IplParameterBlock IplParameterBlock; + +extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); + +#define S390_IPL_TYPE_FCP 0x00 +#define S390_IPL_TYPE_CCW 0x02 + +static inline bool store_iplb(IplParameterBlock *iplb) +{ + register unsigned long addr asm("0") = (unsigned long) iplb; + register unsigned long rc asm("1") = 0; + + asm volatile ("diag %0,%2,0x308\n" + : "+d" (addr), "+d" (rc) + : "d" (6) + : "memory", "cc"); + return rc == 0x01; +} + +#endif /* IPLB_H */ diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 1c9e079..9446ecc 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -12,8 +12,8 @@ #include "virtio.h" char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); -uint64_t boot_value; static SubChannelId blk_schid = { .one = 1 }; +IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); /* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that @@ -61,7 +61,7 @@ static bool find_dev(Schib *schib, int dev_no) return false; } -static void virtio_setup(uint64_t dev_info) +static void virtio_setup(void) { Schib schib; int ssid; @@ -75,12 +75,18 @@ static void virtio_setup(uint64_t dev_info) */ enable_mss_facility(); - if (dev_info != -1) { - dev_no = dev_info & 0xffff; - debug_print_int("device no. ", dev_no); - blk_schid.ssid = (dev_info >> 16) & 0x3; - debug_print_int("ssid ", blk_schid.ssid); - found = find_dev(&schib, dev_no); + if (store_iplb(&iplb)) { + switch (iplb.pbt) { + case S390_IPL_TYPE_CCW: + dev_no = iplb.ccw.devno; + debug_print_int("device no. ", dev_no); + blk_schid.ssid = iplb.ccw.ssid & 0x3; + debug_print_int("ssid ", blk_schid.ssid); + found = find_dev(&schib, dev_no); + break; + default: + panic("List-directed IPL not supported yet!\n"); + } } else { for (ssid = 0; ssid < 0x3; ssid++) { blk_schid.ssid = ssid; @@ -101,8 +107,7 @@ static void virtio_setup(uint64_t dev_info) int main(void) { sclp_setup(); - debug_print_int("boot reg[7] ", boot_value); - virtio_setup(boot_value); + virtio_setup(); zipl_load(); /* no return */ diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 616d967..ded67bc 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -44,6 +44,7 @@ typedef unsigned long long __u64; #endif #include "cio.h" +#include "iplb.h" typedef struct irb Irb; typedef struct ccw1 Ccw1; @@ -61,7 +62,6 @@ void consume_sclp_int(void); void panic(const char *string); void write_subsystem_identification(void); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); -extern uint64_t boot_value; /* sclp-ascii.c */ void sclp_print(const char *string); diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S index b6dd8c2..43f9bd2 100644 --- a/pc-bios/s390-ccw/start.S +++ b/pc-bios/s390-ccw/start.S @@ -14,8 +14,6 @@ _start: larl %r15, stack + 0x8000 /* Set up stack */ -larl %r6, boot_value -stg %r7, 0(%r6) /* save the boot_value before any function calls */ j main /* And call C */ /*