From patchwork Fri Sep 6 11:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 825934 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp745794wrb; Fri, 6 Sep 2024 04:18:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzOjkL9q/NhLeOFv1JJLCtUaJF2ItsnFo96XKOZeNcwAoXG5x0jqc5QQkSlUtgHWSmdYWzHg==@linaro.org X-Google-Smtp-Source: AGHT+IHd8g3/nHpWzFv/22GZJkCxT/x1q8cFbewlGoggZYR2AUFE7VaAbno+yv7yLffbZR3YklEO X-Received: by 2002:a05:6902:1684:b0:e1a:a13e:cc07 with SMTP id 3f1490d57ef6-e1d3486ef87mr2598945276.1.1725621517848; Fri, 06 Sep 2024 04:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725621517; cv=none; d=google.com; s=arc-20240605; b=YWTphdT9b9ohIWZOISD+armtQjR2reSvfmUNJz0o+8j+iWL0184bLuMGXB8fWENp6s NW/BJYouKE968RnFR/3xY4iv1kuKoHUkmExFnnaX/DEPCdOSeMKopXdUC99JWrHNZQfZ bwtzmPwI2j9gPWO0FnVx28kNw5qY91cP+AUthRyVal8tnywNfzhKHqfgFH+6xMzreiq3 cYerAcC9c0+/wLHrwImH10ZLudY8GqIRK3SuHWcW1n36VXHCmITqdbI2HG4ayduMC3sW lACKNR8HfrjKjewmq67FNT/qRYjt7BgtE/GpxJRW+Ifocugq/ShXTVPrH/010AU4cUIO uvPg== 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=/7TWBNjBHievxBVj2ZRQvsMG8acNJyhnPeiah5F/DWU=; fh=5bR2Ckfc1WOYjVTih8W/ByZTKk2PNsQ3J6+3vQjlF0I=; b=XHM5SiyF2WHcQOLp5xez4EjAlAjHTIhDYbxDrpsbr1IHM3zYvpoPXihCAGxjsdc+LK xpGdy61NtyIBhsKx8GwaKsQfHjA183zGVqqxaR/P3ar4sL9Gh/jr62uqBPOHlh3yJxqp AEfYd/uHw1FL5RrD6kKmP0w7jWKeHCdn7whi6Utb6Lkk8NUrzaVKyoUMKQw4aMBW6K7E F4P8Stho/VoHJW9J373WRxQQY6gn4BW2Ax9nxNEN3LytryNrUZWO2wDMn5x4ZdCA6WMv GiKd3dw4l2541mjyfjGM9fId3H6V5HNKq+8tGd0WQMHnP/Cee/nx48T9NIr44W5deiX7 kEkQ==; 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 6a1803df08f44-6c530635fffsi688636d6.187.2024.09.06.04.18.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 04:18:37 -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 1smWyY-0003st-1w; Fri, 06 Sep 2024 07:18:02 -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 1smWxd-0008HU-FY; Fri, 06 Sep 2024 07:17:05 -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 1smWxb-00088E-CX; Fri, 06 Sep 2024 07:17:05 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 2AEA88C499; Fri, 6 Sep 2024 14:12:09 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 36B03133702; Fri, 6 Sep 2024 14:13:27 +0300 (MSK) Received: (nullmailer pid 353674 invoked by uid 1000); Fri, 06 Sep 2024 11:13:24 -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-9.0.3 40/69] hw/sd/sdhci: Reset @data_count index on invalid ADMA transfers Date: Fri, 6 Sep 2024 14:12:49 +0300 Message-Id: <20240906111324.353230-40-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 27673e1c70..8c5eab1b83 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;