From patchwork Tue Jul 2 09:19:48 2024 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: 809054 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116602wru; Tue, 2 Jul 2024 02:23:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3vHXMqY+JxgvkPLYDbeOMOjl1Ci71yQ0vX8bf6Woe3S9yylEBPsNLyI6GCYmdg453Am223EBQjEBnBus7nkoD X-Google-Smtp-Source: AGHT+IHtKeiG4KM9e9WP5ZQFBWKZF7+DH2oSO8HbljdF2VWrDwrN+ADb9KxrZBEP2yc5EVWqX7SC X-Received: by 2002:ac8:58ca:0:b0:446:448d:8e26 with SMTP id d75a77b69052e-44662eaab9dmr104401221cf.54.1719912192653; Tue, 02 Jul 2024 02:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912192; cv=none; d=google.com; s=arc-20160816; b=SebpVjpWd1KKCMsXuRDpubdmYxSZgvEufQpERREz7uV/52wqiM0fi8yiCMGUlCqDCK IgtT/tWu0dXH4g6wY+cSTPALJJnm/EQFges1mZLT/2osYJtzxi3ypxbnidVweTzTDsQb r9XgnJIinjcUn2YFpmMPKvapAGNGDT5r0sWThsaWI+0NOUMo8yARgjEHRb4/BYORA8eJ ZNmgiNzlLzyyLkpt7RIhBzUwNUA+uUkk9xI+bL3CoEtLpSjwjxmDthb3py6xc3/NH+Kp q+eDKbNqTQerMRKnFiEGXGcMyzr7hryTHe/ylI6u1p0qsGCDFN0J+tXZ+1a4Lbnbf6r1 V3iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:dkim-signature; bh=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Gz7T5Ptt4HLi3pxKIdfQpqTKPZA9sJHxEW3rpSedOkUo8Bas/IYm50/57pmixNqzR/ X8xh4Y07Z8DnfX2a3jNIw5kj8l34sDgRbtV4ui1lEocAidLEtiVwS5Vhz7/vYLZcBkzn ReJH4S4i+R+x7oziOm2HMtIVCwBXn8PCv4vtOBnRBlvVu9vzg1QGI0THIC4Wsi4FH+Yr +dgE3Xk6Kyh97zP+/pstltK9TileQApg3COyOiJuxzcrnx0NotjZUg8Ld8oHIimAXkTa 8+K6JLhr7/tKaeT3rPnp2I1kxWNVJCuAc1iCGIDBVo70tHqhF61CfkY/tzlzhYR1EHie ln+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnU6ueup; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44651489ee0si95218181cf.335.2024.07.02.02.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:12 -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; dkim=pass header.i=@linaro.org header.s=google header.b=wnU6ueup; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOZht-00017z-Ae; Tue, 02 Jul 2024 05:21:49 -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 1sOZhn-00017F-23 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:44 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhY-0006QB-9V for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:42 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4256f102e89so26449405e9.0 for ; Tue, 02 Jul 2024 02:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912083; x=1720516883; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; b=wnU6ueupR7UviJVu5I+ll/Mp37YvmIKMeTcxNrwzSH7TGnw+1IGYWx9bI+rbMdLAqV /orqb7tba2FmrNvKCyjuaDDcDmso0epaamgDmJB71BNHkQIhD3ufkd0HaPWY7lzFcYzm S7tbDWA9aGKZg63Y9IFQj9RZrVR64vfLHkPqZYxoNL/mOSfBl5xcAdrXyKpCNTFOBcFd 4au5a2SrpC8IoNAShFVFB68l1fqra0DuxEVfgxINUWuCdjocREB96RYo1THIBhFr2x8X jJZ3H+4lMB7fdTiiJA5LMNrANKBLc/N7zQzrzf8MPobd6H4wyklt0hDEmTfLOsqNM8Ei ES4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912083; x=1720516883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; b=KynFcKJFZC39byPyl/ePPDcyBfkPrfeguTFP+1eKZ2ogizbcjIcRLdVVJZZjeZQLc4 5qO9WVNCLi8mxCTjDKK9mT5/tPBxwxXbS48NX9wiik/NbpNO6P5U2xqgAO8H0QC93ELP Ls3obVXswhv9SMRmQEpejX2EqWHOOAIOWjguLaonQM0w9rm+FpCMYiUW6vfsYR0rKd7R g+3hN1kC9KPnv5Ui7WulypXlPLCjDq1JNZypLxQ0eszuyJoBhWs2yKSp3GjWUXqwLsaL EV+qdQdfBgsasxHbp8KDP+fXF+hOkQM08ucmrCAmDgH1LuxDRLkZwxV+g+pyfh8ZDiXv SqMw== X-Gm-Message-State: AOJu0YxXw+LKmK0iOY/JYACHB7Pq697DYf9wrk067QZ4AKkajpycMJ4F O/DryTlN2dHysauPW4VqygNg+CGSNN+2McM7LdLO6iBzh39uXCX1Z6LOi9wob6MfH9cUaEMoLQX P X-Received: by 2002:a05:600c:5cb:b0:424:a4c1:6ee7 with SMTP id 5b1f17b1804b1-4257a010baamr52164595e9.18.1719912083293; Tue, 02 Jul 2024 02:21:23 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a102bc5sm12637966f8f.92.2024.07.02.02.21.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 05/67] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6) Date: Tue, 2 Jul 2024 11:19:48 +0200 Message-ID: <20240702092051.45754-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 SWITCH_FUNCTION is only allowed in TRANSFER state (See 4.8 "Card State Transition Table). Fixes: a1bb27b1e9 ("Initial SD card emulation") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-13-philmd@linaro.org> --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 396185f240..b5d002e6d7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1204,6 +1204,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd_function_switch(sd, req.arg); sd->state = sd_sendingdata_state; sd->data_start = 0;