From patchwork Wed Oct 21 17:34:38 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: 302363 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=-12.5 required=3.0 tests=BAYES_00,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 2AA9EC55179 for ; Wed, 21 Oct 2020 17:36:26 +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 621C22224E for ; Wed, 21 Oct 2020 17:36:25 +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="XaV+oj0F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 621C22224E 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]:59424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI2B-0004DT-S1 for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:36:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI0q-0002nY-EC for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:00 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI0o-00061d-Tk for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:00 -0400 Received: by mail-wm1-x341.google.com with SMTP id c77so2988080wmd.4 for ; Wed, 21 Oct 2020 10:34:58 -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=KaLHZkyMV310GRpm8xmZb+UEiBALh924PFEJvj8hcI0=; b=XaV+oj0FziPlbSlHvjGjj/aR9lAah6vuPv5eHBR4MN6rZv7zfpiHm2vx/mP43rNEwI 1+kBNefVAQd0K811g6ovqCI6pyeTvgFXD2LTJViPI0pN3nND1P4HXk6JtiEu3FITGYrD DwZdt6EvrJVNTL8E668bQcdg2ZpEGFOqU/L7IsG8rci5vvhG8KZG9O81tJON+X1iVyc9 EgwDd+VLnr6mQ7b1Q/Vh3foY5Y3xn2INIGcLevUwqgjAVLWPjRpQWnGTrrP5miL1M8Nl j62IE/H681F4RI9a+SVPChBtJMfodh65YVwhj6brFTUvtytc4e5zg9SH5DH9ZEpwz0dH eX1A== 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=KaLHZkyMV310GRpm8xmZb+UEiBALh924PFEJvj8hcI0=; b=peuQ5OjxAHPhXF1duAdP6ZtzYOOvenmAHQjqHTXnCYwom3YL8nTdjdzLssB+y54EQ2 XBSZ0Kct6dV0CsYDtMv4Z2U0I+vZqLW+joBJy/GpPLre0Pz5kSJSDehYGEZxJpZrZPZm qc2W7ySljXAzMoyK7/pGmQb6t5xWgyKoTuQlPS4NI7SoRAmIPcTv1+2/dUVgb9IuX0X6 QM+SuEnbdHa9Ye4st9JM9LOPxcqGV6nRSbNoNEX2WADPx6QQY2rjqjPCGZNpR7J8dsJp uJtPboAkdq/oHuzq4288SCL4W7P6QQgCeTReWc6CbmLbuW+GJmCIhhoGnK63q/BRgqm3 C/oQ== X-Gm-Message-State: AOAM531oTGI6rjpRP4vEqlB/GxPcKb7/j8DJ71cytIghb96+Z8baI/ZX sPKCXjaHMkKONqF93fccH1iekxlq0As= X-Google-Smtp-Source: ABdhPJxC5HhsH3754EGbfk2rd2x1DQd0L3Hh82CY25ufBmUR9ajcWKntZZve+rDuPao2thV9Duq5ZQ== X-Received: by 2002:a1c:9641:: with SMTP id y62mr4823756wmd.145.1603301697230; Wed, 21 Oct 2020 10:34:57 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id i126sm4943809wmi.0.2020.10.21.10.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:34:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 01/13] hw/sd/sdhci: Fix qemu_log_mask() format string Date: Wed, 21 Oct 2020 19:34:38 +0200 Message-Id: <20201021173450.2616910-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add missing newline character in qemu_log_mask() format. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Tested-by: Alexander Bulekov Message-Id: <20200901140411.112150-2-f4bug@amsat.org> --- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 69002130839..6d4603f5b19 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1112,7 +1112,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) /* Limit block size to the maximum buffer size */ if (extract32(s->blksize, 0, 12) > s->buf_maxsz) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Size 0x%x is larger than " - "the maximum buffer 0x%x", __func__, s->blksize, + "the maximum buffer 0x%x\n", __func__, s->blksize, s->buf_maxsz); s->blksize = deposit32(s->blksize, 0, 12, s->buf_maxsz); From patchwork Wed Oct 21 17:34:39 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: 270753 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=-12.5 required=3.0 tests=BAYES_00,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 35EC3C388F9 for ; Wed, 21 Oct 2020 17:41:06 +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 758D22224E for ; Wed, 21 Oct 2020 17:41:05 +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="CZlfdIDV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 758D22224E 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]:39820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI6h-0008Ff-TB for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:41:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI0u-0002uc-R9 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:04 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:47095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI0t-00062Z-Bw for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:04 -0400 Received: by mail-wr1-x442.google.com with SMTP id n6so3918711wrm.13 for ; Wed, 21 Oct 2020 10:35:02 -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=stHBs8t1SdzbGJ1mjGKIp/i5L6krBUedXaMQsIqK+Xk=; b=CZlfdIDVWJE+WicDutKs0fe97832DbicIN5v0uHVioOSSxbYs7Hc+Rle1EnDruFM4A TrdAktW48y08obRLppBLHpPM0k6MhK2PR48Cd3WK0PzRdDQocH7YAUr3hJMbVKKRzCZj WfCHQYMyfWmzsczlRmud92PQBloWA3wlwGKqqSBbOrcUhYjs8ZkHZl5XW1g441pWFIrj GHNHpx2qlUkbQivQ6bjEvg+BGJmNA5s8B2afH//9aD03U3UgvUsW9QJReSeKvEicwyK3 v5UYUk8O2YRA5Z1bzUlMNU3DuZdVv0G2Wdlq1F847WzU/94VolcBlqEeVBeY4JYNYYrj J61Q== 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=stHBs8t1SdzbGJ1mjGKIp/i5L6krBUedXaMQsIqK+Xk=; b=YI7R87MFns+p/TkI9zrJialIgruheSDHGMGQeVW7OArYbLPBfJL5rgyCij9RsKwB8Z jFRZv/g4TxD4eyQOB5OA4f9ULqZiwyIrdHvsDKPX3p2ys6lHq+Cgtgj8RlHaDXm717iz LRXf9pk+/l6THVjph3mMZI+Z4Azt2D4RP1oUV7JU9hy1vhoeVJFqr08oDjKTD1mwno+P 9OhVvxxb7daTuKI8kY6/3tIrD+4TF64CeDD7aB1sgFRUBOB7129MevlKznofLVF1Ojiw pLmx1+r22ilJp1yGb+SXl4onO17hfP/VHdq8jlpLUeiI35CWFKNyOEQO2AKItquidqMk O3iw== X-Gm-Message-State: AOAM531bMtYJhOiQ+lONqToIj62NuDGk89JTm2dxl/Xmr5pMOj5fDq9B fXEcVU1/gAzyliLIRAspmoaN4hLU+Y8= X-Google-Smtp-Source: ABdhPJxYq64l9aFQQCwVRNijMNgW76q9BdpDf96cjI9Mxf2A0X7HxcaV+PivV7veNtOE2r/lpOkUFw== X-Received: by 2002:adf:9c19:: with SMTP id f25mr5981425wrc.366.1603301701831; Wed, 21 Oct 2020 10:35:01 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id u15sm4411740wml.21.2020.10.21.10.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 02/13] hw/sd/sdhci: Document the datasheet used Date: Wed, 21 Oct 2020 19:34:39 +0200 Message-Id: <20201021173450.2616910-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add datasheet name in the file header. We can not add the direct download link since there is a disclaimers to agree first on the SD Association website (www.sdcard.org). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Tested-by: Alexander Bulekov Message-Id: <20200901140411.112150-3-f4bug@amsat.org> --- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 6d4603f5b19..ed717ab549b 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1,6 +1,8 @@ /* * SD Association Host Standard Specification v2.0 controller emulation * + * Datasheet: PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf + * * Copyright (c) 2011 Samsung Electronics Co., Ltd. * Mitsyanko Igor * Peter A.G. Crosthwaite From patchwork Wed Oct 21 17:34:40 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: 270754 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=-12.5 required=3.0 tests=BAYES_00,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 B1680C388F9 for ; Wed, 21 Oct 2020 17:37:00 +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 04B162242F for ; Wed, 21 Oct 2020 17:36: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="qqOIURXF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04B162242F 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]:60430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI2k-0004ek-Rn for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI10-000347-8e; Wed, 21 Oct 2020 13:35:10 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:39804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI0y-000635-Jq; Wed, 21 Oct 2020 13:35:09 -0400 Received: by mail-wm1-x32c.google.com with SMTP id d3so3472794wma.4; Wed, 21 Oct 2020 10:35:07 -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=5sS64GiSnmfXDwPIZCoMSvNhCEcsO6wIvPcArhV3+yo=; b=qqOIURXFloBEn82NoV8gQANlT9mqefCoMan0WiMmhQHNdPP0hGC6hLI7iPr3eV1HJV vczs4pQOxNgUUJJzMcCiK7BqLhv+5nWfXV9mw92A8wHX4pbOkJGTsqAw/4feQl4jwOJv IiwLdB8oZJSy09i+Px6Qmmi8cMVxw4sYmFeLJGcUg1xMFkRWaatDVwoKOaHymeh4zk2R i6Wmnc/XnidT0HCk+0LJUetrf6TIuJFjZtMCDaBskkx4DT7ikhoRQTGC0arPiTb/oU+w 1amfTjJ17V2L0SyyOah34UcZL/kSMCxl4WP1u0l7zzTE5P97jb3TZkN+YtksIlw9w6Gs rNWA== 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=5sS64GiSnmfXDwPIZCoMSvNhCEcsO6wIvPcArhV3+yo=; b=b7nH730qSfocfvCNMTn1xndIZbC5+pmhUVIcCfv7YNJRETJY4roa21pKcL6XpFUDUE oQEbhw0sj7M3ZKJUDILXXnSiNQf3kNE/M5Pu86R8NS1Wak6gUtCaXQNHJQE10rm/iLqf UDFnGetaEzCyLyW7Do1oQsQUe6RdtEumMup5XAOPVtrKiMhj+drmmZFd43GcLWOdv6I1 Pa9TfUzjuFi0XSipYb1ssJXPh7FI2Fk4LRopom9MJApD2dTo/FTQbYurt6kqlwjU5pSx +okr7IEezwd6I0VG5BrXuPOkVd/BXyGl+ZDSLFDvr+9vdPFEvVeSOlbXwJWyo8p+U+E0 h06w== X-Gm-Message-State: AOAM530dFORDzSDpK1ayYUPS/nWrqqS1Km/CvqCffd/eUtl30dtYROsx 3YMRc/tWx4oLZECgKzHykn8KUNNYzxM= X-Google-Smtp-Source: ABdhPJxELr3Os9sKHjCQIcYuZ2miiyJBdHWWbX0zykRyqwVxoDhrxTd+WhoTaGUjIMdkcz02f1Greg== X-Received: by 2002:a1c:4c05:: with SMTP id z5mr4666672wmf.122.1603301706778; Wed, 21 Oct 2020 10:35:06 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id k6sm4770610wmk.16.2020.10.21.10.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 03/13] hw/sd/sdhci: Fix DMA Transfer Block Size field Date: Wed, 21 Oct 2020 19:34:40 +0200 Message-Id: <20201021173450.2616910-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32c.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , Prasad J Pandit , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The 'Transfer Block Size' field is 12-bit wide. See section '2.2.2. Block Size Register (Offset 004h)' in datasheet. Two different bug reproducer available: - https://bugs.launchpad.net/qemu/+bug/1892960 - https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Fsdhci_oob_write1 Cc: qemu-stable@nongnu.org Buglink: https://bugs.launchpad.net/qemu/+bug/1892960 Fixes: d7dfca0807a ("hw/sdhci: introduce standard SD host controller") Reported-by: Alexander Bulekov Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Prasad J Pandit Tested-by: Alexander Bulekov Message-Id: <20200901140411.112150-3-f4bug@amsat.org> --- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index ed717ab549b..c849c3d99b8 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1107,7 +1107,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) break; case SDHC_BLKSIZE: if (!TRANSFERRING_DATA(s->prnsts)) { - MASKED_WRITE(s->blksize, mask, value); + MASKED_WRITE(s->blksize, mask, extract32(value, 0, 12)); MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16); } From patchwork Wed Oct 21 17:34:41 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: 270752 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=-12.5 required=3.0 tests=BAYES_00,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 E1F4CC55179 for ; Wed, 21 Oct 2020 17:42:03 +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 DD67E2224E for ; Wed, 21 Oct 2020 17:42:02 +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="jfGUQlnE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD67E2224E 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]:41532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI7c-0000dp-Pz for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:42:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI14-00035y-7u for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:15 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:35900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI12-00064a-So for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:13 -0400 Received: by mail-wm1-x32a.google.com with SMTP id e2so3471181wme.1 for ; Wed, 21 Oct 2020 10:35:12 -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=qenmuCcnJ1D62WnJyuSqdVB8Tn5y6BCbZljNKEVfJGQ=; b=jfGUQlnEjIHR8AoZTx+A5arMjqBjO1NEUwl7ZOOotDGbIAoakyVz/IRSAjVTIam89A SP7ihZ7r4XTXJn4bZehNFVG3loQlfMRrE41PHzrF79xmmoZUdXUZcz0vMnyTNhFxVK2D 12izHK73q7xFqaBiN0VIWIkNQuFMD9ileL52I0kvtAgymROxPBLie39iA+ehu3ig54LO AmbqpAasvPAYb1/H/PCINvpW6lHSLbWz8sLpgKni0HV/TK90iRA5eS2GBGHJxpwXOHgj gR7x9aV/96BuM/RlE6lFz2wV5ZfpNJRJCGstSiaOMpRyOb/ug5H96n2I/H/Uz3Uw+CF0 A6jQ== 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=qenmuCcnJ1D62WnJyuSqdVB8Tn5y6BCbZljNKEVfJGQ=; b=YPZqxRz+ErJdjY/sBN2PaMhmjbdK2h/X6ZHWbCg1DboHH56WG1NYeUry16qjtNG/VT QfrhCQU2PHpu29k21L+BNp+XIwaYtCtvtoIlC95r3V37cpMVvpCxVHiYqU4RA/lT5Fgk indW32+m3Je4HIVSpegco/a5wXmCybpq1BodE1XINyaqb2XxkKjSWrnzljaWv8IbckYn khDhcSeQScaUlGBDQ3OXXLlntG+z2qlVAoGx4KngQ3T+PAUiO5LjoFbyFJA4iocS52is YS3V5Rd73pn+DfNXuvlSBi6Yrlr2oB+v3vV9iRIcEe4m5KQh2KlMlMNpQmEiGAD/j8nL g41w== X-Gm-Message-State: AOAM533PZVAmB5cRs9V//Ud55A4Hz6sv+48Lqs28Bz/H9Nc8kTeVcbQF KZp059q6ihchIeJmkQbGeXH819wdmSk= X-Google-Smtp-Source: ABdhPJxS5ezFrvPd0MHkWnh8QXM41bcr50V0Qz4hiz21TfvGE4xSkp4NZl5kFe+Gr38JitOK2YANAg== X-Received: by 2002:a1c:8057:: with SMTP id b84mr4679185wmd.116.1603301711436; Wed, 21 Oct 2020 10:35:11 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id s2sm4900028wmf.45.2020.10.21.10.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 04/13] hw/sd/sdhci: Stop multiple transfers when block count is cleared Date: Wed, 21 Oct 2020 19:34:41 +0200 Message-Id: <20201021173450.2616910-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32a.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Clearing BlockCount stops multiple transfers. See "SD Host Controller Simplified Specification Version 2.00": - 2.2.3. Block Count Register (Offset 006h) - Table 2-8 : Determination of Transfer Type Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20200903172806.489710-2-f4bug@amsat.org> --- hw/sd/sdhci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index c849c3d99b8..61e469bd32f 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -731,6 +731,12 @@ static void sdhci_do_adma(SDHCIState *s) ADMADescr dscr = {}; int i; + if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) { + /* Stop Multiple Transfer */ + sdhci_end_transfer(s); + return; + } + for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH; @@ -756,7 +762,6 @@ static void sdhci_do_adma(SDHCIState *s) switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) { case SDHC_ADMA_ATTR_ACT_TRAN: /* data transfer */ - if (s->trnmod & SDHC_TRNS_READ) { while (length) { if (s->data_count == 0) { From patchwork Wed Oct 21 17:34:42 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: 302361 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=-12.5 required=3.0 tests=BAYES_00,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 7C535C388F9 for ; Wed, 21 Oct 2020 17:41:56 +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 BADB42224E for ; Wed, 21 Oct 2020 17:41:55 +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="nbqb3u28" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BADB42224E 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]:40800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI7W-0000H5-Ld for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:41:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI18-0003DZ-W5 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:19 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:38587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI17-00067O-J9 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:18 -0400 Received: by mail-wr1-x42a.google.com with SMTP id n18so4023102wrs.5 for ; Wed, 21 Oct 2020 10:35:17 -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=/ytGsokUFsJElQ21X2X5EL4wzQhSW3vyhSdpuBM3Iy0=; b=nbqb3u28VHRphmKZEzSFjsdEdoWb6g510uG/iCvddSmNhxu0cAi71HdNQtp486yHFg 6Wj7B5GJrJTFwn9RAIVi1ymprnLRIAYv1T4bqrAwRv1UqcxZgAG21dUxvtQ8oweWAfnP YKAk6NjgNzWn6ZR9gp/YwYtB2O35FLeMkW+DCgBX7FrKPtOSLR7+Kjn93ZNNHYIURQ2g tW61TFHYTGy1K7Z8A0Wk+7xtDgedGmVR/mtLAZ4dAhFi2ETCYSGJeDBNK61qiA5wqo1+ yffuZeUumRsDjez4FOitRw8p+RmOC2MwJKecNK+NtZajJEHZvY/O1aRblFJ+Wvdabrfl jNBg== 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=/ytGsokUFsJElQ21X2X5EL4wzQhSW3vyhSdpuBM3Iy0=; b=QEsvIcmGqUTdeiYYOhVy1wfHwu+yJpv1m6pkcgJQfDnCF/JPt3Aqa5LqRD4zemO7yM hf0td+/kyYbCuhliHUOnmu3jWttrowYjsmyT9slmms0C57w3Ai9Y7h7kXQ8p09Efr5YU C1pm3n/fuFqaTWjoTfGghs3z2wGfv9595YaX0mOIOR5D1vNDdPHROBixtetbwZ79vtCy GMfLgqvS/6lO8pv/LrigLeWpWmfslwiDjVllNgx5aIPWxa5CzF5hbqGVgmucNqEUWjk8 i5j6p0QECMz/wxGWNEPY2aAB7wQOk9jKfPRqQtMVv8BA+hQGXXi/b4lZ3+6cWYIXzns0 Nm4Q== X-Gm-Message-State: AOAM532wIvAhPbjecqk5zCMOwbr+kqIqcByB2h+2Z2Vy8hGue5cdzaR0 de7xK2MwYAq5kawS9I8bpvDzeVQRm+o= X-Google-Smtp-Source: ABdhPJw3Ykui0kKbtPN1zUJZUG2Lfz3PHxhrCmEw/cYAMRh3lABSC4TWJVB9VWK/qq2adF9/6VbPcA== X-Received: by 2002:adf:f810:: with SMTP id s16mr5758443wrp.424.1603301716086; Wed, 21 Oct 2020 10:35:16 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b63sm4643367wme.9.2020.10.21.10.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 05/13] hw/sd/sdhci: Resume pending DMA transfers on MMIO accesses Date: Wed, 21 Oct 2020 19:34:42 +0200 Message-Id: <20201021173450.2616910-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42a.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If we have pending DMA requests scheduled, process them first. So far we don't need to implement a bottom half to process them. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20200903172806.489710-3-f4bug@amsat.org> --- hw/sd/sdhci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 61e469bd32f..4db77decf87 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -948,11 +948,21 @@ sdhci_buff_access_is_sequential(SDHCIState *s, unsigned byte_num) return true; } +static void sdhci_resume_pending_transfer(SDHCIState *s) +{ + timer_del(s->transfer_timer); + sdhci_data_transfer(s); +} + static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) { SDHCIState *s = (SDHCIState *)opaque; uint32_t ret = 0; + if (timer_pending(s->transfer_timer)) { + sdhci_resume_pending_transfer(s); + } + switch (offset & ~0x3) { case SDHC_SYSAD: ret = s->sdmasysad; @@ -1096,6 +1106,10 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) uint32_t value = val; value <<= shift; + if (timer_pending(s->transfer_timer)) { + sdhci_resume_pending_transfer(s); + } + switch (offset & ~0x3) { case SDHC_SYSAD: s->sdmasysad = (s->sdmasysad & mask) | value; From patchwork Wed Oct 21 17:34:43 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: 302360 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=-12.5 required=3.0 tests=BAYES_00,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 66CF4C55179 for ; Wed, 21 Oct 2020 17:45:33 +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 9B76D223BF for ; Wed, 21 Oct 2020 17:45: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="eABs6x0c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B76D223BF 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]:49512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIB1-00044n-1z for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1D-0003MS-J2 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:23 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:54822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1C-0006Cq-5P for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:23 -0400 Received: by mail-wm1-x32b.google.com with SMTP id c77so2989239wmd.4 for ; Wed, 21 Oct 2020 10:35: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=NoDwWHinBIKIuPIX7ZFYNJrNUHL9vQFLXTimhcq4kjQ=; b=eABs6x0ckYBmbr2/3W50NFaxR//eZ8uRR1aTJoOcp4sbfqePoMQVs5vxzTxpKjAA+A 4ZpYwm0o9ggJLVZAOmYjIlGYc0c8Z8cKl3FyuV4PE6XgvVbsYZlZ8UgUJtOdGpiso2TS 62VxDPlgduVHVEPO7g8N1GDGcuVzWah+4xOfwVNXuUhHMLehfk5tTOnBvGjfSshnGDBi pTq16nUI8YU5DoZRTNRa6JoxxkFndcyWTzoz8GJ6Bqp7NudLKqb62TO/sACbC7ZjYDUr WbnOc/9/gjzuYXPhmWbEAluCLUmWceLY2R+i+xBaVfkm8JKfit4tnaEu8TLn1jyw0tz5 pidQ== 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=NoDwWHinBIKIuPIX7ZFYNJrNUHL9vQFLXTimhcq4kjQ=; b=Rj7qtqicP19+zdoMfbWqjxZ1ASIIVZaO1kfJzDVT9RqOecLBPegXaVxnXUXtIbh4ht eA2D5dKGwx3i96LzK0gYYq2CF7ZTFOwAiA43yHVrKgHN0PZuM7TtDIbXkA6+RTjK5f48 6Fc581uTyIMBOWp9FVSDz12kYqTLlyzHhXPg34o9qlbJEfCLqL9Ll9/KdHDTwbR7SdwJ G4aFuW+/xk+F6kwJDUYX9poEhKd6v7WUMT49RoW641jCtEHLjhjg4EfARrEEPo7zYmoH gKhTc+Vy1+UOa85Pqw/aRst1/Df3vWta1FMSm9ar/jUolbxlIuxVZSlyJtGZ1z1Q2yNe RSzw== X-Gm-Message-State: AOAM530iRxI2deCdO8Fm1wBGK8QYZGgaLPDKljV+DiT7vKPAcGIHc6LL mqJJSuG0kYXRfrIX1Z/Ne/YhH/64QXQ= X-Google-Smtp-Source: ABdhPJwLQIJqc+ZE4gBsTy/pCChmQBUWALD1zNHXGavM6wG4C/6wgeCukFTprryZmUyK1sRUsxCKyQ== X-Received: by 2002:a1c:2803:: with SMTP id o3mr4162007wmo.97.1603301720651; Wed, 21 Oct 2020 10:35:20 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b7sm5101971wrp.16.2020.10.21.10.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 06/13] hw/sd/sdhci: Let sdhci_update_irq() return if IRQ was delivered Date: Wed, 21 Oct 2020 19:34:43 +0200 Message-Id: <20201021173450.2616910-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32b.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20200903172806.489710-4-f4bug@amsat.org> --- hw/sd/sdhci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 4db77decf87..b93ecefd20c 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -218,9 +218,14 @@ static uint8_t sdhci_slotint(SDHCIState *s) ((s->norintsts & SDHC_NIS_REMOVE) && (s->wakcon & SDHC_WKUP_ON_RMV)); } -static inline void sdhci_update_irq(SDHCIState *s) +/* Return true if IRQ was pending and delivered */ +static bool sdhci_update_irq(SDHCIState *s) { - qemu_set_irq(s->irq, sdhci_slotint(s)); + bool pending = sdhci_slotint(s); + + qemu_set_irq(s->irq, pending); + + return pending; } static void sdhci_raise_insertion_irq(void *opaque) From patchwork Wed Oct 21 17:34:44 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: 270750 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=-12.5 required=3.0 tests=BAYES_00,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 C8DEAC388F9 for ; Wed, 21 Oct 2020 17:45:45 +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 2DF5C223BF for ; Wed, 21 Oct 2020 17:45:45 +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="vDcf6gZu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DF5C223BF 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]:50020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIBD-0004Hf-UJ for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:45:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1J-0003Wu-1S for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:29 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:35536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1G-0006G1-Re for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:28 -0400 Received: by mail-wr1-x42a.google.com with SMTP id n15so4079526wrq.2 for ; Wed, 21 Oct 2020 10:35: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=1T44dRrHJFyTG6J3zUPzNWduAlmSBzN4WxwodQQd2DE=; b=vDcf6gZu0N7BOib+GMVdXn2IJ+yMN7KzNJyEZt8IbpLlR0mqm1pLlyHuEcmULWLQ1R pLeUa5zPK0MtS83JrcwSA1MeBzbBY62lzHueHhozsZtyrhWATjOzP7pdEXVxUnx44vgc RHPALfbJYmNuq+AwmpE0zEFDV6vg/MnOB4F/iJ1WPzuu8RLaQTot8Ml84Zuf7YsS5PeH f/5fogY7GUshEdB5mLXk/EDav3YGluzZF4UUCzwxNFUHc97NesLIlafy9DEyOWvTir6N YwqJb2pdzSCxZHnnfdLiDd6NE/oON580qMYNa4PVOGyPZGSfdLssqMMdxlxDcYwe+hIY u8Xg== 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=1T44dRrHJFyTG6J3zUPzNWduAlmSBzN4WxwodQQd2DE=; b=CDfby2G24ooWN/LNQZkUG0AZjoCXl7Vf5j2RD6lXMSuWxi66gUWstTtc2DsB5vuH5W 6BxX44dYGrYHypDt3nQQp3fMdHBuD4RAC/4gy85oJX/4vgCbz+Ni/zS+I0TeES11VTgI KRVR12iMoX3ICPOcDbvMx5Kpfjv0DbUq0Lt5JtC2HdbIJrxk1ZT5qPFcTc6TJyzWau42 NEeOQRQ37QU9aDCRWiPWtXAkW7PXumPRlIsqqn6MUV5oq+2+rgSRgHQhUSvUT06xw+VA Gp3ywgZdLM5xslCesGtctcwySOuQOLJBtxWTjTUN5M8Pa9m2WJP8GgtSMMMX5aaN6g8E 9SVA== X-Gm-Message-State: AOAM531KfH3rBts3x/KW7hJjfW7TTLjPPgxyMzQVXQRJeRN53mhMxvrA ryqIsphlud2DKhJEaW9xT8c33QiXVuI= X-Google-Smtp-Source: ABdhPJxsvOAD4Sg/dhZO+BQpjrfn3YX1tqt3EiPn72WcpBB/de83OEXxGzxoJmuosXE+Jv5PQR4SDQ== X-Received: by 2002:adf:9069:: with SMTP id h96mr6289680wrh.358.1603301725217; Wed, 21 Oct 2020 10:35:25 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id s5sm4320261wmc.3.2020.10.21.10.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 07/13] hw/sd/sdhci: Yield if interrupt delivered during multiple transfer Date: Wed, 21 Oct 2020 19:34:44 +0200 Message-Id: <20201021173450.2616910-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42a.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The Descriptor Table has a bit to allow the DMA to generates Interrupt when the operation of the descriptor line is completed (see "1.13.4. Descriptor Table" of 'SD Host Controller Simplified Specification Version 2.00'). If we have pending interrupt and the descriptor requires it to be generated as soon as it is completed, reschedule pending transfers and yield to the CPU. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20200903172806.489710-5-f4bug@amsat.org> --- hw/sd/sdhci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index b93ecefd20c..2f8b74a84f7 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -837,7 +837,10 @@ static void sdhci_do_adma(SDHCIState *s) s->norintsts |= SDHC_NIS_DMA; } - sdhci_update_irq(s); + if (sdhci_update_irq(s) && !(dscr.attr & SDHC_ADMA_ATTR_END)) { + /* IRQ delivered, reschedule current transfer */ + break; + } } /* ADMA transfer terminates if blkcnt == 0 or by END attribute */ From patchwork Wed Oct 21 17:34:45 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: 270751 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=-12.5 required=3.0 tests=BAYES_00,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 10E69C388F9 for ; Wed, 21 Oct 2020 17:44:58 +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 36A24223BF for ; Wed, 21 Oct 2020 17:44:57 +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="uuQl3lsG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36A24223BF 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]:48266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIAP-0003a5-OU for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1M-0003cO-FA for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:34 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:51124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1L-0006GV-42 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:32 -0400 Received: by mail-wm1-x336.google.com with SMTP id 13so2988690wmf.0 for ; Wed, 21 Oct 2020 10:35: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=W5cNhnlAua+FOcK+awIb+jUgiTp6wkKIcsuybacXu04=; b=uuQl3lsG6QEoeL871Ku7B2hgq+rS8wCFkbhrhZiPMVZzvNv2ik3yLV/g/DwtBFYJVh J8/jaLeMX98KAb7+d6uS+U7KfikqP5JljWzzY1iIxE6x1RHj4mg5kMYIT/62Ems8r+Kc rVjfH0qkzGSSeu19Rqq8Xr4ofqLNyMf6xsgt5sfnwT+PHKvqaqH+67ttvurBq7agxyi2 PGOZY2jLqY8HCXuHkU6evHwREcD3qjkZDpkH2wAwyeljGNNyJ2Nr/13VdGaQuBOBhl0x DxeGjg0omDFiKLoFFHBF8mwRnOMxCg0AmD+OIcvioOKjcNOzbgz/q0yDbBLHF6mChkd6 878w== 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=W5cNhnlAua+FOcK+awIb+jUgiTp6wkKIcsuybacXu04=; b=SMY5u/VQU/C0bRGG0TIAQ779ngZVbh5wq+VKlDHu3t1zAMV7kqrN5IWT6iwsosh8nT JOLIpVahx5WQlTrl9qe6FuheSSFdfhKFax5YwiusftivOm/dhRrjE0YQBLTWGS62Fhl2 HYTUEUy8oomyKYrUKplxSgOBypGE4pfNMKqG5S249Ic5vJ/fOWVSO9/l//CtTyrvoRU8 nIeQp3pa+R/MO2xXOL7nMZPC8S455Q+Yu4iTFEqcvysPWqfC6cT8OAHpMYZ49llMdFU8 iNN5ca3hK8UR+Ynb7J28s0axM/k6HW0R2K724PAHUAt3CrnE5UJxwJzMQGjPAfTh9BAr RZ7w== X-Gm-Message-State: AOAM533xxjs8l0KKGAJKkRMy7FGLli3BRGlJjk4onWsUt76rSpa/+XBO mD4uHpuaM6XJHuiu5xOjoyI3B5J3lZc= X-Google-Smtp-Source: ABdhPJxqB4H7EHrnxUhjd98VCfoocJJcFw13ayFKIk/phEUEE4OjLvC4e0hCiTw01XWOsZxFipWkfg== X-Received: by 2002:a1c:2042:: with SMTP id g63mr4539960wmg.174.1603301729666; Wed, 21 Oct 2020 10:35:29 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d129sm4719627wmd.5.2020.10.21.10.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 08/13] hw/sd/sdcard: Add trace event for ERASE command (CMD38) Date: Wed, 21 Oct 2020 19:34:45 +0200 Message-Id: <20201021173450.2616910-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x336.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Trace addresses provided to the ERASE command. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20201015063824.212980-2-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 00128822224..2606b969e34 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -749,7 +749,7 @@ static void sd_erase(SDState *sd) uint64_t erase_start = sd->erase_start; uint64_t erase_end = sd->erase_end; - trace_sdcard_erase(); + trace_sdcard_erase(sd->erase_start, sd->erase_end); if (!sd->erase_start || !sd->erase_end) { sd->card_status |= ERASE_SEQ_ERROR; return; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index a87d7355fb8..96c7ea5e52f 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -46,7 +46,7 @@ sdcard_reset(void) "" sdcard_set_blocklen(uint16_t length) "0x%03x" sdcard_inserted(bool readonly) "read_only: %u" sdcard_ejected(void) "" -sdcard_erase(void) "" +sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32 sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" From patchwork Wed Oct 21 17:34:46 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: 302362 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=-12.5 required=3.0 tests=BAYES_00,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 E8AA5C55179 for ; Wed, 21 Oct 2020 17:37:46 +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 5CCB62224E for ; Wed, 21 Oct 2020 17:37:46 +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="oNEXywAi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CCB62224E 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]:34284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVI3V-0005V9-2f for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:37:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1R-0003jY-86 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:37 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:55914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1P-0006Gn-Ho for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:36 -0400 Received: by mail-wm1-x332.google.com with SMTP id a72so2992019wme.5 for ; Wed, 21 Oct 2020 10:35: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=fzUN3m5jQNygQt0awS2eaBT0Cdsnit89rpHTEPVkwn0=; b=oNEXywAiA1XRgqBTjH8uT0rQFi1YQhY+FOxcCAMDWa5wYVZk6ZxPr/f6wd5eulNCII 74fg99kDITdU3+Jt+nMBKL88dyz6jl0nrVYH1x5CGjktBYX1phb1kwG5pa1hV6EPvYBi ZScXuRyHcp8zPk2vWaKpT2WpcL/1xDZ/l5Nh7cB6OpZETUwJ2VWSnztSM4kgr7KnU9Im 2vgfsI+OFzBQJdTQ/OF08iR/ZsegiOnGMfcC4wFbJmi6Av2BgU4XP5b8hn73Sd1lIAJn 602MJJ4S1l/xPDEjpBtjvve+ioJcx60r6rXM2wYKIa9IdR2420YSYGoeVxowiA0Vgafo +80g== 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=fzUN3m5jQNygQt0awS2eaBT0Cdsnit89rpHTEPVkwn0=; b=sHyA6k79s5X1sjC3Gzi+lkbzStNpKmfbYso1rTeo/4xVVHrOSC4poWCwOECVOaN/nT TWKP69GyQmbZPjbc4Jov3LMkcSNPxqLucUSbSAlXmglqnHuyOO1n/s9OqSbKAe6GKbuo US07by51d+jRN23aN2vAyyOhMR3WDH36jZhacgVXH/kTjAOlK6+JSzMwWO2DzIW71IVT 2gJ1XalgXk5N+Bh707Uh1BWtCKAzX0JvnK5sC21EZMb7/D51IjMTsN8Tdt1sY/9LiuS1 i0dMRKOU0F2Snx0ihfPbrO33PNgc34E0XThlBXZ1H29oMbyHpt90z3X1W+9H+wbdRNjI 6IjQ== X-Gm-Message-State: AOAM532Iq2sBG414qeUgttqGVsbHozHRa9RxosASKIDBA3wVgdBwM0PL WcM1MWcyy+ZTNZ9BDP8Zs/vTtBBfNLA= X-Google-Smtp-Source: ABdhPJwXBoRsdDb44X9EuqWeZflAOBRTVuTjdzWUu+OVIA3Rkl7nxfTTlIJV7lDIa7IO9G5VvrDJOw== X-Received: by 2002:a1c:4445:: with SMTP id r66mr3286682wma.140.1603301734029; Wed, 21 Oct 2020 10:35:34 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b25sm4412857wmj.21.2020.10.21.10.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 09/13] hw/sd/sdcard: Introduce the INVALID_ADDRESS definition Date: Wed, 21 Oct 2020 19:34:46 +0200 Message-Id: <20201021173450.2616910-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x332.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" '0' is used as a value to indicate an invalid (or unset) address. Use a definition instead of a magic value. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20201015063824.212980-3-f4bug@amsat.org> --- hw/sd/sd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2606b969e34..30ae435d669 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -53,6 +53,8 @@ #define SDSC_MAX_CAPACITY (2 * GiB) +#define INVALID_ADDRESS 0 + typedef enum { sd_r0 = 0, /* no response */ sd_r1, /* normal response command */ @@ -575,8 +577,8 @@ static void sd_reset(DeviceState *dev) sd->wpgrps_size = sect; sd->wp_groups = bitmap_new(sd->wpgrps_size); memset(sd->function_group, 0, sizeof(sd->function_group)); - sd->erase_start = 0; - sd->erase_end = 0; + sd->erase_start = INVALID_ADDRESS; + sd->erase_end = INVALID_ADDRESS; sd->size = size; sd->blk_len = 0x200; sd->pwd_len = 0; @@ -750,7 +752,8 @@ static void sd_erase(SDState *sd) uint64_t erase_end = sd->erase_end; trace_sdcard_erase(sd->erase_start, sd->erase_end); - if (!sd->erase_start || !sd->erase_end) { + if (sd->erase_start == INVALID_ADDRESS + || sd->erase_end == INVALID_ADDRESS) { sd->card_status |= ERASE_SEQ_ERROR; return; } @@ -763,8 +766,8 @@ static void sd_erase(SDState *sd) erase_start = sd_addr_to_wpnum(erase_start); erase_end = sd_addr_to_wpnum(erase_end); - sd->erase_start = 0; - sd->erase_end = 0; + sd->erase_start = INVALID_ADDRESS; + sd->erase_end = INVALID_ADDRESS; sd->csd[14] |= 0x40; for (i = erase_start; i <= erase_end; i++) { From patchwork Wed Oct 21 17:34:47 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: 270748 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=-12.5 required=3.0 tests=BAYES_00,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 41BB3C55179 for ; Wed, 21 Oct 2020 17:49: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 94CB822453 for ; Wed, 21 Oct 2020 17:49:22 +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="Im8TggUk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94CB822453 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]:58458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIEj-0007x2-Fj for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1V-0003uj-Ld for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:41 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:40513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1T-0006HO-TC for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:41 -0400 Received: by mail-wm1-x32b.google.com with SMTP id k18so3474189wmj.5 for ; Wed, 21 Oct 2020 10:35:39 -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=DwXydEAJFsxr67ybFIbW+LVmbJToV8/GLo4Xc+I23PM=; b=Im8TggUkWiRcnUmFDECAQ8iBDKaO0Y1v1N/nxp6jAzi9IadnyocqH1CIsG3k0dMuQE RNt5EBQsI9wtTUO2QZUaPGtHNRRK1JMG22mOM6rOiWS/lGX4gSE2SDoiL4XodjOgiWtT oXP/nY77WZNbbAtft37sij41KwtLF0lOfhWhPgptQduCH7DxzoLHa2cFqqGFeEotD6yb HI4ytohulQI0b72ljb7T1YeGO96jbmGNEJI1wpaSKMtKy4PtV+4xuUtmcSbqKV4DibEq o8ckljxrjsd+n1yWCFNYBmoMC3TSgXpfnnv2n0Omq28LKfK/Vfff5iMOjJ8IJrprVeXm WYzA== 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=DwXydEAJFsxr67ybFIbW+LVmbJToV8/GLo4Xc+I23PM=; b=Pi/tmAEd7AXBhby1M1jFtBbPvneZWFsLb0x2K6WFDHuSUnsv1P6Bv+iQ1rp6B7tJVz SdHkfUyDKvRmHoBktv+owI4PXwpe3oLQaACozX3CGSSozQxEOzdOIlOCaChwMbUZooNf irv4BHjE6l31jWfKWBqK4y+QSXiwJ64xtc12Qjaoe8EaQV4XVUaCD1Fq02qUqFV81PiN 4yJpXLp6iu3DzDq0QsMFQsMCITa9sP44T237Nhs1kRK7EjVD36v+HzbOg397++CVb3Im rAy8+InaMuYEOHc4AU7p2hk1MyraYxKQm8AjqTuoQP5lJhpg1oU94h3iAkCthBT+W/fp ekqg== X-Gm-Message-State: AOAM533RAry9Cg8grgu3RxGaQ0aADEhLuYZJjtC5r8cjVXSadlCgcYyH zl5iVOGoXn4/4oXVpCf1dmszzI1vPXM= X-Google-Smtp-Source: ABdhPJwI6VnW4GRKD8pxDcALl9ybnwvYcPXmbCXGchSks8gAyUXet8NBK4az6hVVm7ZlcXiacyBvwA== X-Received: by 2002:a1c:c915:: with SMTP id f21mr2673961wmb.73.1603301738435; Wed, 21 Oct 2020 10:35:38 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id y14sm4274650wma.48.2020.10.21.10.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 10/13] hw/sd/sdcard: Do not use legal address '0' for INVALID_ADDRESS Date: Wed, 21 Oct 2020 19:34:47 +0200 Message-Id: <20201021173450.2616910-11-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32b.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As it is legal to WRITE/ERASE the address/block 0, change the value of this definition to an illegal address: UINT32_MAX. Unfortunately this break the migration stream, so bump the VMState version number. This affects some ARM boards and the SDHCI_PCI device (which is only used for testing). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20201015063824.212980-4-f4bug@amsat.org> --- hw/sd/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 30ae435d669..4c05152f189 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -53,7 +53,7 @@ #define SDSC_MAX_CAPACITY (2 * GiB) -#define INVALID_ADDRESS 0 +#define INVALID_ADDRESS UINT32_MAX typedef enum { sd_r0 = 0, /* no response */ @@ -666,8 +666,8 @@ static int sd_vmstate_pre_load(void *opaque) static const VMStateDescription sd_vmstate = { .name = "sd-card", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .pre_load = sd_vmstate_pre_load, .fields = (VMStateField[]) { VMSTATE_UINT32(mode, SDState), From patchwork Wed Oct 21 17:34:49 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: 270749 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=-12.5 required=3.0 tests=BAYES_00,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 1E5F7C388F9 for ; Wed, 21 Oct 2020 17:48: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 82A2E2242F for ; Wed, 21 Oct 2020 17:48:58 +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="XMcvC8yP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82A2E2242F 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]:56696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIEL-0007Do-FZ for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:48:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1h-0004CH-Gh for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:53 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1d-0006IA-PV for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:53 -0400 Received: by mail-wm1-x342.google.com with SMTP id a72so2992637wme.5 for ; Wed, 21 Oct 2020 10:35:49 -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=p6WWIsaS0I3UntqPKdZpY4UhujIkCcQKP7e4gj992fw=; b=XMcvC8yPcH2DqQ0sZMxPYfcTa/pHDgm6brwx7QDW247J4Q4vNCJOSJ0RlfHoRqmECS UBgK71S/JGHsz1wGj4e2hO0wVXjqC8c4cADVY1S1liSc8fxDiNSFAaAgfIMGZYl5oEad ew2ljuNIQp/xhDjs4LXuKvzWZfaoMaJGwjv93v8aBycHV+El5i7DfNLunIILae/oBmJD wCfGbqWy6Vg/U8ccDwF+HZrCttruQIfq3aRUjcdvHHULjtUtLotQe8CH074eax1UUPNt VaHrNcuLoT+Eo+PXp/4XfMheVI20OgAlU4vAE+mdYrh6VrzopoAkGx5nZxmKL69eKACk 3Ksw== 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=p6WWIsaS0I3UntqPKdZpY4UhujIkCcQKP7e4gj992fw=; b=Wj25NE1hUtk5jXZ6JlE8bUvVxs0/FSs+JvT8mqBk/am9uERoA7MHKdTjZH8LhKR9nx MqsOHMSzX/wwJXMuEyTxlKduseYzc0utGRQLej6jtwtJ7ZZzxqsSl1n/ixZ9NLK+OZQ5 UJ/3oISk/1srxD5LrkmQ6rPEVJsZuQIwOh5h07Tdhc0RwyfUzg6hsnoc9iTnQNRbaZDK 7aYhqb7YNI6ycmkj/Er/o0gz6ZIBEy63M0ANnjJPZtZW15K/ZephotIedazfjvvdpKZn wJKcNlgcz+dAkprsoYQJF87/ZmaLS0eGyy43NFtEh7eGRupcg+F6R17Zg3sVP8EF7bV3 w/pg== X-Gm-Message-State: AOAM532+OLeen8DliJaImgtaqaZj8UdJTy7omMYP8TYej82JOb6AhfME 9INLUMgndz+H6egUR5ZCbAU4Or4BynY= X-Google-Smtp-Source: ABdhPJxo1UigovYRWF8fiNhKTbGbLDxlaK/ujDfESF2lS7IbEhMIoRZP0vI1NAl/iZU+Chx33VrxvA== X-Received: by 2002:a1c:2d53:: with SMTP id t80mr4451258wmt.125.1603301747614; Wed, 21 Oct 2020 10:35:47 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id j7sm5150707wrn.81.2020.10.21.10.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 12/13] hw/sd/sdcard: Do not attempt to erase out of range addresses Date: Wed, 21 Oct 2020 19:34:49 +0200 Message-Id: <20201021173450.2616910-13-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" While the Spec v3 is not very clear, v6 states: If the host provides an out of range address as an argument to CMD32 or CMD33, the card shall indicate OUT_OF_RANGE error in R1 (ERX) for CMD38. If an address is out of range, do not attempt to erase it: return R1 with the error bit set. Buglink: https://bugs.launchpad.net/qemu/+bug/1895310 Reported-by: Alexander Bulekov Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20201015063824.212980-6-f4bug@amsat.org> --- hw/sd/sd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ee7b64023aa..4454d168e2f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -766,6 +766,13 @@ static void sd_erase(SDState *sd) erase_end *= 512; } + if (sd->erase_start > sd->size || sd->erase_end > sd->size) { + sd->card_status |= OUT_OF_RANGE; + sd->erase_start = INVALID_ADDRESS; + sd->erase_end = INVALID_ADDRESS; + return; + } + erase_start = sd_addr_to_wpnum(erase_start); erase_end = sd_addr_to_wpnum(erase_end); sd->erase_start = INVALID_ADDRESS; From patchwork Wed Oct 21 17:34:50 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: 302358 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=-12.5 required=3.0 tests=BAYES_00,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 8F1E5C388F9 for ; Wed, 21 Oct 2020 17:49: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 BB0BB2242F for ; Wed, 21 Oct 2020 17:49:14 +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="BJckA9U2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB0BB2242F 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]:57822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVIEb-0007hD-OL for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 13:49:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVI1j-0004G3-4j for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:55 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:35339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVI1h-0006IZ-Ok for qemu-devel@nongnu.org; Wed, 21 Oct 2020 13:35:54 -0400 Received: by mail-wm1-x32e.google.com with SMTP id q5so3462708wmq.0 for ; Wed, 21 Oct 2020 10:35:53 -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=+Fm7KbLir3gbzmjKy+27eSKs45PUg9V/AzuCpZDRK/Q=; b=BJckA9U2TgiC+CxfBuvijCXXMaUfzkPWmqaDBx8HO6JNH6gaogOPzZLGozrWjTu46x XTz0jbJQLeBLigFgBopZdMMy2E+5xv6p9TCrb16908nc1++1fC1wVpp6OhLG0VWLbda5 5e42Re/cufcyukyEKQj6h7+UUiwq3BrTl0p6ozYbipJ9dLn3WYut1QuBVf+S1B9N+Gk1 KkQgV/RBgEwpgtH1uDSm5vfI5BI7r9DJfxe9T4gMgMpMGQe92+SMg4z3S4v3L0Qk338I d5vhhlW1cnou8N77tkIaOmHeNMehe3389IXkCNTEkp0juq9azyvS3XNuJ/6XwE/ua9xy HeOA== 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=+Fm7KbLir3gbzmjKy+27eSKs45PUg9V/AzuCpZDRK/Q=; b=PUXobAKqJFFcPfxf3FVN1nJKY/8DT1JxLjDR00NRV8xdaZwAvSP6FSF72dQ3QsBMJ5 SAGw3eCVpz8b5fDU+oSPIUIMBMW5TyQZ38yAIMz1XdAPXgBYZvpkty/KqVc/5HLyKDi9 MXJwhdr+vbmEieg+K3uWH9It4av2RebosMDfeeTVpbz2BGAzrp4UlW3O8X47ZV9xgyTg pcY9zWGqz7PZkKrCJ6UHFRkpHNhPymn0ke26v165RYbd7baxiIADfPgWG70aharWDuX+ 9TU33Xfjb4FI4qfywejwyfS8r8sJbVt/WjrAluZRmRqaNZIvXd97MzKljgVELcU1133C QXpg== X-Gm-Message-State: AOAM5304TgQVnttgmz3V4KY4el9JNYxljyxPx2xyTOP1Kk5KJn5NVHAl oTakaqh6h/1HiuR0k8hh1D1eXS1V+KY= X-Google-Smtp-Source: ABdhPJyXZR7NSQEPtzfFgA+cILOxyz/oir9OSDeP9Ffxb2N9bdWfaYwgiQ6vdyLLGtlnl4JBwr9PrA== X-Received: by 2002:a7b:c418:: with SMTP id k24mr4913652wmi.118.1603301752277; Wed, 21 Oct 2020 10:35:52 -0700 (PDT) Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 133sm8735201wmb.2.2020.10.21.10.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 10:35:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 13/13] hw/sd/sdcard: Assert if accessing an illegal group Date: Wed, 21 Oct 2020 19:34:50 +0200 Message-Id: <20201021173450.2616910-14-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021173450.2616910-1-f4bug@amsat.org> References: <20201021173450.2616910-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32e.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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We can not have more group than 'wpgrps_size'. Assert if we are accessing a group above this limit. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Alexander Bulekov Message-Id: <20201015063824.212980-7-f4bug@amsat.org> --- hw/sd/sd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4454d168e2f..c3febed2434 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -780,6 +780,7 @@ static void sd_erase(SDState *sd) sd->csd[14] |= 0x40; for (i = erase_start; i <= erase_end; i++) { + assert(i < sd->wpgrps_size); if (test_bit(i, sd->wp_groups)) { sd->card_status |= WP_ERASE_SKIP; } @@ -794,6 +795,7 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) wpnum = sd_addr_to_wpnum(addr); for (i = 0; i < 32; i++, wpnum++, addr += WPGROUP_SIZE) { + assert(wpnum < sd->wpgrps_size); if (addr < sd->size && test_bit(wpnum, sd->wp_groups)) { ret |= (1 << i); }