From nobody Mon Nov 25 03:42:11 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=1718957305; cv=none; d=zohomail.com; s=zohoarc; b=aaFqlWcuba3rBtceUnleQBVHpyHZTB+KVapHbL9Vt2/eQo8gkNEqM8W5+OybMnld7ulMrtrDFqdigqnMNgjTW2Ma1b449dITW2lN6m5/eRMmjBuu7Z+HCddmNVAfmk7EgIb8ZYB08npF/OorFlXl2tdgs4wMK9rAnU38ljew5Q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957305; 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=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=QvAWZCBliIKYuuEkhSY2xSXqW9Yc95B0reES+kvexI4j5khCQJBhPYclCN+Ly1UGWmR3Uw6nNGIC4O5exusiHhxr0SSxdNTX0EjVNWItmgbYygHDkxZzHdnKADjmkDMbC1KF7ZlS03qhLpenqYDbwCFS9tb0H+KGJbbYZOlFXQk= 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 1718957305283135.17648066586491; Fri, 21 Jun 2024 01:08:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJB-0000Kw-N2; Fri, 21 Jun 2024 04:07:45 -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 1sKZJ9-0008Vz-Pb for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:43 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZJ8-00006Z-3L for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:43 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42172ab4b60so17211685e9.0 for ; Fri, 21 Jun 2024 01:07:41 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248482f1c4sm2254535e9.10.2024.06.21.01.07.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957260; x=1719562060; 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=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=uoNsCivAPtjTeqM24po4apHb2hxNWXhF4njNivfLACjkapEqJCzQoe1fhPazTKnV9W MA7IOJ9M/pOoy40bD/ERRxHcd+Qy2bfvXuBG8N5EWImmjxUd2yWd4g3i3zf+c89Og441 vzDC8H+U91L/p/vGjhJmr34fGsidSs50XeORG91QA4Mchz90SsBpTAW64qW0yKiIlrPs brqJ/Q5gK1TmTNcMKhNb5aSb7r9R9WqcwI+jmS0O2wwJYVonLC7c5xCIkCh55MCg2sq1 uU+dt3vM/5P6NC55pyigab/LF8EIMYkh0XDVgM+k2yJ2jhkGWrGwLpYr7r1dQ1+qtfg7 E9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957260; x=1719562060; 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=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=t4fbXyeBtchMZa+4nTqA8SMAD6Db/bvMpsz36kWmtDejbyunbwM12gCtboHWzEx3nz i/l3eQO31yqqpGsohe+sUhLhOnxwmX6FPzWZZs/cjlDMYYIGqjqqjr/TzZEPyr6iOu25 lSn3vtvWgmkfmKNB4fuLIg8Kjqf8+asqMCM8QnFkRmrVL+Ql7yv9nwSkI4TOiMLWuGip hCfkXmq1k6uhxylYhIdsKNacnwYA87oPG6mAuq8oee+r2B9DniHRLsYF4PB2WC2NWtLj lOeLdGRinXLXJArcUIvTtPaDbtrZNG3baK37Yby3kJHPXNl6lNMa4vLxSGXzgpI5NavC 7F6Q== X-Gm-Message-State: AOJu0YwvjXouNqKODgMg787EjCYFiRx04bnxvcENX+/mP8am05rvJT34 KN+FWWlGykyEUWP8OQobyyG2jKrIUQ259eOKiKoMSfOIuotzbGwprRjXH/cfSW3lh8gPmQym0/C S X-Google-Smtp-Source: AGHT+IH31r+630bHuYtx5aBzBCMVZY8YoyyQJepeU1WQHAMxpevFgHrzUcOCAGM0QLWu5KI3hE3itQ== X-Received: by 2002:a05:600c:3b25:b0:422:7dc7:fc23 with SMTP id 5b1f17b1804b1-424752a5639mr51335615e9.41.1718957260063; Fri, 21 Jun 2024 01:07:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 17/23] hw/sd/sdcard: Only call sd_req_get_address() where address is used Date: Fri, 21 Jun 2024 10:05:48 +0200 Message-ID: <20240621080554.18986-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-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::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1718957306576100003 It will be useful later to assert only ADTC commands (Addressed point-to-point Data Transfer Commands, defined as the 'sd_adtc' enum) extract the address value from the command argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a0193a46ea..1df16ce6a2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1111,7 +1111,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; - uint64_t addr =3D sd_req_get_address(sd, req); + uint64_t addr; =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1237,7 +1237,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } sd->state =3D sd_sendingdata_state; memcpy(sd->data, sd->csd, 16); - sd->data_start =3D addr; + sd->data_start =3D sd_req_get_address(sd, req); sd->data_offset =3D 0; return sd_r1; =20 @@ -1261,7 +1261,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } sd->state =3D sd_sendingdata_state; memcpy(sd->data, sd->cid, 16); - sd->data_start =3D addr; + sd->data_start =3D sd_req_get_address(sd, req); sd->data_offset =3D 0; return sd_r1; =20 @@ -1337,6 +1337,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) =20 case 17: /* CMD17: READ_SINGLE_BLOCK */ case 18: /* CMD18: READ_MULTIPLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: =20 @@ -1357,6 +1358,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: =20 @@ -1415,7 +1417,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { @@ -1437,7 +1439,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { @@ -1459,7 +1461,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SEND_WRITE_PROT", --=20 2.41.0