From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593188984; cv=none; d=zohomail.com; s=zohoarc; b=Yv+CYtTHMkQ+wXbid2OLhuwgEJlCFwrA41uTDPxo5nRwGXadJkYwAyB4tnlMYidrYPz1CqJgxbEz5hEJb90rcQAOct9yj1JKjYCv7DQj52TPXFHXxymdWkZO6Lvop+w5BymOCNGLSV6sCxDkYXiTI1pe76MyBDHcZQNR3CqSN9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593188984; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VaBeUAKeU/Fm4s8wzR3hU4H0t6OdWhihwFpjUJ3q1zc=; b=J6GlI9E+K8hHUCyKvMoamOqWWI0zkKSxdsOwL450w2moHMjcLpHN0+634rbqKsYRRuBfwpgsA0ydoxFgzYQ+VPoAl6tHZYd0DY+P3zCQKJy35FVQBUo9aZDKhu1wia2Jdz731DnMZ43FenXMtLUgptFsC6j3Ow0I+eFhOIX7P1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593188984041831.9208576597669; Fri, 26 Jun 2020 09:29:44 -0700 (PDT) Received: from localhost ([::1]:56558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorEU-00076V-P4 for importer@patchew.org; Fri, 26 Jun 2020 12:29:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDF-0005D4-0R; Fri, 26 Jun 2020 12:28:25 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDD-0003Ig-KZ; Fri, 26 Jun 2020 12:28:24 -0400 Received: by mail-wr1-x442.google.com with SMTP id o11so10071628wrv.9; Fri, 26 Jun 2020 09:28:22 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VaBeUAKeU/Fm4s8wzR3hU4H0t6OdWhihwFpjUJ3q1zc=; b=r560fzkokcEVWlFkV7LVeE2POo1n+l8lipXd3vSRJDJFdIlurfoWXiasumC3FtwFAM 9FNaTTHbejEQHDsPYiiRuI0vFeuo4pkZgkdFgSLXT7FhFTa3M1Xzf2DFjjZul0sTjpa4 +iAxeiHO+5lRsdyNl4aPWMudgeOCE9RZ/tCFydZt+enAONOp3XAVwGXAnomsr5VYECUv 210XXRJeo4tfTAVFLLq9VunaWREcMtXucfGXlOF9t5qnW07VgpTnD8sj8oPMFOIMstR5 YY5uHMzlRG5lgdxYbZDkgnADan6pECdN5LVFixI2tYs4PFWBziapHrOUsF1orlMEsHYI 72UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VaBeUAKeU/Fm4s8wzR3hU4H0t6OdWhihwFpjUJ3q1zc=; b=R7TkXoCUuARkzJBSxp23/KAE+WqH6jSI2M0ss7Hccu14n0QMtKtgg+eMXLPnflHVb5 FyD4hLenF3bQNxXZKum2W1Y0jS5dbafIR0Gnj5q1Cp1j+qsLKJc3EGhRoUiceUFACLuI X+7B8sgPK/28A9+nBM/qfONsXK72gk1F4cNaKYx5YZ2uqooQZib6s4p7bRG5SerEkjey jpMI0ZISpeeEV0RCxS3qWSZHcdB/BYJ8stzakE6Tf0lusvjMn5KFnxmR/5cNJ/iPQkUp pHxlrW2ucDHRXxxl9MQ5YKP67poEhKRsFAm3ceYzoNpF68yMV1NCTydvO6BznamH9q28 z2mQ== X-Gm-Message-State: AOAM531mssPp0YwPN5rqC1YBTjwq800HJomolMLp2VwSDuS94vdFRL+A JPE5J0+Fwrj84uz0E3YQYlXYP6WP X-Google-Smtp-Source: ABdhPJxxksGu7Lw/QlhrliYbDv88B7B8f+pSopUt93I4yYEn4PRt9n4qjRCvebdghkVnZm/uHJe7ng== X-Received: by 2002:a5d:500c:: with SMTP id e12mr4496378wrt.236.1593188901627; Fri, 26 Jun 2020 09:28:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 01/14] MAINTAINERS: Cc qemu-block mailing list Date: Fri, 26 Jun 2020 18:28:05 +0200 Message-Id: <20200626162818.25840-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 We forgot to include the qemu-block mailing list while adding this section in commit 076a0fc32a7. Fix this. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1b40446c73..d9695a2cb3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1622,6 +1622,7 @@ F: hw/ssi/xilinx_* =20 SD (Secure Card) M: Philippe Mathieu-Daud=C3=A9 +L: qemu-block@nongnu.org S: Odd Fixes F: include/hw/sd/sd* F: hw/sd/core.c --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593188989; cv=none; d=zohomail.com; s=zohoarc; b=oJbvCRE+jX/Mr+wSwhqF6rsQLhUoDfylyTpJVChB/xV9Zyh2CArQtldvhWY63tMIX+2hXA49H95RC961VqIYGuLFoD2ygwkL8+POWKOL3dpaGScQ1h7y7VP5uWkRica/2EhwGi5oK8hMQe2Jjblqa824cp5A7diknQ4fKmYpjNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593188989; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MjRNdoa0rZpF8KkV/ND0ssqMkJTZ9vSTBVaUds1+aIY=; b=cH4fWKwhTUgMsRUIMgoK8O3nCqjKtqNUh9DPTFy/4RmnT1xW9HX/CPfeksekUAlQR6V/X70gLeE7QEK4GsGG9E1S5SARJ4/S3oOu/W7IrconDevuQ67t5b4H46E6RddteMi9xRcTBO2w/xv+seBa9CAJ+pqeO1IXitJ6VH/zQgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593188989294835.2522478656297; Fri, 26 Jun 2020 09:29:49 -0700 (PDT) Received: from localhost ([::1]:57074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorEZ-0007Kg-UD for importer@patchew.org; Fri, 26 Jun 2020 12:29:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDF-0005ER-Qw; Fri, 26 Jun 2020 12:28:25 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDE-0003Jq-9H; Fri, 26 Jun 2020 12:28:25 -0400 Received: by mail-wr1-x442.google.com with SMTP id z13so10089843wrw.5; Fri, 26 Jun 2020 09:28:23 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MjRNdoa0rZpF8KkV/ND0ssqMkJTZ9vSTBVaUds1+aIY=; b=qAStDZRVr7ScDijLA9Ah2b13vm8F+l336IWdpYR/DDFT1sM0VaVO4Oe+aAOwjwvHry Vt91tTTymcq3vwztjFWbN6Pqq3Kohplzu5Cn4WI4UXERvU5AIvrnrAj/+mlZ3WoP2aDp QePOmYK5aExk+F36hzvidIpCUJ+EY1Jmw8p3jeKpsQzYepJnZ7BfXa+3s7zQGG1prGM4 GXKFoGTG+SGPy2Hr/qMTaqtSAza5Wo1ri5ORVCnF67RMeslFv9kGCVOVacoh/N9v+/Ta vw27OltOoWJ4sSNY8PixBJTfR7HGOA4LmlN9utdfX8fDi7VT4TZRC7d3JAucgTfeQHex gsYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MjRNdoa0rZpF8KkV/ND0ssqMkJTZ9vSTBVaUds1+aIY=; b=JijXTD034crakli0pEd61VASyLRZWOynH0au4rXkje2bh4QMebKtdSTyssyxxC+kgv kLtfKOlq2jDL8lr7WFgH4ea0zr8ZuInGtcZkr9DvjSQlVKpNs9/3fhI7h9Zovo8ds9s/ 6caTv+8svlNCfKf3HMH3sUgSGBnF1bZy+5XyLrRN7rXViGLIsGWYBNGmHNLeyd3tyorN jRADoMF3KW9aWECoG6fMfcLTQlO7i7zaOb5OR2WHHfzr0fbNb01L2KlesRxhAjwUZbri zdvVgoGVIPCRB2urNnO4dPE0lSS4Vt0A3Fyt2nUbw3iJG641tSYHJ0pov3KaCjcUmYX+ tGuA== X-Gm-Message-State: AOAM532c0VeVJqKFTObVRzT/bkIL6C4q8VyKhn1MBR9F6Fd0qon5Ji0Z lxgJ0ZwXoThM6JySeRWCh+BavdKJ X-Google-Smtp-Source: ABdhPJw/BF1uVbSI/SzDx7PDYGkQzpsU2++1zSIM5HNoA0h/BNIZcjwhK4fzCXzybUrjU0wj9OY9FA== X-Received: by 2002:a5d:4202:: with SMTP id n2mr4465897wrq.171.1593188902554; Fri, 26 Jun 2020 09:28:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 02/14] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Date: Fri, 26 Jun 2020 18:28:06 +0200 Message-Id: <20200626162818.25840-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 To make the next commit easier to review, clean this code first. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 97a9d32964..cac8d7d828 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1170,8 +1170,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->data_start =3D addr; sd->data_offset =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + } return sd_r1; =20 default: @@ -1186,8 +1187,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->data_start =3D addr; sd->data_offset =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + } return sd_r1; =20 default: @@ -1232,12 +1234,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; - if (sd_wp_addr(sd, sd->data_start)) + } + if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; - if (sd->csd[14] & 0x30) + } + if (sd->csd[14] & 0x30) { sd->card_status |=3D WP_VIOLATION; + } return sd_r1; =20 default: @@ -1256,12 +1261,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; - if (sd_wp_addr(sd, sd->data_start)) + } + if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; - if (sd->csd[14] & 0x30) + } + if (sd->csd[14] & 0x30) { sd->card_status |=3D WP_VIOLATION; + } return sd_r1; =20 default: --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189140; cv=none; d=zohomail.com; s=zohoarc; b=h4V6Gs3klmOnu2bDzqQO/SCyul9mBMUuMWvLAGI3Ng3LqerdlVYsHY6+rh5RtWKUgQrgKYnhQQvcmFAY6moViDmwLQG+s6zjcNZvpRR+BGRBjVb1LLSOLk093b6tYdJO/Hx8UeUqgPXZg1+RqvD6f7ocKk2FxtA3aacehtsZZdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189140; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NATlEi/FrWfP9Y28UrUe6cx6ZnLH5i2MWU0fBA6ejkY=; b=EG/90Y6VyNPl47nJmOJD1eRU9IuJ0zRkK16ylzJdztc5YB6t4N6Gg3gdEiw6mJ8ik1MgfBuYKvtV/JdgWc6svBMLsJXu1rhPg++qXIpo2VRO+qMNn5Q9afWzTms32p8883kAt009ydiKe+EQTH3E2Re5QBV81UmnyV0fzzag6Co= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189140876569.4693271026808; Fri, 26 Jun 2020 09:32:20 -0700 (PDT) Received: from localhost ([::1]:36846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorH1-0002JM-9u for importer@patchew.org; Fri, 26 Jun 2020 12:32:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDH-0005HM-3O; Fri, 26 Jun 2020 12:28:27 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDF-0003K3-HK; Fri, 26 Jun 2020 12:28:26 -0400 Received: by mail-wm1-x344.google.com with SMTP id 22so9385449wmg.1; Fri, 26 Jun 2020 09:28:24 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NATlEi/FrWfP9Y28UrUe6cx6ZnLH5i2MWU0fBA6ejkY=; b=me1/iF1aFo1fTxDERquHZZNX7zuzCNPRbCgkK7mbuGDpLPmFSPRgOLe/V+sC6EA2wT EcLQfZ2BgiPLa6SEaY+RZyPqrohkPUuLRsdrkayMhQt822f1yRK0mV3yGFZY0gwKrYAd umAmHPbdnOMbijTgvWPwCMOzQSDsOpjfoYLepNaAsGMf+uJolUsOVlAnCCr+mFa/vuKU Q90G/tjjNjeMgru29NeIT84jYnsfSkzJo39gdobE05XFPBhrdiaFIYZUGNrv6KhFawFY eIa4I87js81E0nPYBE02n/3k6iT1nME1vTeSND8Sh4HQ2XRKJ4LStqBNu+9pPv3siZyB aVPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NATlEi/FrWfP9Y28UrUe6cx6ZnLH5i2MWU0fBA6ejkY=; b=Z4gmsBC0ChiY40xK4Ts9fDolWLBLW3cXVIBFuoWbair2KKbrI0gg0tO4kCUmUZo1f3 ViFVP43Hzj0wI33HSr0duYqiM5xjhlf4hXUupNwwTuqQW10GnTfp5rrUgCw0n63aj8EZ 4sMz1NhJKS8FUxiInVF0ghZjKD6OsohDkUp+FRtZVBsyqN/eAzFGXZKQwwIRLxFVyrj9 F5cAldObEvTX9fbchKDxCZp9rhpM4uQm1ST2zlU6/UtroDaxEqer240swnfdCh2y//9r A1I+G1LMnp9eU88KKdVQ5JjA4GvWLrvx68Wa9q5PWcYacvBPP54RnbEXR6hf62QK+pP2 rLDQ== X-Gm-Message-State: AOAM5317otVN0MFYZrLUTwRPKU3Wqkxz0Y9sjGwkbbFRkAnU25LuJskZ 26qiCFKOK6XK0/U2Bg47RS7kUNm4 X-Google-Smtp-Source: ABdhPJzj8YR/NMdyAkkcYLLw/zYIhrQBao0in30cw8Xty/GsQI2g4+fayEO0/s1CdCYPVsyEATksyA== X-Received: by 2002:a1c:f702:: with SMTP id v2mr4148991wmh.71.1593188903732; Fri, 26 Jun 2020 09:28:23 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 03/14] hw/sd/sdcard: Move some definitions to use them earlier Date: Fri, 26 Jun 2020 18:28:07 +0200 Message-Id: <20200626162818.25840-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Move some definitions to use them earlier. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cac8d7d828..4816b4a462 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -80,6 +80,12 @@ enum SDCardStates { sd_disconnect_state, }; =20 +#define HWBLOCK_SHIFT 9 /* 512 bytes */ +#define SECTOR_SHIFT 5 /* 16 kilobytes */ +#define WPGROUP_SHIFT 7 /* 2 megs */ +#define CMULT_SHIFT 9 /* 512 times HWBLOCK_SIZE = */ +#define WPGROUP_SIZE (1 << (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIF= T)) + struct SDState { DeviceState parent_obj; =20 @@ -367,12 +373,6 @@ static void sd_set_cid(SDState *sd) sd->cid[15] =3D (sd_crc7(sd->cid, 15) << 1) | 1; } =20 -#define HWBLOCK_SHIFT 9 /* 512 bytes */ -#define SECTOR_SHIFT 5 /* 16 kilobytes */ -#define WPGROUP_SHIFT 7 /* 2 megs */ -#define CMULT_SHIFT 9 /* 512 times HWBLOCK_SIZE */ -#define WPGROUP_SIZE (1 << (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) - static const uint8_t sd_csd_rw_mask[16] =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189269; cv=none; d=zohomail.com; s=zohoarc; b=VIGc7YITPxL0SqZi8D8WXD9PYzXlIKbm9U8y2o3GoUEGabij7EpKL4xbVLFxu7OcS3RMhE9jevPkXxWHYtSqacWNDVjR6qayQd9NV2B2kUAHV9YIS00KcoAdzaOzqekmtSV/r0/P8FZpaVbmvez0gcbjML5qrmH0+ylkuMn7bC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189269; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i3AX6k9zJcs7ntcPjDjs5EOqKiW+/SX/Gp5bwn7hkCA=; b=Ke1jW+V67g44Kwfdpl4jiq1AbtGEsXNplPSfz5Yqzoj/+SaBX22z6DMv8XV7DEq0N3EqZuexo+s5mtw8nRnjFBLbhQXeFvYupN8G7L+hY5+KDobxXz/1d88gVEYxFisxOKZ9owA2OjaaFDZvzimOWyF7ev91jE+8gD4R+rvKFsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159318926988457.34100917746025; Fri, 26 Jun 2020 09:34:29 -0700 (PDT) Received: from localhost ([::1]:45980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJ6-000680-BM for importer@patchew.org; Fri, 26 Jun 2020 12:34:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDI-0005Kn-9b; Fri, 26 Jun 2020 12:28:28 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:34441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDG-0003KN-Ph; Fri, 26 Jun 2020 12:28:27 -0400 Received: by mail-wm1-x344.google.com with SMTP id u26so9222577wmn.1; Fri, 26 Jun 2020 09:28:26 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i3AX6k9zJcs7ntcPjDjs5EOqKiW+/SX/Gp5bwn7hkCA=; b=NvfCZttOGz8tB9+6My1zPfHN6H1+XEyvbdNgtNX2q36ojoyII9aTnHBsedBvvZQPxE 8PvZF0Q2uqM2FpMYwhvTjhjOOWGgeihnoO87d6B+FuT3ZAm4CwLslf83uKSOJrCfPKcf PPxPr4tEs2O3qQ8IgyIswlSFk8GAekAXe+/qCaXE+OwMrTXRgstt8qO06nFx7J2ESrVy 9H2/HquxNDMuPPzbysBSfDPDYtiMt6t9krrCHRKa6QfoyQ/6W73uSQIdRCwk11/0qoc4 0dEx3oXYlN7jQtMlRwYa2OPkm0GEskBY3M9Job22q/gBiV1KU/HA95eLmn3/5epd+t0C 94Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=i3AX6k9zJcs7ntcPjDjs5EOqKiW+/SX/Gp5bwn7hkCA=; b=YQvlWgBX7jI/VUaitjK+3hvIbUhe5qPfriJsVVhIYo0PCCoF1t5nZke6VhsM2dL8+p Fplb02YvLeEvGGEG1Q5ZHoM3DmKrLGciRrUpfNa3MG2e3Cjh4KG/L1PN3I26mi1RM7Yz lH99AFRH53FRsPbgAW+7QB4hFgbHbQeQL2Vy7Sc83ALqnViCe4YMlhr8AKAhbcPI5dzS T+XMsS0kJrKTfzL8pU0qgcZmEGt4MwwQ4tneuld6B/w/nm5Vtro0ZcQQ40vEA9bWdY3z x4QTlZo4xaZto8cw5vdT9MuV2w1MJle93aLCff5atI34oBn7KQ43q4yilL4Cranbih2n SMyQ== X-Gm-Message-State: AOAM531goojKxB1l1CHxkkQhhefqb4u+qqZJabCYFz5MbakLQ4VKpRsh kP1sUt11SWOTHwCGCz+HvN1Snk0T X-Google-Smtp-Source: ABdhPJxu/cpLfmD+VnBOo+qRwlyWsoOZ4Kzp6bzhUPBfk6LZxzJcuxiIq0npsWcaPjqNzpFym5Tibw== X-Received: by 2002:a7b:c944:: with SMTP id i4mr4232248wml.22.1593188904883; Fri, 26 Jun 2020 09:28:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 04/14] hw/sd/sdcard: Use the HWBLOCK_SIZE definition Date: Fri, 26 Jun 2020 18:28:08 +0200 Message-Id: <20200626162818.25840-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Replace the following different uses of the same value by the same HWBLOCK_SIZE definition: - 512 (magic value) - 0x200 (magic value) - 1 << HWBLOCK_SHIFT Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4816b4a462..04451fdad2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -81,6 +81,7 @@ enum SDCardStates { }; =20 #define HWBLOCK_SHIFT 9 /* 512 bytes */ +#define HWBLOCK_SIZE (1 << HWBLOCK_SHIFT) #define SECTOR_SHIFT 5 /* 16 kilobytes */ #define WPGROUP_SHIFT 7 /* 2 megs */ #define CMULT_SHIFT 9 /* 512 times HWBLOCK_SIZE = */ @@ -129,7 +130,7 @@ struct SDState { uint32_t blk_written; uint64_t data_start; uint32_t data_offset; - uint8_t data[512]; + uint8_t data[HWBLOCK_SIZE]; qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -410,7 +411,7 @@ static void sd_set_csd(SDState *sd, uint64_t size) ((HWBLOCK_SHIFT << 6) & 0xc0); sd->csd[14] =3D 0x00; /* File format group */ } else { /* SDHC */ - size /=3D 512 * KiB; + size /=3D HWBLOCK_SIZE * KiB; size -=3D 1; sd->csd[0] =3D 0x40; sd->csd[1] =3D 0x0e; @@ -574,7 +575,7 @@ static void sd_reset(DeviceState *dev) sd->erase_start =3D 0; sd->erase_end =3D 0; sd->size =3D size; - sd->blk_len =3D 0x200; + sd->blk_len =3D HWBLOCK_SIZE; sd->pwd_len =3D 0; sd->expecting_acmd =3D false; sd->dat_lines =3D 0xf; @@ -685,7 +686,7 @@ static const VMStateDescription sd_vmstate =3D { VMSTATE_UINT32(blk_written, SDState), VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), - VMSTATE_UINT8_ARRAY(data, SDState, 512), + VMSTATE_UINT8_ARRAY(data, SDState, HWBLOCK_SIZE), VMSTATE_UNUSED_V(1, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() @@ -754,8 +755,8 @@ static void sd_erase(SDState *sd) =20 if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *=3D 512; - erase_end *=3D 512; + erase_start *=3D HWBLOCK_SIZE; + erase_end *=3D HWBLOCK_SIZE; } =20 erase_start =3D sd_addr_to_wpnum(erase_start); @@ -1149,7 +1150,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) case 16: /* CMD16: SET_BLOCKLEN */ switch (sd->state) { case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { + if (req.arg > HWBLOCK_SIZE) { sd->card_status |=3D BLOCK_LEN_ERROR; } else { trace_sdcard_set_blocklen(req.arg); @@ -1961,7 +1962,7 @@ uint8_t sd_read_data(SDState *sd) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return 0x00; =20 - io_len =3D (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len =3D (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; =20 trace_sdcard_read_data(sd->proto_name, sd_acmd_name(sd->current_cmd), --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189162; cv=none; d=zohomail.com; s=zohoarc; b=XVQjR43GlY0Qu9FiuAKa4BrQWqrvdzMd92zGZDF/RXYzp9ERI7B1EsGQmshVKoVJ92S53QemKGaipDalZgs0i7/75bnrZ1ly8RURdS/B4mZAxWP0bgFUkZBxs9vkYlbkTAy3GVpPf3O7cuNu0lhl0cIJOVTCoV3EbZfXJbWAqpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0q3fvINBMewfm4ouk0ChZ+kON+bgL7uzrdyA1Uly1X8=; b=R9rPmGVPFjHiGFzZIeDp8PlRhze9RsY1XIbnHRHTu7WkYRAgndrAXK/jB/asUdnJcAipQyUjvcBIlOoYSZkaC+QbLfH7Flg1E4o9HasiCItQHSkdBF8KK0mN7WCCTEVG1uuwn2Hki9mjuovT3cVTOCrnRfAwtAKpWoj/ktgXdDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189162170318.093245268028; Fri, 26 Jun 2020 09:32:42 -0700 (PDT) Received: from localhost ([::1]:38186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorHM-0002vL-M3 for importer@patchew.org; Fri, 26 Jun 2020 12:32:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDJ-0005P4-QU; Fri, 26 Jun 2020 12:28:29 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDI-0003Ka-1B; Fri, 26 Jun 2020 12:28:29 -0400 Received: by mail-wm1-x342.google.com with SMTP id f18so9932623wml.3; Fri, 26 Jun 2020 09:28:27 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0q3fvINBMewfm4ouk0ChZ+kON+bgL7uzrdyA1Uly1X8=; b=f+wmNB8G8JOaWUmH2S4Zhmj6TCiVETj8LbbARXDF9waok9EXdu6hwlgvqbPiDMVZBT L4qSyiXsIPnKzx2zDQzSq3ahd8BdLgYvuDJgYDmBQVc9TurTr0CHtn2HPALKyKknU9SW 3UkeVgsjUKweRrQ66bkqX3IYjhiRY+Rod8BwhybKGtmGlwmQPiYa6GBRK39M1E9RGzEq OXXFdooswOUGrNy02Pbh+pWqrPPL4NjjRBoXcGgfs04DbQnMmD3zzWMgzI3Q9cW3UsN4 Hm0JRXfvR7nvoWVOb2vTRD/981U683IsyjSy4mJVE8I6hAGxat4RirJe022Y1JKtWO6A 57AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0q3fvINBMewfm4ouk0ChZ+kON+bgL7uzrdyA1Uly1X8=; b=oM3GFHYg17gEY7zGHpoCWpJ0NcudMFFvybC7Xiiew3McuXT5Y6NqlqKG01hx/u2b0t /fe9SDIi1gFkoORMw6jIKcKmhLIGYpdmQPf1FD7H8g36JrKKFJV1KKr8FqorK23VGdZQ 1AbPbKV6TtHA4qpuA7VfBAPNyz7QJNgQAEcOofPENBvsRJszGkmCVN+2R3xCftQ120lU 3aL2jymWeq+QI4+z+OTs9bi2PYfjlc4R3P3a+t5CpX1Dzc/Rq0Ze+2BpkYvMYSvc8E1m /vUYQaLCM+DN0gehliqxBOS6K08oHtEa7XiJNHc+RcIFTZ9p1M44eEkBjpnsVhKPiZRg hXjw== X-Gm-Message-State: AOAM531IMFYmGBzmxWBaM1gTWpja334B8lWUtTBg98WxAiSHKutAjRcR oaXexKbahaO/iryTdCcr+MMjfmHZ X-Google-Smtp-Source: ABdhPJz6MeSZdgxW5+n7i1glaudEfIu7yuZgpUxHuc9bhMFaIwD00nfjqdAb+HHNPj2Lyv/FTxqMEw== X-Received: by 2002:a1c:a7ca:: with SMTP id q193mr4323211wme.69.1593188906134; Fri, 26 Jun 2020 09:28:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 05/14] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Date: Fri, 26 Jun 2020 18:28:09 +0200 Message-Id: <20200626162818.25840-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Prasad J Pandit , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Only move the state machine to ReceivingData if there is no pending error. This avoids later OOB access while processing commands queued. "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01" 4.3.3 Data Read Read command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. 4.3.4 Data Write Write command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. WP_VIOLATION errors are not modified: the error bit is set, we stay in receive-data state, wait for a stop command. All further data transfer is ignored. See the check on sd->card_status at the beginning of sd_read_data() and sd_write_data(). Fixes: CVE-2020-13253 Cc: Prasad J Pandit Reported-by: Alexander Bulekov Buglink: https://bugs.launchpad.net/qemu/+bug/1880822 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- v4: Only modify ADDRESS_ERROR, not WP_VIOLATION (pm215) --- hw/sd/sd.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 04451fdad2..7e0d684aca 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1167,13 +1167,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) case 17: /* CMD17: READ_SINGLE_BLOCK */ switch (sd->state) { case sd_transfer_state: - sd->state =3D sd_sendingdata_state; - sd->data_start =3D addr; - sd->data_offset =3D 0; =20 if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; } + + sd->state =3D sd_sendingdata_state; + sd->data_start =3D addr; + sd->data_offset =3D 0; return sd_r1; =20 default: @@ -1184,13 +1186,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) case 18: /* CMD18: READ_MULTIPLE_BLOCK */ switch (sd->state) { case sd_transfer_state: - sd->state =3D sd_sendingdata_state; - sd->data_start =3D addr; - sd->data_offset =3D 0; =20 if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; } + + sd->state =3D sd_sendingdata_state; + sd->data_start =3D addr; + sd->data_offset =3D 0; return sd_r1; =20 default: @@ -1230,14 +1234,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) /* Writing in SPI mode not implemented. */ if (sd->spi) break; + + if (sd->data_start + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_receivingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; } @@ -1257,14 +1264,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) /* Writing in SPI mode not implemented. */ if (sd->spi) break; + + if (sd->data_start + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_receivingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; } --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189305; cv=none; d=zohomail.com; s=zohoarc; b=bJ2EzlQAwabpzGt6y89BzJqN+3p0tTU8wkZqP+PXaTw/mSnu8s6cIloX9Fe4wssxPxZNS90PfPF9lbaeAYHDS6EhSOFAqx6ixIgcQep410gIkMBaWD2IL5K3X3ULBD6ChZcRnVaq/uC4/CDgvv8a0jcGEJ0qEYRBLRDyjVRxWVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2FehWZv489g7gLp1IpuJgAw0ELgG4HGTfqwfreEPxtg=; b=DPn8eaoyeudzxVXjlX8NHzXNfKqwNb1eBOre0MPK7IlX/lo3Zvqsb3HLsw0krXvPfm+O7cqua8n4RJVMktpopaddYdJ8oeZ3z7hvRZKarI2GPQG2NkAvamX3L6eeGSv2qaQK0T5Ahg2bhRz9du6d4K7JpQHwJIGf3o2S6lW9+YA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159318930597454.0572332705334; Fri, 26 Jun 2020 09:35:05 -0700 (PDT) Received: from localhost ([::1]:47862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJf-0006u1-Lk for importer@patchew.org; Fri, 26 Jun 2020 12:35:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDL-0005Sm-1h; Fri, 26 Jun 2020 12:28:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:37380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDJ-0003Km-83; Fri, 26 Jun 2020 12:28:30 -0400 Received: by mail-wr1-x444.google.com with SMTP id a6so10090591wrm.4; Fri, 26 Jun 2020 09:28:28 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2FehWZv489g7gLp1IpuJgAw0ELgG4HGTfqwfreEPxtg=; b=vXDcmHWou/Bj8r0kvmNmPomx7yO6hR73iJaBzyHMZTu3VQxDsQChcnbyiL0M+WBzSe 1Zh84v7azNUqHyWG+faFWp4tlWFpQDonagRDY966Tsk8MH+B71gz//zuTY5Ud8ORyrcM c/ICK6BcEbmAV2MsxxnUX2RmDhDYDcMP4DAt/gwk5DvRvRelI//EEv+8XojRUeRzQcfz CwR9kv5xJb4T1D10uzKyzzhU1uMfmeI4O+THdbB/IUuLFgvbjuVRpkn/dDwZe42EHWvs dyfAicZEJtm++fA2CcqLVy5TOCyRFSX4waKlwQXKHEFMTBXTzDfU4heVwe+M30uVatVx sy1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2FehWZv489g7gLp1IpuJgAw0ELgG4HGTfqwfreEPxtg=; b=s6IiQuDRMsG0OOD/lH3YRETq20lwrDVyYS+xkJcmSC3A1PxOKpdVBI7ij+QqK7dh4/ StUpr0ZaWC8sRVkCF0PEl29sa57ajBQEcr9lPH+bfZOIuAYhNMGpbJCBP9NN8HYBBBIp Kup0h8fxtRyC0lX0BpaRSAnf0t2pIz40ZtKNUk2MN1+Aq+lVWc8sG/cYOMk1Whk468Xk XtXZ9G9eYVSeymX6lpn5YlUf4BcxQNHGR/a9nPtZKyNcTENRnMC9FOw8mjx+UbVUEF6L cV9XpHlc6T2pjSoLqKS1mfblcfpc++lCq6MknGC2VeDzjRT8zfjIzSbRYaUluQA4E6B8 SW8Q== X-Gm-Message-State: AOAM5326rqXXntJG5/qAbwOPDcmmXmn5N2zcs8FfOnwL1gE79DFztXyt DCNSWstsKHw2ZQukj8TfhfgMg4+T X-Google-Smtp-Source: ABdhPJyQZWOj7gN5p9VbLJrviZQT9fLo53LhR3zYdorhxD8yZi8UXmcJoKYEQKy+soR9Jt/e1JNWcQ== X-Received: by 2002:a5d:5270:: with SMTP id l16mr4567462wrc.122.1593188907361; Fri, 26 Jun 2020 09:28:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 06/14] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Date: Fri, 26 Jun 2020 18:28:10 +0200 Message-Id: <20200626162818.25840-7-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Only SCSD cards support Class 6 (Block Oriented Write Protection) commands. "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01" 4.3.14 Command Functional Difference in Card Capacity Types * Write Protected Group SDHC and SDXC do not support write-protected groups. Issuing CMD28, CMD29 and CMD30 generates the ILLEGAL_COMMAND error. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7e0d684aca..871c30a67f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -922,6 +922,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SD= Request req) sd->multi_blk_cnt =3D 0; } =20 + if (sd_cmd_class[req.cmd] =3D=3D 6 && FIELD_EX32(sd->ocr, OCR, CARD_CA= PACITY)) { + /* Only Standard Capacity cards support class 6 commands */ + return sd_illegal; + } + switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ case 0: /* CMD0: GO_IDLE_STATE */ --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189161; cv=none; d=zohomail.com; s=zohoarc; b=LUzVwTmPuMA89k3096QvqTtkrGz4uL7IZMJyb/n9cZQxS+LosuTN2TsJm5vmb4JlYjJiMl+lz35rxc8rHe8nxSX7y3GoX5w2fjZ2M1jhVer5XyYjvFWCVriojTujKFoBDmdS/it3Crqqqu+zSf/1Evf/fp4xvf2ow6P3kgX1ZEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189161; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q2Dr1F51NNYfRmDxzHUuA6aQIgYrZuE2BYPtrlUH9Ok=; b=LFu6YvK8bUl0PdbijWOcsSDaMD/XzPDgoI9XIdGocBL1ZR64N6liNMI0dMYi+LAIZ1pf49TMv9n2uRoGMDSLdOIEzh5ozX6kVi/avPK1speuTraM7PjZ44vKCBs1LDtTn9QNPekWyW73EMCkZ6kUzojAn2qLlazcUmOqH2lDV7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189161889517.4256585061169; Fri, 26 Jun 2020 09:32:41 -0700 (PDT) Received: from localhost ([::1]:38060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorHM-0002sC-9m for importer@patchew.org; Fri, 26 Jun 2020 12:32:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDM-0005VK-0E; Fri, 26 Jun 2020 12:28:32 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDK-0003L0-FM; Fri, 26 Jun 2020 12:28:31 -0400 Received: by mail-wr1-x443.google.com with SMTP id o11so10071932wrv.9; Fri, 26 Jun 2020 09:28:29 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q2Dr1F51NNYfRmDxzHUuA6aQIgYrZuE2BYPtrlUH9Ok=; b=VroG3sCX/GnrLSwQZyFwBa0QNsHOJc63q3kMy5xidet/I10niuuHM4+GbfxDY6bPj3 uVlwbgNnCF9Oc6l9At+TAzInU6KmYaygcwZJTs+x+vcxyNR8EgSmyuDPChNXtMQ/nhRg Bss9vYilFCEoGztyEeToLfFSeMj6SRxOVtT/d0YMu8pGJRqyBMlA2/IJiP9nLcQVBSWX 85h7jC1Z2FdOTzfdAlPy2DH6/wbAqwvODFC9klvOSWRz20gFP03c7UcNbKIQjGROP2cs YFYSpdbuudYMb5oWJvzpBDa9/jkGb60sSITvHAt8P1YmTkPC+zckHoiYzmmLyg6MxPkl T2sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Q2Dr1F51NNYfRmDxzHUuA6aQIgYrZuE2BYPtrlUH9Ok=; b=iJXbOfLLLicLS3Jwbc/yiaeu4pIKM8WhStdTCJ7EXDMF/KM1GzXiQN0FQ72dLBKI/C fGDgQ5MeEGKkROnrPSt3f4+DkZq59NNOE1ThZx5jGmQXG3YL9TJznjxvzPSfcLgzOgkm FQxzltTgkd/45OT18Ck25yYsts3puReU+WSWCppPTX7uZEyqXvEv7FGs7FWFnk/TcpTc K8WFj92XurvSEUdkpdKuDKppS7Dlsu2O65c8fa6YfMRVV+1R0RxIydJtFBZTUQuBo5UM QNYFiMeXciPgC12aLROTDpm54BjSChXIxF4eXxZsuELa0EBB1JvT7UOfwFLdWZfCvPw/ Z7pg== X-Gm-Message-State: AOAM5317kjIussgr2tfXcgouCUboUWc3ppc3wQc+o6LuufeJrKuqW0DT ZklO7ipNdXOOoKkqQ/Qw3Z5s7EQs X-Google-Smtp-Source: ABdhPJyXI1Qx63Ng1eXKV9TBY7Rb3I/mcn0N2ie+3C6ugEEu2TQq2x9NTHMaNNrQXHSdFUB3vB2kHw== X-Received: by 2002:adf:e38d:: with SMTP id e13mr4561001wrm.304.1593188908619; Fri, 26 Jun 2020 09:28:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 07/14] hw/sd/sdcard: Check address is in range Date: Fri, 26 Jun 2020 18:28:11 +0200 Message-Id: <20200626162818.25840-8-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As a defense, assert if the requested address is out of the card area. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 871c30a67f..0b606e9054 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -539,6 +539,8 @@ static void sd_response_r7_make(SDState *sd, uint8_t *r= esponse) =20 static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { + assert(addr < sd->size); + return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); } =20 --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189433; cv=none; d=zohomail.com; s=zohoarc; b=RLF01FAN5/yQBz/oHX2kaxtzcSvOoJF8ubBSRzlSx00tHg3iZFzZtjjT/1TkEzb8BWk9gCZmtUIBqaMk2VxRLfs6BYvOWstEJNULszO/deB10iPAn4ImGZNrEIVc5WJhg74pXhRagL+oXlk+vpfc/TFmh16vg6bqxY5aVnSN59M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189433; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KpF9MIzXWHFH1j+WNA+tLcvpyt6lEogn0WVElNJnFTM=; b=nhRqnsvfpCrSnbzYKL6zxYF5BRUnyMkEXAKAoR/lXzppW9P7t8EuYGPE5Xoi4fczCm2TvwOoABnVgXzSfeSmGDDDZsDmcdxZuIkhIttwxHxR9Hi+S3zBQpJx1Xz8e3QkXd6VH802urSo+q8eW4CnudE2JJUiLyatDiFDWsvPpNY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189433363893.0271943303466; Fri, 26 Jun 2020 09:37:13 -0700 (PDT) Received: from localhost ([::1]:56066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorLk-0002Hq-6N for importer@patchew.org; Fri, 26 Jun 2020 12:37:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDN-0005Y9-5W; Fri, 26 Jun 2020 12:28:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDL-0003LI-N7; Fri, 26 Jun 2020 12:28:32 -0400 Received: by mail-wr1-x442.google.com with SMTP id h5so10073198wrc.7; Fri, 26 Jun 2020 09:28:30 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KpF9MIzXWHFH1j+WNA+tLcvpyt6lEogn0WVElNJnFTM=; b=ZQz6ojscR4GpPX9HEkimPLCyckwIyMKDMgjh21CemtY2xrLgtuJ/z8qRlNqxv0egq5 tj9pGbSfwbLotvo+zvIfyw1+t0yv11cpXNh5AKMDQsnoRg9xi/Oyx6jHFeiTBwZo5K30 r3Wlrjl8tvRm3OGhJLrYtJNd9DH1QjoCfsuCh1/pnvKWy+f41PjAj/due6AN61pNfEeK cO5igRpOql+tJlt5LUPi4uzXX0r3+1KggcJ8VEZeDf3+pBuTIzekaqdbvfRCtf/76U8o AttAx7oM8Xp04SHQJ8ONGb+dMdmvB2Z8fo70d9M6cgEcOyz960nf6a80jtkSYK7QQ1Wu XFKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KpF9MIzXWHFH1j+WNA+tLcvpyt6lEogn0WVElNJnFTM=; b=bjzNMUoB0dnvnD1FcRL118/Dn7I94ExF0MuJzq24v6kDZ+G9IQyit8QeMBw/VCdfK0 RLIfh3HX21P+QtByIGFyKmS/FiAzCRIuUXT4KpsTRx7s+RyjAknqmEfTHyqQYZb2zM9v Uye+z4ULSUak3AvovSvMrfZ2zA89ifC3odG75Ru9aLfL29ygI0LfrJIjxcUT+I3NdO6K 1IEbOOAWsntUnbwq1w+/obPDepRKsmNqw6rUwf5nwox6WFFt4sUrWOhUAL6Dm4g0Q1pX rwL4WAEnCw2VtqECZ8s7TqpmdxtzKsBFMO5XHcvBEiKBhh9kUAjDEA7eoD7svVAhJZ2T DYzw== X-Gm-Message-State: AOAM532uPnPyLIyq+a+zETpAEC4LZtXlW+Ep0hO44EfiaCZbMASsToMe QjYK0OcpGKg/LPzEhoigCKRV8qnq X-Google-Smtp-Source: ABdhPJzr3vN4IIPed9yajvsrdON/AAcvvefPm6imYi4Lkpixm6+n1A/pt7IbOcoueBCcgwK+DjrLWg== X-Received: by 2002:adf:ec88:: with SMTP id z8mr4557160wrn.395.1593188909631; Fri, 26 Jun 2020 09:28:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 08/14] hw/sd/sdcard: Update the SDState documentation Date: Fri, 26 Jun 2020 18:28:12 +0200 Message-Id: <20200626162818.25840-9-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add more descriptive comments to keep a clear separation between static property vs runtime changeable. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0b606e9054..7d20f344bf 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -103,11 +103,14 @@ struct SDState { uint32_t card_status; uint8_t sd_status[64]; =20 - /* Configurable properties */ + /* Static properties */ + uint8_t spec_version; BlockBackend *blk; bool spi; =20 + /* Runtime changeables */ + uint32_t mode; /* current card mode, one of SDCardModes */ int32_t state; /* current card state, one of SDCardStates */ uint32_t vhs; --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189292; cv=none; d=zohomail.com; s=zohoarc; b=KwWlLq7BhGWiiKQC28sPt58atjvYw5dEXLHpkdsHes3h1wuHNOLyJf0tVv2Jb1py4BuvVNCOULXW9IcTdGBrxkcb9sp2fpsq8eZIJYpw6iCMfZHuCc5qKj5omMnQV2wizm9XLeaVHv6tux1GsCJIe07WkplahUgqkeZCpzbUVCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189292; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=VoHOxfF61Ewj9yLUxT+hx1IlOYCScOe4KxE+NGxBHWox6VwSUTkxFPlzQclu9XnuqXBi0IOt0g/GfdnuW0ogvucvoOJOCY9amyf68H6IugZ5mZZXWU879HHg53bEW8VXGQLPXxmSVUlObDMboFaa/ORXAhGpzLjuvY90WoOq7Y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189292430283.7662107229763; Fri, 26 Jun 2020 09:34:52 -0700 (PDT) Received: from localhost ([::1]:46776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJT-0006ST-12 for importer@patchew.org; Fri, 26 Jun 2020 12:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDO-0005bR-9k; Fri, 26 Jun 2020 12:28:34 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:47037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDM-0003Ld-N4; Fri, 26 Jun 2020 12:28:33 -0400 Received: by mail-wr1-x444.google.com with SMTP id r12so10024964wrj.13; Fri, 26 Jun 2020 09:28:31 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=UsGsFqPff4byO+Q81uVb6SiuKiI3wvz0W87LcZfET3165RbmBZj3VGkD4hS4BK5ab0 szHuEoNsROADkrk1bJL5T0NfyEW6j8S++4WsnMFTaTAMYhAE+++/kLgefbgcAGofBOkX JU3pfeQ2JPrOjOPTVsfTbgPg2jHz32izJNsJ5miChXiBsUFp0zcDBlZVu9iOL10xKL5G 7O8G9NybwwAmpExFN1g5grooDMJYFLy+ajgmyBtit3iB/DUyg2OD4k8v+Pq/FM+4sfeF VLebxsAh7W288lASPaBGfN0mDx2fPKhypxi1f6i/XTim2lVs5mfzw29H9v89fKZUZK6d C3lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=HdjK6qb/pj4tIkpEdoCkk3rEgrMN+VmwAncyauN4MOTA4NIUJpunc5dOsYP9L4ZMCB fOTA+HuYH0of/uTnXnGor+NGLc4X3BzkJurc+5n5/vHzmMSRhdEYV9ldNeqZrY4FjQ1+ vVijnynD+f4HL3vo5POFMnyEgPzjxYRD+SMvPKvKkJT+Mh0LeWp4oR9RKQJcj2pXNTAh zOQh8/XfdnpwU34cU0aTQbkNZq1CjzfRuwmvZy4RbUk7+4kv9uAo18qN2fPUcRGtGi2i 51bucswxqcKGsfmijjJK45T3VyDJ9nnd6Mbssj4roktSxJYi6lT1n6WfF9SmD6HZsR9m 9sQg== X-Gm-Message-State: AOAM531ShpFSkU9SYnPK2kdhI4jrGUhf6Hnvz+OwhxY++JVEzh61H17O 7lEX2BUNgXVljeis+al31j5Vt6mc X-Google-Smtp-Source: ABdhPJx38FVdo2pvzuXGnx9jLVtqX6DL79DTMHn/pAB3Lad5+p+Vlua2ElK+H0nwY45qQMh9GaE9oA== X-Received: by 2002:adf:e901:: with SMTP id f1mr4608999wrm.80.1593188910851; Fri, 26 Jun 2020 09:28:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 09/14] hw/sd/sdcard: Simplify cmd_valid_while_locked() Date: Fri, 26 Jun 2020 18:28:13 +0200 Message-Id: <20200626162818.25840-10-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) cmd_valid_while_locked() only needs to read SDRequest->cmd, pass it directly and make it const. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7d20f344bf..b887dce0e1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1664,7 +1664,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, return sd_illegal; } =20 -static int cmd_valid_while_locked(SDState *sd, SDRequest *req) +static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) { /* Valid commands in locked state: * basic class (0) @@ -1675,13 +1675,12 @@ static int cmd_valid_while_locked(SDState *sd, SDRe= quest *req) * Anything else provokes an "illegal command" response. */ if (sd->expecting_acmd) { - return req->cmd =3D=3D 41 || req->cmd =3D=3D 42; + return cmd =3D=3D 41 || cmd =3D=3D 42; } - if (req->cmd =3D=3D 16 || req->cmd =3D=3D 55) { + if (cmd =3D=3D 16 || cmd =3D=3D 55) { return 1; } - return sd_cmd_class[req->cmd] =3D=3D 0 - || sd_cmd_class[req->cmd] =3D=3D 7; + return sd_cmd_class[cmd] =3D=3D 0 || sd_cmd_class[cmd] =3D=3D 7; } =20 int sd_do_command(SDState *sd, SDRequest *req, @@ -1707,7 +1706,7 @@ int sd_do_command(SDState *sd, SDRequest *req, } =20 if (sd->card_status & CARD_IS_LOCKED) { - if (!cmd_valid_while_locked(sd, req)) { + if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |=3D ILLEGAL_COMMAND; sd->expecting_acmd =3D false; qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is locked\n"); --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1593189298; cv=none; d=zohomail.com; s=zohoarc; b=X1KZri3qMRgw/WbyUgpyoTi7h4y4Q/J4c+2T2ih03OVUgeZDsFuvZABsJ4ktxYKM7aAGFHK/8FebHFTwu6aMupHFvyJsaE82+f3A2+29SEDt8g+JXoWcXZH9pHkOgsgRdacibRIaspLltng3WdYn+jfagyvsa8Sv3MW06igAuX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189298; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JbDqgfPHpizj2Xr97jabygp2Vi8eQjOpNs5caV4op9Q=; b=HanTcip9zDffRPyfc+pZc8rIlC7QF68RQnRHekx3Q7sISAXwWZM0hiHCu9loEdCXqsA94S+9mVWriAXSx8x1ORLcQUAeWn/YII3SMFhaFKivnt8KyodCTcQQwNLYdr+WHORpIhVj2zvLJv/eA8zXrP527RIXGOboOjp7xIZ34Mo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189298264782.8663237528588; Fri, 26 Jun 2020 09:34:58 -0700 (PDT) Received: from localhost ([::1]:47278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJY-0006fN-Sg for importer@patchew.org; Fri, 26 Jun 2020 12:34:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDP-0005ep-Eb; Fri, 26 Jun 2020 12:28:35 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:47036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDO-0003M7-02; Fri, 26 Jun 2020 12:28:35 -0400 Received: by mail-wr1-x442.google.com with SMTP id r12so10025024wrj.13; Fri, 26 Jun 2020 09:28:33 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JbDqgfPHpizj2Xr97jabygp2Vi8eQjOpNs5caV4op9Q=; b=ZZxJPx41H/UkyyTgJmq9CsOhjw9pZVvtam7IX/v4TM7ifyEbYVMWIjowqONG6Iu96E vNne6Q3HWHDYEZ1xa+uzMLplzXCLZc4PGgHpvG+AVOiL+1+uEm+DNy1QdeGi0ENG75oI /jec3YSsxJ+HkCkNmjRo0wr2FUkVJ51fE97KJmn9698MjrjFaHouggf6bBLYtEFSi+av J8wcZCMMSDruu4rQG+I1+sfLr8n3KZHjg98mo5Ka7YSlfFWLnXTLlRsuFBSrrQ2mTQHA WNLDBf9mqlsuM9uqPqEb5mjdD7V60O3a+Rrmjk1YXNI/yQN1Fifinjuv3HXdm2EkNLlv 2QlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JbDqgfPHpizj2Xr97jabygp2Vi8eQjOpNs5caV4op9Q=; b=ASYNN1r2AGFlp+8xBrl6xuBd5LtOjGAiYdtNLVmjqalKiCnN141fqZr7OB5qRelDcz b83dbgpYNjeuxSnp4G/c1TxsnewQPxMj0l5p5bfAXYOqkN6a1yNaHQ+LozIkguO8BiuG vRF17G2JMwyWh0P9+Vzj+BiypYnkE5c3pbm6um/MVOV/eWilexqdMgzm2lqs+IIUBpXZ KCNdRH8F9huOYPEl42GJOIBL/lJl5Y/qfzKnDf2AZk6hZqtFAvG0uBVlJkkjxNjPiSGN TUrXTfFBl/uE1R1wcqseB5Zd2iQATeqDUoROKurSFG8yFYuy0XXRl//6ApXweCfH/+YU U9uw== X-Gm-Message-State: AOAM530uD0+copJp/cS68E82c25/n17XRC5K4vus4R4Olmt6AI7L+LWx kk5Q3RnXZy17eC1TggIBJd3X/nU2 X-Google-Smtp-Source: ABdhPJwPpDsDCj1k8H5EKnGvTCUUHTsCVV0utlAE0FFIAmbmtRo4I636sFB2cps9EmDC8SU8+3Ou4A== X-Received: by 2002:a5d:630d:: with SMTP id i13mr4671593wru.208.1593188912169; Fri, 26 Jun 2020 09:28:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 10/14] hw/sd/sdcard: Constify sd_crc*()'s message argument Date: Fri, 26 Jun 2020 18:28:14 +0200 Message-Id: <20200626162818.25840-11-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) CRC functions don't modify the buffer argument, make it const. Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b887dce0e1..a0500f4551 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -255,11 +255,11 @@ static const int sd_cmd_class[SDMMC_CMD_MAX] =3D { 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, }; =20 -static uint8_t sd_crc7(void *message, size_t width) +static uint8_t sd_crc7(const void *message, size_t width) { int i, bit; uint8_t shift_reg =3D 0x00; - uint8_t *msg =3D (uint8_t *) message; + const uint8_t *msg =3D (const uint8_t *)message; =20 for (i =3D 0; i < width; i ++, msg ++) for (bit =3D 7; bit >=3D 0; bit --) { @@ -271,11 +271,11 @@ static uint8_t sd_crc7(void *message, size_t width) return shift_reg; } =20 -static uint16_t sd_crc16(void *message, size_t width) +static uint16_t sd_crc16(const void *message, size_t width) { int i, bit; uint16_t shift_reg =3D 0x0000; - uint16_t *msg =3D (uint16_t *) message; + const uint16_t *msg =3D (const uint16_t *)message; width <<=3D 1; =20 for (i =3D 0; i < width; i ++, msg ++) --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189543; cv=none; d=zohomail.com; s=zohoarc; b=OGvAmun0MJFnCYC+hg/hvlnUhQalm/ZP1Iu9Es91PChg3byjUDK98f/A8OrguL4D42QGuLCZq8jVfnlHrz5hjq2xsws1zWo6ZOHRqQqj9h/2pNWuPlOt7XE8QsUJrfWHe+sl7oLXSlh+GbZQC/z5n6eRREsltQxrJP6ezQxgb+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189543; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oHFlPrMpcTtOBWP3NYrDS+TwAAQ4/bzOCIhgvn/adfw=; b=atX0lV1N7G63xvkuBRKYw8elqH58w2/CjOt20PIMKMc8ZoVzthobKSvGyhWsIVDVolUTkbqSgSp4FyvPg4PhUVqnEpd4RSlXHYq459+AFbFQJIVskJ1Jb+N1rpspTW7mRI7ndvlhs4guGqX9I+OssXOXmkRspY36u6cmQNBu8i0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159318954355387.7027617018648; Fri, 26 Jun 2020 09:39:03 -0700 (PDT) Received: from localhost ([::1]:34466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorNW-0005Ew-8F for importer@patchew.org; Fri, 26 Jun 2020 12:39:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDQ-0005iP-PC; Fri, 26 Jun 2020 12:28:36 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:45041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDP-0003MP-0v; Fri, 26 Jun 2020 12:28:36 -0400 Received: by mail-wr1-x432.google.com with SMTP id b6so10058273wrs.11; Fri, 26 Jun 2020 09:28:34 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oHFlPrMpcTtOBWP3NYrDS+TwAAQ4/bzOCIhgvn/adfw=; b=RsG66TjsIQCKMEb+V8Q4ZvNkqmDMnrtWLg77QSwkYf/89eX9degbWi2evFq52Nz5jw yFa9OiTpILgZhb6kQzbSexTv1YagVa77F8swL6jodGIj2YTwcSRbL3EEUoiaX2e1/9v7 lOWQvNm9HIqs/I1+cu77m9+9Ub+mJHRuWdbyBuNV8RNDxNuxJWsZ/3LQuNYnEP0AP0FH 06QfVXMh95CsaOHZsPyaxWxhShgKfugRjVvxRkoPnBKhd3pJ5oh0q0RAtUULW98BEHTe csjbWvbD0bWxnToTAEq8c8qFWocPuRQixropiWjwIZIASwSDL0Kw5tbjkOVX+5dP8cXd cy5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=oHFlPrMpcTtOBWP3NYrDS+TwAAQ4/bzOCIhgvn/adfw=; b=Ia3GgvL4IFG7DgBSI0v8Fy3UrhdZpRbElyBGAulpV4QDkNkeyzE7xyvxbP66yq0Rbz C5UYjUAjvEIq9gMoaJAuJ7rcmwz9eBYqOeKSMAyUvrXVK0Ggmbhl5iwrF7RqTwSoMban ypIQfG42p8drjSe4HIjF6WdkPCsc5Bun5KpWG1NJ6DCJ6XV8m8bKWpvbhDIAj1E8qlgP PgHgzMcYf8OOIe3HA+kQbKvbCgo8BnlfFxVP3C6hI5a+3nr7bP7er5SnQNaZ8nat/MMb U0rtE98tgIM+1Id1eMljjxY5Q01a+nnz0QiFIWFEYDV+9wxeUIheDY6BFRkZYFptFHDx oMgQ== X-Gm-Message-State: AOAM530osD+ZH1fnAaZpw7zCHF5SnTwvgbunamxO1eg56UXJtbuD9SEX hpV8g51X5Q+9VDzYp1lhgaCFc1jR X-Google-Smtp-Source: ABdhPJzL2lWCzIRVpUZW0t7zSIVhe1fOvQ1SuouYV0gHoYnjJ2qvdtsYsHaKayvA1y1ejbuvn95SBA== X-Received: by 2002:a5d:46c7:: with SMTP id g7mr4549583wrs.365.1593188913262; Fri, 26 Jun 2020 09:28:33 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 11/14] hw/sd/sdcard: Make iolen unsigned Date: Fri, 26 Jun 2020 18:28:15 +0200 Message-Id: <20200626162818.25840-12-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x432.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 I/O request length can not be negative. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- v4: Use uint32_t (pm215) --- hw/sd/sd.c | 2 +- hw/sd/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a0500f4551..8dd83c365c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1967,7 +1967,7 @@ uint8_t sd_read_data(SDState *sd) { /* TODO: Append CRCs */ uint8_t ret; - int io_len; + uint32_t io_len; =20 if (!sd->blk || !blk_is_inserted(sd->blk) || !sd->enable) return 0x00; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 5f09d32eb2..d0cd7c6ec4 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,7 +52,7 @@ sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x= %x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0= x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, ui= nt8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, int= length) "%s %20s/ CMD%02d len %d" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uin= t32_t length) "%s %20s/ CMD%02d len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" =20 # milkymist-memcard.c --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189413; cv=none; d=zohomail.com; s=zohoarc; b=nybwRM5hHpRB9wXcFwDFueYfhkPiPCvuINCjYV9GN6mz0GUxU+TG1m/Qpk7hahU52bi1ifelICwZTdmd25xSN3vnoR2BPnglptDuSup/PeL+1Lw+QAVarSjrSygRcYfrxrsgFjBlLTn0jmWDfzqf7k5vExcfaDPEfZgqDw9BIGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189413; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j4YLj9RlP5uo0+3BOkjl/ihTz1eGF7coUl6hG3PUY6A=; b=Kf8C3uIZi2JGuttw2ULpQj0cgS/xktxUZPZRrWX0ataoGXMnvV6YGNCUCMbi9KcFrm2Jdm3EtYuqigeMZybcLz43HmXP9MUgXSVXPO6YpLIZOerTz4YKTQmRljEPAw0HcqYuf7XFDLR2zJKUic/etgzg4o83Qnkftu6saMyjcQ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189413873215.37757095698862; Fri, 26 Jun 2020 09:36:53 -0700 (PDT) Received: from localhost ([::1]:54324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorLQ-0001KP-Hc for importer@patchew.org; Fri, 26 Jun 2020 12:36:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDR-0005kp-Jq; Fri, 26 Jun 2020 12:28:37 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDQ-0003Mc-40; Fri, 26 Jun 2020 12:28:37 -0400 Received: by mail-wr1-x441.google.com with SMTP id f7so7088347wrw.1; Fri, 26 Jun 2020 09:28:35 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j4YLj9RlP5uo0+3BOkjl/ihTz1eGF7coUl6hG3PUY6A=; b=CUjZAt8b3mMAT+05mccVgH9jGMD+GA5IbtnYWCjVTkib+UDzUQpHaVlpP1dher+8IM aTY6eAguh5gq2GTE83jsbjnKQ3ix0BitcRGkNRaJepkn+JBtQOrPdyySO3FwI46uNATp Vq1GWWpLXDqIUspZY526Pg/3z0PxIX4mkAT7UllyfO1wyCNNFY935hU/dINLR2dO7PMQ liT7viVINtgQT+E4Xm7mMC1z53k4NvX/VEeLF5EDQAgz/4mWvYvSuLcU3XhxODfLhS/H 93kOcikkac2P3oHg8Ko+vGRQm9NUxX0D/73dJidZSLQ/0+uHiTxqsDUIkAsRj8yhDu6S zt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=j4YLj9RlP5uo0+3BOkjl/ihTz1eGF7coUl6hG3PUY6A=; b=eNS4YMiZbxZUHqhP3K1RMgpRK2TQ+tid61oKv8yW1QIr6Q8DIqJjrLp6R+onsWKz51 ZCrvGDx6EpZyEeYQyRL7YD2o6norf92meyCGzG+v479sOT5D6LZCXfig84QsBzBFPyWx lTFeRsx7ycXpuCWhHTQSWzTJvvEQc1VKcVFDk5MC4dYKf8AlvnBMy+EzOXkq8Q44sJxw r/UEzSPueJmQLkB6s7tIGjm+32DjSNxuGcy6qs0bsPUl71hEo9WSQCCofopXUF+H8sJS nhCAZ+Efp6VvvJ+33Gvv05Vl0U0v+/SR3ct6zAxSc+TfAXXk8XTtWxyI1I8SGeNfzL1l zS9Q== X-Gm-Message-State: AOAM531gqKDQ+eKB5mQ1a5SFtQ7EklcvE25XcrBOzqSV6TLdbA3mzM33 9O16noG+0nZ5YuemzU5A+MA97KHZ X-Google-Smtp-Source: ABdhPJxrkRdqQZQyUGb9pBMElH67D/oKd6bg6+/C6Yf0EspRZK+VP0ju866POmIsD7CwLGKqodtGfA== X-Received: by 2002:adf:dcd0:: with SMTP id x16mr4371446wrm.387.1593188914332; Fri, 26 Jun 2020 09:28:34 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 12/14] hw/sd/sdcard: Correctly display the command name in trace events Date: Fri, 26 Jun 2020 18:28:16 +0200 Message-Id: <20200626162818.25840-13-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Some ACMD were incorrectly displayed. Fix by remembering if we are processing a ACMD (with current_cmd_is_acmd) and add the sd_current_cmd_name() helper, which display to correct name regardless it is a CMD or ACMD. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8dd83c365c..798a2346a7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -125,6 +125,7 @@ struct SDState { uint8_t pwd[16]; uint32_t pwd_len; uint8_t function_group[6]; + bool current_cmd_is_acmd; uint8_t current_cmd; /* True if we will handle the next command as an ACMD. Note that this = does * *not* track the APP_CMD status bit! @@ -1704,6 +1705,8 @@ int sd_do_command(SDState *sd, SDRequest *req, req->cmd); req->cmd &=3D 0x3f; } + sd->current_cmd =3D req->cmd; + sd->current_cmd_is_acmd =3D sd->expecting_acmd; =20 if (sd->card_status & CARD_IS_LOCKED) { if (!cmd_valid_while_locked(sd, req->cmd)) { @@ -1731,7 +1734,6 @@ int sd_do_command(SDState *sd, SDRequest *req, /* Valid command, we can update the 'state before command' bits. * (Do this now so they appear in r1 responses.) */ - sd->current_cmd =3D req->cmd; sd->card_status &=3D ~CURRENT_STATE; sd->card_status |=3D (last_state << 9); } @@ -1792,6 +1794,15 @@ send_response: return rsplen; } =20 +static const char *sd_current_cmd_name(SDState *sd) +{ + if (sd->current_cmd_is_acmd) { + return sd_acmd_name(sd->current_cmd); + } else { + return sd_cmd_name(sd->current_cmd); + } +} + static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); @@ -1830,7 +1841,7 @@ void sd_write_data(SDState *sd, uint8_t value) return; =20 trace_sdcard_write_data(sd->proto_name, - sd_acmd_name(sd->current_cmd), + sd_current_cmd_name(sd), sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -1984,7 +1995,7 @@ uint8_t sd_read_data(SDState *sd) io_len =3D (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; =20 trace_sdcard_read_data(sd->proto_name, - sd_acmd_name(sd->current_cmd), + sd_current_cmd_name(sd), sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189520; cv=none; d=zohomail.com; s=zohoarc; b=IpAy7RQdlSw/C+mrg/qFXqNMSIOufCRa6SH/dMM1GLQDd56XFODqxirEn1rsONI73G5uDsu+L2JNHQm7XPdyStg+B4wPNel5qxfway/RzRhOdyNlrX+UUHUoHLvihEa4piQFKMj++WmM91X6na4kX1L5LJmJ3sgWbV7Yjk7vmjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189520; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VIIvOy6xGDcv8qAbLrm/t2ngeo9iKJmDK5qOtaGJrrc=; b=hSJk27I3JXKAvp3aJAF842/rw/Rhpvp8quvmEYAXz1gEu8UqMY8uEFjwy/nVRI5kNq1+YD0dfDfkDsP5H7dicbo12xh8lG1Ss3Ii4b63TSvKLZelM+WEOUUgSXtBV7s/gMtHVqKLmyW7r1HWA01NqRGt9Kq/NT2IaGiwkFaR/EA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189520434190.0584413134752; Fri, 26 Jun 2020 09:38:40 -0700 (PDT) Received: from localhost ([::1]:60808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorN9-0004LN-1y for importer@patchew.org; Fri, 26 Jun 2020 12:38:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDS-0005m6-UN; Fri, 26 Jun 2020 12:28:38 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDR-0003Mm-BI; Fri, 26 Jun 2020 12:28:38 -0400 Received: by mail-wr1-x442.google.com with SMTP id j4so7627574wrp.10; Fri, 26 Jun 2020 09:28:36 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VIIvOy6xGDcv8qAbLrm/t2ngeo9iKJmDK5qOtaGJrrc=; b=XXxHiMsxsZGwFtGngMUd2Ed2otjmy/3JGSIvBaS6xaKOt+8tnstXbCRlrcIiC6o0cP occfP2XzcmBzNWyLX2sTXHwLwyt4I+VklK5Qo5vC9sFDLr4lU50EpyhOUFyBgc6DPQKz KDJu2HzIcZo++i+fmsUQMuSbxWwSdDEJPpsYVmnkwXDFatnAA67kl6Moq7rWwxTHE6ji VSrdZ61Ob3arnBibk9QLvhSIwmsWpsOa8Uii+Bbk+0eL+Hg59aT0EtpZ9sOaESFYV+oA XaTK9rI/7b9NlASrj9QoMqs1M/6NXCkEr9V/pA7wmTIFQRRR+PH4In34MDzzlGzG5A6F YTuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VIIvOy6xGDcv8qAbLrm/t2ngeo9iKJmDK5qOtaGJrrc=; b=WWrVCUfz9W/x0/dg9fMZb5cfXkiYt/r1wNmLi5BHKmj3kFSLR9gYvPSQk12Qz6Zy/C +RhC16aaMIVgQq0CO5WHc5KJO9HDhEoUtdr2fTKIn5sLWnLe50Ht7iTUbemQS7SOFHsW 1qoIVVoUE44KSyQ0LA73onwBjZ1tYWxKBhRi3nk3IvDdyTVzc0yXMxF0dnXWCPGihNl+ r9igkoVVWtQYiyZyyWmDbzc6Mftc/7VL8D061ZGyzN5eWrdQL7iUFEeLi+a63oNqAKfL 5FE7yf1Xc9Uqp9iiF2JqX+nGYSHGiWhqAmgU03dWKzw5BtEPAFM3rM9pNBHF9e3VptXk iTgA== X-Gm-Message-State: AOAM532HOcUl17icPlMI4BuN0A7VvOgnmCMu30bH3px9A6rtFAQd7pP9 P9HwCraDNKVgXxz04986ecsV3RP2 X-Google-Smtp-Source: ABdhPJzmE2rNgHQDzCXusMKCqM6qIZB+15ipTBPlkOtJet7/QdzMLf5jhysAqFJad00nfssFQUCIpQ== X-Received: by 2002:adf:e2c9:: with SMTP id d9mr4541191wrj.227.1593188915584; Fri, 26 Jun 2020 09:28:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 13/14] hw/sd/sdcard: Display offset in read/write_data() trace events Date: Fri, 26 Jun 2020 18:28:17 +0200 Message-Id: <20200626162818.25840-14-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Having 'base address' and 'relative offset' displayed separately is more helpful than the absolute address. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 8 ++++---- hw/sd/trace-events | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 798a2346a7..8fdee4ed56 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1841,8 +1841,8 @@ void sd_write_data(SDState *sd, uint8_t value) return; =20 trace_sdcard_write_data(sd->proto_name, - sd_current_cmd_name(sd), - sd->current_cmd, value); + sd_current_cmd_name(sd), sd->current_cmd, + sd->data_start, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] =3D value; @@ -1995,8 +1995,8 @@ uint8_t sd_read_data(SDState *sd) io_len =3D (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; =20 trace_sdcard_read_data(sd->proto_name, - sd_current_cmd_name(sd), - sd->current_cmd, io_len); + sd_current_cmd_name(sd), sd->current_cmd, + sd->data_start, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret =3D sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index d0cd7c6ec4..946923223b 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -51,8 +51,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x= %x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0= x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, ui= nt8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uin= t32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, ui= nt64_t address, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d addr 0x%"= PRIx64 " ofs 0x%" PRIx32 " val 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uin= t64_t address, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d addr 0x%= " PRIx64 " ofs 0x%" PRIx32 " len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" =20 # milkymist-memcard.c --=20 2.21.3 From nobody Tue Apr 30 00:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1593189447; cv=none; d=zohomail.com; s=zohoarc; b=AhdfEEPbhL/IlMtn0F7EWD92Chiq6nV0hoWT9ka0jYy4sENcL5J4NpfPzbslLc05RgO9GqhjPQC4M/qsIj38qUe1U1KPx6DYUs7gJw7IZ6AHagoG5R7khoxZF06eUZFpJ8DU8yJmB8Ae9wnlTs/LoRBsRkLA6B/dSd0o6wVkNjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+8tgefUeT5/9N4gOvIe9EAniXsDLRRPR141VmG/d0+0=; b=FC5gv57NqFqdikA3mh4p6X7R/BmRW9M0OnSkUbkfwqz3QLmh9ji/s8o/T2WzNt1IUijEkGDvcZ6mumzyTSq6o1P1Ejy0Zad3B3evg59oZe5LGhoQXMME1SUf4INtewuHUZZ/02QillcR4qaC4Ek03UYS6+h9hJ7axcTvk29F7YI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189447509142.6127937133881; Fri, 26 Jun 2020 09:37:27 -0700 (PDT) Received: from localhost ([::1]:57314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorLy-0002rq-Ao for importer@patchew.org; Fri, 26 Jun 2020 12:37:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDT-0005oL-VT; Fri, 26 Jun 2020 12:28:39 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDS-0003My-DZ; Fri, 26 Jun 2020 12:28:39 -0400 Received: by mail-wr1-x444.google.com with SMTP id b6so10058414wrs.11; Fri, 26 Jun 2020 09:28:37 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+8tgefUeT5/9N4gOvIe9EAniXsDLRRPR141VmG/d0+0=; b=uF9Tw83Dk1rUCojYgrRS2FHYPs0sJSZpDX5J04Eb8q/I0Z6DiJsa91d1zkEJUXnPKG sEbbAwVtuBehmQw0IpuT8R4f66+Lo5bHSooSmpOo1J5l3QXlck8/QA2GFRp+ugY6jmyO uIqbVVJTRGKNVqfiT2YFS3twdCwMoc2i3yFzLRlrVc9l7o8oMZY2wR73RyxAlIcLdsYY roipTu18JZeIG9eXCHEhp8ipS24bYNHexDLLs1RClhimLxQzSfHmcRYEGtG/vkTadevg r8poti930etTbV78F8vd/A0+5RSCkVDzuyF2Xv4uDueGD6z8igzoNmOVyDAx05urrFBE 6EtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+8tgefUeT5/9N4gOvIe9EAniXsDLRRPR141VmG/d0+0=; b=nsscnbwG1hI/esYvFqHghUjrvsVOHSehe9PG5O8isUfAT9qhCjDeftSengHWK0EZxt GY+QfaehfZ4yx/wlEreaXkAYbFcY41CpfloB8jBCMAJAwSLaU5b/LSkfBkxZZqVUEAua ySeBKFWMdL3CvXAUxJkTI14Pylf0U9e/k8IeHFIO3D/mpy6oPbrgOE3NjMzlKhUgNyNp +Zyg8YxvNccIzF4BJH4/q/JuxEXkGSwmzHp/way/sNfsc66il9q1HjpCukS+3rMHkEhU hrFAdx3Briy3XNyPwZX+y91B4O+s0Pha6z2tPHq4lRHrkmPvvKpKC/5PoQS6XHnc69qt 7/jw== X-Gm-Message-State: AOAM531pKtwUBe8ClQtZ8c7AZpiaCt7c66HoD4LuZR2XBfLLbUEIn0IT qBbY8MS3Jm98oSydldYyfZR0/ljI X-Google-Smtp-Source: ABdhPJwoLvgUORYfhq/Vqw1lTQGmJjFbltOQcumKDJS8d4fAbaxKEc0vt+2G4sxod8H7FAkJbFKkqg== X-Received: by 2002:a5d:4202:: with SMTP id n2mr4466653wrq.171.1593188916688; Fri, 26 Jun 2020 09:28:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 14/14] hw/sd/sdcard: Simplify realize() a bit Date: Fri, 26 Jun 2020 18:28:18 +0200 Message-Id: <20200626162818.25840-15-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We don't need to check if sd->blk is set twice. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 8fdee4ed56..46cd7c1aba 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2140,12 +2140,12 @@ static void sd_realize(DeviceState *dev, Error **er= rp) return; } =20 - if (sd->blk && blk_is_read_only(sd->blk)) { - error_setg(errp, "Cannot use read-only drive as SD card"); - return; - } - if (sd->blk) { + if (blk_is_read_only(sd->blk)) { + error_setg(errp, "Cannot use read-only drive as SD card"); + return; + } + ret =3D blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_= WRITE, BLK_PERM_ALL, errp); if (ret < 0) { --=20 2.21.3