From patchwork Fri Jun 26 16:28:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 963FDC433DF for ; Fri, 26 Jun 2020 16:29:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61DDD207D8 for ; Fri, 26 Jun 2020 16:29:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="r560fzko" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61DDD207D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorEQ-00076V-Hs for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:29:38 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , qemu-block@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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é --- 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_* SD (Secure Card) M: Philippe Mathieu-Daudé +L: qemu-block@nongnu.org S: Odd Fixes F: include/hw/sd/sd* F: hw/sd/core.c From patchwork Fri Jun 26 16:28:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80B14C433DF for ; Fri, 26 Jun 2020 16:32:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B686207D8 for ; Fri, 26 Jun 2020 16:32:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="me1/iF1a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B686207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorGw-0002JM-GA for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:32:14 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move some definitions to use them earlier. Signed-off-by: Philippe Mathieu-Daudé --- 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, }; +#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)) + struct SDState { DeviceState parent_obj; @@ -367,12 +373,6 @@ static void sd_set_cid(SDState *sd) sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; } -#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] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, From patchwork Fri Jun 26 16:28:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7884C433DF for ; Fri, 26 Jun 2020 16:34:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93029207D8 for ; Fri, 26 Jun 2020 16:34:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NvfCZttO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93029207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJ1-000680-Ml for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:34:23 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 { }; #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] = 0x00; /* File format group */ } else { /* SDHC */ - size /= 512 * KiB; + size /= HWBLOCK_SIZE * KiB; size -= 1; sd->csd[0] = 0x40; sd->csd[1] = 0x0e; @@ -574,7 +575,7 @@ static void sd_reset(DeviceState *dev) sd->erase_start = 0; sd->erase_end = 0; sd->size = size; - sd->blk_len = 0x200; + sd->blk_len = HWBLOCK_SIZE; sd->pwd_len = 0; sd->expecting_acmd = false; sd->dat_lines = 0xf; @@ -685,7 +686,7 @@ static const VMStateDescription sd_vmstate = { 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) if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *= 512; - erase_end *= 512; + erase_start *= HWBLOCK_SIZE; + erase_end *= HWBLOCK_SIZE; } erase_start = sd_addr_to_wpnum(erase_start); @@ -1149,7 +1150,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest 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 |= 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; - io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len = (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; trace_sdcard_read_data(sd->proto_name, sd_acmd_name(sd->current_cmd), From patchwork Fri Jun 26 16:28:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FA7CC433DF for ; Fri, 26 Jun 2020 16:32:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3730B207D8 for ; Fri, 26 Jun 2020 16:32:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VroG3sCX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3730B207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorHD-0002sC-4K for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:32:31 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As a defense, assert if the requested address is out of the card area. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- 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 *response) static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { + assert(addr < sd->size); + return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); } From patchwork Fri Jun 26 16:28:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7555C433DF for ; Fri, 26 Jun 2020 16:34:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71153207D8 for ; Fri, 26 Jun 2020 16:34:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZZxJPx41" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71153207D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJU-0006fN-D9 for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:34:52 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" CRC functions don't modify the buffer argument, make it const. Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé --- 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] = { 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, }; -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 = 0x00; - uint8_t *msg = (uint8_t *) message; + const uint8_t *msg = (const uint8_t *)message; for (i = 0; i < width; i ++, msg ++) for (bit = 7; bit >= 0; bit --) { @@ -271,11 +271,11 @@ static uint8_t sd_crc7(void *message, size_t width) return shift_reg; } -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 = 0x0000; - uint16_t *msg = (uint16_t *) message; + const uint16_t *msg = (const uint16_t *)message; width <<= 1; for (i = 0; i < width; i ++, msg ++) From patchwork Fri Jun 26 16:28:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5608BC433DF for ; Fri, 26 Jun 2020 16:38:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22186207FC for ; Fri, 26 Jun 2020 16:38:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RsG66Tjs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22186207FC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorNS-0005Ew-EX for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:38:58 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé I/O request length can not be negative. Signed-off-by: Philippe Mathieu-Daudé --- 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; 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 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_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, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # milkymist-memcard.c From patchwork Fri Jun 26 16:28:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D9C1C433DF for ; Fri, 26 Jun 2020 16:36:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3011620781 for ; Fri, 26 Jun 2020 16:36:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CUjZAt8b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3011620781 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorLN-0001KP-EI for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:36:49 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 &= 0x3f; } + sd->current_cmd = req->cmd; + sd->current_cmd_is_acmd = sd->expecting_acmd; 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 = req->cmd; sd->card_status &= ~CURRENT_STATE; sd->card_status |= (last_state << 9); } @@ -1792,6 +1794,15 @@ send_response: return rsplen; } +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; 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 = (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; 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 */ From patchwork Fri Jun 26 16:28:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E090C433DF for ; Fri, 26 Jun 2020 16:37:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5810120781 for ; Fri, 26 Jun 2020 16:37:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uF9Tw83D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5810120781 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorLu-0002rq-Jm for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 12:37:22 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We don't need to check if sd->blk is set twice. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- 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 **errp) return; } - 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 = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, BLK_PERM_ALL, errp); if (ret < 0) {