From patchwork Mon Jun 24 13:14:22 2024 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: 807036 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878479wrt; Mon, 24 Jun 2024 06:18:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSMXFD1mvhO4smOVDULH2wK6u9cch7ECOKzqMQdDPNq/ji4guCizEAwYCoW8ayR+qS4phezLyodZtYvtPRStTX X-Google-Smtp-Source: AGHT+IEMvUuBWTDzhy2uh05R22CUiKaUXs74//hRPRVfH+R3IxJGrg9yCLcs035yYlQFDvI9WB4E X-Received: by 2002:a05:620a:2951:b0:79b:eac1:52da with SMTP id af79cd13be357-79beac15353mr427671685a.16.1719235123647; Mon, 24 Jun 2024 06:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235123; cv=none; d=google.com; s=arc-20160816; b=qOyXpWqvvImwwdlftYacLpdzgXdGMT1BmZaQdAPjHOacTTOhpc6aZTztUMjy/wjhFQ 8G7Uno6kMmikZPkUZIQwOiw0CExra+NSc0w0baqyB7LaQKfyNELxvalX/vA9pkY+gXFZ xcymok7H4j+rkux8bs78ePuBSgHMDhV1AwImdnegaEjDCE+2OBuE87YVA/lYJbt5vT7G 29xFLwVybe8VvjHNf7nnZ+Uz7hFkuIWyVmyv8yIyidgxz0E1+iaBUjlH/3h6y7T4OYJt jJasAXOUArRl51QA1mV3Tugxe1d5HRoDIDkYLhw1cX6/JZyTUREr2huqqjZotAniGYNV LKYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7mJMievbUPjRodtOESUjRxIX72igzigbVmP1VpcJ+Qs=; fh=KlSE9ML5fZB/DxDOCqHNqoSGg+cM4CHFOUygk1jAoeY=; b=Stg+r7maE/r9LSD+lpQ5jObpBRNGo12CCAMSBeuiltrTiuijTwS90rHLbfjNQ7ADre SgmtpakHWZAEyvGAjAIgR05e+yT49PvOnVDIJY2UeSJnD9GS/XJnUlj4kKfZWVKFsOeP sKEGesixIC2nvFpRhmYANu4tYe107BghNoIptI9Im52uQ8XgznI/f3KGIGevXhQOXgbw d2hvQTBQGYIv5TnWhgeEWbwFVjBSuvWYHeRmFr2eUosYD8JZrR96sB7y3BIpb/3QXODG DqXB9BdQwASKyU2I5s2zRLcV9JC3CQ4QdXfpZhMNfEEvvDAp0pPs0CfuBlI0NIfqoVbo d2uQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AyLzsuEv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce882bbasi860055785a.36.2024.06.24.06.18.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AyLzsuEv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjX3-0001Lm-Ir; Mon, 24 Jun 2024 09:14:53 -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 1sLjX2-0001Ld-6p for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:14:52 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjX0-0004x3-Ke for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:14:51 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ec5fad1984so15556521fa.0 for ; Mon, 24 Jun 2024 06:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234888; x=1719839688; 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=7mJMievbUPjRodtOESUjRxIX72igzigbVmP1VpcJ+Qs=; b=AyLzsuEvGwqKY+pNXiS6CKQuRD1FaJkYZ4FlJiCEg9DJss/XOAxVJix9cy8c41qifr J/obTuV8jwWhIRA3ONHYRWzTizYVGGfEbXj5716qV9Vxji7WPQSC9d3WYgYW6Gvmnvfa aY041ASuDB6KJfbASvDmZjeLt/Y6HzbF5iaPaJ6AGMNEmlP7qNiQt6y/p5wtbejrH1ih eiNXRJnV9ayr3+TkDw3JIcJGsWdgutyYJ0FAv+mTJk4olFERVqIsgyhFfFLtnE7MFTeA Q+L1sSTo+CGvIF5jQZWoV0ma6J61hL5RJvlHP9WHPfRM0ouFBbdRPP3aVsyjwvlmcvlF k2yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234888; x=1719839688; 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=7mJMievbUPjRodtOESUjRxIX72igzigbVmP1VpcJ+Qs=; b=MMoR5cAXprJKP91uLAoQu7OS5ZTUNFVWqsvyZlodCEPoDcasOnnCrJU/1ugFTv2y7w 4Tzg+6hSZIg8kmd3qRR79w3zkm3Gv3RdQIg1Ddx9t9eb9dnPVloCc/A2hfX1gx51sQ0J xcEc0p7aMT+78Wk03xKrIF2u3VudR9gh75h+ug+GhFrLT/HYUy8vsb3IHDdY74lXomNg CGFpVEmrKdHEFpwBuX3Q7amiuEAfSDTBzKKR7/bMbveR/FFTT/SPKZz42cGTSKesYDna qMVeyp3vp+UgmyVLhr9JVtpurumUZhECGGoQef/1O9X9z54qq9BBEL/Z98uLE3IPzy6o aIqg== X-Gm-Message-State: AOJu0YzSQwscAboFnzuPsglkbIzj5E6a+v/h08hIt02HjhtMIa8xjVWm EIawNV2JnAAo9A8urAQntRJCKYvdMYg7LJdHbw4AfisTe7M2g4oLcr1GaoRGq3yefI+JrtG2BAp P X-Received: by 2002:a2e:918a:0:b0:2ec:4086:ea66 with SMTP id 38308e7fff4ca-2ec5b2fc27bmr38710701fa.4.1719234888511; Mon, 24 Jun 2024 06:14:48 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663ada0bdesm10021016f8f.113.2024.06.24.06.14.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:14:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Richard Henderson Subject: [PULL 01/19] bswap: Add st24_be_p() to store 24 bits in big-endian order Date: Mon, 24 Jun 2024 15:14:22 +0200 Message-ID: <20240624131440.81111-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Commit 14180d6221 ("bswap: Add the ability to store to an unaligned 24 bit field") added st24_le_p() for little endianness, add st24_be_p() equivalent for bit one. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Reviewed-by: Richard Henderson Message-Id: <20240621075607.17902-1-philmd@linaro.org> --- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index bd67468e5e..ad22910a5d 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -38,12 +38,14 @@ static inline void bswap64s(uint64_t *s) #if HOST_BIG_ENDIAN #define be_bswap(v, size) (v) #define le_bswap(v, size) glue(__builtin_bswap, size)(v) +#define be_bswap24(v) (v) #define le_bswap24(v) bswap24(v) #define be_bswaps(v, size) #define le_bswaps(p, size) \ do { *p = glue(__builtin_bswap, size)(*p); } while (0) #else #define le_bswap(v, size) (v) +#define be_bswap24(v) bswap24(v) #define le_bswap24(v) (v) #define be_bswap(v, size) glue(__builtin_bswap, size)(v) #define le_bswaps(v, size) @@ -357,6 +359,11 @@ static inline void stw_be_p(void *ptr, uint16_t v) stw_he_p(ptr, be_bswap(v, 16)); } +static inline void st24_be_p(void *ptr, uint32_t v) +{ + st24_he_p(ptr, be_bswap24(v)); +} + static inline void stl_be_p(void *ptr, uint32_t v) { stl_he_p(ptr, be_bswap(v, 32)); From patchwork Mon Jun 24 13:14:23 2024 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: 807037 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878495wrt; Mon, 24 Jun 2024 06:18:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUjz+cea6PD6PGt1D0W9GwtC8z0ORdubC4bTJZJQEe9zsM//m5AWlVkBwQv4OI1p72oL0WwgjzY3RWId+brbDfy X-Google-Smtp-Source: AGHT+IEHATdmh6O+VkZZDJoSRWNKYCpJvqOJ6LbHxTobCFYDqkDBWu2X1jtTFs4TKcp54cDgJcGC X-Received: by 2002:a05:622a:1491:b0:441:207b:51b4 with SMTP id d75a77b69052e-444d9226578mr51983161cf.63.1719235126100; Mon, 24 Jun 2024 06:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235126; cv=none; d=google.com; s=arc-20160816; b=K4grzHG2RbDwdBOytPb860DmPjxXxv15tpFi4jQyuu41DZDzFztoY/LxkWPuMWiFuG R93Rkwn8puL5N+3ITxIqdrxgupUqkm2MIV4HS3hL6tZ2cmd2rsPLA7KVMfW70MWq5aKm gfIIZKvHKPM5eO/RRjJjkkjlYTO9WnET3ekZgkc3nxKxWBASsAjJnzelNWVz/k35J0Mb rp5AY13Axz/dhGvmEPVyCvzRDpDo8ntHbSRjw4Vj86YSFePmQ67HIT3TNJ9t7nPvPfwt wZJWoQISFxQGJdqd4fdvWmo0W5K6ZfU9fJc3TN82c6yHDTn4IdapzxtTvH9rsW5Smn9Q cC/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aSK8hO4sLlN1hU/1KYxtFOH8CJir4+Yl/Ws4QmLQZLA=; fh=tt+3ECGW8cDEhVx2HU0Owtb2/5U3Hq1G+1swpphCm4g=; b=k5J6ScsUy/5/DRmq74YSrYbJCjoDiXtBr/NmskHwtHvkPuCnqBMrt4Z7GcuNvIMMvd afcCgnL8+YLTxsHkUy9sF+3X6ie9W9z3yYist8JD6IjjZ/Ymec0Z4WS0ELcomIVWCDJi CAHR+Hk+3wUAgxI509GvrRcw7TENtfsaMT9Mbk+iVXIsEujnm1Dajq6+Chtn6R3TEWhr a+0enGWixXSo2vFzUceP2n0hIwbwE9vireIAjVCApXRNzu8gXrDFehz2B1h6Dk18Ry3x hupgAdJce/+bSwe27iD4uNcG8xzlD5N3oWgyOgL5RiGf6vbmchOljS/TnxuIhf49fwzg Dq/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=upOoYYP9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c9b3bbsi89746651cf.694.2024.06.24.06.18.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:18:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=upOoYYP9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXA-0001QL-1g; Mon, 24 Jun 2024 09:15:00 -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 1sLjX8-0001Mo-BR for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:14:58 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjX6-0004yd-Dj for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:14:58 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4217990f8baso37997685e9.2 for ; Mon, 24 Jun 2024 06:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234894; x=1719839694; 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=aSK8hO4sLlN1hU/1KYxtFOH8CJir4+Yl/Ws4QmLQZLA=; b=upOoYYP9Vsy5BRy55w+Egr7n6iTSPcyii49ZI9cECZIr7UYB4jX4K9fRJKquQ7dH4l Lv7GZ082QeVTDCHKLxvO7R6MhR6zU++xlefFmfsIgml/TMXzhCU4lFKNYa+LDA6K8lWX Hg4ugob2kVrL4EDc8F65TsZ6+1xxTw0d8Omp7zd9psdTI9Z6OnebaDnQW1lVrPxsfPj2 MmcMiD4xQrDErVztytfU1fdTLbBjmrL8Dxt6dwr8Ip99PEqMnPsBPNY9tT089xO9ie56 q+YORExKpOR9g/thnBQjiwfoURbtmJNZC6LEZMg8W4D2/rHfzMlnXjfL+XSrzn26ZxYu 7OsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234894; x=1719839694; 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=aSK8hO4sLlN1hU/1KYxtFOH8CJir4+Yl/Ws4QmLQZLA=; b=IWWiuT1z4bFEmZm4EnkTfwGN9ebqIPcD1p/8Q4kcbIE1ljPZ6VF01FYIfkyQQl7r2N u1IyIkU90SprB5zewLgp1+aA3TP87lJK3W3f0MHo8u0OcbkCxhLx9UOlU74MAuwlDQnS 5Ip/T+sqCSCY+1DxLjAAJWm7bmBzBopp1gfGr+rX3IGZU5I8mxNSs6d1DDvz/lGe58gb 3mUow2fxZmBXC1XorkEV4S8u+Yy5/8a4lGG1/XT2PUiMedAn7ybh6uomLLVfGTK0wVuz bQE3o4quYvQV8YGkCZlba+Y6OyH8A9EeiiJE+BjyJoTJi4GsAf7YhUAcsJpxA5WFIk4/ J78Q== X-Gm-Message-State: AOJu0YwmgGcoTsMNzZ8Q+ziZua8FMu433JQYajuP2ckDqP79qJx2pHE/ wYsumSlE2Sa5h/7sUujoKxRl68fyftoIz6nfo/9KXTift58gGKyMNeO0c5l7fc+LlCRuU0e/Z+y 8 X-Received: by 2002:a05:600c:818:b0:422:1163:4488 with SMTP id 5b1f17b1804b1-4248b9c9c5dmr35020065e9.25.1719234894569; Mon, 24 Jun 2024 06:14:54 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247cf5272esm176765475e9.0.2024.06.24.06.14.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:14:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexander Bulekov Subject: [PULL 02/19] hw/sd/sdcard: Avoid OOB in sd_read_byte() during unexpected CMD switch Date: Mon, 24 Jun 2024 15:14:23 +0200 Message-ID: <20240624131440.81111-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For multi-bytes commands, our implementation uses the @data_start and @data_offset fields to track byte access. We initialize the command start/offset in buffer once. Malicious guest might abuse by switching command while staying in the 'transfer' state, switching command buffer size, and our implementation can access out of buffer boundary. For example, CMD17 (READ_SINGLE_BLOCK) allows to read up to 512 bytes, and CMD13 (SEND_STATUS) up to 64 bytes. By switching from CMD17 to CMD13 (see reproducer below), bytes [64-511] are out of the 'status' buffer. Our implementation return R0 status code for unexpected commands. Such in-transaction command switch is unexpected and returns R0. This is a good place to reset the start/offset fields to avoid malicious accesses. Can be reproduced running: $ export UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 $ cat << EOF | qemu-system-i386 \ -display none -nographic \ -machine accel=qtest -m 512M \ -nodefaults \ -device sdhci-pci,sd-spec-version=3 \ -device sd-card,drive=mydrive \ -drive if=none,index=0,file=null-co://,format=raw,id=mydrive \ -qtest stdio -trace sd\* -trace -sdbus_read outl 0xcf8 0x80001010 outl 0xcfc 0xe0000000 outl 0xcf8 0x80001004 outw 0xcfc 0x02 write 0xe000002c 0x1 0x05 write 0xe000000f 0x1 0x37 write 0xe000000a 0x1 0x01 write 0xe000000f 0x1 0x29 write 0xe000000f 0x1 0x02 write 0xe000000f 0x1 0x03 write 0xe000000c 0x1 0x32 write 0xe000000f 0x1 0x06 write 0xe0000005 0x1 0x01 write 0xe0000007 0x1 0x01 write 0xe0000003 0x1 0x00 write 0xe000000f 0x1 0x11 write 0xe000002a 0x1 0x01 write 0xe000002a 0x1 0x02 write 0xe000000f 0x1 0x0d write 0xe000002a 0x1 0x01 write 0xe000002a 0x1 0x02 EOF hw/sd/sd.c:1984:15: runtime error: index 256 out of bounds for type 'uint8_t [64]' #0 sd_read_byte hw/sd/sd.c:1984:15 #1 sdbus_read_data hw/sd/core.c:157:23 #2 sdhci_read_block_from_card hw/sd/sdhci.c:423:9 #3 sdhci_blkgap_write hw/sd/sdhci.c:1074:13 #4 sdhci_write hw/sd/sdhci.c:1195:13 #5 memory_region_write_accessor softmmu/memory.c:492:5 #6 access_with_adjusted_size softmmu/memory.c:554:18 #7 memory_region_dispatch_write softmmu/memory.c #8 flatview_write_continue softmmu/physmem.c:2778:23 #9 flatview_write softmmu/physmem.c:2818:14 #10 address_space_write softmmu/physmem.c:2910:18 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior hw/sd/sd.c:1984:15 Reported-by: Alexander Bulekov Resolves: https://gitlab.com/qemu-project/qemu/-/issues/487 Buglink: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36240 Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240408141717.66154-2-philmd@linaro.org> --- hw/sd/sd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 807b5d3de3..6a7a10501b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1826,6 +1826,13 @@ send_response: break; case sd_r0: + /* + * Invalid state transition, reset implementation + * fields to avoid OOB abuse. + */ + sd->data_start = 0; + sd->data_offset = 0; + /* fall-through */ case sd_illegal: rsplen = 0; break; From patchwork Mon Jun 24 13:14:24 2024 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: 807034 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878104wrt; Mon, 24 Jun 2024 06:17:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXS3qPGQZtBWGQPlppenrKyL3Jx54bnbIgDPRSjrpRoRrSEQ9/bUjsWYan6nW5hJjpcxgATho+KXMNFs/YurHbH X-Google-Smtp-Source: AGHT+IEY/LK7I0PeeOgvfkfToyFqz8tq4AT0GWMs7Z4ffxjKBXeQUtvmUv71+ldWMIMJGgoo7oYA X-Received: by 2002:a05:6808:1447:b0:3d2:2a0b:cf1b with SMTP id 5614622812f47-3d543b7bed3mr6232172b6e.37.1719235079258; Mon, 24 Jun 2024 06:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235079; cv=none; d=google.com; s=arc-20160816; b=0bVSu5H7clEWxiofkIysQxwKfUDuxAhAxUE5qYSOFfGqc7KYTFDbPRmNh48YSu7GWt yXNJQNSMA73WiBFNF7P7subz4dt9xuSNxd/Ts6QnLMTe5nCRumRRFmHin3z4CC8w8mqT iF8pJmj/Ncq9ICK70Q96Qv/Nqn/0cfwDa668oCNQq5vZEyGdZzzISyc8qEykPlAwW8G6 SnACybNKIaZYG+WXtKBJkW05B6Dnr9yvcG74Pg+niyya6KViEapMCKSLeOuWqejy7BMr qM2p0UTVy/nHbxPvaNH/EDm6f3rKjkgwtbg9MW8yN0CntC6PX/0DJscp/Rv12rM0tYLR Wv/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G5C/rBGUajz/uZ65x4moAAqa+NPc5S7yF9iilS4WUHk=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=BnOvLUICDQwCYxo1gdxn9rHqyU+oQAgpDw2TemrD3xIa9OiY7a0sMFT35xxiKDrj47 JuZtowi5S+UHCB9/4dxUl0Z7989Nk7CPqHI0WqtpQBLvp8aItndi18XThn5vkOEoADFT f2olxelSvCqB6bY4pn202dT9C0cUPLJY8xwcibuWn27F4f7MAU/bpOdYWVY2plWVO9KN Aifup3Upcq7ZsWQVtkJ8zJuLnmlaS7/WCeTHfXt3vJEDY8sXsaQXiS8j4cSNHh9JsXgO SK03f6xkXYZUCFYeA3Q4BdSEtA9EpofxRkpk66/+tHCyOvP1BJMiS0rW2i8S36xww1LV YFXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bQ4G3gE+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b7808asi79560831cf.212.2024.06.24.06.17.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bQ4G3gE+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXH-0001WC-2j; Mon, 24 Jun 2024 09:15:07 -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 1sLjXE-0001VD-NJ for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:04 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXC-000506-5h for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:04 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ebeefb9a6eso47625211fa.1 for ; Mon, 24 Jun 2024 06:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234900; x=1719839700; 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=G5C/rBGUajz/uZ65x4moAAqa+NPc5S7yF9iilS4WUHk=; b=bQ4G3gE+VPTTgE7xHzMNoeYf92xWNXMWYVj2KrdoMFRsILwwyQkhm+JHZHScPISZty GyJ1tRYcU2bvLPg6XiC9Ap884zbLMXL6E6Otsqj0tGPXUnTBmfh5KeCViEX/7pTO6gN1 mYJA1Qh0qNkRMyQBcxiYLwlsI1AptKKb5EGRYpygtGM+ur6ISn4VtAZaKyu+slAPfcv9 FxImM925Tk0jjGYr2FaIW5TBAwB1T0q04FbGpl4TReG2DU1QSqMOppasw6dHRkguHPOF 7hUjV9T3hFFo19vcoxosQHSJa4eFoXaUJPQ+a7K2UbibrVb7kK7QQBAWPsjzKKNOGckI 89zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234900; x=1719839700; 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=G5C/rBGUajz/uZ65x4moAAqa+NPc5S7yF9iilS4WUHk=; b=GVg7D5hLy5wxk++ilYlpLvZ1YZb74/fiKRC/Rj7nP/4VxN1bW+0jHPZjDg9XR83xnW BGxSaQ94jXl0AAANRFatLbR+AgtuuqjguWom8NqZue1B04yVj3FFbMC3S6bABo1uimGp E83zO+XACxQrOLC5D/JeIplX/VTPCkeKy22PKpCgMN7cmJZRQZaO8mF6hmjD57XHO1fK zH6BnNCisLkAEeNBUvaDZben24yJXSS8SDEKzocgHOjMw1G36qZUQBHAILWCKpuvtjMN vO7/tpc+P2+EB/w8AVwsrGYFSXZr5mH6lNgi8MiYOcb5HwTrpEZj4OT/XKnLv2SjjGN/ OjJw== X-Gm-Message-State: AOJu0Yyo0pfK2IE4AIzrdY8XTcJAtSv+Wg4OM7oScWp3ODy5rYKS5t8B HaWeez/IngWs6i5B78sWg80mRCR9nkkRBx8HUj2FFTdo4wweR7r3wimcEWo1rQeOOKdXHGTYoPr t X-Received: by 2002:a05:651c:104f:b0:2eb:fb9c:5a85 with SMTP id 38308e7fff4ca-2ec5940087bmr28858911fa.23.1719234900175; Mon, 24 Jun 2024 06:15:00 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424817a9667sm132776375e9.15.2024.06.24.06.14.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:14:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 03/19] hw/sd/sdcard: Correct code indentation Date: Mon, 24 Jun 2024 15:14:24 +0200 Message-ID: <20240624131440.81111-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fix mis-alignment from commits 793d04f495 and 6380cd2052 ("Add sd_cmd_SEND_TUNING_BLOCK" and "Add sd_cmd_SET_BLOCK_COUNT"). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-2-philmd@linaro.org> --- hw/sd/sd.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6a7a10501b..ba7f165cb5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1069,33 +1069,33 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { - if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { - return sd_cmd_illegal(sd, req); - } + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + return sd_cmd_illegal(sd, req); + } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } - sd->state = sd_sendingdata_state; - sd->data_offset = 0; + sd->state = sd_sendingdata_state; + sd->data_offset = 0; - return sd_r1; + return sd_r1; } static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { - if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { - return sd_cmd_illegal(sd, req); - } + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + return sd_cmd_illegal(sd, req); + } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } - sd->multi_blk_cnt = req.arg; + sd->multi_blk_cnt = req.arg; - return sd_r1; + return sd_r1; } static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) From patchwork Mon Jun 24 13:14:25 2024 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: 807023 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1876919wrt; Mon, 24 Jun 2024 06:15:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVy3p3e8SIEWsMhYWQTkdx/GkECZzK9jydzKK8xtUj0lehEXjEoR1KDVyLtlo3jfPu7mygsAZEzOiKLr6v2CFz2 X-Google-Smtp-Source: AGHT+IE+0V+Q9Go1Fd+x0YfFHnoGlWwA5eIgcBdSijOjfVFU5arrMr6y/M+jXJIykRA0sxPp0509 X-Received: by 2002:a05:6808:f8e:b0:3d5:2bb7:867 with SMTP id 5614622812f47-3d54596af33mr5459485b6e.17.1719234932205; Mon, 24 Jun 2024 06:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234932; cv=none; d=google.com; s=arc-20160816; b=OEJYTHd6BzRH8sO54X6QnNXGd7riWfBGAAh/OA9M7cS+2zdOgxXDi6k6AauHAYItq2 thEgYb5nbgASxTc/DGUfQXAE02uGjSJzmDLz3Cso8yZlWR1uKLuCJG4JYs0G/Ei399Nb FEm12oqH8zHbyZk4grli/wAwBOoSjg+xAyDeaXRrQWMVeWH93AHv0hAHR7Zix4sUCyhA nWwOElYkVbf/m5uLW9iNUClJvbfAVV7O7kQnq9uD9zofTru8NdcNAXTFRfAgyPVAh82Z kCwKVcEEgvfIsNPh7Tj2ZeQyPbJybb7546Rm3iblkhW44TBRbeh6XAQs+TBVYIySWEgm j0jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=QEChop7NtP/RMPlC3Zvh4xmyrmeXiwzO1k2Cl1M7Tg/FhNQKk2VO8ST2GnOwbtRCWA PGMrTkg1O5kHMY6AJ92rA/S1bKe4wVj2jnMYml85YacCt6A8rLrLAMnTsRJH7y8PIfym o8064wLJE1SWCxhTYUt/1oRd0L9GvRmhTni5kQBkvcEpymysLMMnD2i5rwVJDT7yj/Ph 88EIlTPkILOo7A9Ux0PiQHcpupxgnmJRcmNMddcAUlhREk+/jVDTBuGamrT+H34tZr49 CCTsK4NxaeDM8fDaTe9k8dGKRsNNwpKcAk7yricXKPxE4sk41dc5KoELxyZM/iddEr1a QBNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1OZqC93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b72274si81926531cf.191.2024.06.24.06.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:15:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1OZqC93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXK-0001da-Kl; Mon, 24 Jun 2024 09:15:10 -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 1sLjXJ-0001cR-8K for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:09 -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 1sLjXH-0005CD-GL for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:08 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso2930121f8f.2 for ; Mon, 24 Jun 2024 06:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234905; x=1719839705; 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=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; b=L1OZqC937Pj0hY6ez4EYhB7/WxrMeLvrkxZXm9rXtzWMmnpKWFVXmE5Z8FmWS0Hsal 7QB+E/Cax4imOGqhTVOzT3+e5gkwFpRDQ3gCbsJBPehkD9Tp+kHSa0J6Zzcg5SYX1TMT 2MMFfMwZ1YCr1U83fGfASOIjc01xWFhkt/c/JyhDZrbCc5vId2TXVMpyxQ7QXmpYTk4K cLm0s4fE8j0kRI7WOTtnzyYuItOp+WzqAxuZyPVQfHZbVZNWH1pH70lEBts25H51nkHa WpnpoPLKGQptaGHM/EHQXaeuvh6kyaoHpOsiKKvjZUYP2VDfSbOi3gzET4AvZHijnTvY aUUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234905; x=1719839705; 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=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; b=KxAja1OvsjaWuXI8EU6v+tNEn2hPuTZ8YwEgCBHc1bCx7L0s+I1J/v9BErRKRK+paV H3+xWbrI98HFR6Ikcn71mp+iHG2itJJTpiSbj+0JtAwIYP1nqgRsIz9ZGpmGpB0vPLQl 9PG/MvL3g3kJcUO5HxK0kPIeMQ0SaPBV4cK/2E2GqnP6gEbX1N/hj7ZMK6YrLjL4nlM4 jbevSkCQeOUFLOpL+dSs2AHkom9Z47f3L+QhpU96IlP9KAHISG8tm0VW7yEGffd+gzVn kMIxFbWVDjLbkvhrC8vKcK3dhHQP1yJbQcRn7LYESdJbg1mXDeJPI/dh+q5vIIK+iWr5 a4sw== X-Gm-Message-State: AOJu0YxBDoAy9fQPQDBB8qQcrtCKWdV3GOAw+G/K9ZwSHPa5lGr4oX2B SV/he2Mz0FEPnmBQ4pYCZExAR53pBuovSBv5ixSZjvW1R8Zb3U3UiI0tXrZxM3r+6PWp0hHJc+W p X-Received: by 2002:a05:6000:154d:b0:366:e7b5:3b49 with SMTP id ffacd0b85a97d-366e7b540a8mr4645416f8f.54.1719234905753; Mon, 24 Jun 2024 06:15:05 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366387cf44asm9978938f8f.26.2024.06.24.06.15.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 04/19] hw/sd/sdcard: Rewrite sd_cmd_ALL_SEND_CID using switch case (CMD2) Date: Mon, 24 Jun 2024 15:14:25 +0200 Message-ID: <20240624131440.81111-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Keep this handler style in sync with other handlers by using a switch() case, which might become handy to handle other states. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-3-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ba7f165cb5..46388a140a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1044,13 +1044,13 @@ static sd_rsp_type_t sd_cmd_SEND_OP_CMD(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { - if (sd->state != sd_ready_state) { + switch (sd->state) { + case sd_ready_state: + sd->state = sd_identification_state; + return sd_r2_i; + default: return sd_invalid_state_for_cmd(sd, req); } - - sd->state = sd_identification_state; - - return sd_r2_i; } static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) From patchwork Mon Jun 24 13:14:26 2024 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: 807026 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877197wrt; Mon, 24 Jun 2024 06:16:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFKS2fwf/oU+/JvFcpNSXNm95guygFR8b1r8LyVRqxolJ6CvVg1ifoKVDNqlC7JSLzR6ZM17mr01jtuEDJXUbv X-Google-Smtp-Source: AGHT+IGR6GCE4wJ1vSHs/++yzLsq1/7QMzmXOkKD/BxyW6Q8IEm1UWS0aa+xfvN40krIAraiLac/ X-Received: by 2002:a05:6870:e901:b0:24f:d9fe:8b9f with SMTP id 586e51a60fabf-25d06c11c38mr1925836fac.22.1719234968782; Mon, 24 Jun 2024 06:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234968; cv=none; d=google.com; s=arc-20160816; b=00MbHMBnBODjs7zIfmERdTDb/8utTYyWyiVPDi8gKVogsAaJc9gy5zgpYtS8C/PuMJ jBC5KPKLiCZv+vNt6iQzjZElYC3JE2GxX/Xn6xlUhjDiO/d6FTh+3MlNlpR1KGL0Bj1b TO34aHgV3DrnwJu6gld7g8Sx8yoNGEsd83ClWjxLUHpghsyocb5LEnAeZcfer5BFvGKT NA8fj1A1bcM6mjJBnZeeFjXFr3KRkZtOmY7boTAROBBoSXofYroLuW8l2yEBREkn5yzX 0UftYvD3i4QNCDokjhRJ7o6aeEqbllzyOMTlQoh3nzMdZcyrJ+3S0gbprO1xffG69Pt4 wNhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oLr6VQ/1L7wjwJ5K6EJixR6ZpMPokOVueWHu3KJVNLE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=a3FdlRntBVgLKkjKC8kK+Hsg4ohOVPWQAJfUcr1BnCyWosbjP0DWgn3bnyKLtSvV9g Evw5pPR/MBSUA2dVnbTjQNlkC3uL9ynbzxz2/T3gWTd+X7Vv6TXmS9xBNiHFWHAKM5xk D221Bg3VNOfcwTH97xATAmhWi6Q+HKkokYIYAjUK4wXmVZeD0dyIew/YP2eL3EEELVQv 11pntXsyRhK2QkiVPw4FJ0nWP7AaXO7iA0so5VPFGIzGPXP9pbOYyuYs8Dtov7qoujTE /dKzICKQfBviUvnxCJxKBvgbZ641vZPtjQ81p2F4LooDEnTAnYRekV7dEkh65AvVO1Cy H+8g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gd+IDBeE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c66b66si79223031cf.651.2024.06.24.06.16.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gd+IDBeE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXR-00021y-Bd; Mon, 24 Jun 2024 09:15: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 1sLjXP-0001oB-Nr for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:15 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXM-0005DP-VJ for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:14 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42179dafd6bso31523655e9.0 for ; Mon, 24 Jun 2024 06:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234911; x=1719839711; 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=oLr6VQ/1L7wjwJ5K6EJixR6ZpMPokOVueWHu3KJVNLE=; b=Gd+IDBeEtCwFpt9748UgNVgPz215uNbMBHMrHDi2B3isOvIODAQZthQtsE0N2M6gV+ xaa9CICJdCvUHlGFlrKR82WJKk8Hjx7FwsyfMznVuH8vrM4X09sinG18IW5eAwRuSt8Z aGtW+qVT1f550pFVIzkWkiYiWVzU+frBS+x24wZW6f+NNP3WLwOGxJiUzbPLqhYCcWAL vj9DxCwGzscnpaSM/peUbTmtMlEmljm0IMh7Nx4ar07/enkPgUrAsL2rci/QTyuU+Xd6 0M+NxwXlwOGW9TjYel2IPI2utHbdhhjFrS3bhr1IbgrVV1+7d09K9RhLKUegVV7hOnEO cCUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234911; x=1719839711; 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=oLr6VQ/1L7wjwJ5K6EJixR6ZpMPokOVueWHu3KJVNLE=; b=u2E8g4JUIz29300zW6+YxCfAGArtw5nt16OkZN9e4ERtAhUasm40+wR/mxVejjIJ7T pDyM6AgcQycYy6o7IpmvsIkQA6Qe5zYVfttmfmiHQY12/Vr+S5JcxtKJbvCb+oPbVBuJ HS1AbQfXKm3bKW5npiYfhYTQ89Wb4iQpNyZf6iPDZ8t9AxpSff8XEUfWpXB3vzN7HIMo aJZaXCWcSGGaNirDF59AgaiVAZy+0gkU+bdLj17UYY7+eJ9PKtleePSnSNhapxALTgKQ 6k0wtGTU6IEEZ3FFlkD2f6D+QWy0KffqfoGaRjZQoPa4IXJwGvVmy5nrb/AniEb+jncB m9hw== X-Gm-Message-State: AOJu0Yznc3cN+L6amQ8cBzreRBYRbZPk4UXMegke9ooHWBdJDrPyXf9W 9YpUzPvV/lK4e0ooVpi3eBaavHhI7g5fxFHpUBySAKzl9F4re2I4lWp05TWxAtMs3QRuYhnAjQv B X-Received: by 2002:a05:600c:138e:b0:421:805f:ab3c with SMTP id 5b1f17b1804b1-42489533effmr55383735e9.14.1719234911131; Mon, 24 Jun 2024 06:15:11 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191c5adsm133562855e9.39.2024.06.24.06.15.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 05/19] hw/sd/sdcard: Fix typo in SEND_OP_COND command name Date: Mon, 24 Jun 2024 15:14:26 +0200 Message-ID: <20240624131440.81111-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is no SEND_OP_CMD but SEND_OP_COND. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-4-philmd@linaro.org> --- hw/sd/sd.c | 6 +++--- hw/sd/sdmmc-internal.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 46388a140a..72d71259d3 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1035,7 +1035,7 @@ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) return sd_is_spi(sd) ? sd_r1 : sd_r0; } -static sd_rsp_type_t sd_cmd_SEND_OP_CMD(SDState *sd, SDRequest req) +static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { sd->state = sd_transfer_state; @@ -2150,7 +2150,7 @@ static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { [0] = sd_cmd_GO_IDLE_STATE, - [1] = sd_cmd_SEND_OP_CMD, + [1] = spi_cmd_SEND_OP_COND, [2 ... 4] = sd_cmd_illegal, [5] = sd_cmd_illegal, [7] = sd_cmd_illegal, @@ -2160,7 +2160,7 @@ static const SDProto sd_proto_spi = { }, .acmd = { [6] = sd_cmd_unimplemented, - [41] = sd_cmd_SEND_OP_CMD, + [41] = spi_cmd_SEND_OP_COND, }, }; diff --git a/hw/sd/sdmmc-internal.c b/hw/sd/sdmmc-internal.c index 8648a7808d..c1d5508ae6 100644 --- a/hw/sd/sdmmc-internal.c +++ b/hw/sd/sdmmc-internal.c @@ -14,7 +14,7 @@ const char *sd_cmd_name(uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_CMD", + [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", From patchwork Mon Jun 24 13:14:27 2024 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: 807024 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877110wrt; Mon, 24 Jun 2024 06:15:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1Pzxs41zynkWWuhTHNEbhjSGj5rhBw9kjXzHB4d2P2ln0R6q67PKvrOmV61f8Yrig4gXGB7omn5JqXVUzxNmf X-Google-Smtp-Source: AGHT+IGpwSHkB0EjemRUF+1tbWc9+zxvLgGn/uVsG2NJrJYC6/JP9k+m5ZrXmT2gFl5pUJqNFaij X-Received: by 2002:a05:6122:208a:b0:4ec:f7d0:e71c with SMTP id 71dfb90a1353d-4ef6a5dd33emr2794744e0c.4.1719234955227; Mon, 24 Jun 2024 06:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234955; cv=none; d=google.com; s=arc-20160816; b=p+Z39oxUJimZiyET4czijyRp+kR4LNFJjHYyHup2crZ+k9NIQTyz30/vnwNc4cd/Io aTPhov/Y/tQoMtx4w7CP2wrqr4aiGQ7x4TaBmXjh7j5NHGFuytYhwhvx/G63H91Z2Z9l j2zZxWfT8gBpyrJlmVNok3L35sGWCHK/P8YIaV3GQzeEPilZeZuXaQq+LlU54Tp0MTsk vxcgHBJyOoiGk1PXjNC3BL+uf6gb5aJvFUOQI6S/J4oN6nc6PvLwupcz573W3FmL8hs8 /Asar/EKluv9Rtx9gBClkcbS0IY0aHPEolwRpt8A53ShOHdVtG+0itUB6INhU+dODM2S /sMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cGq9CknDLxCzVytX4zHmuSLklJOyE1bcs9yCSxS9ogk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=mM0u/OgMg5qyFBL/9thPGrBA1Tz6AF4/ueBybH6tmwX4hqfn2tJNIrv4vhA+ZLlKEM 6mR7OYrvLpRVdp0KZOicQWDiU6owsMA2jlZcKxY0H8Cr3ejzZk01KYjCNeQGseyrEBG1 GyRP0JydTuGnHShnyQ8s8V/2Kowu/4tkhg0px6mIPwsfhX0Qk4wkOkSBoYG2iR9fuhyG 5yqVUqLOvb7aSEJsMEBBVZlmy9e/p97ovRs914d8PFChM07pGyoXm7Qrm2ppjdTAvapc jxO9v7awi+VX9rwazv897TMxomQpRdJUPW/BSXJXDh1rH1+rTZ4miuUyH40vzjDqng9l kfjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CmaqscEN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4ef611a0b33si513785e0c.40.2024.06.24.06.15.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CmaqscEN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXZ-0002JG-RQ; Mon, 24 Jun 2024 09:15:25 -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 1sLjXW-0002GK-0d for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:22 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXU-0005EN-BP for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:21 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so49021551fa.3 for ; Mon, 24 Jun 2024 06:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234917; x=1719839717; 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=cGq9CknDLxCzVytX4zHmuSLklJOyE1bcs9yCSxS9ogk=; b=CmaqscENhnn2kYiljC6eAO0ISCj2LFcmNolkxTeqx0/qXdk3qTjpKbOdw3GlHvu/2p 3vrCvOO4uVsx/lrsSqDWUWkw8P81BbvtDEy5b0GiZ0pK7BWd5R0N5mkCPgFkMTJMvXzo pi2OYWlkgvIJtf5GOwmtEfEhPSJeqHawfwvdgTY08Jvb2fYKvRi5tweV7eXnSJL3VvDG kZd+WXvj0r80o2Uc4PhALcv8YIZaG2fRFehPm58lni/2m/2KEQ4LuvsIMuRRwRnCLmU/ js2RJ04vOKVT3hLCISRw11ERJbWo0/oQRDrJanjTXuYmAzWRiRUmOyHVqK5IxKeiSfGy BMlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234917; x=1719839717; 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=cGq9CknDLxCzVytX4zHmuSLklJOyE1bcs9yCSxS9ogk=; b=uxEgZ/L3HO63I41dgdktPO5yp+O4JBjxTHEknLoAmGyDvy80Lpnvfk/l8mbjbPvNHh AI3NZtMxfnn5G12XPukmFK3kWFxyaxeNEzEjFnLyCqrGsmp98lYVOXiJQf0aEPhpNg4L JlOsp4RVxuNqfowtgKosWs1c7Ifi16OBJ+0B4gUeLlEYl1tmWJxrVrfwpnSbtEuhod+h S/x1gK6WaM6xJhMh8ma2oQODz/4HD6V793ahOeShF6JEloezRI72uyiDEHH5fc3wwfxq J36oBWRiudLUuQMbDYz+y3RagSAD0BOZ59kvBj47iVB3iqsGFVF9VhDOj/AiK5hiOC09 hx3Q== X-Gm-Message-State: AOJu0YykswFW4LDnF96ZDyHG3/D49V4BiEKupfNq2ETuPm7jz6fcpXng o1+3i+xhvCRQieOgcjgveU6nHHe0Cy6IyCbOJLU0o9umBK4FFloRUlasUdzBk4z2/eFHE0tOreS c X-Received: by 2002:a2e:9e0d:0:b0:2ec:49c2:a79f with SMTP id 38308e7fff4ca-2ec5b388519mr25367741fa.42.1719234916739; Mon, 24 Jun 2024 06:15:16 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0bea05sm173281545e9.18.2024.06.24.06.15.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 06/19] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values Date: Mon, 24 Jun 2024 15:14:27 +0200 Message-ID: <20240624131440.81111-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-5-philmd@linaro.org> --- hw/sd/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 72d71259d3..a14c5ff147 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -596,7 +596,7 @@ static void sd_reset(DeviceState *dev) } else { sect = 0; } - size = sect << 9; + size = sect << HWBLOCK_SHIFT; sect = sd_addr_to_wpnum(size) + 1; @@ -822,8 +822,8 @@ static void sd_erase(SDState *sd) if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *= 512; - erase_end *= 512; + erase_start <<= HWBLOCK_SHIFT; + erase_end <<= HWBLOCK_SHIFT; sdsc = false; } From patchwork Mon Jun 24 13:14:28 2024 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: 807027 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877220wrt; Mon, 24 Jun 2024 06:16:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+8q2YYq/Z0eJqXwbIi8j42xlJlWuths4fuMfi7D4SWCLRpOt6iqU6QDfO6gY6DJqBzpBmZ4XQKbCLKwEn33ZL X-Google-Smtp-Source: AGHT+IE6Y2tPoStTZ1WuxqsMOBH/kAG/6hbpRIrbmAYsGpaFfX5WU3btJ9A/9XDGBR+WHIOKUSnY X-Received: by 2002:a05:6122:4594:b0:4ef:6d02:f4a with SMTP id 71dfb90a1353d-4ef6d8b4e09mr2992208e0c.13.1719234971571; Mon, 24 Jun 2024 06:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234971; cv=none; d=google.com; s=arc-20160816; b=x47TdSnDFEzfpU/zeYdD6jF8L+6O0zwIkcZg/vht2Vzj70WyV0cHdhTl3gpcR8HtUU yHJmWhJ+TMb3HsT5TZMPbNnNgvggK0sIYBezUEYLLu/wBmyowhWNeuFeARDalWLloBqJ 5ax82b6tyeHIhl3Tc2iWvZxAcObjKH6DHxiwvGYZfjxXb0QUE71EUkpSFvLrmtuAFLZy iTw82aeV1A429KcXL3JGB7yzv+AXS1u+UXemZrZiRjyVxLszk8hLg4d8HyiczNflmWYe 9FNetJvu8R0oq3PJxdp2diZJvDeMpkVwCBIL0FVxQEOIpzhrQ65wvlP5XPKim759IJif rF2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A3kIXqxbyj4EO+8ab6+OipvibcTKTQuRzHPmi/RkZhY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=ipa3jmAYAWpbCWgFFju34fuK/6L+f1PWR4+Op2GhLmbvmDLlRLOsmma0kHIikOn/hs oqSfhePdJZ+Da/codCcugyNRs3n505MhwC/Vj2jT64OD9gCPfB8orPZpN7oZ3TPi22Rz TIhoL+QfOaBSogk/sFaLCFTrrvVLMei6uCVofqpAQCDgD++sjSP4jZRKz2KnKGGMiMuw 21+TpiDohEADdkb0fV69VS7wE0T67d1Hs9d5c9E8nZ/2LB2IpVjBPnOpcKhuBfn5a7/v A8coDbxkrZPqwY2NVZmB8FgnWnZQfv218rISYxqxPR4WL16w3hvnl14g/lS9kwVCaWRM IyaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1TaVrMv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4ef6db2cb47si382138e0c.52.2024.06.24.06.16.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:16:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1TaVrMv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXm-0002Vw-AM; Mon, 24 Jun 2024 09:15:38 -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 1sLjXa-0002Li-K0 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:28 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXY-0005HY-UK for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:26 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52cd628f21cso3302778e87.3 for ; Mon, 24 Jun 2024 06:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234922; x=1719839722; 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=A3kIXqxbyj4EO+8ab6+OipvibcTKTQuRzHPmi/RkZhY=; b=g1TaVrMvsOlIOrBgoZw4ZNXRvilrw2b9lVbFQFqf4gji8sN/iiOL4oRQyNewKNVUx7 8RqseZJDqxMcnl8XvBu/cEm3xXXb1PBBSVCvo4lMfYiogPCFt2eJv025cnQPVcwRcyRx WZl7Bz0VAoVkKbVVTfr8Q94hAhXLPZlxcFveshFAoCgqod/daqGCkiBUP1LjgaNxZBL0 G6fvKB7ugBpzjBvSJCAOA4KJGkiAs1bZpytA4UHhR10TkY3AmS2UnwptfN6TZM07BJjt kglTYEJCrWsCOMpgV6XqfiGklfuNwWO3usgNp6d+bCJBzQLiyXzBFXGSTrnX0hHRP0W+ nYGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234922; x=1719839722; 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=A3kIXqxbyj4EO+8ab6+OipvibcTKTQuRzHPmi/RkZhY=; b=VXMxTKIA2nUMoR4xi/bDkHwZoksoMZm+AIsgAFlfrizxjmqd3caFvPIYkwyNL4t5s1 mOmVnJDHPZQ3n0VLACpEubIg4Y7fvYpDkEy05DJqkWGP5sKi7awaomLdDgVQ9dmwPr+Z alZH27V2enoDlPjaI7fsCFRvtEojtqDcV0+Sb8c6BZjiCnJe5xllxWyl/YDJSCbDb/xb xbuvheBoOqVHAvzCat2feonT8kVQVVNx5sF37oWC3mR4SVp3RO2JR3v8aPxSNhJAYIrB UTXiimX3gtxn9525mfi7PK7JnnJHg73B60MIWHsDzZLLYGh1Vw4YDQYD+e8QeKhXIwjJ 3kXQ== X-Gm-Message-State: AOJu0YzytvjpT/tE3jZnDXA9ErmAPZ3VdxGUCP4upOfe/+BWBlo6vAji 0rtw2gYemwFx3axttHnHqMXX3FWQO5tZClGm+W+VlKDTdNoVHr8QGUw/r+Q8//IKEyUpQc1RC2I X X-Received: by 2002:a19:911e:0:b0:52c:de9e:194 with SMTP id 2adb3069b0e04-52ce1835b48mr2368094e87.28.1719234922215; Mon, 24 Jun 2024 06:15:22 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366ed18dfeesm4046705f8f.93.2024.06.24.06.15.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 07/19] hw/sd/sdcard: Use registerfield CSR::CURRENT_STATE definition Date: Mon, 24 Jun 2024 15:14:28 +0200 Message-ID: <20240624131440.81111-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use registerfield-generated definitions to update card_status. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-6-philmd@linaro.org> --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a14c5ff147..64270dec0f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1788,8 +1788,8 @@ int sd_do_command(SDState *sd, SDRequest *req, * (Do this now so they appear in r1 responses.) */ sd->current_cmd = req->cmd; - sd->card_status &= ~CURRENT_STATE; - sd->card_status |= (last_state << 9); + sd->card_status = FIELD_DP32(sd->card_status, CSR, + CURRENT_STATE, last_state); } send_response: From patchwork Mon Jun 24 13:14:29 2024 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: 807040 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878680wrt; Mon, 24 Jun 2024 06:19:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwbWwBa66sQPuE2v6RnlwRPvdpTWc65EEVDQF3kSKZ4FWfMUuCjPmsE9tAXet2ia/jRuCY8552ZRMzR3Ypkh2X X-Google-Smtp-Source: AGHT+IEKETlEZgFGgJ3v+YzoAWAPqRFE+PdlD1NfV057S4blYVMDTqC+QObfbZKZCAXZ6n/WkqVS X-Received: by 2002:a05:6808:1824:b0:3d5:2bb7:850 with SMTP id 5614622812f47-3d54594d8a6mr5176546b6e.5.1719235144892; Mon, 24 Jun 2024 06:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235144; cv=none; d=google.com; s=arc-20160816; b=eTGnbonA/+u7Q2rBFmKCXg6gdCPjBxIvfrN7A4dxxQbpxPyGAWjBD7ujuLJKjSB5Kh +QMKWt+X9mwPVUZLcOq40dPo1NX3mX5l7BqDtriESgyuUgrxsSC0OuUusE7mzvpwSEzU kLYLlG9w5Y5ulhcbtIrMAKKyZXssX37fLWC4Ffod6WGK4sW0St3vFPsVlZfIQMtCN0WI Fnq7tmWihhi8Y/MTuhJ1CfquB5PjJ9/Im++J/crPxz6TpEA2srqbWQtzyFxNo8M9EEpC 7Mnsoy28LN3t5YXp87muV92e6bgjvgNzrdZaqpbF75RiKhKcVSG8WYyu724fYlww7aDJ /lYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RqlOEyj+8xJJtMHox3KeLzXAnw9eaudtpJH6jXIsYOM=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=B4DJkR/qi9tEq1JqkCIw1Pbmi3Hi5s+kOacOh1yc/qYU79dHR+rO6Fuqd+5S1NBkyf wxFv5GTmY0tU+umQg9dvjvxv76zrz2BqkR0COgfxo0gvc8Mpw/QabAQEoGvaACsItABV n+mIaIX75SdPmu+QP1uHaG0+dTWFvqxl4ssOlwU3/eo71FVXuMXbPUcni/w/kHgR4LzW 6NaN9V3aIkn1wKXfzO3N62otP+gmU6iJ2Dpl+6YHLLLoPeCtO35oEdzphNAfl2xsb3+t QsW09jiuTRY8g/7kbj2jPjE5ykweKyNvo/drE5xdwv50kCR+hMKMcCYIqfSqSII3m0Er nM0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w0e55R1j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b49aeesi82358921cf.108.2024.06.24.06.19.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:19:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w0e55R1j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXr-0002c4-SH; Mon, 24 Jun 2024 09:15:43 -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 1sLjXf-0002Tp-Ua for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:32 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXe-0005LN-9P for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:31 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so32928525e9.0 for ; Mon, 24 Jun 2024 06:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234927; x=1719839727; 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=RqlOEyj+8xJJtMHox3KeLzXAnw9eaudtpJH6jXIsYOM=; b=w0e55R1jxQgPIHzVaV8IuY/CBhxuRl9AU+O7IwifzRNR3XHo2LxmK2r3qx103Ot2Ez J6jMXIlUSP0OZKyTy5fEXo69zPdklwb8jni5l/7DNffh3sQ1lH3F5f0w0a6IYk71c6Vs kBDXhRrTEdgprWDipP7WXgL2v2CIyZVBcYOl1ZyPTfpgwleiFHWVBd3aE/NwyB7rxQE9 TomomL3lxNLukEC1OI179MXjhDnVWM+fd3BkR4c1+iTEttYnhhDyZgk1aZN+5LoL3rVH Z7yNuZqV1jIGQFQkXHobCB5+gQdK1XcAhAsKzoAHEHI4LvNL1MCbqDxwYGWuz7THobNd olEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234927; x=1719839727; 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=RqlOEyj+8xJJtMHox3KeLzXAnw9eaudtpJH6jXIsYOM=; b=f5gtK1oSxYfsY/AymIVXtNieF7tPqworGcz3lXYYLJOJ0UTqqpF7xBXUV1uTgStTXc Bp84Xiz+tGN/89qLLxnXtg396mdyhtqRJHucZdCuNs38AgGOjLiURXfpZsWo6QAXmDZB 9EJI/WxSWFO7SU5opjbbaGWtIzkDMzsbSNbGnst/OPs5KuDH5yljJyakGAQ366F/HAzL 2AOUseYN2wZTbKoeLMkcf27SfYrlzFB8FuLenbMdFwbNDMRZex7xJ9uCCXRdSrDG/CMx vhYPshall2xMudRnu6k8U+JSJPpRMryCFpvQ4XE6S4SbQQsYSr/0au22aMdHpJPEeJ8M KlHg== X-Gm-Message-State: AOJu0YyAXDNQuHi0hjsSQsG7lpsRblonjrooae/eRsVsh6u9gJplGHjq AosDWwd7J/7o2lhpV46pleEKAbPRqEMLjrpm9srmPuOh6Aifo7Jt2As7I03HE1CtSEoQnk//1RV g X-Received: by 2002:a05:600c:354a:b0:420:ffe3:8536 with SMTP id 5b1f17b1804b1-4248cc66a8emr36771655e9.37.1719234927498; Mon, 24 Jun 2024 06:15:27 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191c5adsm133571485e9.39.2024.06.24.06.15.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 08/19] hw/sd/sdcard: Use Load/Store API to fill some CID/CSD registers Date: Mon, 24 Jun 2024 15:14:29 +0200 Message-ID: <20240624131440.81111-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The ld/st API helps noticing CID or CSD bytes refer to the same field. Multi-bytes fields are stored MSB first in CID / CSD. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-7-philmd@linaro.org> --- hw/sd/sd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 64270dec0f..6e346e28ca 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -393,10 +393,7 @@ static void sd_set_cid(SDState *sd) sd->cid[6] = PNM[3]; sd->cid[7] = PNM[4]; sd->cid[8] = PRV; /* Fake product revision (PRV) */ - sd->cid[9] = 0xde; /* Fake serial number (PSN) */ - sd->cid[10] = 0xad; - sd->cid[11] = 0xbe; - sd->cid[12] = 0xef; + stl_be_p(&sd->cid[9], 0xdeadbeef); /* Fake serial number (PSN) */ sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ ((MDT_YR - 2000) / 10); sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; @@ -462,9 +459,7 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[4] = 0x5b; sd->csd[5] = 0x59; sd->csd[6] = 0x00; - sd->csd[7] = (size >> 16) & 0xff; - sd->csd[8] = (size >> 8) & 0xff; - sd->csd[9] = (size & 0xff); + st24_be_p(&sd->csd[7], size); sd->csd[10] = 0x7f; sd->csd[11] = 0x80; sd->csd[12] = 0x0a; From patchwork Mon Jun 24 13:14:30 2024 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: 807043 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878949wrt; Mon, 24 Jun 2024 06:19:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+tMmBsGskjVnpxfWdzEPQb2QPT8g5tgQBdfne4pUpO93ZMa3d3WnMWh6pSMg2mml18uWiFkaQInfDZV0G+vkv X-Google-Smtp-Source: AGHT+IEg5mE1I9Rk87xQceXSj4lTKk78op2967HBl4h+mCVKXrK2DrPR2YiNgFQee0ygAy/fQjJp X-Received: by 2002:a05:6214:19ea:b0:6b0:7482:313 with SMTP id 6a1803df08f44-6b540998490mr58340496d6.11.1719235182850; Mon, 24 Jun 2024 06:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235182; cv=none; d=google.com; s=arc-20160816; b=l3ZESb5rsFVyBGqf3Ck8SzGQ3Zhz/9cu/BuaeuTXkIgf4yTpLC2nOXdaiEOMn02mdf DFst2zZu2GX8DKTHE+jL1eNfZ9CuwxmeipY7GBojBh/8eMPqlrh26Nnd62JyqR3BBAm0 Dv4dhXUDcYXywE5u8useRaAVczfiaPC8x7z9S2/ulRB77n0WaiJqRgWrF4l0jK2DO/0H EVR/1ot0dy+yBlVDcpr/JBueY0nL4OFcnnV4+KyOCKwaMY7YW21RV1WmPlvtIw4Iqss2 x7lDoYiUtU1GjZSFb4YNVuCPdo/OGcfCqOy4i9ZKGHLI0NSPB60CEkHG51biPc9B1QsP e/Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Te+GIxXW5gxfuWRPules7rOyRScrC1BJa4kjtT/0R0c=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=PsP2113AXv4DsEwAWFhztgI1y9X5bWQ1R8/O7eOfVExXKpOQdOdSrnrhyZ9VqXSjhd QX3ffYYyf8LAtPdl5RDYvNii/CxFIcbrVLwHZP5lwUhz4hsLOfzJ2Zrcffh5Zw0iCe8Y sKCs35TIVUPn3bNW1CcVlc1b7WJlTzgN7nEtZCiXCHISZDepIwSBK1F77VHVrBgv62/R bmWwxW6RNsfd6nqC1aqgH7kZ1vlSTJmCjQ2yHxVey4TsDM7LwA5r+Arv+zfIQ/P6VA3e f9w7SC4V9taEEAhIbcdDSRIrYaSAuAV09hJtQ94T82VNUJWfa0uLPeE8cQ3Zz2oN7auA 4AcA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EcW/XXJF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edbc22bsi84988366d6.203.2024.06.24.06.19.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EcW/XXJF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXt-0002iI-N8; Mon, 24 Jun 2024 09:15: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 1sLjXk-0002Wm-IG for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:38 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXj-0005Pf-0z for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:36 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso2930488f8f.2 for ; Mon, 24 Jun 2024 06:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234933; x=1719839733; 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=Te+GIxXW5gxfuWRPules7rOyRScrC1BJa4kjtT/0R0c=; b=EcW/XXJF+iN5ouAe7RWaQicBoYHFZj3RWCaz5nAgCtl+4mBKv1QjL1czSvuZtaCf2x mXEOW7sMhx+jFpIdbJrvm1bKiXsbcTJEOl5wkGxGLkpSlp6gzsV4YAIqR6NqUbKfBWoi f7YdUx3bXZzYpg17/cvIrEpPd9uLKOgW34HeFfYx5dpWE4e+Yk1hYuRlDD9d+AGYZTTu +rQ2PNxGK0FARe//K9HrOM29szC0005cM3Gl3zDZV4+1QZtcaehHxAD/G85uL0IVu8zf HHdkWPIwP9uDECxJ70SEmzOHBG6F83S1RKD+yKOT+R1HWeRpPwpESrdOglKq06QSn9WV M/Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234933; x=1719839733; 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=Te+GIxXW5gxfuWRPules7rOyRScrC1BJa4kjtT/0R0c=; b=KPNaStrdW9SPDwASSvv2X78zllXamNZeKuOWICymMFgJdhRoLwZke0B4KhJzWCakUa lE9N/rY1HfmqKP/7rJp+eyaPh8bL5vHz62gM+CagIOWa46xE86KwMOc+0jkjr3/VjWGg d5C1fyepsuEcKq269lugPV9+aTMDZVwfC/w5EkfxPjmO/9Ffn/EFNeQs4EG7zsoekbqr 2tnbnu9IMN+mwP9cT8ZVJKrAMfwk7m6aAkP9obWvIv+HtWVFmBoGsy03MSCcmRKsB1Ij O4lvQeR8nHupbBkueG0A2tl3VE48b4nJ8Q/XFm8wB/vdlGpg01C5RYNmCT1mAHI4DAYl yWBg== X-Gm-Message-State: AOJu0YxTPcerKtdMoGa9PyBF6Xj24nrfBUlpa7YOmzDXxDpvUasM6JBJ MmSmA2GlknmEL0aMcNTNoczWCRNSO72yE363eARuZdJkVALU17H6DgNGOXme51WnHyhrkeDm5TO 8 X-Received: by 2002:adf:f610:0:b0:362:bb3e:93da with SMTP id ffacd0b85a97d-366e7a637e1mr3579520f8f.62.1719234932841; Mon, 24 Jun 2024 06:15:32 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36638301cffsm10046735f8f.10.2024.06.24.06.15.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 09/19] hw/sd/sdcard: Remove ACMD6 handler for SPI mode Date: Mon, 24 Jun 2024 15:14:30 +0200 Message-ID: <20240624131440.81111-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is no ACMD6 command in SPI mode, remove the pointless handler introduced in commit 946897ce18 ("sdcard: handles more commands in SPI mode"). Keep sd_cmd_unimplemented() since we'll reuse it later. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-8-philmd@linaro.org> --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6e346e28ca..08a6d0aff8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1012,6 +1012,7 @@ static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) } /* Commands that are recognised but not yet implemented. */ +__attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", @@ -2154,7 +2155,6 @@ static const SDProto sd_proto_spi = { [52 ... 54] = sd_cmd_illegal, }, .acmd = { - [6] = sd_cmd_unimplemented, [41] = spi_cmd_SEND_OP_COND, }, }; From patchwork Mon Jun 24 13:14:31 2024 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: 807030 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877801wrt; Mon, 24 Jun 2024 06:17:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUu/QrCoCp7ahZ8Gk1ljilu4RI94J9aE3yV4SPaHLbf7l7jAIPfg0F7J6BBhM+EQiUSjh/PNBhe3Mn0Js/Og3e7 X-Google-Smtp-Source: AGHT+IHcwL54NSuzPfdyvPVcVR64tdWBILhsA0Th09QmSl/o+RnqhJvNC1YWxLtwWayzWx4nIn3E X-Received: by 2002:a05:6871:54a:b0:25d:1c96:cc32 with SMTP id 586e51a60fabf-25d1c96ceabmr2741209fac.56.1719235034871; Mon, 24 Jun 2024 06:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235034; cv=none; d=google.com; s=arc-20160816; b=r6GP4UrFCL5yGOkdqSjhIop4wIB/Qzb53suOrB/KbPGu2ZxexXP/6PhsV3a4BGbr12 Z2/gLYJj1Trj2mt3P1h7j2bSv51Zo19MjxtyJeEz8SV22dUiJd0J6nsdlkUEx8E2RKEa Gdoqc+7LKeEhS2oDuF8UWYeS/AA2qMMkb2yT1vVGbbCuEn5slPLzO3vXjEVmEiyI0Y/D 6J3so7FDKyQWejkx0UDobnXJE9nw6csWCKV3gsD0fgSnKuNBKLUO/rQ1NV3DrJAGiVLK KFghoo2dJ6TjfDJ9O3kzrBygR69EPrdU6DAMmhxu1Hs8wrb9FtZbtWALMh274AxBBQnB o8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HxQAYADKfbhpE1hUX1tIATqcZpfO3HwJuZqR6r1E18w=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=LAmB7osppGAzqSBCV/b9RLwTKG6v9lx/une3gRDHF72oeNGRYuot0FMT7Q2xrVRcAR 3kZxBJPg4GIJGjC0o0ZMdtlTc0vnZUWG8KvC833TlY3gHQdxsbz9HsfAcv1HNJ/pccBT 7LI+49vAFhz+CpExQsDWHZthBoeopKv22fF7EGrFBStzC9d3I1mIJQPpS/wIpUcNL4ff JO1UqW+GnRsnXwVx3R9Hf74m1QaHkCepFrntd30TA/OY9EaGyxlWXtMtY0m98y/kf4uN e2bCyBhyg6Rde74QbFw2linfZCOkCmDCJolX9jLl7zH/cY0vW3nFVHMUw+H/UtHMd9nh uVWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=trNSHaPg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444e3572d23si24830261cf.469.2024.06.24.06.17.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=trNSHaPg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXv-0002if-Bb; Mon, 24 Jun 2024 09:15:47 -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 1sLjXp-0002Zp-Pf for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:43 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXo-0005TC-2y for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:41 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42172ed3487so32262695e9.0 for ; Mon, 24 Jun 2024 06:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234938; x=1719839738; 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=HxQAYADKfbhpE1hUX1tIATqcZpfO3HwJuZqR6r1E18w=; b=trNSHaPgnX4IaVip/hUksNO34idS2zor3C73sUoOxui5ToLnr5dwCPwfLPGVYYmhbi +pmxwL+8PXyHu0xEL9Hz1H27lEXbb3YAVso33gH93gQ9YM6tDIrjA+z1pLpSAOQz5w+/ cggP5Vf0aT1i4WQMAvCtbfpNQID+mXayTTJEU9YXN1vrP/QsqWWocEU9L4qE3upRHecm fZZNJiQC1Gpg57ux5sRJvXfykcq/IHY9viTklOacRDCJUCa/+B4QP8qRQzwoUfEUyBPR A8b3UxOQdy9AVOLJ4lNxc9pCLKf8m03h6vr8PAU1OEe0pES892y1cROnahpb/PWq9Z0w bm9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234938; x=1719839738; 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=HxQAYADKfbhpE1hUX1tIATqcZpfO3HwJuZqR6r1E18w=; b=n20sWrj78esjAuE0hZHX/wEPnjI+dhhLYOlrivP/v+EeMWklb+lYvP+JNsumfPjoc7 xowJFcJ0FTSHwSmygmtBdRpju8BMhYisaUOQWPKGHNZfmpntttMSXzahuBOBVWms6Vm0 H8r4WQaBXAgUT1JrhyNnn+rZ6yqkIqmxAV6rYxFyR9cIyQB8/hS2L5QBvRMqJpkdSpA5 N1GNivO1kfrZiRPqCrVu5Jd3mbadETB2UJC8E6ch0NhVfT5VMBurBRu6kyEXFi6VBQuE eDwMqUi0HDD9cQhkDM43zji1Lqw7fBkHfmS+/Mk1tMp5d7Rwz7LP2SHbtRywFzlugB4s lWwQ== X-Gm-Message-State: AOJu0YzfbL/WrUh+gYrh+WYC9+KvWltnDX+mJiPwPzCtk7KCZO3b28Bs McG1fDdEmSopnso54ieyQ1QsvLO2bsOHhm0LGh5gufef/JLehmMTQkAbpOTgOmlK7EAPLzSc6EM r X-Received: by 2002:a05:600c:3225:b0:421:9fc4:7490 with SMTP id 5b1f17b1804b1-42489e3a9a0mr40156845e9.11.1719234938135; Mon, 24 Jun 2024 06:15:38 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42481921f16sm133394085e9.41.2024.06.24.06.15.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 10/19] hw/sd/sdcard: Remove explicit entries for illegal commands Date: Mon, 24 Jun 2024 15:14:31 +0200 Message-ID: <20240624131440.81111-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org NULL handler is already handled as illegal, no need to duplicate (that keeps this array simpler to maintain). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-9-philmd@linaro.org> --- hw/sd/sd.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 08a6d0aff8..4afb6988c7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2147,12 +2147,6 @@ static const SDProto sd_proto_spi = { .cmd = { [0] = sd_cmd_GO_IDLE_STATE, [1] = spi_cmd_SEND_OP_COND, - [2 ... 4] = sd_cmd_illegal, - [5] = sd_cmd_illegal, - [7] = sd_cmd_illegal, - [15] = sd_cmd_illegal, - [26] = sd_cmd_illegal, - [52 ... 54] = sd_cmd_illegal, }, .acmd = { [41] = spi_cmd_SEND_OP_COND, @@ -2163,15 +2157,10 @@ static const SDProto sd_proto_sd = { .name = "SD", .cmd = { [0] = sd_cmd_GO_IDLE_STATE, - [1] = sd_cmd_illegal, [2] = sd_cmd_ALL_SEND_CID, [3] = sd_cmd_SEND_RELATIVE_ADDR, - [5] = sd_cmd_illegal, [19] = sd_cmd_SEND_TUNING_BLOCK, [23] = sd_cmd_SET_BLOCK_COUNT, - [52 ... 54] = sd_cmd_illegal, - [58] = sd_cmd_illegal, - [59] = sd_cmd_illegal, }, }; From patchwork Mon Jun 24 13:14:32 2024 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: 807025 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877140wrt; Mon, 24 Jun 2024 06:15:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUPt6/ddQpuG696nuLA5sDpxoEMA23xJKZ5TkT5pGg9bOh5gGiF0RptD8C7IWiO9iAOsJC2K0gC48m+QQzgc3by X-Google-Smtp-Source: AGHT+IHqM/ZREqqxLlyKFI0UiLgqpxBeDma3d8i4ucLNgbCHcksKEVyN0tvNzfYuJT3NjQxmK/da X-Received: by 2002:a05:6870:612b:b0:258:4dcb:7d64 with SMTP id 586e51a60fabf-25d06c1b559mr5277871fac.13.1719234958204; Mon, 24 Jun 2024 06:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234958; cv=none; d=google.com; s=arc-20160816; b=BbmyM1ERJg9y2c2wsPzknNu/M2X0+GtVyBqJzUjLj8mFOpuk3dPkq63pWNJy7uSfEu jeJQ3AG0Mu6jRn2cI2hmzfKG6ZNwBxetQiUNT+0le4YScF4VsLNcbU2PxJO17aaVv9ll zi4154fN1Q3yuqJkCXmRqhWiDd9r9EtuygryQHLCgebPeBIk/4NTSp6n9qrQnSqe7OQi Eb+3ffinDd2jh/0pIwdNndDEizxNVc24zbRd/jHugWGdPxbqodwCFzhFloZ4rb1dXoFg tM2ZMqHZClLHiQaqlf2S6dsCfpa6kljpZZCdckqOzd8z8v1Todbr8DuQMmvE/VGdgoyF GVxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OJnTXjeu6vchkfoyUhTtN0woxxCm+FO3y7c+ViS30WY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=iBvVSQYhPV9VREMZqrJ9Bx7d26TYctKEAW0DntPujA9B50+rE++6Fvt+MFaMQFAoqG XBenfHK/QZf9y8QL9z2SuZSpT2mPIKhGBbreq/fqPD1nEq8fD6rlkUKS6hrALs8dLF6P 9eVpM4W3IgnUGkvcd+hZHNKK5Lf1dFuG2JOhXgn4UwGBGgkRG7AZpBjHjVQWubaLJNDY mB2Ji9ronRkFkAsbNddVN6OwIbq5wWO13FbCuTSoQiBaPAkjGra3gDx9ZKMIBUR3TEJT LcjkqSx8nnI9UYwetALyezXPKmrUGk60iLOTr/7QPAYVwWfdT8Q4QA0mqti0QUaQ+TpO fOFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iq5bvPnE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48f510fcd18si489506137.725.2024.06.24.06.15.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iq5bvPnE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXx-0002rX-Rp; Mon, 24 Jun 2024 09:15:49 -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 1sLjXw-0002mq-Bc for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:48 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXu-0005Vf-Jn for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:48 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3620ee2cdf7so2765564f8f.3 for ; Mon, 24 Jun 2024 06:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234943; x=1719839743; 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=OJnTXjeu6vchkfoyUhTtN0woxxCm+FO3y7c+ViS30WY=; b=iq5bvPnE7yPZW80eNVcyaJ1HBiMh51MaGmzBaLCpCNLEG/momRb4++LBnxHEXpNY83 qrKfXVzDUzWfxcwBI2cN1SrN1XZK8+kBeFX+Ov8S3T85bYM4LJWUrMJ7gZimX9gQ5AjR IWAUZxY77StPAM2qfcGMkNRoOzZUHBMJRowQot8mzPh/5kEWy/wrN2twrhkgp5Hv8LQm qHK2z7szBPeKL0/U0RKbmduGOMHe3BYsjJFkgxqd0w7vUUYEWknK5Z7EJNyh8mQ3uK8E TY3S6qyZrydBqXXBu4srjDPbqKiUGcpfStUDl+w3E7Nf507cLuWggB7rAEZHTjH6QsaR tamw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234943; x=1719839743; 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=OJnTXjeu6vchkfoyUhTtN0woxxCm+FO3y7c+ViS30WY=; b=jAqP0V4DhpC8v7fs5Quzfr1BBsAkwEwiUDoqsLEv2wHPekVGRePIpCg7gVPaWOONY2 bZy9TaLCRX5aygCiH4vJNlmc8u2EEzc3d5cVNGM3X5sZumt7ES/Nnt4gaLaovZUajq5U uYIP0FGzEgoII/j5SFmy/A/T+cPrEUafUU0KIwM8cvruShlFjnD3t6LckA/BTf8KGC6d G8+mfaju7ygLogDAFVIVQm0LC48cEnM16dvvVnAYTdWlMiln/5cH5s6KSLQnEPfn8vPF tyXX6vtypM9FH5E/AVomWzoiqNlghbLPRRCF9LCP7RKpktBFw1MV58VivXtHZcUyRlLH EKJQ== X-Gm-Message-State: AOJu0YxlA+y/T67liDjss/iCVhpLquaetTyn3irYXXqnVou0nIO0iTiJ tRemIis0btRSPqoyf6dz5153Wlgo1p8Yi3BQt6ogPIMDdws9ec64PdHJhzhxTqNme5nuY3UjJb6 7 X-Received: by 2002:a5d:5f48:0:b0:366:e90f:3758 with SMTP id ffacd0b85a97d-366e90f38b2mr3986933f8f.10.1719234943421; Mon, 24 Jun 2024 06:15:43 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366ea4c0d9dsm5018823f8f.0.2024.06.24.06.15.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 11/19] hw/sd/sdcard: Trace update of block count (CMD23) Date: Mon, 24 Jun 2024 15:14:32 +0200 Message-ID: <20240624131440.81111-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-12-philmd@linaro.org> --- hw/sd/sd.c | 1 + hw/sd/trace-events | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4afb6988c7..44225bae9b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1090,6 +1090,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) } sd->multi_blk_cnt = req.arg; + trace_sdcard_set_block_count(sd->multi_blk_cnt); return sd_r1; } diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 94a00557b2..724365efc3 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -43,7 +43,8 @@ sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" sdcard_powerup(void) "" sdcard_inquiry_cmd41(void) "" sdcard_reset(void) "" -sdcard_set_blocklen(uint16_t length) "0x%03x" +sdcard_set_blocklen(uint16_t length) "block len 0x%03x" +sdcard_set_block_count(uint32_t cnt) "block cnt 0x%"PRIx32 sdcard_inserted(bool readonly) "read_only: %u" sdcard_ejected(void) "" sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32 From patchwork Mon Jun 24 13:14:33 2024 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: 807028 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877493wrt; Mon, 24 Jun 2024 06:16:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUk03dExTpcotPz4bI7TjTfNrpiHSdEbr0gfF4QYfv9cLrSY+Sn5TGqSBh1HSEweAXiWpUaav3y10AXKxSHn8CI X-Google-Smtp-Source: AGHT+IF2Y3VGhontXnTFxxGxPDS+H2X0eCGwoHTyV6z/fsrBBNKm1MIqXJZOTD+N5Uy3RvAwh0mz X-Received: by 2002:a05:6358:3396:b0:19f:15b2:2825 with SMTP id e5c5f4694b2df-1a2389dc97dmr707078755d.13.1719235002602; Mon, 24 Jun 2024 06:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235002; cv=none; d=google.com; s=arc-20160816; b=k+BlpbdiU0dV/mat2IKornIdPgFaVGM2mIecwpKjws0NOKHe3qkSeOnVHehoAWKFna r+t9EV0nfQJ9H+q9dTHyx9lP+klRwfaIGIU+TBAmZeM4fj1mdWVte7XOgFyOpYw05lXR AiWPd+SDkmTFjAOZzk7kvmgrCAexvZqTZaYDdIiJf2JQFVE6kDi6HS86zH+ZpRNupaE8 61kiNoUgGM013ERhsuCB65oBypCwu5evoRsvv03sxNf1plQtndBpL7yvzR1Pi8LAPBKn hl2NbD+A+L4LFQZlxqrGoDCIj3qYrbDAoKMC0YxxFKYyRtvlh8GJSeCnWxaLR4KOCafG kdZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DdZdPflGxnU9+ulU0ghp7a6tzZgDef0bM1QxWZe/c5Y=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=ajR+o06ak1jiD59caHNVj4QXtFQdpcwzT0AcWsnqo6c8A2UmZ2IrCriGqqNvVWV9mF zqWiY8QlAGorG7tF8q9MGWZ6tT4IDKo1YW8oL3GGvRLUJtFSHIuCxE0sVcUUUKDf5TGW Nn//TJ9fQBDI8IBp9eTKwHQsmF8hnVQiqz9KDikaxup8hZzDS4FQWnfDc/bMfg3tdQ+Y xFr18z9G+mc9yW+GJzXcJyXcXLF/egwzH2ZpkEJeW3f2jh/eXg3zgwyEqLMtq1nEs2/G /q+a2su4iciN7OH1v5ehwCgV6YnkH5U0boKmVHad55AA8Z8DUxIz/lC6MxmeDhPJFowx 3r2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkgm4+aj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ef32f53si78993806d6.486.2024.06.24.06.16.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:16:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkgm4+aj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjY2-0003Fm-Aq; Mon, 24 Jun 2024 09:15:54 -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 1sLjY0-00031Y-6y for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:52 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXy-0005Wr-Ju for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:51 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4249196a361so6725015e9.0 for ; Mon, 24 Jun 2024 06:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234949; x=1719839749; 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=DdZdPflGxnU9+ulU0ghp7a6tzZgDef0bM1QxWZe/c5Y=; b=kkgm4+ajCkOKNAuFarhMNdjDKQo1TAN09CQdAt06qAKOJVzbHJp7mhgcKvCefjFkJd ylMWs89fjow63WlaoufzDas4HeWu8n8QLp2p/B9Z2ZnWHdtxmHYcKldba7co4sAqNTGs GG8efpvGN8tyAIwAjtLNWt6XzMXNleh2l5xag1RWZC/fqUirCFZ6aohncyDyHOsFNqKC fxZvAyfLkKQBLF5GUsrn+Rt65kT1OBuUhSu3BhsQMSiO73QYO6lsw0X2i7ot7qYP6+KG MPz80+i6ut9LN0ijm0A0U442pwiniZKrvKU97mRqZOcmBhy9tBAA4godfuy0rGc9tzYQ syjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234949; x=1719839749; 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=DdZdPflGxnU9+ulU0ghp7a6tzZgDef0bM1QxWZe/c5Y=; b=r5+Zd+eaETuOGuD0K3ZawCOEGmLDa2Yz6/UiH2go/6DKs64Kt7Ep67Axz93Jly+W+e IVFFXuRqE2nCEYufmMKcHvw1FMetA7G9N4Zd8LLLD55kMONyd1Ancqd385IDBCs0fJqe uMAeIoR/CFz8+6yztaRWDJkUo9/d45HF3iM0FW/C/1n5oijLF+Z9bb1/+4+nZi5GsblL 5fCSNCcjEN6L79DO49hI7kEssVt04OuboGQfO0tPKg7Hk53aJXHBsPI3YKsKHzvoCWlj mBouvETM1qO5TtegUcVQ3NwpRlwK+Ch/9wavShivV2XrpfZeMUHFiNsRJer2XmIksRkH AFjQ== X-Gm-Message-State: AOJu0YwzTW4f2gxQ82Yai59YjuOCBX/aPxVKMqANvpKBvA2uhankbwAH MWAVcbmU71cw8CoauiYRIPbWf/sUP50AHE6tVTdDcbXcl7K2njqHWAU+pYGaWR+fHREpECZ5YF/ L X-Received: by 2002:a05:600c:4fc9:b0:422:7c50:18ff with SMTP id 5b1f17b1804b1-4248cc66677mr29054385e9.39.1719234948767; Mon, 24 Jun 2024 06:15:48 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d3afsm140585865e9.5.2024.06.24.06.15.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 12/19] hw/sd/sdcard: Have cmd_valid_while_locked() return a boolean value Date: Mon, 24 Jun 2024 15:14:33 +0200 Message-ID: <20240624131440.81111-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-14-philmd@linaro.org> --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 44225bae9b..04b141784b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1717,7 +1717,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, return sd_illegal; } -static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) +static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) { /* Valid commands in locked state: * basic class (0) @@ -1731,7 +1731,7 @@ static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) return cmd == 41 || cmd == 42; } if (cmd == 16 || cmd == 55) { - return 1; + return true; } return sd_cmd_class[cmd] == 0 || sd_cmd_class[cmd] == 7; } From patchwork Mon Jun 24 13:14:34 2024 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: 807031 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877818wrt; Mon, 24 Jun 2024 06:17:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9CX2lDczbDTgoJ7+TsGFFKyeKYq0Bx5BaP3DyqiRgSjSSxz4SKIYWyTilwoRdxDidQSPI6e0Kb+TDrMgeSHGJ X-Google-Smtp-Source: AGHT+IFpoXYFf5yR8MJ2tWw4MGJE6Zna9iwMwSF5X7+aI8dm4vyF8OQucQHGabj1iGw5uKTp5NRc X-Received: by 2002:a05:622a:3d1:b0:441:1de:8aba with SMTP id d75a77b69052e-444d921a76emr55342491cf.25.1719235037010; Mon, 24 Jun 2024 06:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235036; cv=none; d=google.com; s=arc-20160816; b=cabdejHkrWbe9BOdZ2fSYzahDv6QHSOgJkD7rGNN7RUSCg9TGZKR3J1AtWeQQF753q SUaR71ll+GwRA89x/dBRTNUp/f6XQ8ttTVRF8wq5E6OqrhMPGfOjKmvtnVWkZKZojccw KUTinqNF/MvqIckjAG2qhi8qix+vk79P2w0XHWEvLPn9/YqB/2CT1Xp9mvqjM301Jned OhoQYIhfqkb7U1sGYsRHFSBp9etess0FBmdQG4+E9PLzylIkMdiaNIBPn23/wq0G1N36 rk98hxqOdoHgPAIsmyxzFVXrfn5g7LRcGMYT0QhDj5jFIBjBsIKoMlvN36BzMNVT8Mbq hobQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BZMgxVGycu8UCR6fk1Qn9uFvwvmJUGQDSX4skzfq58o=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=jJPz5IYR6+L4h33M9ydOY0F6x7Ecl2T3CrLEPwO2D34SZSny004ND1TzIK+wVtzMTB 0Bsb+Yf/k41jXLGCEVKKADKMhOkG5GFgd0ZsBNAWO/yGw97/V1oa/DUGq7FhKt8U0WAm ZwF+pTg3bAniJWixYkYsvA08qhbdKze/UMkobMDeXeyAUWpnOG/LxuQVJq831+E1V5rG MTqtC390aL8tcxOB3clO1oByjrgUPcXZAwreuVC9tcryUnjDfyDiYdGWuWdO/W/sEmDR 43z4a8GmnpkK7t8YnlvWNyf4UohEcGejKeJsX34rF0jF8oNDJIh0GjCSELAOn/I7GP6u k+Zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rah9nWw2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c3d952si79055591cf.483.2024.06.24.06.17.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rah9nWw2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjY8-0003rH-LW; Mon, 24 Jun 2024 09:16:00 -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 1sLjY6-0003cn-J9 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:58 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjY4-0005Xp-RR for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:58 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso2930738f8f.2 for ; Mon, 24 Jun 2024 06:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234954; x=1719839754; 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=BZMgxVGycu8UCR6fk1Qn9uFvwvmJUGQDSX4skzfq58o=; b=Rah9nWw2jGg1E+C1rBbVQZHvJLAh1e6p7iCmnftlRMR+azz99L3OkhRmJ+2/NxV4iq fCR27sWYfQ/ok++U3TZiI832pyJ3U5RRTC92RntVXNQRScpBzy83WJMwbbfhrCHT5GAa ubbvdbcrvIwVXo6G64AnaRnPJ135FQSahvnozQQzIumhIo+yGNfSzZswFnBHGnyNyYrU c8ohBOUzcfxajy/y+HWa/0Tm3/y00NV+Xbod1BysWOZ69SM66HCkkwBJuTXLj/L51ihx SEWS3MVB5W9HhyUx5QC6QoykT3pZ27ro0bGqZKIIUPAC61vUgv3J/AcX4/nFD6OhmA7K fpRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234954; x=1719839754; 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=BZMgxVGycu8UCR6fk1Qn9uFvwvmJUGQDSX4skzfq58o=; b=CsVEdAJBtAb3etXR8wkVdguKGj2V3JryOQMmqlZPvPqQ130LVBfkhVNhq18v+w3ugn GhZxWDYIBJDcnTk2SVFCJfidMUOQRhA5sbbT28gixk3odWx5Oqke5DDk2NgJXT/CV+6r rOJ7DLfKPTuciYGO81d436Z+BnpNGIs/ZfUqtMxtG9iddl8oVCaI9vzsQIX5j2LwDy4r 6fwhyAkn9gSDFM9JQlJkasqJRvTIRDtSjp4qmvUWnBCmBH33XBl/DhEJetNFa2n3eihG ueZ0GOja3H7ZnrFO+AVDLgFiTbNVaAJZW5Taryd52V2bdtc0prvlINaA07JFbdDzWTDM AtaA== X-Gm-Message-State: AOJu0Yxex8eELlMooBNQ0nGvjGJFUzRNbrnY4GLzdc0lvFeNJ+PkLSVw hCjnHj0Lmky5UKe3XAxC/wbZyUueYQH9MQmb18UgBgaqEaphZErMIHq7E1xZUP3B74AYEiS3lhK R X-Received: by 2002:a5d:58fa:0:b0:35f:1b73:1d83 with SMTP id ffacd0b85a97d-366e7a08ba5mr3921036f8f.4.1719234954103; Mon, 24 Jun 2024 06:15:54 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366bd575f6asm9398981f8f.6.2024.06.24.06.15.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 13/19] hw/sd/sdcard: Factor sd_req_get_rca() method out Date: Mon, 24 Jun 2024 15:14:34 +0200 Message-ID: <20240624131440.81111-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract sd_req_get_rca() so we can re-use it in various SDProto handlers. Return a 16-bit value since RCA is 16-bit. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-15-philmd@linaro.org> --- hw/sd/sd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 04b141784b..b909a85d53 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -474,6 +474,14 @@ static void sd_set_rca(SDState *sd) sd->rca += 0x4567; } +static uint16_t sd_req_get_rca(SDState *s, SDRequest req) +{ + if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc) { + return req.arg >> 16; + } + return 0; +} + FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) @@ -1097,7 +1105,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) { - uint32_t rca = 0x0000; + uint16_t rca = sd_req_get_rca(sd, req); uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1112,11 +1120,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Not interpreting this as an app command */ sd->card_status &= ~APP_CMD; - if (sd_cmd_type[req.cmd] == sd_ac - || sd_cmd_type[req.cmd] == sd_adtc) { - rca = req.arg >> 16; - } - /* CMD23 (set block count) must be immediately followed by CMD18 or CMD25 * if not, its effects are cancelled */ if (sd->multi_blk_cnt != 0 && !(req.cmd == 18 || req.cmd == 25)) { From patchwork Mon Jun 24 13:14:35 2024 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: 807032 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877863wrt; Mon, 24 Jun 2024 06:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwDVjTIxde2yP0rxRX+Pe1O5UEEyB1ffyN8IGoyjBQMpBKExpQ6GJ28pjqaFTMYyUpuYE9nYYl2b4V5eJw2sp5 X-Google-Smtp-Source: AGHT+IHHc2nt7qR4PoS4MnP9sL9KxLSzADwcGQ+vnYKGPdJtBVe2UMYiGTqnfK2Ed4nMISyLo4BY X-Received: by 2002:a05:6808:238e:b0:3d2:1be8:5487 with SMTP id 5614622812f47-3d54594d872mr5556747b6e.6.1719235045718; Mon, 24 Jun 2024 06:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235045; cv=none; d=google.com; s=arc-20160816; b=b3jQ3VZYLTM2vCDvcGSg/1SqUzomUgVLAaKXJTpBkP3Yu4t3bG8CFS9m7wXhRaV6Bj zNtZi4+O5q+P4IwmwMrCme0IQrhIgbbV/6xMAs74uQR6T+rQibpcaq48sajG8cWyjhg3 pSRnva00IJlKvGUAYuz6svZVQL5lIPjJgOO8AaK9j9xUf1eIkvQX3712B9irjd0fBCQK 1MiSEP2/zXlnN5G0FdFcZL8epX+KVk+pOgz95s2cY4Z9yVDgPydLnb7M4JJTeTpCPSTj QCu3uRusLL5vPx8NsDJSYvAKM2aeEymtjcKUwBgOknsG1Pq6sq31ebmguZtBAGQc9n6q 3uMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=I+I2xkje8aG+UsG30Iym0Im2gx9BouksKYsIilAPoE0nYpcAVFodQwjQY9goKX6Urf FP17iqTmIjiZucvDeP/+m4Nb7CnTMD8riF4wbdHajWhKufam19+sB8Z0bNN2cE+obVG8 f4RfQ6rkOjePhR/fxFkvymZnQglsz1o+hktb8aaTwiHJMXkODXBLhIxQ7xb5DwYheDWJ aUBFvTM+ueXbMNE7z97Nwt1e9vkGX57flOke4AFLWkJPaMWgK6dueNrkrc3hrz3f+Y/+ 23SsaZyIeXutggV2uqFIpmwNDdOqZ70//fWB1AAq0lnWnCDrx/eEC7aDely0oNgXFAZt PCtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6LrmzLp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c9f7dcsi81514401cf.733.2024.06.24.06.17.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6LrmzLp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjYc-0004OG-RD; Mon, 24 Jun 2024 09:16: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 1sLjYB-00041k-U7 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:08 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjY9-0005Yr-UK for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:03 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so2683836e87.2 for ; Mon, 24 Jun 2024 06:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234959; x=1719839759; 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=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; b=j6LrmzLp1nqmfhoMaLu63dcyl+6zSn0FVgkqczhcjradNyZjtfgYDXlFBmS16Xq7ln K5g+H/Cj6U5ubhnOqwMtFxsKfCdoUYAE6qUmhgNb0XSlLr7dcJTuSe4YIe+uH2qgKSe6 OfApWZgt0b7UOHIsZ7DbmaRBvSMDXjguxBXV2ROzlSajGkmgT3wQDczLVZIntbu/3fLh EW8KhBx/LslVM99t/zpDCqOdwfJ52uHHV8yRLFY43WPAZg8IeaymZiS5zag5yogvwYWX YdVNVvVDubysueZryklvPs/4THOfl1F3/04gO1vRwAPlq+IvnT8nR/g1PRLUjWfnXF9U bPAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234959; x=1719839759; 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=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; b=jSExQW3aehf609BUqMPzFyM2x1CNpV8NGhaOKOkIC7mrx+HeCrcjNNVjcLBznTDOYc Uw8nu9HoBoiryTRiv12Ra/u2OfouKc4lgA3y4Nzw8AZKhsFtNYi4RztMQfx9z7wZcTWo nWpN0Nc/7JD+BJAD7m0rbkzVoe7ySVfpwMvIzlUoD2pBo3JYbFHhmUh9jms7EZ0irLGS 13GoF2Zb5AnoFc85SA9qix6bE0wWqYD3io9VzpDR4BHAbhXFu7G/MvXj5i5hwK+OhJk1 i2+FJlVW6e77EHuhrwLAZhh/AMoOnzj06ZrJJ4x5kZ4LB4geanmosfyJ3omBnChu5QBB Vh+Q== X-Gm-Message-State: AOJu0Yw7qoe1hVqMxCZ7AaHxgrG9KtHAgCJOCvZbUWwRO3A/J+mLffJY 2hAbtVPjWzAwjgaegBxui36p6oZPJpLiuljYIZ81NwGL7GQDy0PKBHGUYpZ1muvSxBuGuGOY6// F X-Received: by 2002:a05:6512:1050:b0:52c:e012:efad with SMTP id 2adb3069b0e04-52ce0610531mr4941757e87.12.1719234959448; Mon, 24 Jun 2024 06:15:59 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191116fsm139386125e9.37.2024.06.24.06.15.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 14/19] hw/sd/sdcard: Only call sd_req_get_rca() where RCA is used Date: Mon, 24 Jun 2024 15:14:35 +0200 Message-ID: <20240624131440.81111-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org It will be useful later to assert only AC commands (Addressed point-to-point Commands, defined as the 'sd_ac' enum) extract the RCA value from the command argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-16-philmd@linaro.org> --- hw/sd/sd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b909a85d53..912b2f8984 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1105,7 +1105,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 = sd_req_get_rca(sd, req); + uint16_t rca; uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1162,6 +1162,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 7: /* CMD7: SELECT/DESELECT_CARD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1216,6 +1217,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r7; case 9: /* CMD9: SEND_CSD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1239,6 +1241,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 10: /* CMD10: SEND_CID */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1279,6 +1282,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 13: /* CMD13: SEND_STATUS */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (!sd_is_spi(sd) && sd->rca != rca) { @@ -1293,6 +1297,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 15: /* CMD15: GO_INACTIVE_STATE */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (sd->rca != rca) @@ -1525,6 +1530,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_ready_state: case sd_identification_state: From patchwork Mon Jun 24 13:14:36 2024 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: 807029 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877510wrt; Mon, 24 Jun 2024 06:16:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9hgsJaQOYL2qa1td6Qq371Ek083PONtGnMUivvFeDr/k/gfZHG/2r6XWeWmwEqa2uskTRLTjDpOQPAbGOUNAs X-Google-Smtp-Source: AGHT+IG/XqQ87uwaPZniy+gnxgcRX+1wwiHcIiw71hHdIEWfFK7hFg9Dj/De6A99+pbPizt6WJMO X-Received: by 2002:ac8:5a83:0:b0:440:5f3e:5a33 with SMTP id d75a77b69052e-444eec9de3emr7419651cf.7.1719235004001; Mon, 24 Jun 2024 06:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235003; cv=none; d=google.com; s=arc-20160816; b=eYTV4QwFaXfQVfwgyysH1GH9LCIB2u6+k3Q2J3dBnpYc/Cmt8gQndpJPFFUrR7Gaul DUDiWQJkWEtnyj8QIl8RfvgDZUFYer8o/heb20zuRp5uxtDrdfKTheRgUNXrWxnuvbY3 phEITaad6E7vbcuwp++WEW4rXTTdp/iDDvL1MCtzlfegruSNjSVMmnzg/8F9EiDzji5e PJGbq211jRTRP9lDHiMgFDYHLAZenM3kYaTldTwDgIlXiL12AW5ck2k6HqdIYa1jHgYf aqOZ5LT14l2TgXhMF6TXXhWZEsVJ1qvdAU2hwEMaEgCSPziQSvyzDYmP1bUjmVlNK4ns y8gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=l2GbBPU7vTKb7ZfjUFvGvbDeW6b0KFGZneMYzzAol8EZn+yiwYD++4uOSLOJ6Ywy06 ihAs395hZpTkrM/H1gYg8ILK+pFStwcduf5OXDB2zPO9Yq0KUh/2HiBcS5eAN80yi+wq aCbHiI1V1HyhbWYGGZ6r34PnZ+j6F+w2kpwRChDqoJjm0XGHtXgJ20tecoUs+tIQj3h2 PkDcOoJQbJyQeYX+GHEsAvInXyEh/GCxePvs+09XGDI0aeK68B8RW1LFaO+QEkQsNcr+ FJMHMaUIC+vxhqRQm92INFAjkocw5V86tGTP0t54hBvnGRYR9o6wErdmNbeCLIccb84F 0fGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BfLxruUA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b70f68si81414331cf.214.2024.06.24.06.16.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BfLxruUA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjYg-0004Qw-TO; Mon, 24 Jun 2024 09:16:38 -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 1sLjYI-0004Fs-FJ for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:10 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYG-0005Zo-53 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:09 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42172ed3597so25439175e9.0 for ; Mon, 24 Jun 2024 06:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234965; x=1719839765; 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=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; b=BfLxruUA5uyuhB7xUoaomyYBhg1tNFjGtXTgn9K38tSe9K/6civ/LiBRgUTC1+YS+p SVL8WNo3OlyX2z2pin8YdzrDpH6+IfMQawSZpeRZNm404k7GIcG3hb7wXHY9A06OTEWW +IN2fG53ZR+hwLU+WbRYq2cCLwfSF03uwziUIQNbRSfeS7OkYOoDpV6F6LUrB7HIHVct P1por0bpwHIorpSqgZorWLyTGm+dBUl0prrDYMdxKYNVg+rbvygoicz3QpYJpttzz+Ql PwRVQr6Zy+pjS3WumIUYV2S/zaq+blRHRwrmfl3X93lfm6vVnMxvRLjfVA+WK0Yoozp6 GNlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234965; x=1719839765; 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=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; b=rqFtB6Qz43CPg81B4Od51Q/rz0rPccU8ZHzP2Dfop/Qk9NGGrD8LcPhTKxfuUqRmpi 9D3g2RywEj84EubqaCOWffrvWbuezpQ/YN1dejthkaxUk2OCXFopuQR86AnAZwPc0QVi 362fOy6fU6AIJSr8Cg/M6zBMKN2csn8qpYdGS3AzB9KKr9h4YTkl1Yn9LvHJ8rDAD6hy AJwFdgwvwJt8wPRcnQt7P5VwQCStvbmcLMAotizV6P2XblLWiCO3WiGvv0OWAqdy9LaK MLAE90c1vGF5Xdw82408rOCs4xrOfuMs2EhNOd5pRgYngBWFHQux0/tj+EnVj3fw7Z6M tLNg== X-Gm-Message-State: AOJu0YxVVybwXfUB24RFItgh4Qzn28ooEwHIAogj9jI6Y9+FcqZ/PM+u qQIHMfmiXrN8ssjXRkwllha501PTgvNs5ibCpjSFeWBnyP696yp5p75b3xSIwe2z1t0Wv/5MtxL G X-Received: by 2002:a05:600c:3b28:b0:421:347a:f0a6 with SMTP id 5b1f17b1804b1-424893dfbadmr44229715e9.3.1719234964807; Mon, 24 Jun 2024 06:16:04 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d506sm132267055e9.6.2024.06.24.06.16.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 15/19] hw/sd/sdcard: Factor sd_req_get_address() method out Date: Mon, 24 Jun 2024 15:14:36 +0200 Message-ID: <20240624131440.81111-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract sd_cmd_get_address() so we can re-use it in various SDProto handlers. Use CARD_CAPACITY and HWBLOCK_SHIFT definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-17-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 912b2f8984..51ab7cd003 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -582,6 +582,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) stl_be_p(response, sd->vhs); } +static uint64_t sd_req_get_address(SDState *sd, SDRequest req) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return (uint64_t) req.arg << HWBLOCK_SHIFT; + } + return req.arg; +} + static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); @@ -1106,7 +1114,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 = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; + uint64_t addr = sd_req_get_address(sd, req); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. From patchwork Mon Jun 24 13:14:37 2024 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: 807038 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878606wrt; Mon, 24 Jun 2024 06:18:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUO2pYHg16J7EBOxhQg0RKUFn8QyCQEh77lApEbE85YklY+9GtOkBIvwSQxTQ12i3wH6Y8JqrxFKtuPn+F5qN2G X-Google-Smtp-Source: AGHT+IEKGW4CMdju0mL/4b2r8HS3qscq5kwVkc1f/mUqtGVA70INpCelHTdWce+BXCfQ2A5cPetB X-Received: by 2002:a0c:f74d:0:b0:6b5:5c9:d1d9 with SMTP id 6a1803df08f44-6b53bbc4818mr49730356d6.35.1719235138688; Mon, 24 Jun 2024 06:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235138; cv=none; d=google.com; s=arc-20160816; b=zDcS6PijgBXIWdnx+ZoDm0TsMFni8h+rVHlb191lgkdJIpnzKMb/wTM2f44RvasaG6 n9yxryoVB9JYHVm4ymH8byxokWnyjkIUHYaXxKXlA5ElNnFhzFQl0TYndMF4hQFRzUqt udL+dEzpWPL+o66AvLatX4gnEod1VbVKy5AzxnIh3OXpe8b/2JXnWgr4TEnrtd56guce LiAN7k5DSbkIj1KE9ZdebOg+jRwdpfIXj6d6J/ueGtHxpmQBipsZXotZ5GBo2ZNo//BB VErWnT15LrGVf6L8TL1CPvC8M1eYjDF7UJLd5oLpYE6PRRIyc75qGSMJuqOBbwZViIDt UuQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WHRr6B3uuTd3EFTNdg9fHFN+Zyvmx7WRQ/X+xj1mCi4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Wbefu3oSo5dIX7r/PDGdssNYCKRsk4R+WhoX6sVrYAYXRLYulWD0z0lFmnF30ORwe9 zO/3amk4ZJKjgVZoZ971Tz6GQxd97LHptScZX6DoGPkxYKlMNLqMFt6u5VsTH+pSfOJ3 tiFGqGcOJjD5VfrwUZqheta3k9jQnocOUiJKBzhkIcccll88YO9chvUaT9mtEUo97XbO MQirULgTP8R9edbzRXJLPINT5v1xnjPnZJ9yava2wMLo4CM1wcSYC/5ObQqMJ24c9ZqT L7wCce8iY78GRLk9PUrd3kBLTJCisPddFUd6TlfUNR8SOO9O8UQ3XiASISbDQxgzXi1M hu9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gqBOqknQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edd2faesi79909656d6.347.2024.06.24.06.18.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gqBOqknQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjYq-0004rp-Gh; Mon, 24 Jun 2024 09:16: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 1sLjYL-0004OP-UF for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:14 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYK-0005ap-3R for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:13 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so2491215f8f.1 for ; Mon, 24 Jun 2024 06:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234970; x=1719839770; 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=WHRr6B3uuTd3EFTNdg9fHFN+Zyvmx7WRQ/X+xj1mCi4=; b=gqBOqknQ/OIPJxDm3WWkgHhOi6csfteVs4louhsZw6C/BYDtx3Bzunaz3alzCoPYQv mIusBWY9bhlP6I4fNerJjoGcXk4tuq8hJtW1V9JIYlOk+LcSWE92R5OT4vsiB7DPTysa eKGdcgqVrfzQ+r+lIiX+QpQQNlGezTev4bTdasjPy45VM569XSiujIOgUi5t28o9U3sT T2yWw1jcgSON8Xf3o8p03G3JPPN89aRH93EeMDKInZilOTsbSuWL7O3uAn1TZPtgzATI n4R9d+zY0axZM+bdO0FGfQramUzzMk4Ades6n9pFzyyxlJgwNtZjKgd+fIsbUlTV3KTE 4TLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234970; x=1719839770; 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=WHRr6B3uuTd3EFTNdg9fHFN+Zyvmx7WRQ/X+xj1mCi4=; b=KG40Mj5ni/CYOG057/iMD3t+ZbpmfyCF+bizrGJRGH50dT7K5bE8ei6dXVAKh4NqZV vo/Et3iUNzsvgw6u9hXjhMJZP3pFzs7uV9TP3Ym0c+d87KKCm2YO3WzI9hPw98fCBPH2 lYzkdMEttewIejtxm3T7cfuJPY63TuXcmOWg71NPjjyP03m/RY7BhAiaPOJMjDi+n+jA uYbkSg31paGX6hhSqbRwOd1olKUES5AMbpy5NybBNY+7CC8i709z7E2r4uGH8MpY1gxi VIetKKJIlIb4I8T0J1+jYgCIqr+aaoJq02yH0lvCqNEgS5pHB4fE7uQQDA92mIQFawkP vAKg== X-Gm-Message-State: AOJu0YwR5j7J/RyccM1DBQlSY3yPu9k3p4uGMRx51fJiuvVMMai7HV5E 9f129PpipTR6EE/vNIN5h/19wByAdXAqZoKgXscOnxeRXcl1jAQLlZUHJk2MDHBtRMKgZicyxM9 x X-Received: by 2002:a5d:690e:0:b0:365:aec0:e191 with SMTP id ffacd0b85a97d-366e32956e7mr4379778f8f.21.1719234970345; Mon, 24 Jun 2024 06:16:10 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366383f6da6sm10006561f8f.12.2024.06.24.06.16.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 16/19] hw/sd/sdcard: Only call sd_req_get_address() where address is used Date: Mon, 24 Jun 2024 15:14:37 +0200 Message-ID: <20240624131440.81111-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-18-philmd@linaro.org> --- 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 51ab7cd003..3e4eb656e1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1114,7 +1114,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 = sd_req_get_address(sd, req); + uint64_t addr; /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. @@ -1239,7 +1239,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; memcpy(sd->data, sd->csd, 16); - sd->data_start = addr; + sd->data_start = sd_req_get_address(sd, req); sd->data_offset = 0; return sd_r1; @@ -1263,7 +1263,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; memcpy(sd->data, sd->cid, 16); - sd->data_start = addr; + sd->data_start = sd_req_get_address(sd, req); sd->data_offset = 0; return sd_r1; @@ -1339,6 +1339,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 17: /* CMD17: READ_SINGLE_BLOCK */ case 18: /* CMD18: READ_MULTIPLE_BLOCK */ + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: @@ -1359,6 +1360,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: @@ -1417,7 +1419,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { @@ -1439,7 +1441,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { @@ -1461,7 +1463,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SEND_WRITE_PROT", From patchwork Mon Jun 24 13:14:38 2024 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: 807039 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878609wrt; Mon, 24 Jun 2024 06:18:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWrbn5dIkN/kQTbHVKp9vQBkNA5Oi07AJmiKnaHunkzmmxVBgh0s7cpdZYtgQXPy1bcS1c2oO8g1n0eK9earha8 X-Google-Smtp-Source: AGHT+IFbXY8jYui4u0yUnokbZ0ETjeRNUrjig7U5lVS6n4kkDW4CT4SmNkKy3+Uy8S9kgM+cPvlE X-Received: by 2002:a05:620a:1909:b0:795:5465:5989 with SMTP id af79cd13be357-79be6e507e0mr537548385a.27.1719235138888; Mon, 24 Jun 2024 06:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235138; cv=none; d=google.com; s=arc-20160816; b=0CS1XX3dB9BTcWMryWB30LY7g+v/8slq7DZtfLQqCXHoljHc2uh7NnByZdchiJha49 A73ltJ9XHh0ETXX8OMieT4B6YoLlRcAkJ96EaoxFD2n8LCLmXzObk+0EaV6uDJZYA3sy gHgCTQ2ZW8Tvao8Yc8TfjXJBTwTn/YiDKht8miujhfXXVNIwYrnQ1P2AR7EmnIvino9b HsiLlKyiO/2Zvsvqwon82IeJZE1KjJ2ymFT2pX3+LDFXr1Kgbtw1leC/XihnhaiJMTuU AGhDumbmXlS+r0Aj2j1HoP4v5ZRfFelTAGizqZm09tSCtmw5+jfNvp8bVphhRnSU3VEt y1MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+OyvAZYAFCHsIdySGDiXeFQ2F3N56N52JzU6FXve/Tk=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=hRmFfq16XnAlx2YRL0pKYyWKtQGhkPqfHCbId7RPcCvdItFNOF7J27P1OTNWfiKZvB 0j0hYJcu8qm1qs4lGPpLZEGe/3yiZIfNZfFOU2avqm0cketHJftUFXZCrGMr6lUbqg1T mgI5s7I1ncsjy6OFSSR6YI/pU/kc7iCJ2/u7vpEKFd0MR26K9Mgz/AWQm8vW0nNZxIW4 b/xS6eT8wFfp8HPolFqkR3uKGrPPuvf7Srtunt/cCfw277YChjPU3JoefwMDji1BjTXB 2SEcg4fRaNPpFduy12b3o/B8VO2emvIW6Rp7UwW6GDpcqts07LMGrYo/ziSKTn5pxcXB 5jXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DzUU0xic; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce8ab673si853416085a.215.2024.06.24.06.18.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DzUU0xic; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjZ9-0005LR-JA; Mon, 24 Jun 2024 09:17:06 -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 1sLjYU-0004Vq-Er for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:31 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYS-0005c3-6z for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:21 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec4eefbaf1so32206141fa.1 for ; Mon, 24 Jun 2024 06:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234976; x=1719839776; 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=+OyvAZYAFCHsIdySGDiXeFQ2F3N56N52JzU6FXve/Tk=; b=DzUU0xiczFjZbc9WgaPziF66c2woNd8KtcRbC03A9JHkQHZVSEH+VU0YH5omWSgRWr njhyl6h0yZVWdsPwP4ZxRuY9De3ltdIqWaMGPsGSZcYxse9V360AL03A2gLhCoJ/4A09 lfU+K5bVJK9OjM5B2DL0baVC3FMDFS4yjGL9n0A/YSF2KCq9uX96AW4RKp3KJUenwziV Qm6bVyIx6pVL6uUkbfBb2h2y55nl3DoIWylVOiTXrxAClRZsECQK5Yju6Uk9X3EVtnPn oeT4BUtXnZr1C6MRJjnK2YVyM1RzNEMT50ZOjpgrY+ylOhxZ61Pc5bb6LCm4qe34Q3ox RqZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234976; x=1719839776; 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=+OyvAZYAFCHsIdySGDiXeFQ2F3N56N52JzU6FXve/Tk=; b=WX3M8uRmzf010mGhec5x4D/oAIcu0P5VUMOPvJWUTqq+Cl9D+h9UzUhLpY2DDyIpKP w4S8won5JL+mo1qqUNLgq3NalbIgZ2HOSiqR6VAWn2jfc11Yq3P5UWeKCveEatY09CLj uGEeErGmdig23tg0014+x5v3MHQCnZGLTIwnsFWLdVWQcEhZ6OZJgC55B1Aj4gJj9xxa ochFoifHflbhcg4dN/jkiN+AdE6NQokj390CLzPD6CMdgSE54AP54JxtuCtJsuPLZwc7 3bAw8ajo8lF1EPBdpGsTnA7I1jFyKR0bCN2uVxnNA+gEH+SPjgQBLcc/TSrF92edHhYY BDaQ== X-Gm-Message-State: AOJu0Ywf3z7qKiBjq3YyjNw+iL0TUrFUC0K4QPEHBQXwl6XcNlmKzNJg aftoApYQJozIZWbybwkt5nVvkpTffAArEclCVfYlzuLKLS53zCp2+zrjULczPUwziEzfT7McTI3 u X-Received: by 2002:a2e:b788:0:b0:2ec:4487:6a8f with SMTP id 38308e7fff4ca-2ec5b3d4ab1mr26520821fa.37.1719234975804; Mon, 24 Jun 2024 06:16:15 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366388c41b0sm10007103f8f.44.2024.06.24.06.16.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 17/19] hw/sd/sdcard: Add sd_invalid_mode_for_cmd to report invalid mode switch Date: Mon, 24 Jun 2024 15:14:38 +0200 Message-ID: <20240624131440.81111-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Having the mode switch displayed help to track incomplete command implementations. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-19-philmd@linaro.org> --- hw/sd/sd.c | 75 +++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3e4eb656e1..969340e5cb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -178,6 +178,17 @@ static const char *sd_version_str(enum SDPhySpecificationVersion version) return sdphy_version[version]; } +static const char *sd_mode_name(enum SDCardModes mode) +{ + static const char *mode_name[] = { + [sd_inactive] = "inactive", + [sd_card_identification_mode] = "identification", + [sd_data_transfer_mode] = "transfer", + }; + assert(mode < ARRAY_SIZE(mode_name)); + return mode_name[mode]; +} + static const char *sd_state_name(enum SDCardStates state) { static const char *state_name[] = { @@ -1018,6 +1029,15 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) return sd_illegal; } +static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s)\n", + sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd_version_str(sd->spec_version)); + + return sd_illegal; +} + static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", @@ -1156,18 +1176,14 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 6: /* CMD6: SWITCH_FUNCTION */ - switch (sd->mode) { - case sd_data_transfer_mode: - sd_function_switch(sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + sd_function_switch(sd, req.arg); + sd->state = sd_sendingdata_state; + sd->data_start = 0; + sd->data_offset = 0; + return sd_r1; case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); @@ -1291,33 +1307,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 13: /* CMD13: SEND_STATUS */ rca = sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (!sd_is_spi(sd) && sd->rca != rca) { - return sd_r0; - } - - return sd_r1; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + if (!sd_is_spi(sd) && sd->rca != rca) { + return sd_r0; + } + + return sd_r1; case 15: /* CMD15: GO_INACTIVE_STATE */ - rca = sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_inactive_state; - return sd_r0; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + rca = sd_req_get_rca(sd, req); + if (sd->rca == rca) { + sd->state = sd_inactive_state; + } + return sd_r0; /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ From patchwork Mon Jun 24 13:14:39 2024 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: 807042 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1878930wrt; Mon, 24 Jun 2024 06:19:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVtutLntxXt10teiTnqdvd8YtLbXADYkbxqV+uQ7hIx3XvaZHkBAs4yXJxV+s/wZ3qSB+Aq+jdTXZLtNasQvXnv X-Google-Smtp-Source: AGHT+IFmCG7zvVCJvhgGUScQop47AQ2lCmrXNuCeLcJXchnViXVNkRETBkMF42dv6DTCvNgLNgUf X-Received: by 2002:a05:6870:eca5:b0:250:73d9:7739 with SMTP id 586e51a60fabf-25d06e564b5mr4976742fac.45.1719235179472; Mon, 24 Jun 2024 06:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235179; cv=none; d=google.com; s=arc-20160816; b=ifk6x60pdyKX7hBs0ShlF188//W9Gl3noM8CO+B8vlQzkeYa8PAPtxO9kKqXp4XvAG S2rduiLho/f2yuy8ranl4CHeqCnqTNCLJwlvXW1a2zAs1capq0A3PJWB8KDFtuUTH/F7 k1nU2tXPl4Aho8aflzGxy5Hp5W/yfSFA5xcGZvuQPhEo5I8Bac/OVA8QG57E89y61JRU prVToVBmgNK5VFby4lgFl5owOoExAefFsWb5nnad+1FEtPEBcIIAUlUytCkeB9xq8PHH ipSkZOB1OmzdHl9pIKJn72dRuU47tUea6JTZ9G/zWsux/FBMXz/IFxVrXKZBzNnhEGXl 2xaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cdaAnkUJwowtFskE1jnezvCSjmf7OfsaigbewXS0J/c=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=WC/Sf/9k3n0fy8yW3WCdXfr+PVpjBiNrmCR9XqKtLr9lHnnbwq9/bcU791qcGf/nHE ptVTSkqV2Ae2iPQtgfjRjvcAmyRxfj70QDnhHC0kBw9FBcMTIl3hr0lHQaNLRcNco/pa e0ef9WmENJKjtv7+/eepRjONJW/Y8v0l59BK3VRXiveAUBDE8pU/EXstVGljsjgirc09 3kcTeaQM2/vHBWAoKKpVnk7hs0OYEpoBDtcqcma5C37wfDacUB/raBDOuhdtaxwFelAO 1Cq14B9NbMQekMSHT89k14znYkxW58jqqi6Bk0SELq+L1Z0yk8b0VTUahRjfOeWdz2Ss BNzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcxT2kCI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c3e3a6si79281461cf.508.2024.06.24.06.19.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcxT2kCI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjYt-0005ES-6V; Mon, 24 Jun 2024 09:16:48 -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 1sLjYY-0004Wb-Jc for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:31 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYW-0005cc-Uf for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:26 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ec52fbb50cso21891711fa.2 for ; Mon, 24 Jun 2024 06:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234981; x=1719839781; 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=cdaAnkUJwowtFskE1jnezvCSjmf7OfsaigbewXS0J/c=; b=dcxT2kCIg8m9Hm+Ga5mbs6X3mJ943gViHmm2gNoloOKAZtNngKXMetmVLFB3NO7Lpx S4bhDs7GDnMmrf1zgpSlm2Vc+AmGsR+FYhNofP2xe2e3xf+Mm0DHhj1evcVKzqA9l2Bo IRzcHAIXqG9H8K1kSDJvVLSw7CrCBHuLIjLsf03by7zQ3hMxIWG3wr5M54/WV2syG3Kq iykVAuVgRFBf4jDPUIEkhHHmw1M+MR2l6H8ewkW/kcXIBIsAtqCl3pIvt/xQrppTiuLT 6XVxBt2GpzBL9reAWXyZl7dHDH19cZoGg60eP0xfn1mEwPwEZcRkEIgPQzs+UGI5gHJq k9tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234981; x=1719839781; 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=cdaAnkUJwowtFskE1jnezvCSjmf7OfsaigbewXS0J/c=; b=lLoUwfYIRXhdmdpLIgH9XIx2XWPAm/L4Wu+jJ4CVFmcFWVJi4g2IjNtoZPwVeqYXzi bTWOehH0vNQmGibbXcVnFmqBi0Y+se5M8QUO0HrwBK9z6VeMIjx5KO4yW2DxrrnDY6hr j7E3kYwwK6uf6mLuIsQNy8jy2PRAy1YfafOoZdJ4LmtOtalqjhniqvMeFWXkiAAHwjAg V1wOT9DzUJi3tfeeLMLfuaa3M7gCCRa52dhHvPDyjYgLukUBRwqHg+6WCa7WukhTVQEh EuS0dRgSQOMCMC3bNSddtOtIb7EHqkyyl9GlI1YZoq9QgO2tCTJyJbqMyU98DcJf/AFd 5ENA== X-Gm-Message-State: AOJu0YwK1EYW81hqreT21eT+mWlHIVfR0AP5gura0pB5rS09eIaJGG6M +dLnIDCntTm55AROdUD75nUYbsWJkTIJWAyA1hE7pzz7viFgRbMOgqXJ0rfSIe4dUi8wumOcLvs 1 X-Received: by 2002:a2e:890d:0:b0:2eb:e258:717f with SMTP id 38308e7fff4ca-2ec5b2f0400mr27285961fa.42.1719234981135; Mon, 24 Jun 2024 06:16:21 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d208e13sm171560425e9.36.2024.06.24.06.16.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 18/19] hw/sd/sdcard: Inline BLK_READ_BLOCK / BLK_WRITE_BLOCK macros Date: Mon, 24 Jun 2024 15:14:39 +0200 Message-ID: <20240624131440.81111-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These macros only save 3 chars and make the code harder to maintain, simply remove them. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-20-philmd@linaro.org> --- hw/sd/sd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 969340e5cb..d4e3d079a8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -819,8 +819,6 @@ static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) } } -#define BLK_READ_BLOCK(a, len) sd_blk_read(sd, a, len) -#define BLK_WRITE_BLOCK(a, len) sd_blk_write(sd, a, len) #define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len) #define APP_WRITE_BLOCK(a, len) @@ -872,7 +870,7 @@ static void sd_erase(SDState *sd) continue; } } - BLK_WRITE_BLOCK(erase_addr, erase_len); + sd_blk_write(sd, erase_addr, erase_len); } } @@ -1903,7 +1901,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >= sd->blk_len) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; - BLK_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd_blk_write(sd, sd->data_start, sd->data_offset); sd->blk_written ++; sd->csd[14] |= 0x40; /* Bzzzzzzztt .... Operation complete. */ @@ -1929,7 +1927,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >= sd->blk_len) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; - BLK_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd_blk_write(sd, sd->data_start, sd->data_offset); sd->blk_written++; sd->data_start += sd->blk_len; sd->data_offset = 0; @@ -2077,8 +2075,9 @@ uint8_t sd_read_byte(SDState *sd) break; case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) - BLK_READ_BLOCK(sd->data_start, io_len); + if (sd->data_offset == 0) { + sd_blk_read(sd, sd->data_start, io_len); + } ret = sd->data[sd->data_offset ++]; if (sd->data_offset >= io_len) @@ -2091,7 +2090,7 @@ uint8_t sd_read_byte(SDState *sd) sd->data_start, io_len)) { return 0x00; } - BLK_READ_BLOCK(sd->data_start, io_len); + sd_blk_read(sd, sd->data_start, io_len); } ret = sd->data[sd->data_offset ++]; From patchwork Mon Jun 24 13:14:40 2024 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: 807033 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877945wrt; Mon, 24 Jun 2024 06:17:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXZIOIU6pIiSk5/pbTMuPJLpQ63Ht9yiVq1lr5dc9IahCYnUs3LlU/WmYz0NbklOoRj5f5FupTSfi6tWqkZtklk X-Google-Smtp-Source: AGHT+IFbSRL86QnS61PMkxtGx4wGEbWZs0GOqkWF47bHZHlcF8FGJGjZrf9N9icjV13mXeLC9acf X-Received: by 2002:a05:6214:174b:b0:6b5:4bd5:74b0 with SMTP id 6a1803df08f44-6b54bd57535mr24900826d6.3.1719235055625; Mon, 24 Jun 2024 06:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235055; cv=none; d=google.com; s=arc-20160816; b=ekgv9nqGIeywUE6//kMRbq530ExwI5ZB1UxT44OGmospM9UxUMGXQjr/p6P3RxbyjN 76M+foXiHI2sq1wCF9PgaDpiXwAvUoII+Y0rUo+Pi9R1hW3pBUX87LYZQnu5iAv0kj3E lMSXAsBa6n2zWvSDtsSJOOI/zRwa22omQEmuAIWyPqHwJ9l0Of4eXztQEr4rIJ7g41/i zLHG5tUsoOn6yoIhbbrdGEEsApdnSCLFVdcgvmrScqpq0BIbY5SWtTNkSBqR4xgufzZR 8omXl8fUefzGl47RMn0DJFO2HaJgvpnwOvb6eQpJti+FMUX22Ieo46F89jmy5Rya/dR9 Hg2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HXfJJfCbngNXWETKRmSoaVmSjOkjTU89WVvhepuXul8=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=haT/xkVMM67aXq8B4zewsmptIeXLCWcBGjgaPs5VdvySoOX1FcntveoINo3WNm1X81 eKRtSynQa6n5vNwfAZl+VHt1H3tYyiZC/Q14H2oUIbiNnlRxMesvXljbo8nPdAkyoJRm wQbAS3DY7c1ezrXXRixoLtmEDByBAS8Pynk9msTvPaHd5VUrLZ3tmJ2xDey0GgpSFKSI QdY/L/mkT+AFvwbzetCn5zqUyt8CCylSpr7QPcCBW0fwVpcBdQY8tQ5a5TMCnud7r+lb VaFFa8jkk7gUCUhpW6xgk3I1bfOJbWLqIx4NOMqFNFy66w1uUh0F0DWCZoMOSJMNTNV1 o5cQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fir262Vd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b539d2990fsi48722706d6.424.2024.06.24.06.17.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fir262Vd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjZM-0005jU-Sg; Mon, 24 Jun 2024 09:17:18 -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 1sLjYe-0004ix-1N for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:37 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYb-0005de-N1 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:31 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ec1620a956so51699961fa.1 for ; Mon, 24 Jun 2024 06:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234987; x=1719839787; 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=HXfJJfCbngNXWETKRmSoaVmSjOkjTU89WVvhepuXul8=; b=fir262VdbE3+A4+6tFWLLdW2ydwg8ioyytaFvNDzRA70DQdUKTvy3z72csUw7XXVJO kb7D3mlckeu13XzwJpgr9GRbLz/gXQgB+6K/mzr+CwlTOOy9DqklWhdiBtCDrLfyDYsw BcpSMR4RbA6IHhXalUpQZe2+3rIzb/VfjsFkRSjWWWSQMN0mcT7b8GbsU4+6PnfTJKAC +8L8a/3oM0xqbgTIf6B/S+mr3x9wDGTJEsvf8k+8fYM777dIFHeeU0XV00DUpHU7XHZj /6E7ltMTVMums8hvQUi2kLWQHkUqC7E47WS9H+I8ZrNs8DCVTHuq3pVlltTtw9AnyAbl Luhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234987; x=1719839787; 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=HXfJJfCbngNXWETKRmSoaVmSjOkjTU89WVvhepuXul8=; b=A+eE1xzVHhO0Q7MQzJrCmClnZ7VPw1hYq5WOssxMkZf5Jh8Bp5eROkUr1WoTLuODha i/jayxtNw78dl+tnqjZKOW1aaCMPUbbXpmJCEg2XEc1RTKk+fHxVlAce5UlTQOtxoFeh BEqK1oh3Qx2MxgcwlZw9lbVJk6n8GtjVYScMLjf72KEJQXLvaP6DXdltGcaZiLBig/vT IPX1aYqjUMxoxLKFwv9/w2kgZH/5SSH1tVTGuG88q43RFhDYatdZfJp3B7m8NtgKgDPh +sktbRQs8OIydkakqFTHO/lpcMCAjyGObGURundGpVO23QMP+Y3Z22bPvrbgW5yR0iw4 +CFw== X-Gm-Message-State: AOJu0Yw23i5Hl1AK+uaUSnuhuBfuJRBYPgNf3mLkjtKHAlBIHmAqr7PO Y2ioJJo2Awy4+WSYQV9omfKkvJk3v+R0ag9L1iPBCEmIWsNM478TLaymUDmHT2TsDappuCRRDyY Y X-Received: by 2002:a05:651c:211d:b0:2ec:5dfc:a64e with SMTP id 38308e7fff4ca-2ec5dfca6demr30542061fa.0.1719234986576; Mon, 24 Jun 2024 06:16:26 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248482f1c4sm120290265e9.10.2024.06.24.06.16.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 19/19] hw/sd/sdcard: Add comments around registers and commands Date: Mon, 24 Jun 2024 15:14:40 +0200 Message-ID: <20240624131440.81111-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-21-philmd@linaro.org> --- hw/sd/sd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d4e3d079a8..a48010cfc1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -315,6 +315,8 @@ static uint8_t sd_crc7(const void *message, size_t width) return shift_reg; } +/* Operation Conditions register */ + #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24) @@ -364,6 +366,8 @@ static void sd_set_ocr(SDState *sd) } } +/* SD Configuration register */ + static void sd_set_scr(SDState *sd) { sd->scr[0] = 0 << 4; /* SCR structure version 1.0 */ @@ -386,6 +390,8 @@ static void sd_set_scr(SDState *sd) sd->scr[7] = 0x00; } +/* Card IDentification register */ + #define MID 0xaa #define OID "XY" #define PNM "QEMU!" @@ -411,6 +417,8 @@ static void sd_set_cid(SDState *sd) sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; } +/* Card-Specific Data register */ + #define HWBLOCK_SHIFT 9 /* 512 bytes */ #define SECTOR_SHIFT 5 /* 16 kilobytes */ #define WPGROUP_SHIFT 7 /* 2 megs */ @@ -480,6 +488,8 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; } +/* Relative Card Address register */ + static void sd_set_rca(SDState *sd) { sd->rca += 0x4567; @@ -493,6 +503,8 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest req) return 0; } +/* Card Status register */ + FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) @@ -623,6 +635,8 @@ static void sd_reset(DeviceState *dev) sect = sd_addr_to_wpnum(size) + 1; sd->state = sd_idle_state; + + /* card registers */ sd->rca = 0x0000; sd->size = size; sd_set_ocr(sd); @@ -1055,6 +1069,7 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { if (sd->state != sd_inactive_state) { @@ -1065,6 +1080,7 @@ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) return sd_is_spi(sd) ? sd_r1 : sd_r0; } +/* CMD1 */ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { sd->state = sd_transfer_state; @@ -1072,6 +1088,7 @@ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) return sd_r1; } +/* CMD2 */ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { switch (sd->state) { @@ -1083,6 +1100,7 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) } } +/* CMD3 */ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) { switch (sd->state) { @@ -1097,6 +1115,7 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { @@ -1113,6 +1132,7 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) return sd_r1; } +/* CMD23 */ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { if (sd->spec_version < SD_PHY_SPECv3_01_VERS) {