From patchwork Fri Jun 21 08:05:43 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: 806331 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653906wrt; Fri, 21 Jun 2024 01:08:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVsdJMonEZXaHQ++t56MYxtb3n6vxoo9rQvil7hZqbrM4QFXLeYjz0rM0oBprPb9Ym8+q1XvhOgIP8b1IEhTWKX X-Google-Smtp-Source: AGHT+IHFNlkiR/pQSIThsoBoW/oGh9RQATJEZOsD0eyC0f/ozFiIbR6yswAi+TGo2hAn9ef3IhOB X-Received: by 2002:a25:2e04:0:b0:df4:d65e:f519 with SMTP id 3f1490d57ef6-e02be2489d2mr7902396276.59.1718957306877; Fri, 21 Jun 2024 01:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957306; cv=none; d=google.com; s=arc-20160816; b=f5575OZRllJqydf6mlIAb9l+q/QKCUEKgOudQVWasSVjiSIsQH9VSccRn2OTDwqii+ 5iSW8kwjiY9IA7/xtH5G4CSgkLxtjIKXU7sCy1anxiyIdzjiUfnyc3tAdOe1HDnw6/hx mJzMcmIIQxRddt5ctewwfZFlqVMX64OJdGYCikCDj5q+7zMcERd+4thBVdG8d7Tkh/+z x/iNqsxol7oTFjaIRIT2XFY0dt7r3L8Tuc4l/9wxn6sdJSl6d1ukvbqDEi7fkSsWXbTd 2GP7IIHSVrKwNomdXdUWF7I0irg1RmJSmQ4XSb3SyzYwGnsSl7K1l3c99/JDzFsnH4IW NFBQ== 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=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=FoHIDwPRTu2YEKCJ7FhzpoaFAZTy0XGrdXjKwnis2csqOI5tTRQEhMQi8WvCSVDpr/ WuKLrqsKPmixwn0BvM8d9PEJlRJ91Wcp2fQ9e66u2mC+X/347ye7pIVZgCVUPStV+H3u jQMH/pdOpfBAdmprfrBAw1GXP8vWTUUH1G3JQIbSJOtH2riDffwj48JbhR7OtiLsHQvF YuhIYw3Ds7jvmUjS7S5fHaDQBge7mDGPEKKCXdjdZwn+tP6TzrRZlAlNe2xuBTeIbFm8 x+UrcAymoHzVsseFXLJp5sifzbTMTyHhSkgM+rEjB3HwgylnyyjIbbC6L2bVQXU9UeHM +mNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3X2IGN+; 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 6a1803df08f44-6b51ed16c29si11063516d6.159.2024.06.21.01.08.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:26 -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=R3X2IGN+; 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 1sKZIi-0006e6-9m; Fri, 21 Jun 2024 04:07:16 -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 1sKZIg-0006Tf-8D for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:14 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIe-0008S9-Dr for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:13 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so20467061fa.3 for ; Fri, 21 Jun 2024 01:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957230; x=1719562030; 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=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; b=R3X2IGN+vUWZo4IiSlxJ9vtqLqn+buTVbx6KbrZJhoaGB03TXPuz2s9lvJW8Gb8h3I Uqev++PRyB+epOnnvDVubILnRWCNf656O/U9/RjTSnQ2mEYawjVvk09cc2SapPKNnMIJ AtPezlXs+JeK4bvlXfY0HRNSdhfTlPIE00eE7mnG36X6QyfPU/vngWeVCAW0qFbnAJ60 TbVTCRBru1UB3ilcM7lw1ZYfSiswfv0TQgufZNYJ59DMRkOJRBFx5DReaF45CjIf+raC SWIIsSAR3oLGuA8JkwfSuq+OMz8CIFqIjkMIGPxvdWDqvL5T6BWQM+0gx4A/k6Ni17un lIhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957230; x=1719562030; 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=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; b=VhlOvJCrmgjniUOAhSFbtvkAklkWgUEF2Cg6oPiIRuV/+EmeI6xNhAtDI5LzIpDvon 4GuxiOAJGR73uZ/TKZzEqcQ4sDgHor4hk9qEsZPFqKtlcnRyiXop9ZFirkab4+WRTryp MUOSrg58UgGupzoKzq7YgSV9NMsHOx+PrDnDSClF4FXPhoqazAUFBwTUGy8CSdpLnKeH z0vnSWQksdmdbrNzULNYNdCLGwLyZ1ahsxm+nnkWobmVWpz77sLKOojThIwo1NeivLXW oJ37f/iBcOUaqBP3uNxV9Qlk1WHENRvKiEU8w9LRaD2wvNyH+D9gwngNVP6OxzfPU86z mmnQ== X-Gm-Message-State: AOJu0YyJ8Wez5stMtQqAezkR+VA1tEUQ11IAXhKZj9dU6EVYlalozZp/ 7UoJx/mARBRnHCys7a8c7xUkjqRhOsQshlyrQkx1tX2FGZkgMcwrklN1sn5TkQL5T9q5IvXvTsd C X-Received: by 2002:a2e:9acd:0:b0:2ec:4aac:8fd8 with SMTP id 38308e7fff4ca-2ec4aac9280mr16514161fa.1.1718957229703; Fri, 21 Jun 2024 01:07:09 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c8e51sm961432f8f.93.2024.06.21.01.07.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 12/23] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Fri, 21 Jun 2024 10:05:43 +0200 Message-ID: <20240621080554.18986-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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, 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 Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2586d15cbd..c6cc1bab11 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1868,7 +1868,7 @@ void sd_write_byte(SDState *sd, uint8_t value) trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -2024,7 +2024,7 @@ uint8_t sd_read_byte(SDState *sd) trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret = sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c