From patchwork Mon Jan 21 10:45:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773531 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 7B9D31575 for ; Mon, 21 Jan 2019 10:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C1D029E34 for ; Mon, 21 Jan 2019 10:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 606AA29E35; Mon, 21 Jan 2019 10:46:08 +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 EE9AD29E31 for ; Mon, 21 Jan 2019 10:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbfAUKqG (ORCPT ); Mon, 21 Jan 2019 05:46:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47662 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbfAUKqG (ORCPT ); Mon, 21 Jan 2019 05:46:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30280C0528AC; Mon, 21 Jan 2019 10:46:06 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E408B68360; Mon, 21 Jan 2019 10:46:04 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 01/10] s390x: cleanup and add SCLP defines Date: Mon, 21 Jan 2019 11:45:46 +0100 Message-Id: <1548067555-15766-2-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 21 Jan 2019 10:46:06 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Hildenbrand Reading the Linux kernel SCLP code, one might wonder what certain magic values mean and why we don't have to set them in our SCLP code. So let's define them for us. We might want to make use of them in the future. Add two new defines for values used in the linux kernel - SCLP_FC_SINGLE_INCREMENT_ASSIGN (used to speed up memory hotplug) - SCLP_FC_DUMP_INDICATOR (used to get more reasonable dumps) Also rename SCLP_VARIABLE_LENGTH_RESPONSE to SCLP_CM2_VARIABLE_LENGTH_RESPONSE, so it is clear where this is actually used. Move the defines to separate sections. Signed-off-by: David Hildenbrand Reviewed-by: Janosch Frank Signed-off-by: Thomas Huth --- lib/s390x/sclp.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 21d482b..629e9e2 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -68,14 +68,19 @@ #define SCLP_RC_EVENT_BUFFER_SYNTAX_ERROR 0x73f0 #define SCLP_RC_INVALID_MASK_LENGTH 0x74f0 -/* Service Call Control Block (SCCB) and its elements */ +/* SCLP control mask bits */ +#define SCLP_CM2_VARIABLE_LENGTH_RESPONSE 0x80 -#define SCCB_SIZE 4096 +/* SCLP function codes */ +#define SCLP_FC_NORMAL_WRITE 0 +#define SCLP_FC_SINGLE_INCREMENT_ASSIGN 0x40 +#define SCLP_FC_DUMP_INDICATOR 0x80 -#define SCLP_VARIABLE_LENGTH_RESPONSE 0x80 +/* SCLP event buffer flags */ #define SCLP_EVENT_BUFFER_ACCEPTED 0x80 -#define SCLP_FC_NORMAL_WRITE 0 +/* Service Call Control Block (SCCB) and its elements */ +#define SCCB_SIZE 4096 typedef struct SCCBHeader { uint16_t length; From patchwork Mon Jan 21 10:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773533 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 C55A413B4 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B52CA29E32 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A904E29E35; Mon, 21 Jan 2019 10:46:09 +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 4BE2329E32 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbfAUKqI (ORCPT ); Mon, 21 Jan 2019 05:46:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727302AbfAUKqH (ORCPT ); Mon, 21 Jan 2019 05:46:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA3581F8C5; Mon, 21 Jan 2019 10:46:07 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A76A5D961; Mon, 21 Jan 2019 10:46:06 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 02/10] s390x: try !FORCE SCLP read SCP info if FORCED is unknown Date: Mon, 21 Jan 2019 11:45:47 +0100 Message-Id: <1548067555-15766-3-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 Jan 2019 10:46:07 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Hildenbrand Looking at what the kernel does, looks like we should - Check for more errors - Try to execute !FORCED read if the FORCED one is unknown The kernel sets the function code to 0x80 (SCLP_FC_DUMP_INDICATOR). We don't need that. Also, the control_mask[2] is set to 0x80 (SCLP_CM2_VARIABLE_LENGTH_RESPONSE), something we also don't need as 4k SCCB should be sufficient for the amount of CPUs we expect to be called with. If this ever changes, we can extend it. Tested-by: Janosch Frank Reviewed-by: Janosch Frank Signed-off-by: David Hildenbrand Signed-off-by: Thomas Huth --- lib/s390x/sclp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 1d4a010..cccfdc2 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -30,14 +30,33 @@ static void mem_init(phys_addr_t mem_end) phys_alloc_init(freemem_start, mem_end - freemem_start); } +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; + + 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)) + break; + if (ri->h.response_code == SCLP_RC_NORMAL_READ_COMPLETION) + return; + if (ri->h.response_code != SCLP_RC_INVALID_SCLP_COMMAND) + break; + } + report_abort("READ_SCP_INFO failed"); +} + void sclp_memory_setup(void) { ReadInfo *ri = (void *)_sccb; uint64_t rnmax, rnsize; int cc; - ri->h.length = SCCB_SIZE; - sclp_service_call(SCLP_CMDW_READ_SCP_INFO_FORCED, ri); + sclp_read_scp_info(ri, SCCB_SIZE); /* calculate the storage increment size */ rnsize = ri->rnsize; From patchwork Mon Jan 21 10:45:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773535 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 381201575 for ; Mon, 21 Jan 2019 10:46:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27CFF29E32 for ; Mon, 21 Jan 2019 10:46:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C64B29E35; Mon, 21 Jan 2019 10:46:12 +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 9D3D029E32 for ; Mon, 21 Jan 2019 10:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbfAUKqK (ORCPT ); Mon, 21 Jan 2019 05:46:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52052 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbfAUKqJ (ORCPT ); Mon, 21 Jan 2019 05:46:09 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DBACD4030; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C9A665922; Mon, 21 Jan 2019 10:46:07 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 03/10] s390x: Add Sigp header file Date: Mon, 21 Jan 2019 11:45:48 +0100 Message-Id: <1548067555-15766-4-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-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..fbd94fc --- /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. + */ + +#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 Mon Jan 21 10:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773537 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 C76231575 for ; Mon, 21 Jan 2019 10:46:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B762229E32 for ; Mon, 21 Jan 2019 10:46:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB9E929E35; Mon, 21 Jan 2019 10:46:13 +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 3E9BA29E32 for ; Mon, 21 Jan 2019 10:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbfAUKqM (ORCPT ); Mon, 21 Jan 2019 05:46:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60072 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbfAUKqL (ORCPT ); Mon, 21 Jan 2019 05:46:11 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECE0A432A8; Mon, 21 Jan 2019 10:46:10 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id A75CD5D961; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 04/10] s390x: Rename and cleanup sclp-ascii.c Date: Mon, 21 Jan 2019 11:45:49 +0100 Message-Id: <1548067555-15766-5-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 21 Jan 2019 10:46:11 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-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 Mon Jan 21 10:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773539 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 C798713B4 for ; Mon, 21 Jan 2019 10:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B759F29E32 for ; Mon, 21 Jan 2019 10:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB2CC29E36; Mon, 21 Jan 2019 10:46: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 4CA3829E34 for ; Mon, 21 Jan 2019 10:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbfAUKqN (ORCPT ); Mon, 21 Jan 2019 05:46:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42738 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfAUKqM (ORCPT ); Mon, 21 Jan 2019 05:46:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E80980508; Mon, 21 Jan 2019 10:46:12 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4258068360; Mon, 21 Jan 2019 10:46:11 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 05/10] s390x: Make tests bootable from disk Date: Mon, 21 Jan 2019 11:45:50 +0100 Message-Id: <1548067555-15766-6-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 21 Jan 2019 10:46:12 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-by: Thomas Huth --- s390x/Makefile | 2 +- s390x/cstart64.S | 8 +++++++- s390x/flat.lds | 13 ++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index ede2961..ed6ef0b 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -50,7 +50,7 @@ FLATLIBS = $(libcflat) %.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(cstart.o) $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \ $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\" - $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds -Ttext=0x10000 \ + $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \ $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o) $(RM) $(@:.elf=.aux.o) @chmod a-x $@ 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 Mon Jan 21 10:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773541 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 DAB0A13B4 for ; Mon, 21 Jan 2019 10:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6D729E32 for ; Mon, 21 Jan 2019 10:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEEB529E35; Mon, 21 Jan 2019 10:46: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 6CFF029E32 for ; Mon, 21 Jan 2019 10:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727796AbfAUKqP (ORCPT ); Mon, 21 Jan 2019 05:46:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60784 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbfAUKqO (ORCPT ); Mon, 21 Jan 2019 05:46:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 307BD85363; Mon, 21 Jan 2019 10:46:14 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3A215D961; Mon, 21 Jan 2019 10:46:12 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 06/10] s390x: Switch to z/Arch and enable 64 bit addressing mode Date: Mon, 21 Jan 2019 11:45:51 +0100 Message-Id: <1548067555-15766-7-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 21 Jan 2019 10:46:14 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-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 Mon Jan 21 10:45:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773543 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 AAA141575 for ; Mon, 21 Jan 2019 10:46:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A3729E32 for ; Mon, 21 Jan 2019 10:46:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2A929E35; Mon, 21 Jan 2019 10:46:18 +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 3648529E32 for ; Mon, 21 Jan 2019 10:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727735AbfAUKqR (ORCPT ); Mon, 21 Jan 2019 05:46:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727743AbfAUKqQ (ORCPT ); Mon, 21 Jan 2019 05:46:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2841C058CB1; Mon, 21 Jan 2019 10:46:15 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A37C65922; Mon, 21 Jan 2019 10:46:14 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 07/10] s390x: Add BSS clearing for non ELF boot Date: Mon, 21 Jan 2019 11:45:52 +0100 Message-Id: <1548067555-15766-8-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 21 Jan 2019 10:46:15 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-by: Thomas Huth --- 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 Mon Jan 21 10:45:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773545 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 5372A1575 for ; Mon, 21 Jan 2019 10:46:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B7229E32 for ; Mon, 21 Jan 2019 10:46:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F0829E35; Mon, 21 Jan 2019 10:46:33 +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 9F85429E32 for ; Mon, 21 Jan 2019 10:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbfAUKqb (ORCPT ); Mon, 21 Jan 2019 05:46:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42950 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfAUKqb (ORCPT ); Mon, 21 Jan 2019 05:46:31 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5B4B8050D; Mon, 21 Jan 2019 10:46:30 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A1B5D961; Mon, 21 Jan 2019 10:46:15 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 08/10] s390x: Move common sclp data and functions to sclp.c Date: Mon, 21 Jan 2019 11:45:53 +0100 Message-Id: <1548067555-15766-9-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 21 Jan 2019 10:46:30 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-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 Mon Jan 21 10:45:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773547 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 7803B13B4 for ; Mon, 21 Jan 2019 10:46:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65CE529E32 for ; Mon, 21 Jan 2019 10:46:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57DF929E35; Mon, 21 Jan 2019 10:46:41 +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 02A5B29E32 for ; Mon, 21 Jan 2019 10:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbfAUKqk (ORCPT ); Mon, 21 Jan 2019 05:46:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41080 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727498AbfAUKqj (ORCPT ); Mon, 21 Jan 2019 05:46:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99D049D432; Mon, 21 Jan 2019 10:46:39 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04EE068736; Mon, 21 Jan 2019 10:46:30 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 09/10] s390x: Add binary generation to makefile Date: Mon, 21 Jan 2019 11:45:54 +0100 Message-Id: <1548067555-15766-10-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 21 Jan 2019 10:46:39 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank "make test_cases_binary" 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 Signed-off-by: Thomas Huth --- s390x/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index ed6ef0b..af40fd4 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 Mon Jan 21 10:45:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773549 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 112901575 for ; Mon, 21 Jan 2019 10:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01BD429E32 for ; Mon, 21 Jan 2019 10:46:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E961629E35; Mon, 21 Jan 2019 10:46:45 +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 9C28329E32 for ; Mon, 21 Jan 2019 10:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbfAUKqo (ORCPT ); Mon, 21 Jan 2019 05:46:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60536 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727729AbfAUKqo (ORCPT ); Mon, 21 Jan 2019 05:46:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 644BB42BDD; Mon, 21 Jan 2019 10:46:44 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E625F6872B; Mon, 21 Jan 2019 10:46:39 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 10/10] s390x: Initialize the physical allocator on mem init Date: Mon, 21 Jan 2019 11:45:55 +0100 Message-Id: <1548067555-15766-11-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 21 Jan 2019 10:46:44 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank 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 Signed-off-by: Thomas Huth --- lib/s390x/sclp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 7f556e5..b60f7a4 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -16,6 +16,7 @@ #include #include "sclp.h" #include +#include extern unsigned long stacktop; @@ -28,8 +29,16 @@ 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; + 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_read_scp_info(ReadInfo *ri, int length)