From nobody Thu Oct 2 03:24:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1584440791; cv=none; d=zohomail.com; s=zohoarc; b=c7p/Ma5Q2u1V7o/dVm9DXI3RLRsNRRUoGBo/QxJM+KPuanjIaSfrfcgxLctdsLUvv3hxkMvMvYghdN9P/0khhQW32nMgxtwapQibQf4LIwkHMkwbRLc4DKO/EPycDLIP54NeflNaxp7f9y0A70Y5sBTsRc+zvXj1kFYXay/dfyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584440791; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1djrN6Pko010lFqtTCW5ugM4n8bdpRHEcRr6ZU9HGaQ=; b=P0PKk4HlIkiQrvrb8Oxu6CbdFPt4ZLF4Kwk96m+F2Mkm8PtHD2cV82EakKLh+VwgJO+JsoAxTPCKG2g1eEvbB5SbMaA3u7Q7x5Mmb6Ke6l3cHLJaeszQJHYBQy0SanSpbl8tGOC8rAd0hiVVBpkXrOQL8qqWh6exv5EV2ZcM82I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584440791453464.28258253234935; Tue, 17 Mar 2020 03:26:31 -0700 (PDT) Received: from localhost ([::1]:55914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE9Qc-0006ms-AA for importer@patchew.org; Tue, 17 Mar 2020 06:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45976) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE968-0001j9-Tr for qemu-devel@nongnu.org; Tue, 17 Mar 2020 06:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE967-0005lZ-Gw for qemu-devel@nongnu.org; Tue, 17 Mar 2020 06:05:20 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:43911 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE967-0002pG-5f; Tue, 17 Mar 2020 06:05:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48hTKy1tGPz9sT9; Tue, 17 Mar 2020 21:04:38 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1584439478; bh=7Oc6dJy7mdLvgRsq59r4wXTl8bUk0MLKqWTXTRm3oTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TtqEkIRIQtvxiAUC0ZN/ZKE28huXHZY6JAoB5ePi6a/zZBCKEBOdmCfE0NeOYjhxa Wl6x30ewA05+rFw/V5Y0gME2KlVUuUkZHjFs77V0Pfm8227gHXIeud8YMDv0ZzeiHZ Qq9TwrZ+RSEam3oZETXnBx0sLPS0tB75hbrClDlU= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 26/45] hw/scsi/spapr_vscsi: Do not mix SRP IU size with DMA buffer size Date: Tue, 17 Mar 2020 21:04:04 +1100 Message-Id: <20200317100423.622643-27-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317100423.622643-1-david@gibson.dropbear.id.au> References: <20200317100423.622643-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: lvivier@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 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=3Dundefined' 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 [-W= error,-Wgnu-variable-sized-type-not-at-end] union viosrp_iu iu; ^ Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200305121253.19078-6-philmd@redhat.com> Reviewed-by: Paolo Bonzini Signed-off-by: David Gibson --- hw/scsi/spapr_vscsi.c | 10 +++++----- hw/scsi/viosrp.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 70547f98ac..acf9bb50bc 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -66,7 +66,7 @@ typedef union vscsi_crq { =20 typedef struct vscsi_req { vscsi_crq crq; - union viosrp_iu iu; + uint8_t viosrp_iu_buf[SRP_MAX_IU_LEN]; =20 /* SCSI request tracking */ SCSIRequest *sreq; @@ -99,7 +99,7 @@ typedef struct { =20 static union viosrp_iu *req_iu(vscsi_req *req) { - return &req->iu; + return (union viosrp_iu *)req->viosrp_iu_buf; } =20 static struct vscsi_req *vscsi_get_req(VSCSIState *s) @@ -183,7 +183,7 @@ static int vscsi_send_iu(VSCSIState *s, vscsi_req *req, =20 /* First copy the SRP */ rc =3D 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"); } @@ -602,7 +602,7 @@ static const VMStateDescription vmstate_spapr_vscsi_req= =3D { .minimum_version_id =3D 1, .fields =3D (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), @@ -1103,7 +1103,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_cr= q *crq) } =20 /* 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_b= uf, crq->s.IU_length)) { fprintf(stderr, "vscsi_got_payload: DMA read failure !\n"); vscsi_put_req(req); diff --git a/hw/scsi/viosrp.h b/hw/scsi/viosrp.h index 25676c2383..e5f9768e8f 100644 --- a/hw/scsi/viosrp.h +++ b/hw/scsi/viosrp.h @@ -49,7 +49,6 @@ union srp_iu { struct srp_tsk_mgmt tsk_mgmt; struct srp_cmd cmd; struct srp_rsp rsp; - uint8_t reserved[SRP_MAX_IU_LEN]; }; =20 enum viosrp_crq_formats { --=20 2.24.1