From patchwork Tue Jun 25 05:53:45 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: 807247 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195794wrt; Mon, 24 Jun 2024 22:56:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoljDvEZn8kvTT59nMrVtqKUDxE8/MxmFyLbC6PeLRWYvJdhyvU0hUa907gMv9WG809gYfiqYAgKztIrExL7ms X-Google-Smtp-Source: AGHT+IGaRcqd7MVhVW0SVTu7UJ3bqq7ZsRjJpERnfJa7d3A6pm0jyU5EowJlGBt9m7+UD39IjHGI X-Received: by 2002:a05:622a:1b8c:b0:444:f42a:eb8 with SMTP id d75a77b69052e-444f42a18f9mr8811811cf.27.1719294963347; Mon, 24 Jun 2024 22:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294963; cv=none; d=google.com; s=arc-20160816; b=mtniPRQD7dV96xrARwNr+1RsPJ8c73YDayVzBLfmBvsHHlSa9WWyKMZxfVKzBZ8ZTq HjKJK5P7QcRiisAl07jHuQaHkzGy3Pbsx5yOqXpx3pPZF9Eg7VJ61Y45jcUtDz7A6CIh FnooBysnSV9DSl9+oSyAcAfvxi9+g4aIPOLjtx150KMXcftSaX65dPjrq+vDusWlqkNs 5UaaVqnUj5hdHyVKEA6M+UZqCh836jjN+n63ZBsxk733yTgXxrkm5K7o0R3MdRjs93d6 qrYGhLqUWJHu54WIrzgS/za9JUkQUvQsVUzs5xloPMIASZon/EnBWC0L2BDsv/GLBjZH wjBA== 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=znja8UZGBmg4PCwdYFD8j0oRgnDm2t8mAzvvqcGIi9D2Ea3fJ69Vi+rgyoFfVVi0sz SPZaKlpmqZ+/XZIzAeWo/0k1nN0NrTR6vyx+YELGyzmZkf0L/RZ1JGBLYGT0P511//38 ADCVOwk6dAhvUb63dV8vT3klks3xXSlqLmk7PFh1cLNILf4t2DsepRpvzEChsmdpR6Vz EJAoitlLefPqm8X63AgW0gdVAz3nx20X+YV5rKjq/oLE9tZhEj3Jm68b63hAq40jtYBF zkk4TGd3nawgPDBp/BkLm2Ar5ryDwNoKbwALKr+5aUoFiTWTZ0z72M/gXYiXacvOjhNw Gtow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+fGnjib; 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-444c2c64cd5si97008021cf.552.2024.06.24.22.56.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:56:03 -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=B+fGnjib; 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 1sLz8K-0001ek-C5; Tue, 25 Jun 2024 01:54:24 -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 1sLz8I-0001dx-UU for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:22 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8H-0001am-FD for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42172ed3597so29971895e9.0 for ; Mon, 24 Jun 2024 22:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294859; x=1719899659; 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; b=B+fGnjib6o/XAH2VhPr4Lw38NqLOqdkWhpfNVqwvZLcyI/5jxfvmOyQ7mWxen7la36 S2B/Qr09hyXOgXH5/JFY/omSaEjJNfxeju3DquYWqBwBLCHHJREtfCuW/Rkh5NQR75mK X4XkYA71u8PgKHg29r0f6NmFqg0W8r7iVjTUbB3ETpEFP1C0q/gHr/3IT8n5Xsyqqfa1 iTtHHNFkX3UfNXblN7DrNRnb8BPGKDwYdOx+isiVz3k9tV18dcvyra1mgcye/oSMVxGF yUb52XPWwoyOx447vvcOwXjAp51TwEDRXeMgemUh3WAk0ulMYzcllnT/imJIeFoOQp16 8TaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294859; x=1719899659; 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; b=kna4C42r0RP1634s+pXovDzzRFZ0IiO2fUz6PmJItegpYppkKMsL6MluhrXYmxUOEG rIJh48PMDv2Y6yp6JyLUFmwZ4F2HAkUwSRdAgPUjyX2kbv8Sia0nKkz1b1PBCqRA+y4L 0n4Lb81SqfS+B5qxASfGgArPuycfkHcwOM3kmsaqM/Njez/u5202sCWsrl/gUvxaowL2 EEYkiA7oij2MI/b+PaaUVrt3TzdKfVlUKqvgJEb/NEf2qjPY+QlxbryW40vgBrnLVR54 PN6lER7Qv1UZbUojKBAk2HXp8w2CGr2Q3gPNVCkr5BAGrWz0rUXNSXUlru14/6yg19A/ G/oA== X-Gm-Message-State: AOJu0Ywc9T2j2Rx9kb10lqn3YysaeDbSgvqgZKdXwPxg0o3YuGG9wvw9 Kpyb3b3MNRoSybHKxPd7T1yOQtfJAiQk/pWqTgYE4VcZOI9V2gkjTyAUxLTiwKwozlEKHf5ddAg q X-Received: by 2002:a05:600c:2e04:b0:424:86fe:ac99 with SMTP id 5b1f17b1804b1-424895eaf2dmr72866125e9.14.1719294859638; Mon, 24 Jun 2024 22:54:19 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0c54c9sm199933385e9.27.2024.06.24.22.54.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 04/12] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Tue, 25 Jun 2024 07:53:45 +0200 Message-ID: <20240625055354.23273-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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=unavailable 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é Tested-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 14bfcc5d6b..e4587a0a37 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1913,7 +1913,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; @@ -2069,7 +2069,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