From patchwork Thu Jan 10 15:41:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D1F46C2 for ; Thu, 10 Jan 2019 15:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C34329AED for ; Thu, 10 Jan 2019 15:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 300D529B07; Thu, 10 Jan 2019 15:43:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFFFC29AED for ; Thu, 10 Jan 2019 15:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729640AbfAJPnN (ORCPT ); Thu, 10 Jan 2019 10:43:13 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43212 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729534AbfAJPnM (ORCPT ); Thu, 10 Jan 2019 10:43:12 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdrhd045475 for ; Thu, 10 Jan 2019 10:43:11 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px8m6s12y-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:10 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:08 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:06 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFh5i765929230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:05 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A2ABA4054; Thu, 10 Jan 2019 15:43:05 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9F2EA4062; Thu, 10 Jan 2019 15:43:04 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:04 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 01/11] s390x: Add Sigp header file Date: Thu, 10 Jan 2019 16:41:41 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0012-0000-0000-000002E60175 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0013-0000-0000-0000211D0840 Message-Id: <20190110154151.24233-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The magic numbers for SIGP are not nice to read, so let's put them in a new header file. Also move sigp_stop() there, it will later be joined by more sigp functions and definitions. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- lib/s390x/asm/sigp.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/s390x/io.c | 11 +--------- 2 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 lib/s390x/asm/sigp.h diff --git a/lib/s390x/asm/sigp.h b/lib/s390x/asm/sigp.h new file mode 100644 index 0000000..899a66b --- /dev/null +++ b/lib/s390x/asm/sigp.h @@ -0,0 +1,60 @@ +/* + * SIGP related definitions. + * + * Copied from the Linux kernel file arch/s390/include/asm/sigp.h + * + * This work is licensed under the terms of the GNU GPL, version + * 2. See the COPYING file in the top-level directory. + */ + +#ifndef _ASM_S390X_SIGP_H_ +#define _ASM_S390X_SIGP_H_ + +/* SIGP order codes */ +#define SIGP_SENSE 1 +#define SIGP_EXTERNAL_CALL 2 +#define SIGP_EMERGENCY_SIGNAL 3 +#define SIGP_START 4 +#define SIGP_STOP 5 +#define SIGP_RESTART 6 +#define SIGP_STOP_AND_STORE_STATUS 9 +#define SIGP_INITIAL_CPU_RESET 11 +#define SIGP_CPU_RESET 12 +#define SIGP_SET_PREFIX 13 +#define SIGP_STORE_STATUS_AT_ADDRESS 14 +#define SIGP_SET_ARCHITECTURE 18 +#define SIGP_COND_EMERGENCY_SIGNAL 19 +#define SIGP_SENSE_RUNNING 21 +#define SIGP_SET_MULTI_THREADING 22 +#define SIGP_STORE_ADDITIONAL_STATUS 23 + +/* SIGP condition codes */ +#define SIGP_CC_ORDER_CODE_ACCEPTED 0 +#define SIGP_CC_STATUS_STORED 1 +#define SIGP_CC_BUSY 2 +#define SIGP_CC_NOT_OPERATIONAL 3 + +/* SIGP cpu status bits */ + +#define SIGP_STATUS_INVALID_ORDER 0x00000002UL +#define SIGP_STATUS_CHECK_STOP 0x00000010UL +#define SIGP_STATUS_STOPPED 0x00000040UL +#define SIGP_STATUS_EXT_CALL_PENDING 0x00000080UL +#define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL +#define SIGP_STATUS_INCORRECT_STATE 0x00000200UL +#define SIGP_STATUS_NOT_RUNNING 0x00000400UL + +#ifndef __ASSEMBLER__ + +static inline void sigp_stop(void) +{ + register unsigned long status asm ("1") = 0; + register unsigned long cpu asm ("2") = 0; + + asm volatile( + " sigp %0,%1,0(%2)\n" + : "+d" (status) : "d" (cpu), "d" (SIGP_STOP) : "cc"); +} + +#endif /* __ASSEMBLER__ */ +#endif /* _ASM_S390X_SIGP_H_ */ diff --git a/lib/s390x/io.c b/lib/s390x/io.c index 7bca637..fd33623 100644 --- a/lib/s390x/io.c +++ b/lib/s390x/io.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "sclp.h" extern char ipl_args[]; @@ -30,16 +31,6 @@ void puts(const char *s) spin_unlock(&lock); } -static void sigp_stop(void) -{ - register unsigned long status asm ("1") = 0; - register unsigned long cpu asm ("2") = 0; - - asm volatile( - " sigp %0,%1,0(%2)\n" - : "+d" (status) : "d" (cpu), "d" (5) : "cc"); -} - void setup(void) { setup_args_progname(ipl_args); From patchwork Thu Jan 10 15:41:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3579F91E for ; Thu, 10 Jan 2019 15:43:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25C7C29AED for ; Thu, 10 Jan 2019 15:43:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19E0B29B06; Thu, 10 Jan 2019 15:43:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A083429AED for ; Thu, 10 Jan 2019 15:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729659AbfAJPnO (ORCPT ); Thu, 10 Jan 2019 10:43:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48098 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729534AbfAJPnO (ORCPT ); Thu, 10 Jan 2019 10:43:14 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFe4mq032535 for ; Thu, 10 Jan 2019 10:43:13 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px6mbfnk1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:12 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:10 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:08 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFh7iS44957804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:07 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CDBCA4062; Thu, 10 Jan 2019 15:43:07 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C4CBA405C; Thu, 10 Jan 2019 15:43:06 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:06 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 02/11] s390x: Rename and cleanup sclp-ascii.c Date: Thu, 10 Jan 2019 16:41:42 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0012-0000-0000-000002E60176 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0013-0000-0000-0000211D0841 Message-Id: <20190110154151.24233-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's rename to the more fitting name sclp-console.c and fix some indentation problems. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- lib/s390x/io.c | 2 +- lib/s390x/{sclp-ascii.c => sclp-console.c} | 38 +++++++++++++++--------------- lib/s390x/sclp.h | 2 +- s390x/Makefile | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) rename lib/s390x/{sclp-ascii.c => sclp-console.c} (54%) diff --git a/lib/s390x/io.c b/lib/s390x/io.c index fd33623..becadfc 100644 --- a/lib/s390x/io.c +++ b/lib/s390x/io.c @@ -35,7 +35,7 @@ void setup(void) { setup_args_progname(ipl_args); setup_facilities(); - sclp_ascii_setup(); + sclp_console_setup(); sclp_memory_setup(); } diff --git a/lib/s390x/sclp-ascii.c b/lib/s390x/sclp-console.c similarity index 54% rename from lib/s390x/sclp-ascii.c rename to lib/s390x/sclp-console.c index 893ca17..deacbde 100644 --- a/lib/s390x/sclp-ascii.c +++ b/lib/s390x/sclp-console.c @@ -35,34 +35,34 @@ int sclp_service_call(unsigned int command, void *sccb) static void sclp_set_write_mask(void) { - WriteEventMask *sccb = (void *)_sccb; + WriteEventMask *sccb = (void *)_sccb; - sccb->h.length = sizeof(WriteEventMask); - sccb->mask_length = sizeof(unsigned int); - sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->cp_receive_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->send_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII; + sccb->h.length = sizeof(WriteEventMask); + sccb->mask_length = sizeof(unsigned int); + sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII; + sccb->cp_receive_mask = SCLP_EVENT_MASK_MSG_ASCII; + sccb->send_mask = SCLP_EVENT_MASK_MSG_ASCII; + sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII; - sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb); + sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb); } -void sclp_ascii_setup(void) +void sclp_console_setup(void) { - sclp_set_write_mask(); + sclp_set_write_mask(); } void sclp_print(const char *str) { - int len = strlen(str); - WriteEventData *sccb = (void *)_sccb; + int len = strlen(str); + WriteEventData *sccb = (void *)_sccb; - sccb->h.length = sizeof(WriteEventData) + len; - sccb->h.function_code = SCLP_FC_NORMAL_WRITE; - sccb->ebh.length = sizeof(EventBufferHeader) + len; - sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; - sccb->ebh.flags = 0; - memcpy(sccb->data, str, len); + sccb->h.length = sizeof(WriteEventData) + len; + sccb->h.function_code = SCLP_FC_NORMAL_WRITE; + sccb->ebh.length = sizeof(EventBufferHeader) + len; + sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; + sccb->ebh.flags = 0; + memcpy(sccb->data, str, len); - sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); + sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); } diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 629e9e2..4c60061 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -212,7 +212,7 @@ typedef struct ReadEventData { uint32_t mask; } __attribute__((packed)) ReadEventData; -void sclp_ascii_setup(void); +void sclp_console_setup(void); void sclp_print(const char *str); extern char _sccb[]; int sclp_service_call(unsigned int command, void *sccb); diff --git a/s390x/Makefile b/s390x/Makefile index 8ba2b92..ede2961 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -38,7 +38,7 @@ cflatobjs += lib/alloc_phys.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o cflatobjs += lib/s390x/sclp.o -cflatobjs += lib/s390x/sclp-ascii.o +cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o From patchwork Thu Jan 10 15:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0324217D2 for ; Thu, 10 Jan 2019 15:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E778C29B06 for ; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBF4D29B0B; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82D9729B06 for ; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729681AbfAJPnT (ORCPT ); Thu, 10 Jan 2019 10:43:19 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35634 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729653AbfAJPnS (ORCPT ); Thu, 10 Jan 2019 10:43:18 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFgxnB177816 for ; Thu, 10 Jan 2019 10:43:17 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px7chwb9q-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:15 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:12 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:09 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFh9Yu61734920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:09 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F36CEA4064; Thu, 10 Jan 2019 15:43:08 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D3EAA4054; Thu, 10 Jan 2019 15:43:08 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:08 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 03/11] s390x: Make tests bootable from disk Date: Thu, 10 Jan 2019 16:41:43 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0008-0000-0000-000002AF02CF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0009-0000-0000-0000221B09D1 Message-Id: <20190110154151.24233-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=981 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently tests are run with the --kernel option of Qemu, which will load the ELF file and jump to the start address. When booting from disk, we need to specify a start address. This is done by setting the initial short PSW at 0x0. .text was moved to 0x11000 because the bootloader can write from 0x10480 until 0x11000 if it has a lot to write. 0x10480 to 0x10600 was not enough safe space. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand --- s390x/cstart64.S | 8 +++++++- s390x/flat.lds | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/s390x/cstart64.S b/s390x/cstart64.S index dc7ddd6..385915e 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -14,7 +14,13 @@ .section .init -/* entry point - for KVM + TCG we directly start in 64 bit mode */ +/* + * Short init between 0x10000 and 0x10480 and then jump to 0x11000. + * 0x10480 - 0x11000 are written to by bootloader. + * + * For KVM and TCG kernel boot we are in 64 bit z/Arch mode. + * When booting from disk the initial short psw is in 31 bit mode. + */ .globl start start: /* setup stack */ diff --git a/s390x/flat.lds b/s390x/flat.lds index b6e2172..977af7c 100644 --- a/s390x/flat.lds +++ b/s390x/flat.lds @@ -1,10 +1,21 @@ SECTIONS { + /* + * Initial short psw for disk boot, with 31 bit addressing for + * non z/Arch environment compatibility and the instruction + * address 0x10000 (cstart64.S .init). + */ + .lowcore : { + . = 0; + LONG(0x00080000) + LONG(0x80010000) + } + . = 0x10000; .text : { *(.init) . = 0x480; ipl_args = .; - . = 0x600; + . = 0x1000; *(.text) *(.text.*) } From patchwork Thu Jan 10 15:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF04D91E for ; Thu, 10 Jan 2019 15:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD73629AED for ; Thu, 10 Jan 2019 15:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D167E29B07; Thu, 10 Jan 2019 15:43:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 795EF29AED for ; Thu, 10 Jan 2019 15:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729677AbfAJPnS (ORCPT ); Thu, 10 Jan 2019 10:43:18 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34090 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbfAJPnS (ORCPT ); Thu, 10 Jan 2019 10:43:18 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdewC088949 for ; Thu, 10 Jan 2019 10:43:17 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px8casw08-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:17 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:14 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:11 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhAEU64618658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:10 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C72B4A405C; Thu, 10 Jan 2019 15:43:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 304DCA4054; Thu, 10 Jan 2019 15:43:10 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:10 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 04/11] s390x: Switch to z/Arch and enable 64 bit addressing mode Date: Thu, 10 Jan 2019 16:41:44 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0008-0000-0000-000002AF02D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0009-0000-0000-0000221B09D2 Message-Id: <20190110154151.24233-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP LPAR and z/VM start in esam mode depending on the hardware (CZAM facility and others affect this), so we need to switch to z/Arch and set 64 bit addressing. Under Qemu/KVM we already start out with both when being run with the Qemu --kernel argument or we lack 64 bit when booting from disk because of the initial psw specifying 31 bit for z/VM and lpar compatibility. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- s390x/cstart64.S | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s390x/cstart64.S b/s390x/cstart64.S index 385915e..6622633 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -11,6 +11,7 @@ * under the terms of the GNU Library General Public License version 2. */ #include +#include .section .init @@ -20,9 +21,19 @@ * * For KVM and TCG kernel boot we are in 64 bit z/Arch mode. * When booting from disk the initial short psw is in 31 bit mode. + * When running under LPAR or z/VM, we might start in 31 bit and esam mode. */ .globl start start: + /* Switch to z/Architecture mode and 64-bit */ + slr %r0, %r0 # Set cpuid to zero + lhi %r1, 2 # mode 2 = esame + sigp %r1, %r0, SIGP_SET_ARCHITECTURE + /* XOR all registers with themselves to clear them fully. */ + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + xgr \i,\i + .endr + sam64 # Set addressing mode to 64 bit /* setup stack */ larl %r15, stackptr /* setup initial PSW mask + control registers*/ From patchwork Thu Jan 10 15:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D2216C2 for ; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C7C729B06 for ; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40D5C29B15; Thu, 10 Jan 2019 15:43:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDAFC29B06 for ; Thu, 10 Jan 2019 15:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729653AbfAJPnU (ORCPT ); Thu, 10 Jan 2019 10:43:20 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49760 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729672AbfAJPnT (ORCPT ); Thu, 10 Jan 2019 10:43:19 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdxDW031838 for ; Thu, 10 Jan 2019 10:43:18 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px6mbfnsy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:17 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:15 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:13 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhCWY44957814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:12 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0F7AA4062; Thu, 10 Jan 2019 15:43:12 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1105FA405F; Thu, 10 Jan 2019 15:43:12 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:11 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 05/11] s390x: Add BSS clearing for non ELF boot Date: Thu, 10 Jan 2019 16:41:45 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0020-0000-0000-0000030476AD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0021-0000-0000-000021557B53 Message-Id: <20190110154151.24233-6-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When doing an IPL normal the memory will not be zeroed and hence the BSS section can have any value. We need to clear it by ourselves. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand --- s390x/cstart64.S | 22 ++++++++++++++++++++-- s390x/flat.lds | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/s390x/cstart64.S b/s390x/cstart64.S index 6622633..dedfe80 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -39,7 +39,22 @@ start: /* setup initial PSW mask + control registers*/ larl %r1, initial_psw lpswe 0(%r1) -init_psw_cont: +clear_bss_start: + larl %r2, __bss_start + larl %r3, __bss_end + slgr %r3, %r2 # Get sizeof bss + aghi %r3,-1 + srlg %r4,%r3,8 # Calc number of 256 byte chunks + ltgr %r4,%r4 + lgr %r1,%r2 + jz clear_bss_remainder # If none, clear remaining bytes +clear_bss_loop: + xc 0(256,%r1), 0(%r1) # Clear 256 byte chunks via xor + la %r1, 256(%r1) + brctg %r4, clear_bss_loop +clear_bss_remainder: + larl %r2, memsetxc + ex %r3, 0(%r2) /* setup pgm interrupt handler */ larl %r1, pgm_int_psw mvc GEN_LC_PGM_NEW_PSW(16), 0(%r1) @@ -71,6 +86,9 @@ init_psw_cont: /* call exit() */ j exit +memsetxc: + xc 0(1,%r1),0(%r1) + .macro SAVE_REGS /* save grs 0-15 */ stmg %r0, %r15, GEN_LC_SW_INT_GRS @@ -159,7 +177,7 @@ svc_int: .align 8 initial_psw: - .quad 0x0000000180000000, init_psw_cont + .quad 0x0000000180000000, clear_bss_start pgm_int_psw: .quad 0x0000000180000000, pgm_int ext_int_psw: diff --git a/s390x/flat.lds b/s390x/flat.lds index 977af7c..403d967 100644 --- a/s390x/flat.lds +++ b/s390x/flat.lds @@ -40,7 +40,9 @@ SECTIONS . = ALIGN(16); .rodata : { *(.rodata) *(.rodata.*) } . = ALIGN(16); + __bss_start = .; .bss : { *(.bss) } + __bss_end = .; . = ALIGN(64K); edata = .; . += 64K; From patchwork Thu Jan 10 15:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CE9491E for ; Thu, 10 Jan 2019 15:43:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6B129AED for ; Thu, 10 Jan 2019 15:43:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40EF829B07; Thu, 10 Jan 2019 15:43:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D27F129B06 for ; Thu, 10 Jan 2019 15:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729710AbfAJPnW (ORCPT ); Thu, 10 Jan 2019 10:43:22 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58964 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729661AbfAJPnV (ORCPT ); Thu, 10 Jan 2019 10:43:21 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdibH074337 for ; Thu, 10 Jan 2019 10:43:20 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px8ebhmc8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:20 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:18 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:15 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhEoH55836870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:14 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77BC1A4060; Thu, 10 Jan 2019 15:43:14 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD2B3A405F; Thu, 10 Jan 2019 15:43:13 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:13 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 06/11] s390x: Move common sclp data and functions to sclp.c Date: Thu, 10 Jan 2019 16:41:46 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0020-0000-0000-0000030476B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0021-0000-0000-000021557B56 Message-Id: <20190110154151.24233-7-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sclp.c will provide the common functionality in the future and the base memory detection as it is quite small. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- lib/s390x/sclp-console.c | 20 -------------------- lib/s390x/sclp.c | 20 ++++++++++++++++++++ lib/s390x/sclp.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index deacbde..bc01f41 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -13,26 +13,6 @@ #include #include "sclp.h" -char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); - -/* Perform service call. Return 0 on success, non-zero otherwise. */ -int sclp_service_call(unsigned int command, void *sccb) -{ - int cc; - - asm volatile( - " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */ - " ipm %0\n" - " srl %0,28" - : "=&d" (cc) : "d" (command), "a" (__pa(sccb)) - : "cc", "memory"); - if (cc == 3) - return -1; - if (cc == 2) - return -1; - return 0; -} - static void sclp_set_write_mask(void) { WriteEventMask *sccb = (void *)_sccb; diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index cccfdc2..7f556e5 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -23,6 +23,8 @@ static uint64_t storage_increment_size; static uint64_t max_ram_size; static uint64_t ram_size; +char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); + static void mem_init(phys_addr_t mem_end) { phys_addr_t freemem_start = (phys_addr_t)&stacktop; @@ -50,6 +52,24 @@ static void sclp_read_scp_info(ReadInfo *ri, int length) report_abort("READ_SCP_INFO failed"); } +/* Perform service call. Return 0 on success, non-zero otherwise. */ +int sclp_service_call(unsigned int command, void *sccb) +{ + int cc; + + asm volatile( + " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */ + " ipm %0\n" + " srl %0,28" + : "=&d" (cc) : "d" (command), "a" (__pa(sccb)) + : "cc", "memory"); + if (cc == 3) + return -1; + if (cc == 2) + return -1; + return 0; +} + void sclp_memory_setup(void) { ReadInfo *ri = (void *)_sccb; diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 4c60061..583c4e5 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -212,9 +212,9 @@ typedef struct ReadEventData { uint32_t mask; } __attribute__((packed)) ReadEventData; +extern char _sccb[]; void sclp_console_setup(void); void sclp_print(const char *str); -extern char _sccb[]; int sclp_service_call(unsigned int command, void *sccb); void sclp_memory_setup(void); From patchwork Thu Jan 10 15:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8BA91E for ; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AC4529B07 for ; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F336D29B10; Thu, 10 Jan 2019 15:43:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1BE29B07 for ; Thu, 10 Jan 2019 15:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729736AbfAJPn0 (ORCPT ); Thu, 10 Jan 2019 10:43:26 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40082 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729661AbfAJPnZ (ORCPT ); Thu, 10 Jan 2019 10:43:25 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFgxOq177836 for ; Thu, 10 Jan 2019 10:43:24 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px7chwbpx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:22 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:20 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:17 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhGFf6554004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:16 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5905CA4066; Thu, 10 Jan 2019 15:43:16 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8C57A405F; Thu, 10 Jan 2019 15:43:15 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:15 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 07/11] s390x: Use interrupts in SCLP and add locking Date: Thu, 10 Jan 2019 16:41:47 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0012-0000-0000-000002E6017C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0013-0000-0000-0000211D0847 Message-Id: <20190110154151.24233-8-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to properly implement interrupt handling for SCLP, because on z/VM and LPAR SCLP calls are not synchronous! Also with smp CPUs have to compete for sclp. Let's add some locking, so they execute sclp calls in an orderly fashion and don't compete for the data buffer. Signed-off-by: Janosch Frank --- lib/s390x/asm/arch_def.h | 1 + lib/s390x/asm/interrupt.h | 2 ++ lib/s390x/interrupt.c | 12 +++++++++-- lib/s390x/sclp-console.c | 2 ++ lib/s390x/sclp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++-- lib/s390x/sclp.h | 3 +++ 6 files changed, 70 insertions(+), 4 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index d2cd727..4bbb428 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -15,6 +15,7 @@ struct psw { uint64_t addr; }; +#define PSW_MASK_EXT 0x0100000000000000UL #define PSW_MASK_DAT 0x0400000000000000UL #define PSW_MASK_PSTATE 0x0001000000000000UL diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h index 013709f..f485e96 100644 --- a/lib/s390x/asm/interrupt.h +++ b/lib/s390x/asm/interrupt.h @@ -11,6 +11,8 @@ #define _ASMS390X_IRQ_H_ #include +#define EXT_IRQ_SERVICE_SIG 0x2401 + void handle_pgm_int(void); void handle_ext_int(void); void handle_mcck_int(void); diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index cf0a794..7832711 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -12,6 +12,7 @@ #include #include #include +#include static bool pgm_int_expected; static struct lowcore *lc; @@ -107,8 +108,15 @@ void handle_pgm_int(void) void handle_ext_int(void) { - report_abort("Unexpected external call interrupt: at %#lx", - lc->ext_old_psw.addr); + if (lc->ext_int_code != EXT_IRQ_SERVICE_SIG) { + report_abort("Unexpected external call interrupt: at %#lx", + lc->ext_old_psw.addr); + } else { + lc->ext_old_psw.mask &= ~PSW_MASK_EXT; + lc->sw_int_cr0 &= ~(1UL << 9); + sclp_handle_ext(); + lc->ext_int_code = 0; + } } void handle_mcck_int(void) diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index bc01f41..a5ef45f 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -17,6 +17,7 @@ static void sclp_set_write_mask(void) { WriteEventMask *sccb = (void *)_sccb; + sclp_mark_busy(); sccb->h.length = sizeof(WriteEventMask); sccb->mask_length = sizeof(unsigned int); sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII; @@ -37,6 +38,7 @@ void sclp_print(const char *str) int len = strlen(str); WriteEventData *sccb = (void *)_sccb; + sclp_mark_busy(); sccb->h.length = sizeof(WriteEventData) + len; sccb->h.function_code = SCLP_FC_NORMAL_WRITE; sccb->ebh.length = sizeof(EventBufferHeader) + len; diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 7f556e5..e14f25d 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "sclp.h" #include @@ -24,6 +26,8 @@ static uint64_t max_ram_size; static uint64_t ram_size; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); +static volatile bool sclp_busy; +static struct spinlock sclp_lock; static void mem_init(phys_addr_t mem_end) { @@ -32,17 +36,61 @@ static void mem_init(phys_addr_t mem_end) phys_alloc_init(freemem_start, mem_end - freemem_start); } +static void sclp_setup_int(void) +{ + uint64_t mask; + + ctl_set_bit(0, 9); + + mask = extract_psw_mask(); + mask |= PSW_MASK_EXT; + load_psw_mask(mask); +} + +void sclp_handle_ext(void) +{ + ctl_clear_bit(0, 9); + spin_lock(&sclp_lock); + sclp_busy = false; + spin_unlock(&sclp_lock); +} + +void sclp_wait_busy(void) +{ + while (sclp_busy) + mb(); +} + +void sclp_mark_busy(void) +{ + /* + * With multiple CPUs we might need to wait for another CPU's + * request before grabbing the busy indication. + */ +retry_wait: + sclp_wait_busy(); + spin_lock(&sclp_lock); + if (sclp_busy) { + spin_unlock(&sclp_lock); + goto retry_wait; + } + sclp_busy = true; + spin_unlock(&sclp_lock); +} + static void sclp_read_scp_info(ReadInfo *ri, int length) { unsigned int commands[] = { SCLP_CMDW_READ_SCP_INFO_FORCED, SCLP_CMDW_READ_SCP_INFO }; - int i; + int i, cc; for (i = 0; i < ARRAY_SIZE(commands); i++) { memset(&ri->h, 0, sizeof(ri->h)); ri->h.length = length; - if (sclp_service_call(commands[i], ri)) + sclp_mark_busy(); + cc = sclp_service_call(commands[i], ri); + if (cc) break; if (ri->h.response_code == SCLP_RC_NORMAL_READ_COMPLETION) return; @@ -57,12 +105,14 @@ int sclp_service_call(unsigned int command, void *sccb) { int cc; + sclp_setup_int(); asm volatile( " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */ " ipm %0\n" " srl %0,28" : "=&d" (cc) : "d" (command), "a" (__pa(sccb)) : "cc", "memory"); + sclp_wait_busy(); if (cc == 3) return -1; if (cc == 2) diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 583c4e5..63cf609 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -213,6 +213,9 @@ typedef struct ReadEventData { } __attribute__((packed)) ReadEventData; extern char _sccb[]; +void sclp_handle_ext(void); +void sclp_wait_busy(void); +void sclp_mark_busy(void); void sclp_console_setup(void); void sclp_print(const char *str); int sclp_service_call(unsigned int command, void *sccb); From patchwork Thu Jan 10 15:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D526F91E for ; Thu, 10 Jan 2019 15:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3DAB29AED for ; Thu, 10 Jan 2019 15:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B811D29B0B; Thu, 10 Jan 2019 15:43:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D989B29B07 for ; Thu, 10 Jan 2019 15:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729704AbfAJPn2 (ORCPT ); Thu, 10 Jan 2019 10:43:28 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47560 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729746AbfAJPn2 (ORCPT ); Thu, 10 Jan 2019 10:43:28 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFeEIJ172006 for ; Thu, 10 Jan 2019 10:43:26 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px5j7tb8p-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:25 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:21 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:19 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhIVQ60883032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:18 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 33485A4060; Thu, 10 Jan 2019 15:43:18 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9203BA4054; Thu, 10 Jan 2019 15:43:17 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:17 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 08/11] s390x: Add linemode console Date: Thu, 10 Jan 2019 16:41:48 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0016-0000-0000-0000024374A2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0017-0000-0000-0000329D79B9 Message-Id: <20190110154151.24233-9-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=793 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP z/VM isn't fond of vt220, so we need line mode when running under z/VM. Signed-off-by: Janosch Frank Acked-by: David Hildenbrand --- lib/s390x/sclp-console.c | 181 ++++++++++++++++++++++++++++++++++++++++++----- lib/s390x/sclp.h | 55 +++++++++++++- 2 files changed, 218 insertions(+), 18 deletions(-) diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index a5ef45f..3f97653 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -11,21 +11,165 @@ #include #include #include +#include +#include #include "sclp.h" +/* + * ASCII (IBM PC 437) -> EBCDIC 037 + */ +static uint8_t _ascebc[256] = { + /*00 NUL SOH STX ETX EOT ENQ ACK BEL */ + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, + /*08 BS HT LF VT FF CR SO SI */ + /* ->NL */ + 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + /*10 DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, + /*18 CAN EM SUB ESC FS GS RS US */ + /* ->IGS ->IRS ->IUS */ + 0x18, 0x19, 0x3F, 0x27, 0x22, 0x1D, 0x1E, 0x1F, + /*20 SP ! " # $ % & ' */ + 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, + /*28 ( ) * + , - . / */ + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, + /*30 0 1 2 3 4 5 6 7 */ + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + /*38 8 9 : ; < = > ? */ + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, + /*40 @ A B C D E F G */ + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + /*48 H I J K L M N O */ + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, + /*50 P Q R S T U V W */ + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, + /*58 X Y Z [ \ ] ^ _ */ + 0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, + /*60 ` a b c d e f g */ + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*68 h i j k l m n o */ + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + /*70 p q r s t u v w */ + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + /*78 x y z { | } ~ DL */ + 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, + /*80*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*88*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*90*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*98*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*A0*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*A8*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*B0*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*B8*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*C0*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*C8*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*D0*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*D8*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*E0 sz */ + 0x3F, 0x59, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*E8*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*F0*/ + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + /*F8*/ + 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF +}; + +static void sclp_print_ascii(const char *str) +{ + int len = strlen(str); + WriteEventData *sccb = (void *)_sccb; + + sclp_mark_busy(); + memset(sccb, 0, sizeof(*sccb)); + sccb->h.length = offsetof(WriteEventData, msg) + len; + sccb->h.function_code = SCLP_FC_NORMAL_WRITE; + sccb->ebh.length = sizeof(EventBufferHeader) + len; + sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; + memcpy(&sccb->msg, str, len); + + sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); +} + +static void sclp_print_lm(const char *str) +{ + unsigned char *ptr, *end, ch; + unsigned int count, offset, len; + struct WriteEventData *sccb; + struct mdb *mdb; + struct mto *mto; + struct go *go; + + sclp_mark_busy(); + sccb = (struct WriteEventData *) _sccb; + end = (unsigned char *) sccb + 4096 - 1; + memset(sccb, 0, sizeof(*sccb)); + ptr = (unsigned char *) &sccb->msg.mdb.mto; + len = strlen(str); + offset = 0; + do { + for (count = sizeof(*mto); offset < len; count++) { + ch = str[offset++]; + if ((ch == 0x0a) || (ptr + count > end)) + break; + ptr[count] = _ascebc[ch]; + } + mto = (struct mto *) ptr; + mto->length = count; + mto->type = 4; + mto->line_type_flags = LNTPFLGS_ENDTEXT; + ptr += count; + } while (offset < len && ptr + sizeof(*mto) <= end); + len = ptr - (unsigned char *) sccb; + sccb->h.length = len - offsetof(struct WriteEventData, h); + sccb->h.function_code = SCLP_FC_NORMAL_WRITE; + sccb->ebh.type = EVTYP_MSG; + sccb->ebh.length = len - offsetof(struct WriteEventData, ebh); + mdb = &sccb->msg.mdb; + mdb->header.type = 1; + mdb->header.tag = 0xD4C4C240; + mdb->header.revision_code = 1; + mdb->header.length = len - offsetof(struct WriteEventData, msg.mdb.header); + go = &mdb->go; + go->length = sizeof(*go); + go->type = 1; + sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); +} + +/* + * SCLP needs to be initialized by setting a send and receive mask, + * indicating which messages the control program (we) want(s) to + * send/receive. + */ static void sclp_set_write_mask(void) { WriteEventMask *sccb = (void *)_sccb; sclp_mark_busy(); + memset(_sccb, 0, sizeof(*sccb)); sccb->h.length = sizeof(WriteEventMask); - sccb->mask_length = sizeof(unsigned int); - sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->cp_receive_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->send_mask = SCLP_EVENT_MASK_MSG_ASCII; - sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII; + sccb->h.function_code = SCLP_FC_NORMAL_WRITE; + sccb->mask_length = sizeof(sccb_mask_t); + + /* For now we don't process sclp input. */ + sccb->cp_receive_mask = 0; + /* We send ASCII and line mode. */ + sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_MSG; sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb); + assert(sccb->h.response_code == SCLP_RC_NORMAL_COMPLETION); } void sclp_console_setup(void) @@ -35,16 +179,19 @@ void sclp_console_setup(void) void sclp_print(const char *str) { - int len = strlen(str); - WriteEventData *sccb = (void *)_sccb; - - sclp_mark_busy(); - sccb->h.length = sizeof(WriteEventData) + len; - sccb->h.function_code = SCLP_FC_NORMAL_WRITE; - sccb->ebh.length = sizeof(EventBufferHeader) + len; - sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; - sccb->ebh.flags = 0; - memcpy(sccb->data, str, len); - - sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); + /* + * z/VM advertises a vt220 console which is not functional: + * (response code 05F0, "not active because of the state of + * the machine"). Hence testing the masks would only work if + * we also use stsi data to distinguish z/VM. + * + * Let's rather print on all available consoles. + */ + if (strlen(str) > (1 << 11)) { + sclp_print_ascii("Warning: Printing is limited to 2KB of data."); + sclp_print_lm("Warning: Printing is limited to 2KB of data."); + return; + } + sclp_print_ascii(str); + sclp_print_lm(str); } diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 63cf609..98c482a 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -179,6 +179,7 @@ typedef struct SCCB { /* SCLP event masks */ #define SCLP_EVENT_MASK_SIGNAL_QUIESCE 0x00000008 #define SCLP_EVENT_MASK_MSG_ASCII 0x00000040 +#define SCLP_EVENT_MASK_MSG 0x40000000 #define SCLP_UNCONDITIONAL_READ 0x00 #define SCLP_SELECTIVE_READ 0x01 @@ -193,6 +194,55 @@ typedef struct WriteEventMask { uint32_t receive_mask; } __attribute__((packed)) WriteEventMask; +#define MDBTYP_GO 0x0001 +#define MDBTYP_MTO 0x0004 +#define EVTYP_MSG 0x02 +#define LNTPFLGS_CNTLTEXT 0x8000 +#define LNTPFLGS_LABELTEXT 0x4000 +#define LNTPFLGS_DATATEXT 0x2000 +#define LNTPFLGS_ENDTEXT 0x1000 +#define LNTPFLGS_PROMPTTEXT 0x0800 + +typedef uint32_t sccb_mask_t; + +/* SCLP line mode console related structures. */ + +struct mto { + u16 length; + u16 type; + u16 line_type_flags; + u8 alarm_control; + u8 _reserved[3]; +} __attribute__((packed)); + +struct go { + u16 length; + u16 type; + u32 domid; + u8 hhmmss_time[8]; + u8 th_time[3]; + u8 reserved_0; + u8 dddyyyy_date[7]; + u8 _reserved_1; + u16 general_msg_flags; + u8 _reserved_2[10]; + u8 originating_system_name[8]; + u8 job_guest_name[8]; +} __attribute__((packed)); + +struct mdb_header { + u16 length; + u16 type; + u32 tag; + u32 revision_code; +} __attribute__((packed)); + +struct mdb { + struct mdb_header header; + struct go go; + struct mto mto; +} __attribute__((packed)); + typedef struct EventBufferHeader { uint16_t length; uint8_t type; @@ -203,7 +253,10 @@ typedef struct EventBufferHeader { typedef struct WriteEventData { SCCBHeader h; EventBufferHeader ebh; - char data[0]; + union { + char data[0]; + struct mdb mdb; + } msg; } __attribute__((packed)) WriteEventData; typedef struct ReadEventData { From patchwork Thu Jan 10 15:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83A676C2 for ; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7343429B07 for ; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67D9029B0B; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17F6429B15 for ; Thu, 10 Jan 2019 15:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbfAJPn0 (ORCPT ); Thu, 10 Jan 2019 10:43:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59692 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729706AbfAJPn0 (ORCPT ); Thu, 10 Jan 2019 10:43:26 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdhU5074305 for ; Thu, 10 Jan 2019 10:43:25 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px8ebhmgg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:25 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:23 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:21 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhKkp57344170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:20 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F90AA405C; Thu, 10 Jan 2019 15:43:20 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F46FA4054; Thu, 10 Jan 2019 15:43:19 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:19 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 09/11] s390x: Add binary generation to makefile Date: Thu, 10 Jan 2019 16:41:49 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-4275-0000-0000-000002FD2868 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-4276-0000-0000-0000380B3AA4 Message-Id: <20190110154151.24233-10-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=869 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP make bin will now generate binaries that can be booted from disk or as a non ELF kernel boot. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- s390x/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index ede2961..dbef7a0 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -10,10 +10,12 @@ tests += $(TEST_DIR)/cmm.elf tests += $(TEST_DIR)/vector.elf tests += $(TEST_DIR)/gs.elf tests += $(TEST_DIR)/iep.elf +tests_binary = $(patsubst %.elf,%.bin,$(tests)) -all: directories test_cases +all: directories test_cases test_cases_binary test_cases: $(tests) +test_cases_binary: $(tests_binary) CFLAGS += -std=gnu99 CFLAGS += -ffreestanding @@ -55,8 +57,11 @@ FLATLIBS = $(libcflat) $(RM) $(@:.elf=.aux.o) @chmod a-x $@ +%.bin: %.elf + $(OBJCOPY) -O binary $< $@ + arch_clean: asm_offsets_clean - $(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/.*.d lib/s390x/.*.d + $(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d generated-files = $(asm-offsets) $(tests:.elf=.o) $(cstart.o) $(cflatobjs): $(generated-files) From patchwork Thu Jan 10 15:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 447C06C2 for ; Thu, 10 Jan 2019 15:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C9D29AED for ; Thu, 10 Jan 2019 15:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27F4A29B07; Thu, 10 Jan 2019 15:43:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0C5129AED for ; Thu, 10 Jan 2019 15:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729737AbfAJPnk (ORCPT ); Thu, 10 Jan 2019 10:43:40 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51150 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729503AbfAJPnk (ORCPT ); Thu, 10 Jan 2019 10:43:40 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFeBJY171915 for ; Thu, 10 Jan 2019 10:43:39 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2px5j7tbcb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:37 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:24 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:22 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhLWa6750590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:22 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBFA8A4066; Thu, 10 Jan 2019 15:43:21 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4586CA4060; Thu, 10 Jan 2019 15:43:21 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:21 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 10/11] s390x: Add linemode buffer to fix newline on every print Date: Thu, 10 Jan 2019 16:41:50 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-4275-0000-0000-000002FD286A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-4276-0000-0000-0000380B3AA5 Message-Id: <20190110154151.24233-11-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Linemode seems to add a newline for each sent message which makes reading rather hard. Hence we add a small buffer that and only print if it's full or a newline is encountered. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- lib/s390x/sclp-console.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index 3f97653..8e352a0 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -87,6 +87,9 @@ static uint8_t _ascebc[256] = { 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF }; +static char lm_buff[120]; +static unsigned char lm_buff_off; + static void sclp_print_ascii(const char *str) { int len = strlen(str); @@ -111,17 +114,40 @@ static void sclp_print_lm(const char *str) struct mdb *mdb; struct mto *mto; struct go *go; + char *nl; + + /* + * In contrast to the ascii console, linemode produces a new + * line with every write of data. The report() function uses + * several printf() calls to generate a line of data which + * would all end up on different lines. + * + * Hence we buffer here until we encounter a \n or the buffer + * is full. That means that linemode output can look a bit + * different from ascii and that it takes a bit longer for + * lines to appear. + */ + len = strlen(str); + len = len < (sizeof(lm_buff) - lm_buff_off) ? len : (sizeof(lm_buff) - lm_buff_off); + nl = strchr(str, '\n'); + if ((lm_buff_off < sizeof(lm_buff) - 1)) { + memcpy(&lm_buff[lm_buff_off], str, len); + lm_buff_off += len; + } + /* Buffer not full and no newline */ + if (lm_buff_off != sizeof(lm_buff) - 1 && !nl) + return; sclp_mark_busy(); sccb = (struct WriteEventData *) _sccb; end = (unsigned char *) sccb + 4096 - 1; memset(sccb, 0, sizeof(*sccb)); ptr = (unsigned char *) &sccb->msg.mdb.mto; - len = strlen(str); + len = strlen(lm_buff); offset = 0; do { for (count = sizeof(*mto); offset < len; count++) { - ch = str[offset++]; + ch = lm_buff[offset++]; if ((ch == 0x0a) || (ptr + count > end)) break; ptr[count] = _ascebc[ch]; @@ -146,6 +172,8 @@ static void sclp_print_lm(const char *str) go->length = sizeof(*go); go->type = 1; sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); + memset(lm_buff, 0 , sizeof(lm_buff)); + lm_buff_off = 0; } /* From patchwork Thu Jan 10 15:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10756099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A4EF91E for ; Thu, 10 Jan 2019 15:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A3D529B06 for ; Thu, 10 Jan 2019 15:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EB4B29B0B; Thu, 10 Jan 2019 15:43:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1072D29B06 for ; Thu, 10 Jan 2019 15:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729755AbfAJPnb (ORCPT ); Thu, 10 Jan 2019 10:43:31 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60186 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729732AbfAJPna (ORCPT ); Thu, 10 Jan 2019 10:43:30 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0AFdhX1074292 for ; Thu, 10 Jan 2019 10:43:29 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px8ebhmk1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 10:43:28 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 15:43:26 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 15:43:24 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0AFhNkb8061290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 15:43:23 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B64A1A405B; Thu, 10 Jan 2019 15:43:23 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FBEEA4054; Thu, 10 Jan 2019 15:43:23 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.145.49.69]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Jan 2019 15:43:22 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v5 11/11] s390x: Initialize the physical allocator on mem init Date: Thu, 10 Jan 2019 16:41:51 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190110154151.24233-1-frankja@linux.ibm.com> References: <20190110154151.24233-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011015-0012-0000-0000-000002E60186 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011015-0013-0000-0000-0000211D0851 Message-Id: <20190110154151.24233-12-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=782 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The physical and virtual allocators can coexist, so we can initialize the former and allocate pages without breaking VM alloc. Signed-off-by: Janosch Frank Acked-by: David Hildenbrand --- lib/s390x/sclp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index e14f25d..0e76787 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -18,6 +18,7 @@ #include #include "sclp.h" #include +#include extern unsigned long stacktop; @@ -32,8 +33,16 @@ static struct spinlock sclp_lock; static void mem_init(phys_addr_t mem_end) { phys_addr_t freemem_start = (phys_addr_t)&stacktop; + phys_addr_t base, top; phys_alloc_init(freemem_start, mem_end - freemem_start); + phys_alloc_get_unused(&base, &top); + base = (base + PAGE_SIZE - 1) & -PAGE_SIZE; + top = top & -PAGE_SIZE; + + /* Make the pages available to the physical allocator */ + free_pages((void *)(unsigned long)base, top - base); + page_alloc_ops_enable(); } static void sclp_setup_int(void)