From patchwork Fri Sep 6 06:54:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 825920 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp662787wrb; Thu, 5 Sep 2024 23:59:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV1j+7b5R2GRbwU1L2hql3XdVZ2t2+kl1/Yjih4Sm4+yePNuxvQRkCff+v9PG95AksdEeNReg==@linaro.org X-Google-Smtp-Source: AGHT+IGonLRBmSIBwHCcSJKQJC9PLy1ELRI5tlIOTMDlWQG67DvoUrTjtJIQ8anZc2SG5ic5txM7 X-Received: by 2002:a05:620a:319a:b0:7a3:5004:43dc with SMTP id af79cd13be357-7a8041f1a8bmr3255808585a.40.1725605967943; Thu, 05 Sep 2024 23:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725605967; cv=none; d=google.com; s=arc-20240605; b=WNdBApESNtEsX7aB9ruvXpxkb5r1OAeFP5Eu3enr8/A4L/zoJvdorjO9zJy7xftHfi RbBvWVoE+hGIMvcpB7YhQ5iIKSd5nGKLnBy7IMznTKttmqtbNQdHbbbjjLQbxi1umVl5 YMxFJBwfMgBY+fDwTw9GtKmzSganF23jpNXIc+g4EStrjCAvzd6CoUbL0mzjlHqnL0wb iIsyP4YJ8akLWVvI3vJroInIzZHRQFnSfYfscVji/k5C2MvwMlhZkh11acCHAB98soCs piSs69eG1jsPFgA1tdE0cZx8Tq7CMIG8GY0j/TrDv9Rf+lhB4GGrfJt2WpTPaOCdRjA/ o82Q== 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=O+JNv/2ADiHaBzCteTDBJdsWwCjIb7joL84OgyYDO5M=; fh=5bR2Ckfc1WOYjVTih8W/ByZTKk2PNsQ3J6+3vQjlF0I=; b=MlaL6qj4W3LiPchTbcfwGQMGqRFoaHR76cB6rgFuswA6EM7Qt00WXgct2o7Ci5u/2e K8edlTtIw89C0wMmgpOb4gU2AEKkNyb3ytdi/b6EnIPFWK/9fijrXqLk1PHdRSb3McxH BvmIFAErXS5lrMUmgXSE3bT/vz/GztMLUsN6ArEeAZwRUO0SCWA/GzHRFG5gZ/g/suJj 2XfdV3ZaX9lB6+IN2KDlPrDhiy9uU2qZ1f5//uGBtmoAIAMgs0ihm2FXTkI10gLiYCyE G46j//TIZlKmT2fdEMan2ZJ34IJ516KsBxil8wQUV+jtCVU5R32+wlVOFQOIkrPbMHtG wUqQ==; 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-7a98f039df5si363951485a.726.2024.09.05.23.59.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Sep 2024 23:59:27 -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 1smSuS-0002w1-FN; Fri, 06 Sep 2024 02:57:32 -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 1smSuG-0001rV-EX; Fri, 06 Sep 2024 02:57:23 -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 1smSuD-0003Uo-T8; Fri, 06 Sep 2024 02:57:19 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id AE6C48C254; Fri, 6 Sep 2024 09:53:13 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 768CC13340C; Fri, 6 Sep 2024 09:54:31 +0300 (MSK) Received: (nullmailer pid 43574 invoked by uid 1000); Fri, 06 Sep 2024 06:54:30 -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-8.2.7 31/53] hw/sd/sdhci: Reset @data_count index on invalid ADMA transfers Date: Fri, 6 Sep 2024 09:54:01 +0300 Message-Id: <20240906065429.42415-31-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 e95ea34895..8bfdcf6854 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;