From patchwork Wed Mar 4 15:33:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08B1E14BC for ; Wed, 4 Mar 2020 15:35:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D42112467F for ; Wed, 4 Mar 2020 15:35:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U5jJ6EIJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D42112467F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W3Q-0001gM-2d for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Mar 2020 10:35:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W1V-0006sU-Fh for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9W1U-0003Rn-JF for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:25 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57283 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9W1U-0003Pv-Fi for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=biiTpzltwU1sZnuHfx0nIZ3HPWdcfFfqBiK+XWGwsSg=; b=U5jJ6EIJ1Ox5tXqVPybJscwLvQxUaIP4xwwo6MxrSmH5dP8h5XVZH9SG2Nk0Na3s8+fUYM VNEefwdHsFjAHDHrsHRez5ZxVM5wkZ6qBPr7R3b92OJkNhd5hfHD/NVHFhG5ib3Umtc7sZ P7ZT/Qb8O32ofCirG0fIOgmLrPVnKYE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-mIKbVQxRNP2wYB-ddTaSYA-1; Wed, 04 Mar 2020 10:33:22 -0500 X-MC-Unique: mIKbVQxRNP2wYB-ddTaSYA-1 Received: by mail-wm1-f71.google.com with SMTP id t2so700689wmj.2 for ; Wed, 04 Mar 2020 07:33:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/S7pAhQdbWIOFjZggLKf3SMhfw5UacO71zzf9J+ONfw=; b=s72F5V0KABEPmLg6vvYkQAJ/aHXwUzTfN0/KFP0lA/Dx6lN3xS7Cr1H1UOLSTv60If 58K+ti8OMDQN9bs+HLsidB6ZAAN4Xrcg6YElGLM3aSleKr2uBJn6EuAmQYu9k/hYst9n y2Lv5Na60xwYYYVVkDG4MjqiBBD15RbEa408UFWC+bUd8gSQuWgmGLTcmf6u53t2TTMr 7ciR5/QnukWD18Og4pKpsSZoQjbP+4bCW64Y2nKVI8W6eavKfQlp7wLXx5kv3YmdMb/x O4VoTtG0v2MzMpt567NwDUEhZ2+4QsPYGXnn0FghFpePLkP2huYNqlYRlxGoksbZXr87 Vt1Q== X-Gm-Message-State: ANhLgQ1w9F9PcKManeckKqCWhMyaCiGW48tEasmTtch8X33Simt5ZQdI v139XV0za7g13b51fbggEDXDS9qGQvdccwy8v/WyqhSFj9hjtuhI3ZncUwqoEjHgwiQz0EqCbmu REkGZgr5NQKW27ns= X-Received: by 2002:a1c:43c2:: with SMTP id q185mr4152830wma.176.1583336000625; Wed, 04 Mar 2020 07:33:20 -0800 (PST) X-Google-Smtp-Source: ADFU+vv4YvXFHj49GK0qRoaSAyFvdBmUg1iPZ3HA2bytMIDt88kEHu39uA0AjmrOMc54DtYusI9Wpg== X-Received: by 2002:a1c:43c2:: with SMTP id q185mr4152815wma.176.1583336000454; Wed, 04 Mar 2020 07:33:20 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id c4sm4771137wml.7.2020.03.04.07.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:33:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/5] hw/scsi/viosrp: Add missing 'hw/scsi/srp.h' include Date: Wed, 4 Mar 2020 16:33:07 +0100 Message-Id: <20200304153311.22959-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200304153311.22959-1-philmd@redhat.com> References: <20200304153311.22959-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-ppc@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This header use the srp_* structures declared in "hw/scsi/srp.h". Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/viosrp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/scsi/viosrp.h b/hw/scsi/viosrp.h index d8e365db1e..25676c2383 100644 --- a/hw/scsi/viosrp.h +++ b/hw/scsi/viosrp.h @@ -34,6 +34,8 @@ #ifndef PPC_VIOSRP_H #define PPC_VIOSRP_H +#include "hw/scsi/srp.h" + #define SRP_VERSION "16.a" #define SRP_MAX_IU_LEN 256 #define SRP_MAX_LOC_LEN 32 From patchwork Wed Mar 4 15:33:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 985B9930 for ; Wed, 4 Mar 2020 15:36:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F0D920870 for ; Wed, 4 Mar 2020 15:36:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JPz6Zqt7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F0D920870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W4g-0004JT-Gz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Mar 2020 10:36:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45206) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W1a-00070z-GD for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9W1Z-0003hf-GI for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56205 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9W1Z-0003gW-Bz for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VSi8icYpglVwPM4o7Q8ZGmXm/EAEO/DibdkCD45Z2Kw=; b=JPz6Zqt7Tp1a/t+t+g9NatAjYa/57p3IkEI08zvMGQjRlSHYd/DJFCdk3iwskFShWKTxAj MatXEUtCqo51OjTn74tYrUEvjanV7MWZGoWPSFiwnPSWhCfW6zZVERw4sWhSNgfyuVivg3 OF5Ve/UJaYfG5XvNZda/x97LGPkvoG0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-ABfHAalFMVeAdR_g3vSoQw-1; Wed, 04 Mar 2020 10:33:27 -0500 X-MC-Unique: ABfHAalFMVeAdR_g3vSoQw-1 Received: by mail-wm1-f70.google.com with SMTP id y7so1005998wmd.4 for ; Wed, 04 Mar 2020 07:33:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KkhqIVIgOTcLzuFywQWIieMxU39HVlXEuJIdDpMq2pg=; b=HFkFZPo6Z5PKbcsoyU3TABTw3bLgCHr3W9D7NF8o/VBJuCzNfssX2DFTUoG/oTWwyy xRj4z/jgKjVm+owpmbtrRRWa+ZXyaVjlL0irQjZzvpkz1gUa6Ewbhi2D5riMUrbD/pi+ XIq6KweXC3w35e9xfGCbxt0RI6/+oFy+puQdYk1OYSYYCSfPylnm/Z9ah1uXxu8ilue0 d1TAlnVwh+S618i4btxJX11dlOeAWH5o4yuJbjjKxMDdfHmxGbMosmZL1jOtlPVoPkQH ERJwFMGZKvLCSmDQaM/SfvCmtNb82MYDYMggkMM5IlNgtT+yO0Ste4lhim+TmzfUYW5z So0w== X-Gm-Message-State: ANhLgQ1X/SucUwAjpApiPyxzY3DIKM8TI4g0xljTjZxOGzwiLrvcOZeE JwWXAosLLM7GKC2JBxfODmSkcAUchEYaGcIDVhspASl9NSzt+lmyccjgQ1qg039LNxbJwkNvJ+l mPLs4nAPidmbQsTU= X-Received: by 2002:a1c:25c5:: with SMTP id l188mr4390999wml.105.1583336005985; Wed, 04 Mar 2020 07:33:25 -0800 (PST) X-Google-Smtp-Source: ADFU+vtwz9+DmWBd1+B9vH79rxKAxMTDcTxndbAh+V+CTSMCjRy09DnZptZdXUuzSXBw8b189ttXTw== X-Received: by 2002:a1c:25c5:: with SMTP id l188mr4390974wml.105.1583336005728; Wed, 04 Mar 2020 07:33:25 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id t124sm5172965wmg.13.2020.03.04.07.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:33:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/5] hw/scsi/spapr_vscsi: Use SRP_MAX_IU_LEN instead of sizeof flexible array Date: Wed, 4 Mar 2020 16:33:08 +0100 Message-Id: <20200304153311.22959-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200304153311.22959-1-philmd@redhat.com> References: <20200304153311.22959-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-ppc@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace sizeof() flexible arrays union srp_iu/viosrp_iu by the SRP_MAX_IU_LEN definition, which is what this code actually meant to use. Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/spapr_vscsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 7d584e7732..7e397ed797 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -671,8 +671,8 @@ static void vscsi_process_login(VSCSIState *s, vscsi_req *req) */ rsp->req_lim_delta = cpu_to_be32(VSCSI_REQ_LIMIT-2); rsp->tag = tag; - rsp->max_it_iu_len = cpu_to_be32(sizeof(union srp_iu)); - rsp->max_ti_iu_len = cpu_to_be32(sizeof(union srp_iu)); + rsp->max_it_iu_len = cpu_to_be32(SRP_MAX_IU_LEN); + rsp->max_ti_iu_len = cpu_to_be32(SRP_MAX_IU_LEN); /* direct and indirect */ rsp->buf_fmt = cpu_to_be16(SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_INDIRECT); @@ -1088,7 +1088,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq) * in our 256 bytes IUs. If not we'll have to increase the size * of the structure. */ - if (crq->s.IU_length > sizeof(union viosrp_iu)) { + if (crq->s.IU_length > SRP_MAX_IU_LEN) { fprintf(stderr, "VSCSI: SRP IU too long (%d bytes) !\n", crq->s.IU_length); vscsi_put_req(req); From patchwork Wed Mar 4 15:33:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A00114BC for ; Wed, 4 Mar 2020 15:34:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2062424658 for ; Wed, 4 Mar 2020 15:34:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I8d+E3uZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2062424658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W2W-0000Aw-85 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Mar 2020 10:34:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45248) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W1h-0007Ao-Qz for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9W1g-0003qb-PU for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:37 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44241 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9W1g-0003pM-M2 for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q8+T2y2EUOXy4UOGSX8jY7OAnypdhI625RaxfhFsFz4=; b=I8d+E3uZ0OeOOBTf+MV7V6qf48mgwXVsX+WiYvuZXRxor4xC7zJQ5KeXlPdhtEqN2gwokg 8BdFybskyT0yQW5D7VtpjAyxkT2tvo1T49PX83RGdiaEv1o/jfOlz9FELlRdt3OBHsrGca vCfWRpktuyqCxT8o8KCpv1TUE0o9EqI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-137-W-CXajbFMNale2BSYjGOAQ-1; Wed, 04 Mar 2020 10:33:32 -0500 X-MC-Unique: W-CXajbFMNale2BSYjGOAQ-1 Received: by mail-wm1-f70.google.com with SMTP id p186so705604wmp.0 for ; Wed, 04 Mar 2020 07:33:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fYLVugFhvyMP9VPep4uY2EfonI9dvYdGAuHljfXSuxI=; b=Cj37vjadsXLm0UIHDaZjOxvgjkMPbQBpfap5TIz59ES4mYwUx5BiDFkgURG1V1PoN0 oTN3Sq62fC+DDCs0ozXgrCezUQc18m7xb8X8VgS7PsarmdcguLpM1km4IYFugX5QaosJ z/5wCJI+ogNTPDhIqXqWfC2dNDz0G6Fzc3H+1VSwMjhbBJhzi7fjb3RMQMP/3z8Zkk9x ZOhRMyAGoSRZNTg3P0BHc2LCZvUUvgCdRno+mUayj9HFqI6Qq95u9vZ3C6MPX6owgeBY E0IilwwroepBjHmnVvLrW9jKu1wfIU0/yMIqnbwOreEdwM8zOOsWvkEWJq66TKN1ntno AnOA== X-Gm-Message-State: ANhLgQ1uOExDuAtcccExO3Wmlywd+MeWDn+1BIEvelGbEdOWkiM4EdeM oDzId2yERAU7FdXT9L1VE1hcUfMGqxeXwcUPc3+gAOrZY3Bfuu2cOdmFzbJRoY4GeLuecdEw9Tg BZ/6bLissSJOKewU= X-Received: by 2002:adf:f285:: with SMTP id k5mr4429584wro.45.1583336011488; Wed, 04 Mar 2020 07:33:31 -0800 (PST) X-Google-Smtp-Source: ADFU+vuDkTGaqvdahmJHBnwKXtZiQU18mwPT4++o/UW+A7a4NJqr/eYRcw0RPJowCxODkLgsnC4uUA== X-Received: by 2002:adf:f285:: with SMTP id k5mr4429569wro.45.1583336011289; Wed, 04 Mar 2020 07:33:31 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id e8sm40950884wrr.69.2020.03.04.07.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:33:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/5] hw/scsi/spapr_vscsi: Simplify a bit Date: Wed, 4 Mar 2020 16:33:09 +0100 Message-Id: <20200304153311.22959-4-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200304153311.22959-1-philmd@redhat.com> References: <20200304153311.22959-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-ppc@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We already have a ui pointer, use it (to simplify the next commit). Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/spapr_vscsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 7e397ed797..3cb5a38181 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -261,9 +261,9 @@ static int vscsi_send_rsp(VSCSIState *s, vscsi_req *req, if (status) { iu->srp.rsp.sol_not = (sol_not & 0x04) >> 2; if (req->senselen) { - req->iu.srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID; - req->iu.srp.rsp.sense_data_len = cpu_to_be32(req->senselen); - memcpy(req->iu.srp.rsp.data, req->sense, req->senselen); + iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID; + iu->srp.rsp.sense_data_len = cpu_to_be32(req->senselen); + memcpy(iu->srp.rsp.data, req->sense, req->senselen); total_len += req->senselen; } } else { From patchwork Wed Mar 4 15:33:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA047930 for ; Wed, 4 Mar 2020 15:35:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C3242465D for ; Wed, 4 Mar 2020 15:35:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gGRjgiME" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C3242465D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W3h-0001zz-Rq for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Mar 2020 10:35:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W1l-0007Gd-Vh for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9W1k-0003za-Gp for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:41 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:59638 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9W1k-0003yc-5I for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ncXvKgCh7oNRxNDfr+HT+HXiEUoLIL65NXTlOR8SRiw=; b=gGRjgiME74yKTwWRkpZNZ0v4HWXqIWkrpoNSoOklTb1juQmP9QKf0uj38SKUNwBvPAYUjS rzKGlAYAmYb565v6OTDXOQ/j1CW7KWXXh1Ew3U7ginnTAcRXxcsGPpBywD65VJHKDnNnFP CYC//tVI6UN7rjbprOURzQnP72cDoSw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-CEQtzDW0P9CP5AxUZ6E2UQ-1; Wed, 04 Mar 2020 10:33:38 -0500 X-MC-Unique: CEQtzDW0P9CP5AxUZ6E2UQ-1 Received: by mail-wm1-f70.google.com with SMTP id y7so1006160wmd.4 for ; Wed, 04 Mar 2020 07:33:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lIsPttx7EyIfrKo8AXy0rWHmebp0Fo3V9l7UpmGnTwA=; b=B39ijL5C29EvWBywl8gro0Krh/Z5va27I0mB528UTq8iw90PBqf7EYFy2fXwTKGD0b 1/9KOdZkDIS/EQNtKzLMExxVE8jWig09AnQ5UISuDhhjnc2tXMJjP72JeO1LhTHU7LtA x17VlajcdVhq7nO632YW+0bUQwQph4Cn8hT0O8lejrTXjOLTzELX4gMHkGZrRt2Cz1C2 vb+851YG3x9WVt8LCbsnbsSeAID35fljngZYhWdjvwED1Y/SafJXrBclvUmE6bVbyqCk nJBFM3WEqnDWx1hdEjTDJNpV8/2zHjp+FmsRC1lfgrKBb5J8EwZZ5ycVEGIoBueFQpeS WBhg== X-Gm-Message-State: ANhLgQ0M+wLyoa9lQ9wyelEf6Jbv2gnIO2XQwZm4ZavlKzfji1ud91wu LIXKhKMEo6y8v7IQM+nF8Km+8wnWm2ULPy+RLvkTnr1pb9i8LStbqsEelY37DiZRBzSTmXgRGNQ fsxKO/1YJaFGaL+Q= X-Received: by 2002:adf:ee86:: with SMTP id b6mr4483540wro.282.1583336016764; Wed, 04 Mar 2020 07:33:36 -0800 (PST) X-Google-Smtp-Source: ADFU+vvDPT3fAJASBFYUhOP6MiWlX7Asqyk+TsRCO4jq26QmdxrKeTswAcy9CJXcU3BXH/gwzsK+2Q== X-Received: by 2002:adf:ee86:: with SMTP id b6mr4483519wro.282.1583336016489; Wed, 04 Mar 2020 07:33:36 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id h10sm5165717wml.18.2020.03.04.07.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:33:36 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/scsi/spapr_vscsi: Introduce req_ui() helper Date: Wed, 4 Mar 2020 16:33:10 +0100 Message-Id: <20200304153311.22959-5-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200304153311.22959-1-philmd@redhat.com> References: <20200304153311.22959-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-ppc@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Introduce the req_ui() helper which returns a pointer to the viosrp_iu union held in the vscsi_req structure. This simplifies the next patch. Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/spapr_vscsi.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 3cb5a38181..f1a0bbdc31 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -97,6 +97,12 @@ typedef struct { vscsi_req reqs[VSCSI_REQ_LIMIT]; } VSCSIState; +static union viosrp_iu *req_iu(vscsi_req *req) +{ + return (union viosrp_iu *)req->iu.srp.reserved; +} + + static struct vscsi_req *vscsi_get_req(VSCSIState *s) { vscsi_req *req; @@ -121,7 +127,7 @@ static struct vscsi_req *vscsi_find_req(VSCSIState *s, uint64_t srp_tag) for (i = 0; i < VSCSI_REQ_LIMIT; i++) { req = &s->reqs[i]; - if (req->iu.srp.cmd.tag == srp_tag) { + if (req_iu(req)->srp.cmd.tag == srp_tag) { return req; } } @@ -188,7 +194,7 @@ static int vscsi_send_iu(VSCSIState *s, vscsi_req *req, req->crq.s.reserved = 0x00; req->crq.s.timeout = cpu_to_be16(0x0000); req->crq.s.IU_length = cpu_to_be16(length); - req->crq.s.IU_data_ptr = req->iu.srp.rsp.tag; /* right byte order */ + req->crq.s.IU_data_ptr = req_iu(req)->srp.rsp.tag; /* right byte order */ if (rc == 0) { req->crq.s.status = VIOSRP_OK; @@ -224,7 +230,7 @@ static void vscsi_makeup_sense(VSCSIState *s, vscsi_req *req, static int vscsi_send_rsp(VSCSIState *s, vscsi_req *req, uint8_t status, int32_t res_in, int32_t res_out) { - union viosrp_iu *iu = &req->iu; + union viosrp_iu *iu = req_iu(req); uint64_t tag = iu->srp.rsp.tag; int total_len = sizeof(iu->srp.rsp); uint8_t sol_not = iu->srp.cmd.sol_not; @@ -285,7 +291,7 @@ static int vscsi_fetch_desc(VSCSIState *s, struct vscsi_req *req, unsigned n, unsigned buf_offset, struct srp_direct_buf *ret) { - struct srp_cmd *cmd = &req->iu.srp.cmd; + struct srp_cmd *cmd = &req_iu(req)->srp.cmd; switch (req->dma_fmt) { case SRP_NO_DATA_DESC: { @@ -473,7 +479,7 @@ static int data_out_desc_size(struct srp_cmd *cmd) static int vscsi_preprocess_desc(vscsi_req *req) { - struct srp_cmd *cmd = &req->iu.srp.cmd; + struct srp_cmd *cmd = &req_iu(req)->srp.cmd; req->cdb_offset = cmd->add_cdb_len & ~3; @@ -655,7 +661,7 @@ static void *vscsi_load_request(QEMUFile *f, SCSIRequest *sreq) static void vscsi_process_login(VSCSIState *s, vscsi_req *req) { - union viosrp_iu *iu = &req->iu; + union viosrp_iu *iu = req_iu(req); struct srp_login_rsp *rsp = &iu->srp.login_rsp; uint64_t tag = iu->srp.rsp.tag; @@ -681,7 +687,7 @@ static void vscsi_process_login(VSCSIState *s, vscsi_req *req) static void vscsi_inquiry_no_target(VSCSIState *s, vscsi_req *req) { - uint8_t *cdb = req->iu.srp.cmd.cdb; + uint8_t *cdb = req_iu(req)->srp.cmd.cdb; uint8_t resp_data[36]; int rc, len, alen; @@ -770,7 +776,7 @@ static void vscsi_report_luns(VSCSIState *s, vscsi_req *req) static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req) { - union srp_iu *srp = &req->iu.srp; + union srp_iu *srp = &req_iu(req)->srp; SCSIDevice *sdev; int n, lun; @@ -821,7 +827,7 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req) static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) { - union viosrp_iu *iu = &req->iu; + union viosrp_iu *iu = req_iu(req); vscsi_req *tmpreq; int i, lun = 0, resp = SRP_TSK_MGMT_COMPLETE; SCSIDevice *d; @@ -831,7 +837,8 @@ static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) fprintf(stderr, "vscsi_process_tsk_mgmt %02x\n", iu->srp.tsk_mgmt.tsk_mgmt_func); - d = vscsi_device_find(&s->bus, be64_to_cpu(req->iu.srp.tsk_mgmt.lun), &lun); + d = vscsi_device_find(&s->bus, + be64_to_cpu(req_iu(req)->srp.tsk_mgmt.lun), &lun); if (!d) { resp = SRP_TSK_MGMT_FIELDS_INVALID; } else { @@ -842,7 +849,7 @@ static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) break; } - tmpreq = vscsi_find_req(s, req->iu.srp.tsk_mgmt.task_tag); + tmpreq = vscsi_find_req(s, req_iu(req)->srp.tsk_mgmt.task_tag); if (tmpreq && tmpreq->sreq) { assert(tmpreq->sreq->hba_private); scsi_req_cancel(tmpreq->sreq); @@ -867,7 +874,8 @@ static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) for (i = 0; i < VSCSI_REQ_LIMIT; i++) { tmpreq = &s->reqs[i]; - if (tmpreq->iu.srp.cmd.lun != req->iu.srp.tsk_mgmt.lun) { + if (req_iu(tmpreq)->srp.cmd.lun + != req_iu(req)->srp.tsk_mgmt.lun) { continue; } if (!tmpreq->active || !tmpreq->sreq) { @@ -911,7 +919,7 @@ static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) static int vscsi_handle_srp_req(VSCSIState *s, vscsi_req *req) { - union srp_iu *srp = &req->iu.srp; + union srp_iu *srp = &req_iu(req)->srp; int done = 1; uint8_t opcode = srp->rsp.opcode; @@ -948,7 +956,7 @@ static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req) struct mad_adapter_info_data info; int rc; - sinfo = &req->iu.mad.adapter_info; + sinfo = &req_iu(req)->mad.adapter_info; #if 0 /* What for ? */ rc = spapr_vio_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer), @@ -984,7 +992,7 @@ static int vscsi_send_capabilities(VSCSIState *s, vscsi_req *req) uint64_t buffer; int rc; - vcap = &req->iu.mad.capabilities; + vcap = &req_iu(req)->mad.capabilities; req_len = len = be16_to_cpu(vcap->common.length); buffer = be64_to_cpu(vcap->buffer); if (len > sizeof(cap)) { @@ -1029,7 +1037,7 @@ static int vscsi_send_capabilities(VSCSIState *s, vscsi_req *req) static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req) { - union mad_iu *mad = &req->iu.mad; + union mad_iu *mad = &req_iu(req)->mad; bool request_handled = false; uint64_t retlen = 0; From patchwork Wed Mar 4 15:33:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11420297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8736A14BC for ; Wed, 4 Mar 2020 15:38:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DD9320870 for ; Wed, 4 Mar 2020 15:38:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZJEuigYY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DD9320870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W67-0008Do-HM for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Mar 2020 10:38:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45332) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W1q-0007NX-Lz for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9W1p-00046v-5e for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51953 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9W1p-00046N-28 for qemu-devel@nongnu.org; Wed, 04 Mar 2020 10:33:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583336024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M6bOA2bmzs7vUmurz3p844VtrEnDUzC6kMVk052Rcfs=; b=ZJEuigYYTHAfK+kJHJ0POC4ELIj12yMAiYVyTGeGBPmVGLRAVFNN+pMnKU4WNFQ/m/3+L7 MF4EqaXvhDWK53RVxEwNzIbvM78AeR11CGLCxotDgSi/vmTCCexxY/BLvZh9H1PAgSsbQu 7aWPVpaKBJoaTg7LEKArxNJocQ2y74o= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-7-bm9XURKgM6iR7sGxVrtWBg-1; Wed, 04 Mar 2020 10:33:43 -0500 X-MC-Unique: bm9XURKgM6iR7sGxVrtWBg-1 Received: by mail-wm1-f70.google.com with SMTP id v21so694466wml.5 for ; Wed, 04 Mar 2020 07:33:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UqS7KKOYNA08wTI1vIP1P7qHtBq16EhluaX19XU82to=; b=P1oYxNpU3rVlPQDw0hFfeIIDZqEPM11lHO9z51lZ3okHY9vc5isSlYmoqSAq76ieYh YG9O/iP5Ior2uK04EH5J7ehaM7L1Be+fyPPvfHCloB822oF2xQlsxP/b8sQgJOtiE8o1 rNGeVgdBOauHqT1HLwPZAJjK84LOYxcHKCaSrhTearqvYt8wkr6Wq0iMrprE0HO6MRk0 LBBkhhsoZah6Gyh98IlpIDp/2LzC2nwZe7DY9/W6aXxqy2WYN2X+FLq7LNIoRAmx+7tp MRvux/KXv6AQLghSwyg/cCB90xVJxfKC+vsWnCf5Vlp7vOHtrsvM0XEUsSe36R3Rnqr2 hE9w== X-Gm-Message-State: ANhLgQ00RH3UDoV4KaY9Zgl6aZCG8AtK/dZTaqbUqiZMyBdRuTszFPfU DxEbTYyVFuZoh2++vMkLr/JWb0X3VpYRg3kZd1MbAhzBCADCirCPf6vSZZDvWuGA+pGEUv3YE01 73N9oSXaOA6OZTCs= X-Received: by 2002:adf:e9c2:: with SMTP id l2mr4498463wrn.86.1583336021882; Wed, 04 Mar 2020 07:33:41 -0800 (PST) X-Google-Smtp-Source: ADFU+vs3DEEsqfl+Fix8m+E1ul4OTPsKX/aNWB+jmFCsGcVuJb1J59/YT49qLAcYOzAnSWSCy32sSg== X-Received: by 2002:adf:e9c2:: with SMTP id l2mr4498450wrn.86.1583336021688; Wed, 04 Mar 2020 07:33:41 -0800 (PST) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id c26sm4622481wmb.8.2020.03.04.07.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 07:33:41 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/5] hw/scsi/spapr_vscsi: Do not mix SRP IU size with DMA buffer size Date: Wed, 4 Mar 2020 16:33:11 +0100 Message-Id: <20200304153311.22959-6-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200304153311.22959-1-philmd@redhat.com> References: <20200304153311.22959-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-ppc@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The 'union srp_iu' is meant as a pointer to any SRP Information Unit type, it is not related to the size of a VIO DMA buffer. Use a plain buffer for the VIO DMA read/write calls. We can remove the reserved buffer from the 'union srp_iu'. This issue was noticed when replacing the zero-length arrays from hw/scsi/srp.h with flexible array member, 'clang -fsanitize=undefined' reported: hw/scsi/spapr_vscsi.c:69:29: error: field 'iu' with variable sized type 'union viosrp_iu' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] union viosrp_iu iu; ^ Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/viosrp.h | 2 +- hw/scsi/spapr_vscsi.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/scsi/viosrp.h b/hw/scsi/viosrp.h index 25676c2383..aba3203028 100644 --- a/hw/scsi/viosrp.h +++ b/hw/scsi/viosrp.h @@ -49,8 +49,8 @@ union srp_iu { struct srp_tsk_mgmt tsk_mgmt; struct srp_cmd cmd; struct srp_rsp rsp; - uint8_t reserved[SRP_MAX_IU_LEN]; }; +_Static_assert(sizeof(union srp_iu) <= SRP_MAX_IU_LEN, "srp_iu size incorrect"); enum viosrp_crq_formats { VIOSRP_SRP_FORMAT = 0x01, diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index f1a0bbdc31..f9be68e44e 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -66,7 +66,7 @@ typedef union vscsi_crq { typedef struct vscsi_req { vscsi_crq crq; - union viosrp_iu iu; + uint8_t viosrp_iu_buf[SRP_MAX_IU_LEN]; /* SCSI request tracking */ SCSIRequest *sreq; @@ -99,7 +99,7 @@ typedef struct { static union viosrp_iu *req_iu(vscsi_req *req) { - return (union viosrp_iu *)req->iu.srp.reserved; + return (union viosrp_iu *)req->viosrp_iu_buf; } @@ -184,7 +184,7 @@ static int vscsi_send_iu(VSCSIState *s, vscsi_req *req, /* First copy the SRP */ rc = spapr_vio_dma_write(&s->vdev, req->crq.s.IU_data_ptr, - &req->iu, length); + &req->viosrp_iu_buf, length); if (rc) { fprintf(stderr, "vscsi_send_iu: DMA write failure !\n"); } @@ -603,7 +603,7 @@ static const VMStateDescription vmstate_spapr_vscsi_req = { .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_BUFFER(crq.raw, vscsi_req), - VMSTATE_BUFFER(iu.srp.reserved, vscsi_req), + VMSTATE_BUFFER(viosrp_iu_buf, vscsi_req), VMSTATE_UINT32(qtag, vscsi_req), VMSTATE_BOOL(active, vscsi_req), VMSTATE_UINT32(data_len, vscsi_req), @@ -1104,7 +1104,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq) } /* XXX Handle failure differently ? */ - if (spapr_vio_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->iu, + if (spapr_vio_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->viosrp_iu_buf, crq->s.IU_length)) { fprintf(stderr, "vscsi_got_payload: DMA read failure !\n"); vscsi_put_req(req);