From nobody Mon Nov 17 08:03:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) client-ip=209.85.221.52; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f52.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1603710205; cv=none; d=zohomail.com; s=zohoarc; b=Q8HOXN9IIb4ysq+bqrLspr1K+GNdsEnJGcRyByHLL76uyM1nDfz+zl0oQJX3/Mbgy0VV8dbqeQj8HRTAArbn9dsawNTg58DdFXFAQWX6PZZs2zVLHCdb6qfZfqM6OzheOykKcauk8NVzpDMrIWaCyIKkR4Rtl0C6+WCjQoJYyrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710205; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yrIfSe6YicHcmNa56yOajmgv3h3ly3b3aUGVmAig4lI=; b=S2iP3AqNy0T1R99LoWTFVgDSd32aPGkFDS4SKBC+KCQgtHr7VBKlPTtT7I/2lMeTCzSKv+bZH5PY3lDd2zDeMTCKDr2sBVanfjBc0u4w087mDWH+HXQTzUpRp7jvK2o49W7WLfH7fMUOJDYguS3UA9PXgmcuB9Z2voRKeiwW8/I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.zohomail.com with SMTPS id 1603710205148183.81453214901205; Mon, 26 Oct 2020 04:03:25 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id h5so11880987wrv.7 for ; Mon, 26 Oct 2020 04:03:24 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id x64sm19263766wmg.33.2020.10.26.04.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03: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=yrIfSe6YicHcmNa56yOajmgv3h3ly3b3aUGVmAig4lI=; b=kjc/4RFE5iK3HHoKlDbqjcnlyim9wIhQpf5LzbcLMfBew2cg/MEkszynKYCplZMMdv BiDNzy8oZbG3x72qf4q30ypL9xM81FvkUt7GdIBBHbTUjppYGBF6d2pCRdtMYO46yNCq HEOSAfbyaElweX2waulKR1jQ/BhIXv6gcw70mdaI/YDnz0UMxobvebs9O1fnM7aLdDMe bdvz2+qxuSVuK3h96seYoo7hxSj0p8bkTsqiqZgcE4MB3z5dMeAH6syRcrdrSp50E86h TOu6xmhVtsmnq1RqB8jV6NsJWSiPrndylItjmatwh41r48DbsM26tW4Bq6S49Ri4Igfl nRGg== 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=yrIfSe6YicHcmNa56yOajmgv3h3ly3b3aUGVmAig4lI=; b=nwJacJ22tLevURUagHNL1sLUTZ13PxV1oKCPiXs8+0Yyp1zgIIp6Cl+rnT4AW0lgb3 W6lnqxef+Mst1qALLkMILzhqHPJHU9rZ94RtnaEFEbJv7UUBawBPfbM6YQRad7tX8zbt G3/0G0b5anKT2oCx09DLj9uYpM2FYYh0cQCVmXNt/6nNsk0gglHSelEXwJNm9RAKT/qQ 2L7373tFGlqOm9tZe4nHCuF2X2MsGmLpUm6t3tNnTYYcJCPyh4J0k2JXRbuiONXc1vN4 a7NY1v3W1nDewtEK74Mg9Y7f71tHyiOE/Wu5VZUQOyD5JvjhC8shpfgq2a2Fs+s43uDj th4w== X-Gm-Message-State: AOAM530Pa+CP1KM9mX6xOulFrlZPBRS4S4ZiFLUTyNgtcQxN9/w3qTzV Byfi6rzPO9GmX0PXry5E97w= X-Google-Smtp-Source: ABdhPJzCxwyFqVQw/x5Cl5hWncgMKCklk4TYvbavJ3Vxcq64FiMZgKkzI7R5qC1Rs8NKZbXH+2YLqQ== X-Received: by 2002:adf:f44d:: with SMTP id f13mr16484159wrp.385.1603710202607; Mon, 26 Oct 2020 04:03:22 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Peter Maydell , Alistair Francis Subject: [PULL 1/5] hw/sd/sdcard: Update the SDState documentation Date: Mon, 26 Oct 2020 12:03:11 +0100 Message-Id: <20201026110315.4026183-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) 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 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-12-f4bug@amsat.org> --- 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 c3febed2434..9b53053527e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -102,11 +102,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.26.2 From nobody Mon Nov 17 08:03:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) client-ip=209.85.128.44; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f44.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1603710209; cv=none; d=zohomail.com; s=zohoarc; b=K0q+4LbjljAdZiCzPTzTC41XtpkdphZ5RsSNTcJDL6QLxKnzZuc5BiwORtJDBXzTu18Xq35VPICUA16CF19WfIhw9Xvr9u+06cJ2fXxcOEIcT6lpZ8uNPrruiBpSMsLsc5pCfBe/7lpWj8WSyeF8D/SUWWPLLfSUZtc8+gImxLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=l49pVi2lD8dK2RnE8g/H4gl/Pyl9rZSVxR5SvG3C083gY7ig51+N306TzGabw7h6vc5DuHjqTNK37s6mF/RSULTUgtBQZmXnjqGNXjkCB70MFIP3KDbBaGvD0o9fY55D0u1F5l74Pp1fYHKwHKAPnyLJA9AbxsFPC5WLXrjDc2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.zohomail.com with SMTPS id 1603710209582185.20866945371938; Mon, 26 Oct 2020 04:03:29 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id l20so4904048wme.0 for ; Mon, 26 Oct 2020 04:03:28 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d142sm3477530wmd.11.2020.10.26.04.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03: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=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=UCo+P/KimaEH9WytkmPvQ/gRniaWbuuX5EwVTO78FshBUt9XvuxdcqKUYg2HRl2/HF uujgy62NrA307zdeDZagBpPrb/WBbmK6ejwOmopfjlJxceDfmhznY5D7Z3JCk8g0Smnu JhLVbOk/kmZrBxfpz8OR6d2BsVM3r8NABNpEu/WudgZe9NI7uvPKSQFuP6dkEJzV2pGG sYxzpmWo68kYWQpX7fY4ep45ReiTDtXAClQkBrLYwm+hcrdFgdiWvjWtkUJyoMbIBst+ CVgSTIlAIZcGZX+rez0oJ/N/ZAo7trHBDrT+PNwt5jBUx+yH4JEBaWVqqMxfvNUIp10M mKRQ== 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=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=gHEOTAsEI4liKdjI7SuuoOmSe5LEQRIL7ilhp2lIunLW9U2Jj4cIpXx7MayMK/M6E3 N1t9CiG3LtEkNTAdRH34hHnrk4upO5b/6wA54iwhKcPfr/A9LtR0iCWJr/zNtoIBPMbI DVDZttf/7GmnKUd7SxdH+rJ6A5BrNcQ7heuJXP+dHGJ5UW3BgmA6vaHyTYxVYqKZpgDg 8t2UzW70qYhe4h4zPeoVYO4MAISHsvVMOJS1gvmrTrWjbiLLJaVetof76juuRI3Mubta xR1hm/OfpvD0Rf6iFvbbGxyQc6oPutJINlD738euapf9BimxZHDIvqsnNljjOwgQ2rfV Ii4Q== X-Gm-Message-State: AOAM531qVHvFfNrRZla4t0UPnnRX4Uws6p6axiFCkH4LBRd+Uf4HI0tY TXvT4hnKLPu3ParEZ2nKSh4zQ9Z7NzI= X-Google-Smtp-Source: ABdhPJySLdeCrCbVanjmhMuFWvOBkSLtLEZCareuAGPGAtFaAqKlTzrurMZUBBK7Bia6aOfWyrjV6w== X-Received: by 2002:a1c:1946:: with SMTP id 67mr15250854wmz.15.1603710207286; Mon, 26 Oct 2020 04:03:27 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Peter Maydell , Alistair Francis Subject: [PULL 2/5] hw/sd/sdcard: Simplify cmd_valid_while_locked() Date: Mon, 26 Oct 2020 12:03:12 +0100 Message-Id: <20201026110315.4026183-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) 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 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-13-f4bug@amsat.org> --- 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 9b53053527e..5510a64401b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1679,7 +1679,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) @@ -1690,13 +1690,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, @@ -1722,7 +1721,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.26.2 From nobody Mon Nov 17 08:03:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) client-ip=209.85.221.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1603710214; cv=none; d=zohomail.com; s=zohoarc; b=E2rBnuizNvzAdaghvzXx2y9GvRSVv6XB9zZcE/C3OUnt7SmEsrEan1cNuvcFUAGHFD4ptpsbKWkxsrNyEzfEYI7BdpQ2upqeKEUxG5mdsb+3fjKJpsvfudBSXteJ5aqTfDnym8u/Eeg34luwSSg/QhG88clTaSbFS+PcCeLo2YU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710214; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3PqeCvMaRSfOqr/6xhOfmbV28LZjwldqha7vO+7WnUc=; b=Gj/odcY1qpAWC1B7Hu7MjmuCIRnIDB3b1rk5JmK1gF1RMARamqZktiQcxi7Hute2zBTo7JrpWv5j3cI1TTqPuwRrGws7zKZESuvoSjXKAWblCXvnbe1/PL9p1XCimT9EKezchA2NUQ3H0EExJr3MjvEqXtbq9fZHoS4TngHV3Is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.zohomail.com with SMTPS id 16037102148431.784205821427804; Mon, 26 Oct 2020 04:03:34 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id b8so11944465wrn.0 for ; Mon, 26 Oct 2020 04:03:33 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d129sm20226273wmf.19.2020.10.26.04.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03: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=3PqeCvMaRSfOqr/6xhOfmbV28LZjwldqha7vO+7WnUc=; b=Dzfljq8fBMOykHo/ksRTTp5iGGkuIy5dPJHu6b4p5BLmM4tyMbfIvgS6BwRBgId/6l ImdPHDmN4/Uu4EV++mPxvJScZZpf3VcKyU8DlSJBxRMham/HvasbhKW2wvtLmgAcE/Tk 755Va/3x+YMrTaD35I+JHNuL35h0h3m/joSMHZZ9XmsPiG976L0+nnpDj08yKUfuvrhr fDDTTo66XCptH8gO5oI29S6m0kWBOXnU+F/3wBbnW8TzUBzzmg8ou3HhFxLi3VHomkiq swF6F+GOr7NHDKgJfyFRJxk6cjbv6+bN42MKhsSLm6HPvo3KOMdFDN3NnA/IBQsmvRxw 1KfQ== 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=3PqeCvMaRSfOqr/6xhOfmbV28LZjwldqha7vO+7WnUc=; b=NH4Grx3u2D1ChKAYqPx9Bski0zIwvzLKSBWg2DFi2kq2QbKA0lvA/XYA47n2dfQSLs T0ryyP7sp9hTUebTC29nxcAgerQC8lDZTP3I8R4Ba5QtoLDr0CrOfYsINGPQ7edwSHk2 EzMLM63PE10lWFpFVJd6uvWT29ippo6ugMZkdz0EpPY3Oq1yxKhYWGPYCpI1nE8HUgsi am2APoqu8kNZszMTDCKOFMVHHKcCbP4+DGoJR4+n3owconAQacyYj5ugnwE1R7/sUgO2 zDrQj1Dw7kUDCZOC4ZhkkJ0GFdWmi93YdbrC8xIsrvPDp52eY8aqNL62nl5GVXQyRpIU eWeA== X-Gm-Message-State: AOAM530pajU3+KAU/X3suPP67UTNTnsQSY9UTiAjmIGMlHCdFNzW3tmn oDVXCzpx3c3BQOmC7WGS62I= X-Google-Smtp-Source: ABdhPJxXPyQANOS53JmNBde6/D2k8al9tvWCuQLC+USjzFwj6ItTzX25RiIhbfb1ulBKL8GLsWuq6w== X-Received: by 2002:adf:ee4c:: with SMTP id w12mr16429071wro.22.1603710212265; Mon, 26 Oct 2020 04:03:32 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Alistair Francis , Peter Maydell Subject: [PULL 3/5] hw/sd/sdcard: Constify sd_crc*()'s message argument Date: Mon, 26 Oct 2020 12:03:13 +0100 Message-Id: <20201026110315.4026183-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) CRC functions don't modify the buffer argument, make it const. Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200630133912.9428-14-f4bug@amsat.org> --- 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 5510a64401b..aa6059d2ad6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -254,11 +254,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 --) { @@ -270,11 +270,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.26.2 From nobody Mon Nov 17 08:03:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) client-ip=209.85.128.50; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f50.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1603710219; cv=none; d=zohomail.com; s=zohoarc; b=PcLO8e9YsoFcV09CQOediOZsCDqpDER0EVHCV7onIyd+B1aybtmZev/Z6XPLUCbgbTchDdSipF+33ftSftQbjg7cFZOoWMyyqdztq/IEvvLuFq9MjjBcaLJRoSeGD/QjTYe61Inr7Ie1MHy0JpZfyh/GZhCrY16AEu53RCBqWoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710219; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CaEc+EndnthM/jQRSTritjVWMWjtPivpLOdnvFGKtOc=; b=RlcrcU0NS8nMrkamxj0ESgbwfHFrTkSd+6r5jQ34smcj5m7p8KKS+YIpceaW0tI3BsuLIVhs6hhHjgHtbazqhc26cf596fYebJO2jkDBDJW6O6qkwfQe7HwZBXnUUivJbQTmyEBqVBeRzVWi4BECFvcpA61GI025xebThowAUAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.zohomail.com with SMTPS id 1603710219718330.9315457897304; Mon, 26 Oct 2020 04:03:39 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id k21so5445074wmi.1 for ; Mon, 26 Oct 2020 04:03:38 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id h4sm21987467wrv.11.2020.10.26.04.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03: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=CaEc+EndnthM/jQRSTritjVWMWjtPivpLOdnvFGKtOc=; b=B51UdXVNUMxIJXfJbtOeTXONrMoctRM+wW11QjE6H/PSYVoSRYayynce9vro6AfVkW 8GKbBCnOo1VvecTZaTVZq5fx962sOXz9AeSJvUPkKPiDpS6WQrKnR3CvGQjz+i1VjJ5x FyiHUtyctPri1rqi2p/OHAkFRFrBS6yqSBQRRiT5CcYnvGbvdkEqYcNLEbbPLwTsvC45 V1RdzZX7OxyPZG/Di85O8ZPk1EDt6fzwBObdQfj3s2Zhs8VWRqHai4EsOKIJFK+gt4pR JVsUcVGYGGBLKVdsKo7UbSL9vUJbzA5A4NYpR9qn/qHLDWRQnZVuwVjJRen/YeWHoGed I/dA== 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=CaEc+EndnthM/jQRSTritjVWMWjtPivpLOdnvFGKtOc=; b=mHNI7sqO/dhHp4wYOZKcuuv+58xW//y4Rgw137KsrZZsBil3q+DOe/7X7flsj3FKHn SQuKRvSUfzsv/N5/F+uFmeNx+Ao5Y8BX00W3CYgpwn3WoILRc6kyiL/t7VpNQNa2ye1s yxvjTej/WPx0ZLoFkWYu2kiz3kxPjIPlZawHXXOabbcpJbAn+Yxb2E/JgLeSHaekiEmb c8YSxXd3X5pkxBvXGIT+FptC/ggPV0lFHT/rM5d8fC4VvqaOmNXsNGjxXdaldLrdiVIv fURIzY05+96Co0igBGeTn9njNJ/X8Oq3cYfNQp6/5pBcmPEXIf850qp6vycgBd4l6MFQ pEQw== X-Gm-Message-State: AOAM532Kj/dXRU6LKgs5WvAToKqCYtzvISm9gseUUXX2Hj9NGC/7GFSX GTxAs88iRWy55A7kxN8HG6w= X-Google-Smtp-Source: ABdhPJyF1JOQLXzJb3x+ZLCPuqMyMqIwI8BIc/uwm2/AcK/dwJkNka42hifUNxBvR6TNrLS6P3KkBg== X-Received: by 2002:a1c:2302:: with SMTP id j2mr15469805wmj.100.1603710217030; Mon, 26 Oct 2020 04:03:37 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Peter Maydell , Alistair Francis Subject: [PULL 4/5] hw/sd/sdcard: Make iolen unsigned Date: Mon, 26 Oct 2020 12:03:14 +0100 Message-Id: <20201026110315.4026183-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) I/O request length can not be negative. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-15-f4bug@amsat.org> --- 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 aa6059d2ad6..fcbc1fd9d6e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1982,7 +1982,7 @@ uint8_t sd_read_byte(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 96c7ea5e52f..4140e485403 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.26.2 From nobody Mon Nov 17 08:03:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) client-ip=209.85.221.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1603710224; cv=none; d=zohomail.com; s=zohoarc; b=HxYzadVj+QmfPXnPTly/DZkF8/BKnsoky9BVQYm596hyxjW/qGOCS6HCdgMNy+o6cQpodZJIbPxeb3jh61styOwO0N6vATvwvfvwaqLcpNFNOrhI6zVoYJuZu3JofBKIER3bDD272LSQHvI5+w0B3irilbymKvYibdkeazWpmvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710224; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5U8VWtvmcB+mOzFUXcILRLEPHX5B//Lhi6i5VjZPllk=; b=aG1bCx7+62afmuZe/cp5KzOxfBP3dLoyw4/be7yZ6XF+lLgOZ53yt9ikQWcllUedriBTKZSvvbN+tBbZqqPGxw8NudcDMM1/9YK67h3Oqs1/H5UkUEkV90VhbUh2pwCxoVBl9eVyzAA89tPQLhJYK1RA7TdtAVHG1ALM4ak/5fw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.zohomail.com with SMTPS id 1603710224257257.9755012282425; Mon, 26 Oct 2020 04:03:44 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id n15so11934884wrq.2 for ; Mon, 26 Oct 2020 04:03:43 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id k18sm21141582wrx.96.2020.10.26.04.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:41 -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=5U8VWtvmcB+mOzFUXcILRLEPHX5B//Lhi6i5VjZPllk=; b=UOj5nkljlDKhYh9w621rfwoxMHKbnxCtTvOi7lU7FI8flRBUzf+nAAxVssUzllX74M PrCAc78J5684apPjU6UYhL/KuhuqY71UuKKAmwdwasNwnpmi2JJmnl13dCB7XcPNolFx 6mXVG1h5iHavMb7U0Y+fe1SIPZvB+a6MjUuDLLrocZXZVKZbaCDMCG9jxyhM+u7eTzGM JMMgD/clOYZ9B0CvxBUSnMZpCh5Hbwt4bWfrDCTDgQ/zP5UArL/awQw9T+ug6dNFp0np 0gvos3DU+wxUabBMgH770AGviFtwxcmGng2NjgVv2S8kReNsACBy+W/d5LhxvmuFpeIZ pKRA== 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=5U8VWtvmcB+mOzFUXcILRLEPHX5B//Lhi6i5VjZPllk=; b=faiubiCqkc0neyyd5O0ZR3+s333sDvbn2a8HyRtfscm3gjszw4yrtXe6oxAoTjk0/R KQbJbikOZ3CsK2wB0nfgJCGkxGsw7mES3UrWKNOOD3f7wHVnB6fin54kwtAwSQuOYbLf D9w1xQDHViIUdH80E/nOBQyHZkW+pzr5KijJmTfxmyUr/1ylKDGzMV1zCcPu9pC7MXJD 8cR5oUDjMYcdZFbxXPcEMwuM5uO2pYRj+e+j4Y6C5v/9z04EHASKYVENDq1RQg1q3F6r jJbPhxDoa5/WQw20dHzU8GEzEML1ilRm8oyun8L8+a579FHBzJRqd1M/N15GF6TfHeJ1 ywdA== X-Gm-Message-State: AOAM531kVL0VIi+T3rjMqGRyDEGozSuknqZlHT8suhfbIkPN/tdwQ2jN wSInME078BKVSV9mTk0qRPrt8zNheDE= X-Google-Smtp-Source: ABdhPJwIJMSkzJ9ZdoIAXXHOUZikvdrmcf4UsVi4o8MR3oHqi50bixMugLvnZ1sXYwCqLf/R1z5AIg== X-Received: by 2002:a5d:6551:: with SMTP id z17mr17252423wrv.266.1603710222066; Mon, 26 Oct 2020 04:03:42 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Bin Meng , Michael Roth Subject: [PULL 5/5] hw/sd/sdcard: Zero out function selection fields before being populated Date: Mon, 26 Oct 2020 12:03:15 +0100 Message-Id: <20201026110315.4026183-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Bin Meng The function selection fields (399:376) should be zeroed out to prevent leftover from being or'ed into the switch function status data structure. This fixes the boot failure as seen in the acceptance testing on the orangepi target. Fixes: b638627c723a ("hw/sd: Fix incorrect populated function switch status= data structure") Reported-by: Michael Roth Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201024014954.21330-1-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fcbc1fd9d6e..30913826145 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -827,6 +827,7 @@ static void sd_function_switch(SDState *sd, uint32_t ar= g) sd->data[12] =3D 0x80; /* Supported group 1 functions */ sd->data[13] =3D 0x03; =20 + memset(&sd->data[14], 0, 3); for (i =3D 0; i < 6; i ++) { new_func =3D (arg >> (i * 4)) & 0x0f; if (mode && new_func !=3D 0x0f) --=20 2.26.2