From patchwork Fri Dec 14 10:06:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10730809 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 C087D91E for ; Fri, 14 Dec 2018 10:06:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1AB2CFE1 for ; Fri, 14 Dec 2018 10:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0CC62D3BD; Fri, 14 Dec 2018 10:06: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 354A62CFE1 for ; Fri, 14 Dec 2018 10:06:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728962AbeLNKG1 (ORCPT ); Fri, 14 Dec 2018 05:06:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54522 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbeLNKG0 (ORCPT ); Fri, 14 Dec 2018 05:06:26 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80D5F3082211; Fri, 14 Dec 2018 10:06:26 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-139.ams2.redhat.com [10.36.117.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 904F3101E597; Fri, 14 Dec 2018 10:06:15 +0000 (UTC) From: David Hildenbrand To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Thomas Huth , Christian Borntraeger , Cornelia Huck , Janosch Frank , David Hildenbrand Subject: [kvm-unit-tests v1] s390x: try !FORCE SCLP read SCP info if FORCED is unknown Date: Fri, 14 Dec 2018 11:06:14 +0100 Message-Id: <20181214100614.11049-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 14 Dec 2018 10:06:26 +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 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 - Set the function code to a normal write - Set control_mask[2] to 0x80 (no idea what that means) The kernel seems to set the function code to 0x80. Looking at where that comes from, turns out this is a "dump indicator" to produce more meaningful dumps. Looking for other function codes used in the kernel, I discovered 0x40, which is used for "single increment assign" to speed up memory hotplug. I was not able to find out what "control_mask[2] = 0x80" means. I guess we can just set the funcion code to 0 ("normal write). Let's document the other bits in case anybody ever wonders what they mean. Also, let's just set the other bits in the mask to 0, not sure if they will actually be used, but this is definetly not wrong. Signed-off-by: David Hildenbrand Tested-by: Janosch Frank Reviewed-by: Janosch Frank --- Quickly tested under kvm (on top of z/VM) and under tcg. lib/s390x/sclp.c | 26 ++++++++++++++++++++++++-- lib/s390x/sclp.h | 2 ++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 1d4a010..8224553 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -30,14 +30,36 @@ 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++) { + ri->h.length = length; + ri->h.function_code = SCLP_FC_NORMAL_WRITE; + ri->h.control_mask[0] = 0; + ri->h.control_mask[1] = 0; + ri->h.control_mask[2] = 0x80; + + 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; diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 21d482b..131813e 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -76,6 +76,8 @@ #define SCLP_EVENT_BUFFER_ACCEPTED 0x80 #define SCLP_FC_NORMAL_WRITE 0 +#define SCLP_FC_SINGLE_INCREMENT_ASSIGN 0x40 +#define SCLP_FC_DUMP_INDICATOR 0x80 typedef struct SCCBHeader { uint16_t length;