From nobody Thu Nov 13 21:53:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583336148; cv=none; d=zohomail.com; s=zohoarc; b=GsBTGgkDAVjyv/sHFHTfiBBlCbm5n/cXMjStAVTQ3790izXXVFqefliIubpXVrbjJs99xI2Th6FqnWO5UIxNn4Th3mmpVn7eGy+3LHM3rWXKVQta0PKQBu847lSWk1uS6/NoEbgG5amydUtSRwDGpXXg2HZdVlE9ZH/Nt/sqb3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583336148; 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=biiTpzltwU1sZnuHfx0nIZ3HPWdcfFfqBiK+XWGwsSg=; b=mdkU6RTcTrMjknS55CyZdNNKR1mob2AdJedn9szWPoNa+3HG2inLoSmsJcsYBi35F3mX4xmAAjRr565oiP/3ZG2139IiNVZN3cZ7/sA9MCcCXPsrNpFfaxS2FV1XbVRcsTNUvOqjG/k8zymGH5Sgzckw1MntzBpYdaoVbtHcch4= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158333614876013.768073242979767; Wed, 4 Mar 2020 07:35:48 -0800 (PST) Received: from localhost ([::1]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W3m-0001gM-4R for importer@patchew.org; Wed, 04 Mar 2020 10:35:46 -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 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 Received: by mail-wm1-f71.google.com with SMTP id t2so700689wmj.2 for ; Wed, 04 Mar 2020 07:33:21 -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) 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= X-MC-Unique: mIKbVQxRNP2wYB-ddTaSYA-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable 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=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"; text/plain; charset="utf-8" This header use the srp_* structures declared in "hw/scsi/srp.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =20 +#include "hw/scsi/srp.h" + #define SRP_VERSION "16.a" #define SRP_MAX_IU_LEN 256 #define SRP_MAX_LOC_LEN 32 --=20 2.21.1 From nobody Thu Nov 13 21:53:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583336226; cv=none; d=zohomail.com; s=zohoarc; b=PzhwuNBRhVodC/ORXKgmrAQNkmxkmAXXBqwxq+6dJPJkHcE8kF1k5PG9A7u28dX3F0nXQnLGUCi7oRRm2yzUPey03ywvOn7EO/w3jkVawuHkrU4plT84+iOPqI7xTHf9Gkibe4ZDO2hHe4gsWFqVcHlw/wnlO8r05TXz6wOuw8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583336226; 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=VSi8icYpglVwPM4o7Q8ZGmXm/EAEO/DibdkCD45Z2Kw=; b=Et3asttNDErcATlwb2A95URotuKIXOVh5I88OhbMivKlXuVePo+LjxW3A3DK8zwPJc0n5uXKIiV3vDKzoAp1a/uoL71/vS6hWl7ndKHmo5I3uYdqKoUGZ8UJi735CpcS/xT0J8oGTUnS1mlYWgjenJSmjec0BONeues7xkxm8is= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583336226736826.7187498777014; Wed, 4 Mar 2020 07:37:06 -0800 (PST) Received: from localhost ([::1]:35792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W53-0004JT-N0 for importer@patchew.org; Wed, 04 Mar 2020 10:37:05 -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 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 Received: by mail-wm1-f70.google.com with SMTP id y7so1005998wmd.4 for ; Wed, 04 Mar 2020 07:33:27 -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) 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= X-MC-Unique: ABfHAalFMVeAdR_g3vSoQw-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable 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=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"; text/plain; charset="utf-8" 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=C3=A9 --- 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_re= q *req) */ rsp->req_lim_delta =3D cpu_to_be32(VSCSI_REQ_LIMIT-2); rsp->tag =3D tag; - rsp->max_it_iu_len =3D cpu_to_be32(sizeof(union srp_iu)); - rsp->max_ti_iu_len =3D cpu_to_be32(sizeof(union srp_iu)); + rsp->max_it_iu_len =3D cpu_to_be32(SRP_MAX_IU_LEN); + rsp->max_ti_iu_len =3D cpu_to_be32(SRP_MAX_IU_LEN); /* direct and indirect */ rsp->buf_fmt =3D cpu_to_be16(SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_IN= DIRECT); =20 @@ -1088,7 +1088,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_cr= q *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); --=20 2.21.1 From nobody Thu Nov 13 21:53:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583336080; cv=none; d=zohomail.com; s=zohoarc; b=nDnEA/hiuMwow2ym5RMqH1C+G3oPtEADiM9WSvdyVMjys0JCs9oMFni4dhz8Ew7jJ5VDGigz7vDzhbgf2tJsDdhTaHIGXmcFlZKD0U4EQjwhYDtFWLS632naH7jDig0N+haxMd/2VRXfGEdakTDKlzX1NYASKBBHmVcwa24YZrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583336080; 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=Q8+T2y2EUOXy4UOGSX8jY7OAnypdhI625RaxfhFsFz4=; b=JGnFRApXAQMXvDKTle5m3N71y0ych466UyBsbN7xnU/kcsM/f0V8iZljpsZDWkdX36YBuvZ3Di5zWkFBY1DwLs0jyyhB+hhC85xzI+kdAe/x9MnGCWWW45aJTli0Oz/iPHFz+OkvePIg/GX/yfOnJHH0QIIi0FH3p2yDXvvZtvM= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583336080959162.2299991661913; Wed, 4 Mar 2020 07:34:40 -0800 (PST) Received: from localhost ([::1]:35710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W2h-0000Aw-S9 for importer@patchew.org; Wed, 04 Mar 2020 10:34:39 -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 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 Received: by mail-wm1-f70.google.com with SMTP id p186so705604wmp.0 for ; Wed, 04 Mar 2020 07:33:32 -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) 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= X-MC-Unique: W-CXajbFMNale2BSYjGOAQ-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable 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=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"; text/plain; charset="utf-8" We already have a ui pointer, use it (to simplify the next commit). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D (sol_not & 0x04) >> 2; if (req->senselen) { - req->iu.srp.rsp.flags |=3D SRP_RSP_FLAG_SNSVALID; - req->iu.srp.rsp.sense_data_len =3D cpu_to_be32(req->senselen); - memcpy(req->iu.srp.rsp.data, req->sense, req->senselen); + iu->srp.rsp.flags |=3D SRP_RSP_FLAG_SNSVALID; + iu->srp.rsp.sense_data_len =3D cpu_to_be32(req->senselen); + memcpy(iu->srp.rsp.data, req->sense, req->senselen); total_len +=3D req->senselen; } } else { --=20 2.21.1 From nobody Thu Nov 13 21:53:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583336156; cv=none; d=zohomail.com; s=zohoarc; b=MHYAWxGPP03JzRDRqaxYUjFMvgUrdoITYSz0/xQNMrho1NO3UdQYK3+AdHe1bsTmz8aacQIGkbMTwLGW/eGrnAyG4kKmVMN/73sjEMFp7cJgRaQ8kc3BOndKERP6WtlRdNMgrvCOBcyrCoY7VpGlsqeyX+mkfwLSADEFqN9WuB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583336156; 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=ncXvKgCh7oNRxNDfr+HT+HXiEUoLIL65NXTlOR8SRiw=; b=T2dYpVMj1I7gFP0TX4F5HAcJ7YUfBGYYsWzBIia27aK8ykAkEejuwPUXlA266MgQPWDA2epO23v00PZXVm8qd0sy7Ycu4+Oj5uXjhc/+NeZ4WTs2TEYWOGllCd8AxJrJWCaRL8XxuwhgG8iWrx1390d7KC5f8/EsOcZSZ3yaXts= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583336156349240.82125126497488; Wed, 4 Mar 2020 07:35:56 -0800 (PST) Received: from localhost ([::1]:35736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W3t-0001zz-Rf for importer@patchew.org; Wed, 04 Mar 2020 10:35:53 -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 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 Received: by mail-wm1-f70.google.com with SMTP id y7so1006160wmd.4 for ; Wed, 04 Mar 2020 07:33:37 -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) 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= X-MC-Unique: CEQtzDW0P9CP5AxUZ6E2UQ-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable 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=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"; text/plain; charset="utf-8" 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=C3=A9 --- 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; =20 +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) =20 for (i =3D 0; i < VSCSI_REQ_LIMIT; i++) { req =3D &s->reqs[i]; - if (req->iu.srp.cmd.tag =3D=3D srp_tag) { + if (req_iu(req)->srp.cmd.tag =3D=3D srp_tag) { return req; } } @@ -188,7 +194,7 @@ static int vscsi_send_iu(VSCSIState *s, vscsi_req *req, req->crq.s.reserved =3D 0x00; req->crq.s.timeout =3D cpu_to_be16(0x0000); req->crq.s.IU_length =3D cpu_to_be16(length); - req->crq.s.IU_data_ptr =3D req->iu.srp.rsp.tag; /* right byte order */ + req->crq.s.IU_data_ptr =3D req_iu(req)->srp.rsp.tag; /* right byte ord= er */ =20 if (rc =3D=3D 0) { req->crq.s.status =3D 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 =3D &req->iu; + union viosrp_iu *iu =3D req_iu(req); uint64_t tag =3D iu->srp.rsp.tag; int total_len =3D sizeof(iu->srp.rsp); uint8_t sol_not =3D 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 =3D &req->iu.srp.cmd; + struct srp_cmd *cmd =3D &req_iu(req)->srp.cmd; =20 switch (req->dma_fmt) { case SRP_NO_DATA_DESC: { @@ -473,7 +479,7 @@ static int data_out_desc_size(struct srp_cmd *cmd) =20 static int vscsi_preprocess_desc(vscsi_req *req) { - struct srp_cmd *cmd =3D &req->iu.srp.cmd; + struct srp_cmd *cmd =3D &req_iu(req)->srp.cmd; =20 req->cdb_offset =3D cmd->add_cdb_len & ~3; =20 @@ -655,7 +661,7 @@ static void *vscsi_load_request(QEMUFile *f, SCSIReques= t *sreq) =20 static void vscsi_process_login(VSCSIState *s, vscsi_req *req) { - union viosrp_iu *iu =3D &req->iu; + union viosrp_iu *iu =3D req_iu(req); struct srp_login_rsp *rsp =3D &iu->srp.login_rsp; uint64_t tag =3D iu->srp.rsp.tag; =20 @@ -681,7 +687,7 @@ static void vscsi_process_login(VSCSIState *s, vscsi_re= q *req) =20 static void vscsi_inquiry_no_target(VSCSIState *s, vscsi_req *req) { - uint8_t *cdb =3D req->iu.srp.cmd.cdb; + uint8_t *cdb =3D req_iu(req)->srp.cmd.cdb; uint8_t resp_data[36]; int rc, len, alen; =20 @@ -770,7 +776,7 @@ static void vscsi_report_luns(VSCSIState *s, vscsi_req = *req) =20 static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req) { - union srp_iu *srp =3D &req->iu.srp; + union srp_iu *srp =3D &req_iu(req)->srp; SCSIDevice *sdev; int n, lun; =20 @@ -821,7 +827,7 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *re= q) =20 static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) { - union viosrp_iu *iu =3D &req->iu; + union viosrp_iu *iu =3D req_iu(req); vscsi_req *tmpreq; int i, lun =3D 0, resp =3D 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); =20 - d =3D vscsi_device_find(&s->bus, be64_to_cpu(req->iu.srp.tsk_mgmt.lun)= , &lun); + d =3D vscsi_device_find(&s->bus, + be64_to_cpu(req_iu(req)->srp.tsk_mgmt.lun), &lun= ); if (!d) { resp =3D SRP_TSK_MGMT_FIELDS_INVALID; } else { @@ -842,7 +849,7 @@ static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_= req *req) break; } =20 - tmpreq =3D vscsi_find_req(s, req->iu.srp.tsk_mgmt.task_tag); + tmpreq =3D vscsi_find_req(s, req_iu(req)->srp.tsk_mgmt.task_ta= g); 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) =20 for (i =3D 0; i < VSCSI_REQ_LIMIT; i++) { tmpreq =3D &s->reqs[i]; - if (tmpreq->iu.srp.cmd.lun !=3D req->iu.srp.tsk_mgmt.lun) { + if (req_iu(tmpreq)->srp.cmd.lun + !=3D 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) =20 static int vscsi_handle_srp_req(VSCSIState *s, vscsi_req *req) { - union srp_iu *srp =3D &req->iu.srp; + union srp_iu *srp =3D &req_iu(req)->srp; int done =3D 1; uint8_t opcode =3D srp->rsp.opcode; =20 @@ -948,7 +956,7 @@ static int vscsi_send_adapter_info(VSCSIState *s, vscsi= _req *req) struct mad_adapter_info_data info; int rc; =20 - sinfo =3D &req->iu.mad.adapter_info; + sinfo =3D &req_iu(req)->mad.adapter_info; =20 #if 0 /* What for ? */ rc =3D 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; =20 - vcap =3D &req->iu.mad.capabilities; + vcap =3D &req_iu(req)->mad.capabilities; req_len =3D len =3D be16_to_cpu(vcap->common.length); buffer =3D be64_to_cpu(vcap->buffer); if (len > sizeof(cap)) { @@ -1029,7 +1037,7 @@ static int vscsi_send_capabilities(VSCSIState *s, vsc= si_req *req) =20 static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req) { - union mad_iu *mad =3D &req->iu.mad; + union mad_iu *mad =3D &req_iu(req)->mad; bool request_handled =3D false; uint64_t retlen =3D 0; =20 --=20 2.21.1 From nobody Thu Nov 13 21:53:33 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583336308; cv=none; d=zohomail.com; s=zohoarc; b=DX+4wtPr63cGIBtgJjVkRVc8MI99ZZYVS8V2ekigx6zg3byINlIhTyS9yu+wL6JrlN8sOse/hES9khNtsahhCjiGzBocsR6nK14dBwbBJ3VmyM5U+oI5O6W+Pi/rothrc/nkiGu/oyrDCXLCx5g4zTYSVd+WetPSxfogNNDSoBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583336308; 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=M6bOA2bmzs7vUmurz3p844VtrEnDUzC6kMVk052Rcfs=; b=fb/SKhpd56p7WpDTbuiwEbNoE4A+abdjxtdBbur1KR2MFvVLcL9gbsU5OmXxpSQY89gNahw4MILwK95tEMlf6E29vi7i217Hj5lG2rltDuh1YGRMSUWD8XKHybCSVs/Jq0VLxr4vCNPDqFiY/wzJSMch+C56yjyryTx9xF9oEdY= 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583336308056973.8646465043474; Wed, 4 Mar 2020 07:38:28 -0800 (PST) Received: from localhost ([::1]:35822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9W6M-0008Do-W1 for importer@patchew.org; Wed, 04 Mar 2020 10:38:27 -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 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 Received: by mail-wm1-f70.google.com with SMTP id v21so694466wml.5 for ; Wed, 04 Mar 2020 07:33:43 -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) 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= X-MC-Unique: bm9XURKgM6iR7sGxVrtWBg-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Transfer-Encoding: quoted-printable 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=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"; text/plain; charset="utf-8" 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 --- 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) <=3D SRP_MAX_IU_LEN, "srp_iu size inco= rrect"); =20 enum viosrp_crq_formats { VIOSRP_SRP_FORMAT =3D 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 { =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 (union viosrp_iu *)req->iu.srp.reserved; + return (union viosrp_iu *)req->viosrp_iu_buf; } =20 =20 @@ -184,7 +184,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"); } @@ -603,7 +603,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), @@ -1104,7 +1104,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); --=20 2.21.1