From nobody Sun Nov 24 12:41:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722461174; cv=none; d=zohomail.com; s=zohoarc; b=H6n6HN1tfJh958OWoXWqpSyTxvKb5xELHM5xTaSRwy4L5dDTJJiP64YXQWT4SAuhIDTTOPwe20jxK0l8bH33VHXQL4UP7DGhQGubYfARRssTjWc0XuMEGDD6JF36z0ll2bTQ2T2IGGx3y3seJyoCUwP+8+JF4Uo291nsooyUIsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722461174; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=afy5w5WlycxN57mzTHEA+hxArAd0l+KLUuN5LjnCrM0rIETmPINhIjodG5AJAeKItRw0tNCvHZHC2G7nFPHOGGbw70znT+MK9MlVSTSBP4L2d3TxrEgiIM2N06R/b3MMLk611M4HlDhlYWTjIQllK+aNNlwLJgeiPJahfl4yPCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722461174239810.7961321415441; Wed, 31 Jul 2024 14:26:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGov-0007pq-Rh; Wed, 31 Jul 2024 17:25:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZGou-0007nN-7B for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:16 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGor-0002AX-Od for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:15 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2f136e23229so46199901fa.1 for ; Wed, 31 Jul 2024 14:25:13 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857d5asm17928671f8f.84.2024.07.31.14.25.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461111; x=1723065911; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=rDvtgVCKgwsQGA478CUXIzu75jL8QSrmVMfqKRotzBbS/sQvsQdDdyE5Wt8o9voY4r Zb+yT3WKMhFhHnTxo+WJHdku3SPr/By8aArsfFR6FWwT3x5XlNkxC4s28ynW4+iLx8wC Q5BugH45hl/VCRhej8ssh3KtbPbtJGuqQyXseRjeYn+Ajsfti0R2w8Y/EHoRwj4MLSn3 qkNnS1COXWtEA8EPkoQo7UPop68Xh+IwjdtCWMcQp6Na+eMf/dnp3etSbxz/FlI7lEk9 YPXF84DxDLgNglAOaCtvTIfk0XcWxfjz+dJztMJdqArcz30LRazOwtrko9r1B4RdG6g4 x7Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461111; x=1723065911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lmDycacciVDN5eRotRRZuulYkMaRluWb6sjuNguDD+M=; b=bz6lD5TS9Q17+i14b3JhrLzIYN1t3bqC2COH4uPJGlM3kIAATHXSa6hmQENkgoMVTF GxkeCUyQp6gLDvZxFbxjBLJD7uJeQlHlm2KgoAic4NRnlYdnPi5ynd4ZRCRVD2Sok7vv ja91Hd2SAF5BgpxpfP98f3lbJlqqmooNJ6v/kGkjhQvvmcuTCuyp6leewtzM8qbOd7B6 FJpq7gb9faxzqzUhZpTLusdF2GtXfLtjRPjynV6ix+a2GS3u7xffV7lesch3tUkKDkib 470XaBHPDzKI9hRfShYvze9oJisnUhA+ir/91SXX5BO0jGlc3QxzX65LbkFMlgHQuk7J EL5w== X-Gm-Message-State: AOJu0Yy24eOwMfrbpUZV8vb1qZmluNFftW5XPQFLlyvZj94eua56jCPg rRzBohMbWl9bi4dVaCFOT77ZtLpkV+wlQnFjgL74ylGA7Q/YI/zRUJD0RbdzUGGVUguB1pgeCnx 6 X-Google-Smtp-Source: AGHT+IF21v7RXbC4zE2kKVBGAtlj6ogTZmPz2NG8LRoGfLj11Hq+90jT5dDgvIksgMVhMjCINs0qMA== X-Received: by 2002:a2e:3517:0:b0:2ef:2b44:9977 with SMTP id 38308e7fff4ca-2f1531027b6mr3324571fa.18.1722461111245; Wed, 31 Jul 2024 14:25:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH-for-9.1? v2 1/4] hw/sd/sdhci: Reduce variables scope in sdhci_do_adma() Date: Wed, 31 Jul 2024 23:24:58 +0200 Message-ID: <20240731212501.44385-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722461175906116600 All variables are only used within the for loop. Declare them within it. In particular this resets 'dscr' on each iteration. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdhci.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 66b9364e9e..773f2b284b 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -751,20 +751,19 @@ static void get_adma_description(SDHCIState *s, ADMAD= escr *dscr) =20 static void sdhci_do_adma(SDHCIState *s) { - unsigned int begin, length; - const uint16_t block_size =3D s->blksize & BLOCK_SIZE_MASK; - const MemTxAttrs attrs =3D { .memory =3D true }; - ADMADescr dscr =3D {}; - MemTxResult res; - int i; - if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) { /* Stop Multiple Transfer */ sdhci_end_transfer(s); return; } =20 - for (i =3D 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + for (int i =3D 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { + unsigned int begin, length; + const uint16_t block_size =3D s->blksize & BLOCK_SIZE_MASK; + const MemTxAttrs attrs =3D { .memory =3D true }; + ADMADescr dscr =3D { }; + MemTxResult res; + s->admaerr &=3D ~SDHC_ADMAERR_LENGTH_MISMATCH; =20 get_adma_description(s, &dscr); --=20 2.45.2 From nobody Sun Nov 24 12:41:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722461175; cv=none; d=zohomail.com; s=zohoarc; b=nk+okE4Liim2Ihkj/qPXMEJkIoTeJWfCW0dpGVHN+NwQWEtGJREF9O5YTU3U2KiDNtJe4m77ArkNmSceuyxLMIOoOssCB1lJOKgoB0JLDqMLtcj+oKF5O2rig5SNWT05hU2xQ1Akkr8BPgEUH8XLC4YWs4QSKKeUzhcGWmvrS58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722461175; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2dqJthe0fo5ExOTjiiBy7T5s1CTErpsVhn7olcnYzJ4=; b=dc9KfNnAY2xn6zOY7SRuKZU3un9d4KEiWZs9VoCsIsLt4EdrRUAyhFsYZZdAuN1nnklZRCB0bBNXCDMnM7VHLw5bjY7R6lWA2be3dQk9QgJu4cwBYAHl9Q7r7vJIu59upBOMn+i2r+08Q63zcyoMdMYpdZ6zFCzqC7CQmvXm7pU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172246117553038.20650201954925; Wed, 31 Jul 2024 14:26:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGp1-000815-Ej; Wed, 31 Jul 2024 17:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZGp0-0007z3-Ba for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:22 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGox-0002Bf-Kh for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:22 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4281faefea9so28942745e9.2 for ; Wed, 31 Jul 2024 14:25:19 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367c0889sm17960188f8f.22.2024.07.31.14.25.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461117; x=1723065917; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2dqJthe0fo5ExOTjiiBy7T5s1CTErpsVhn7olcnYzJ4=; b=GgPNbAysC4VXSAdVLlg3QIg5wtHE5SuAm0BBpMFIxFyPB8Nr+cN4/jBkvqT1NqgpGK 8EozHKhkoIRcYRm1Ghyh/5MXnXjTf5+yzdtu7QYEUgznhwi72WPYAIeZKv+ASIK2imqv kmuGPvlOsxq0442sLdDCNlSR1WcwkXMV48XBKnfk9JbNJaZaaH4ZyrAZZ+C0ARBTHoeh dIG4oMn7vYylgcz9kfDAl9E10b9hQAC0bo8YI07+2VNRFrwcgupAA/Bz3Oz3gY38ucDG dXpdmh7Z30yhzEfywRRxlA/ej38cwxroFfJTVCElvZV+v0r9zf2cKNy9vg/oLvQ9v7vO vJwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461117; x=1723065917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dqJthe0fo5ExOTjiiBy7T5s1CTErpsVhn7olcnYzJ4=; b=rCb6HvPTeeCQMTHmCh6fc3AGoK6Pxy8INmFlbNO7QihaDI3ivN/bqupvGYA1eAAcJ/ WbG/Z1IHhBGDuO5lfKVAP48VQhexS5jXVuD001qHcvNvnaOqiUhpDInXCl4XnYzuiJIs BKM1k5h6sVB25MdoocoOIY/o7K4o7EWh+kFR1VUYTm4H8vc+seMGr2wjXR/HjOBzMdDm LBneFnydWWGsRzVPGipFxGwJyq2CQ1x7fKEe7hyejzsYrtNE8gvLNskwUpFrkV99wUtc HvzsW3l2OMux2QelLTfppz1viva+kww34ecUx8KSO/wcVNNWzsz4Vp3t23Rg9oMceN6c oGiQ== X-Gm-Message-State: AOJu0Yyl1q7P0v9qW2Qiqb3yxS/MqNpxYcnLxLSPYKpuW/p1yxIAIV8i yV3Qx2V5NcXltDe8vHq0obYMqErK1mL4y7rQkOCLHk6O37IPKvhAOjRo/yD3/jj4htTa42cAUIF g X-Google-Smtp-Source: AGHT+IGa5BxCQhH8ge/A5VN3Uj1JVF3dXZIkEC9f8w/HUC5vTYKEU9rawL4Q3K9Seim9a1oILo0PWA== X-Received: by 2002:a05:600c:4fd3:b0:426:5dd0:a1e4 with SMTP id 5b1f17b1804b1-428a99dfc67mr4484055e9.8.1722461117549; Wed, 31 Jul 2024 14:25:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH-for-9.1? v2 2/4] hw/sd/sdhci: Reduce variables scope in get_adma_description() Date: Wed, 31 Jul 2024 23:24:59 +0200 Message-ID: <20240731212501.44385-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722461175912116600 The 'adma1' variable is only used in the SDHC_CTRL_ADMA1_32 case, and 'adma2' in SDHC_CTRL_ADMA2_32. Add braces in the switch case to use local declarations. Do the same in the SDHC_CTRL_ADMA2_64 case because we'll add a local variable there in the next commit. Replace 0xFFFFF000 -> ~0xfff to align with our codebase style. No functional change intended. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdhci.c | 87 ++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 773f2b284b..0a95f49b93 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -700,50 +700,59 @@ static void trace_adma_description(const char *type, = const ADMADescr *dscr) =20 static void get_adma_description(SDHCIState *s, ADMADescr *dscr) { - uint32_t adma1 =3D 0; - uint64_t adma2 =3D 0; hwaddr entry_addr =3D (hwaddr)s->admasysaddr; switch (SDHC_DMA_TYPE(s->hostctl1)) { case SDHC_CTRL_ADMA2_32: - dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), - MEMTXATTRS_UNSPECIFIED); - adma2 =3D le64_to_cpu(adma2); - /* The spec does not specify endianness of descriptor table. - * We currently assume that it is LE. - */ - dscr->addr =3D (hwaddr)extract64(adma2, 32, 32) & ~0x3ull; - dscr->length =3D (uint16_t)extract64(adma2, 16, 16); - dscr->attr =3D (uint8_t)extract64(adma2, 0, 7); - dscr->incr =3D 8; - trace_adma_description("ADMA2_32", dscr); - break; - case SDHC_CTRL_ADMA1_32: - dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1), - MEMTXATTRS_UNSPECIFIED); - adma1 =3D le32_to_cpu(adma1); - dscr->addr =3D (hwaddr)(adma1 & 0xFFFFF000); - dscr->attr =3D (uint8_t)extract32(adma1, 0, 7); - dscr->incr =3D 4; - if ((dscr->attr & SDHC_ADMA_ATTR_ACT_MASK) =3D=3D SDHC_ADMA_ATTR_S= ET_LEN) { - dscr->length =3D (uint16_t)extract32(adma1, 12, 16); - } else { - dscr->length =3D 4 * KiB; + { + uint64_t adma2 =3D 0; + + dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), + MEMTXATTRS_UNSPECIFIED); + adma2 =3D le64_to_cpu(adma2); + /* + * The spec does not specify endianness of descriptor table. + * We currently assume that it is LE. + */ + dscr->addr =3D (hwaddr)extract64(adma2, 32, 32) & ~0x3ull; + dscr->length =3D (uint16_t)extract64(adma2, 16, 16); + dscr->attr =3D (uint8_t)extract64(adma2, 0, 7); + dscr->incr =3D 8; + trace_adma_description("ADMA2_32", dscr); + break; + } + case SDHC_CTRL_ADMA1_32: + { + uint32_t adma1 =3D 0; + + dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1), + MEMTXATTRS_UNSPECIFIED); + adma1 =3D le32_to_cpu(adma1); + dscr->addr =3D (hwaddr)(adma1 & ~0xfff); + dscr->attr =3D (uint8_t)extract32(adma1, 0, 7); + dscr->incr =3D 4; + if ((dscr->attr & SDHC_ADMA_ATTR_ACT_MASK) =3D=3D SDHC_ADMA_AT= TR_SET_LEN) { + dscr->length =3D (uint16_t)extract32(adma1, 12, 16); + } else { + dscr->length =3D 4 * KiB; + } + trace_adma_description("ADMA1_32", dscr); + break; } - trace_adma_description("ADMA1_32", dscr); - break; case SDHC_CTRL_ADMA2_64: - dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, - MEMTXATTRS_UNSPECIFIED); - dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, - MEMTXATTRS_UNSPECIFIED); - dscr->length =3D le16_to_cpu(dscr->length); - dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, - MEMTXATTRS_UNSPECIFIED); - dscr->addr =3D le64_to_cpu(dscr->addr); - dscr->attr &=3D (uint8_t) ~0xC0; - dscr->incr =3D 12; - trace_adma_description("ADMA2_64", dscr); - break; + { + dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, + MEMTXATTRS_UNSPECIFIED); + dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, + MEMTXATTRS_UNSPECIFIED); + dscr->length =3D le16_to_cpu(dscr->length); + dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, + MEMTXATTRS_UNSPECIFIED); + dscr->addr =3D le64_to_cpu(dscr->addr); + dscr->attr &=3D (uint8_t) ~0xC0; + dscr->incr =3D 12; + trace_adma_description("ADMA2_64", dscr); + break; + } } } =20 --=20 2.45.2 From nobody Sun Nov 24 12:41:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722461185; cv=none; d=zohomail.com; s=zohoarc; b=YQ/6v/8XKeZ4JG7M95etDCSqZoCeZMRT/S7/Y8z1mdqKUVvJtXGF1Z7wOFLUTDo4wuu+w+YZpkY5b2vTXiOM0Os7nnGPK3cQwx80d5s9TK8nk+uix6WbkP3qccflKoUVvVqgYDPiUnRQhhw1Tpsu0JC+1Z0PjEu0+mprLNceKz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722461185; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; b=fEu9HVoMQijNttJJIjM3DtKNcnNT4mBQeJtQLTfyXtfS1vOPrbHDUyLUKpLo8mAAP8QcxuVv0RkAixsNYtqtiNVF1HUJa4/EaRVkFYkl9mHYW8Hh93pvvZochqNDnp7dJ6nFPXmj2hFWIbYLeOlsxA64a9B4Oq7Vrf06Ae3Q6I4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17224611850491017.2116410064046; Wed, 31 Jul 2024 14:26:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGp7-0008M0-47; Wed, 31 Jul 2024 17:25:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZGp5-0008LI-ON for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:27 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGp4-0002EX-8x for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:27 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428163f7635so39240965e9.2 for ; Wed, 31 Jul 2024 14:25:25 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282baccae2sm34983355e9.30.2024.07.31.14.25.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461124; x=1723065924; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; b=Guf4mfy+Pa4b4IAfKEe/iv+6c3fe8KtDPXzmyIC1wLKBfri+6rfzM+wRIrUNFbnYU6 23S/wgVHBz/Pbs34WjFTTWaP6N0kAk7xk3zSEidzH+kMKlo8783MeGCq9XufBSs7E1Kc lg2qTtW9OF3ICCrACvYL09Rs3yJtRD5RXQWrPVl6LUElAyYF2qjF/fRVWkSRDvHOMJQj NljPjo7SqBLK2G6XQX7DCum6YcxXDEdyQohrIIIGuHEe2zam5pJtZXEPl8DEjZ+Y4Jh0 mVCy37VPErc5KuYLnL2OHYsugEiBqxqc9i0xIBv9d0wCuu+xLLcxD1Q/bgMxGhmM7ewH pziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461124; x=1723065924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; b=rQ0KZii78WgQSmDU4zfVn+j+J9EgrguGYFFzMWeFGZ9DosjVKdExl2hR1tkZPRR3pk cUPYH1bylX/Vdje1Hh6/AZPPFA4DNcyYknbxVYoqWClv03A19vxLfp4fvb/6SB7Ofxb9 nr6g6HpOJQ+3cfu9coIA80/slZVjkGSMOO0AzzAS9Ub5HWViyZbUjx+AWwd5TVrWn02/ NRXLuW6GOy019dpa4CQUSV02Zlep5PGkqLjg4gSMfUnzTQBV0vCZ1QHG9Z4JwZAT/A80 3dGq2j3XFW4yiIrUMct1srwgvhdnLA+YFkfeIwvgq9ATzpFF+5ZmVAHfiSLVsbyDMivC jNtQ== X-Gm-Message-State: AOJu0YzIiRUOVeROncAcC/ITwbm+5tKkoP8uXuIZr7KjsN++b+ZHjGHp /Lvq37nhmNz80MgRlMfurXKNG8x/49sfwxVSOjfkWjN9CO+FxW/sQ3h+B0et2xYaR1FRbiwT0vd z X-Google-Smtp-Source: AGHT+IFBNMvEtEwBQ+Q5LVFvrrOzmRaVx39hGRDTtRbQh5GJXCpnQCMe5JrPciQ9Yghz9IfkI1HqAQ== X-Received: by 2002:a5d:6701:0:b0:362:c7b3:764c with SMTP id ffacd0b85a97d-36baaf762b8mr227649f8f.48.1722461124140; Wed, 31 Jul 2024 14:25:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH-for-9.1? v2 3/4] hw/sd/sdhci: Read ADMA2_64 descriptor with a single dma_memory_read() Date: Wed, 31 Jul 2024 23:25:00 +0200 Message-ID: <20240731212501.44385-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722461186058116600 Instead of 3 consecutive dma_memory_read() calls, use a packed structure to read the descriptor in a single call. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdhci.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 0a95f49b93..2d8fa3151a 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -740,16 +740,20 @@ static void get_adma_description(SDHCIState *s, ADMAD= escr *dscr) } case SDHC_CTRL_ADMA2_64: { - dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, + struct { + uint8_t attr; + uint8_t pad; + uint16_t length; + uint64_t addr; + } QEMU_PACKED adma2; + QEMU_BUILD_BUG_ON(sizeof(adma2) !=3D 12); + + dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), MEMTXATTRS_UNSPECIFIED); - dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, - MEMTXATTRS_UNSPECIFIED); - dscr->length =3D le16_to_cpu(dscr->length); - dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, - MEMTXATTRS_UNSPECIFIED); - dscr->addr =3D le64_to_cpu(dscr->addr); - dscr->attr &=3D (uint8_t) ~0xC0; - dscr->incr =3D 12; + dscr->length =3D le16_to_cpu(adma2.length); + dscr->addr =3D le64_to_cpu(adma2.addr); + dscr->attr =3D adma2.attr & (uint8_t) ~0xc0; + dscr->incr =3D sizeof(adma2); trace_adma_description("ADMA2_64", dscr); break; } --=20 2.45.2 From nobody Sun Nov 24 12:41:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722461158; cv=none; d=zohomail.com; s=zohoarc; b=VHswfjSweAKJ7whc0jWHJ84Q4eYseiPoPTPV9YHuku4m9J2sPYQNnKmqQeV1b9bbDNHDajsX+WuNlVvrMZlSH1sWLOSgZRpsX+nZDMHnQBwfzOntKXbXkKwfiQcZmnxeGTyl4L3vDgTcpjole7jDzZRNGxSnpm7gcDbSMfNwA98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722461157; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DSCKNCS385Z7tdy/qq25A1b3soTdqIksx3r0Ajnm5Pk=; b=NUddxemtwOkybtSa+utuGi7MnLRGi0Jeokj51uOrtiAFhltTZ826F+NMs81/L6qLbZpG5eQsgQmHwf36VYuc7qMw97oXs/c+g/5Uc9RVjQor0dtJ/bYEWlrxnHb7Ip445VtDj+WIpE8mpMiwiO5qyA4MhrGBPZpu7SFA+vcOeCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722461157978464.79257603463793; Wed, 31 Jul 2024 14:25:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZGpF-0000D8-PC; Wed, 31 Jul 2024 17:25:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZGpD-00008b-GP for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:35 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZGpB-0002Ha-3X for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:35 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3685a5e7d3cso3542580f8f.1 for ; Wed, 31 Jul 2024 14:25:32 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367d95c7sm17825028f8f.37.2024.07.31.14.25.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461131; x=1723065931; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DSCKNCS385Z7tdy/qq25A1b3soTdqIksx3r0Ajnm5Pk=; b=sz8jzUALidOE1rs3PV9L2UlPNZKnPs8R3QqJU+M5g6um9MLDJUo7DYq9pbzd9ztBJY IGB1Q+neZOO6YDdDHN27cO77jnmpiB2xWlyyS9jkRD+MrPP1OuOVyk28elTkIcvqIop6 7W/VDtryzqxM3Bmber7JlqpNmaO7E+ajRKWwdT8T9B6F5uImeJN918/a3Fea/ZyOlE1M oESrz9NMgNHENh9pGh/PFx0RHCRVHGYUFtgcFYqixl339+5bmKY97J01k7iC00vHhfJW 6ETNWtym/3KHlYBxu9vXK7EBI8yVUPYubNiu+IABCQ7iKtTVnvSYxPA3retzqA6kLAkX vylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461131; x=1723065931; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSCKNCS385Z7tdy/qq25A1b3soTdqIksx3r0Ajnm5Pk=; b=SdSYwlfVyeEh8dIOMRkYLDVApvcJqeytz58Qj5eAWKwvcY1v3A60MT0TlMqvwvtop/ E6EJ5lu1HTFwJ2d7uiOh2jgqCHJz78NNZ2KPUs4LCA+EuuM1hELm+HVYSir56tdpTXaM L6cCGaeTAbVBKbd6bWSKV+LVU+7l4c08GYNmx4F/mJbsDQ3TxXjTH4zmlHYRq0bwsw2K 6+qoFSwkRWNl2VLhb8XZ2RCIiVTxHkIwGcbAUnyk3ucSmdFZsQ0ftiOFydlzFUfFgEZ5 /bxmIq7j8lUy87hADbJdAULXCDba8OMgBil2taWd2vDy5xmeVyVraR2iP3fKTU7BDrrL iF1g== X-Gm-Message-State: AOJu0Yw4vd0Acmf0kJkwfEdD7iGun3lrQsWXla4OwfACDQfbnooMDFnM mKNbV33lx0Ps8UaXByNmpOILUnZnPb+TfsgtAdzKPVaZpN48lSPcC4KoELo49LTRE13bougT0mM d X-Google-Smtp-Source: AGHT+IEeu+k9huFO1cfrt9EXZTMiEMNZH103Pt7NmOXYT4BOnV71kbFvIg1M0+7qYRrFDhRHahCntg== X-Received: by 2002:adf:f6c4:0:b0:367:8e53:7fd7 with SMTP id ffacd0b85a97d-36baace2a4cmr402984f8f.28.1722461130582; Wed, 31 Jul 2024 14:25:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng , qemu-stable@nongnu.org Subject: [PATCH-for-9.1? v2 4/4] hw/sd/sdhci: Check ADMA descriptors can be accessed Date: Wed, 31 Jul 2024 23:25:01 +0200 Message-ID: <20240731212501.44385-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722461160089116600 Since malicious guest can write invalid addresses to the ADMASYSADDR register, we need to check whether the descriptor could be correctly filled or not. Cc: qemu-stable@nongnu.org Fixes: d7dfca0807 ("hw/sdhci: introduce standard SD host controller") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdhci.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 2d8fa3151a..6794ee2267 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -701,13 +701,18 @@ static void trace_adma_description(const char *type, = const ADMADescr *dscr) static void get_adma_description(SDHCIState *s, ADMADescr *dscr) { hwaddr entry_addr =3D (hwaddr)s->admasysaddr; + MemTxResult res; + switch (SDHC_DMA_TYPE(s->hostctl1)) { case SDHC_CTRL_ADMA2_32: { uint64_t adma2 =3D 0; =20 - dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), - MEMTXATTRS_UNSPECIFIED); + res =3D dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(= adma2), + MEMTXATTRS_UNSPECIFIED); + if (res !=3D MEMTX_OK) { + break; + } adma2 =3D le64_to_cpu(adma2); /* * The spec does not specify endianness of descriptor table. @@ -724,8 +729,11 @@ static void get_adma_description(SDHCIState *s, ADMADe= scr *dscr) { uint32_t adma1 =3D 0; =20 - dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1), - MEMTXATTRS_UNSPECIFIED); + res =3D dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(= adma1), + MEMTXATTRS_UNSPECIFIED); + if (res !=3D MEMTX_OK) { + break; + } adma1 =3D le32_to_cpu(adma1); dscr->addr =3D (hwaddr)(adma1 & ~0xfff); dscr->attr =3D (uint8_t)extract32(adma1, 0, 7); @@ -748,8 +756,11 @@ static void get_adma_description(SDHCIState *s, ADMADe= scr *dscr) } QEMU_PACKED adma2; QEMU_BUILD_BUG_ON(sizeof(adma2) !=3D 12); =20 - dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), - MEMTXATTRS_UNSPECIFIED); + res =3D dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(= adma2), + MEMTXATTRS_UNSPECIFIED); + if (res !=3D MEMTX_OK) { + break; + } dscr->length =3D le16_to_cpu(adma2.length); dscr->addr =3D le64_to_cpu(adma2.addr); dscr->attr =3D adma2.attr & (uint8_t) ~0xc0; --=20 2.45.2