From patchwork Fri Sep 6 05:16:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 825900 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp637884wrb; Thu, 5 Sep 2024 22:20:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV007Ta4eNdkxG5h/Y7ET0E2gTFxVlBbDPQO5YGODTjFJZ2mlnb1RfmmZegBYx9YM8eGEhfpA==@linaro.org X-Google-Smtp-Source: AGHT+IGoAr5UGHlfSBNfMvuZUV1nPUoXm7zUo52STvIThiVxXjYxiCxsK76PmUSSwvOYscxgZIEJ X-Received: by 2002:a05:620a:280c:b0:7a1:e3e5:c8c with SMTP id af79cd13be357-7a99731be3emr154000485a.5.1725600002616; Thu, 05 Sep 2024 22:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725600002; cv=none; d=google.com; s=arc-20240605; b=Z0xcFRu22R2D6kKgPa6yLEFqGwo2Qi+hTN/aVwHfADOl+ktqFCuhK+jnmz/urNkLu6 FMxfyZD9bW8GVyHdKoDaajacD70GLHUE28W//YHJ6e43FSnPTHs+h/a1rYLLN76kDq8A Qc5pos1hfhWP6mTEV7U1A9NAEP8F0rKJwHAYnAECkMH6SoYO5sFulX7RZHIPj+0AwgNK NxiiQZ8gxRdV+2WFKHLsgvyJyRDJ92I7Irs0mE2rYbYdL+GIEjUNBrhhBuf6C1LWkSQ6 e0Grb8eh7A0oZPJLhqoS8258BcuIJYm+3hbuZlr66dNrpcVgodp2jg0kSa39wN8R3GP2 2zpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=GsUyc2muy/ozpnoyZ9n/uEyuepQV6Xw8Y5kZil2s/GY=; fh=5bR2Ckfc1WOYjVTih8W/ByZTKk2PNsQ3J6+3vQjlF0I=; b=R1UfORM8EV/CSYVHKnJ06KYsQN+GKtLm7qsFlODpAj32judrSzCykQu8SFuHSrP9Jf 2uIKs3v+6r+61Pf5zujXuOWN1dPr7YuXlt3Sn07degt4HqrJlAo8LWoefvX/oJmpsQE3 t0Q+guMvfUb0LREInjDoCQg6MUU0MedqmLFhs90qTDj+a7lNG9ROCifr5gD2STCp65so IXFOiep9LUoz7s5yVJY32qHkQBgBOMdfi04MS1w1ZqOiJZ8VrEfiKDvuKo89XcvHNUNc ObrdRRQBnZzLvw+x51dOHBYgS7qG13FyGrVMWv3P9c3KtCfybdQiesRB/uZlnnrKPAlf 5ViA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a98f00a09dsi372822285a.394.2024.09.05.22.20.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Sep 2024 22:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smRNH-0004Kf-6G; Fri, 06 Sep 2024 01:19:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smRMn-0002Nh-76; Fri, 06 Sep 2024 01:18:42 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smRMl-0008D3-EG; Fri, 06 Sep 2024 01:18:40 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id BECD18C12E; Fri, 6 Sep 2024 08:15:17 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 6E2A7133373; Fri, 6 Sep 2024 08:16:35 +0300 (MSK) Received: (nullmailer pid 10461 invoked by uid 1000); Fri, 06 Sep 2024 05:16:33 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Zheyu Ma , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.14 25/40] hw/sd/sdhci: Reset @data_count index on invalid ADMA transfers Date: Fri, 6 Sep 2024 08:16:13 +0300 Message-Id: <20240906051633.10288-25-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé We neglected to clear the @data_count index on ADMA error, allowing to trigger assertion in sdhci_read_dataport() or sdhci_write_dataport(). Cc: qemu-stable@nongnu.org Fixes: d7dfca0807 ("hw/sdhci: introduce standard SD host controller") Reported-by: Zheyu Ma Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2455 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20240730092138.32443-4-philmd@linaro.org> (cherry picked from commit ed5a159c3de48a581f46de4c8c02b4b295e6c52d) Signed-off-by: Michael Tokarev diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index abd503d168..c4a9b5956d 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -846,6 +846,7 @@ static void sdhci_do_adma(SDHCIState *s) } } if (res != MEMTX_OK) { + s->data_count = 0; if (s->errintstsen & SDHC_EISEN_ADMAERR) { trace_sdhci_error("Set ADMA error flag"); s->errintsts |= SDHC_EIS_ADMAERR;