From patchwork Tue Jun 4 09:55: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: 801388 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp2312672wrw; Tue, 4 Jun 2024 02:58:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXvkpaGZphDGFC6su3yOqhkF5BeN1OeQ+GJnQKvNoYIJW/Z2hFVHOvZXR3zj91Uqi48nVs2tO3JPgBjYKjmw1Dg X-Google-Smtp-Source: AGHT+IE2a5LbOgAjHoM8Ka8O+FSBe5bLW8/6VNkjTNVWonnPMh0f6q7AV4ALNoRiC/nTE4xmIKB7 X-Received: by 2002:a05:6214:5b11:b0:6af:c82a:310e with SMTP id 6a1803df08f44-6aff726a04amr34412086d6.12.1717495095901; Tue, 04 Jun 2024 02:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717495095; cv=none; d=google.com; s=arc-20160816; b=OXPm6bntqFSMhL2rcP0GTYuYJE6bhY5wNIf+n7r7Le3r77hcZ0rJ08xGZOody8k5J6 18mGEH4EaH348ht/GmrdviDbvVuvgVY8TOqle+jm7r+lw/dYlnIYZbW4ba3Ji3km4mNY j8I+Dzqs7O0TTF/SIMzSlERterMsNn0LeHnhwYbL7fsSt5WRq0voQRoQTinGbMaPAjW9 wp81yk0GHvP4K+f+KL/67dX7cjDUnKEnSGnA5mDMvVvad0ccbT5x9mnL1E/kcMthiGwt LBLNEfW4X7eGXzW1fWnKy9EcKWUHQLaeB7J/vKzdwNfh0mIbBSIfEMcbJ9V5ic9g3RtF sxEA== 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=HhkkGO7UM5NempyNbZSpgeksE20VfiEa/+ho7bDGL5s=; fh=ZXDWg7hKG7Hj19AbRuutTLw+Zvn/B9RsGUUw/YagpFI=; b=VeiEgPxrqZ9e6+IxdKc7m62l565bUl8p4gqNW5w0xPR3HQr1i2MESbq7xZWwMLiMj8 F6iGO7Ky+z6UsJetbHsZ1EhHD2sM0nzIG60JwYoNyRNx7DSEBlgeFbJ7X0NidM1GZy+X 2quwEuQ4SsllhdGuG7EG+3BseJSOaBd8vKqR1dL7i5B5gNgOhMD3vqNstKxYIBdfj85e VCoYJptyxo2r1h6jy4WEcdoq+Mfc1mPKUTKRG7phB2HVqcoZimDzWeTEyeOXXYxcb208 DqU3jkYO1SGgHks5imKHtkli/MtJQlZiGqVZd9+/5NykXf4MmGfI2j/Y9ktPWz7l9+tk EksA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x2FybTSz; 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-6ae4a732a07si13605786d6.12.2024.06.04.02.58.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2024 02:58:15 -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=x2FybTSz; 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 1sEQug-0005bg-Iy; Tue, 04 Jun 2024 05:57:06 -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 1sEQue-0005aK-GO for qemu-devel@nongnu.org; Tue, 04 Jun 2024 05:57:04 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEQuc-00026T-Iv for qemu-devel@nongnu.org; Tue, 04 Jun 2024 05:57:04 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42147970772so5079005e9.0 for ; Tue, 04 Jun 2024 02:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717495020; x=1718099820; 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=HhkkGO7UM5NempyNbZSpgeksE20VfiEa/+ho7bDGL5s=; b=x2FybTSz7/tPL2v1URKH5MUvy983gyExCh1IZcY6EQV2l2ldcvR762jzOnhEFcov+a z/yjS1D8yF9off+Q3gtf7wwl4fEW0S0Lr9AISMzC3KldscJDAf45pay9+32CDImWlKeH g1XDZrP+i/kDmNWFNfDiW55MoF2IxITsy9EkOH1NDnn+wBiiwjpgIbFvjIHHyn3g2qhO X+j8rrqptCR2LBWpHPYztrEXWwiV1Efp57RUTLzrpuqz0zkzQTzJcwvn9k8ggAntxmVj x9zM1PTYFt9KmO2gn2dLKXeSSJA+l4fCzA9sQz+72eq+xMndc53l/nYEUyZbxIE4qtB1 FnSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717495020; x=1718099820; 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=HhkkGO7UM5NempyNbZSpgeksE20VfiEa/+ho7bDGL5s=; b=OPLELOgugaRifvThC2QgC/t7z9XZcJE5+NoUO35we3yoASBgvhv9HfrwyfAFmXm6tL bKxNy1nALl4c3N0219oSC35IQLtEE2Z6o/2edOgGGqhLQkzOm2nJCLURFFPMGpU7RK08 ImkQcgGGAGXP53y4Se+8J3aZQNr+Qjn2+mDE/ZKOjE8Uym4uBnAmdU2MDDvudN94wLQx v7RimYG4nQZb/ksecDkgTRSuaeCu1Fb0bCpD9USo0kuETgz7KJsZFGMUojyOIFsDge4X DW7nD7qT2r/4TjWBADPEO6qefoGVnvPf3kmH7I7007vLEnc63LfmJg0sKmhUvM0JHqB3 nMgw== X-Gm-Message-State: AOJu0YzRObZo0bwX2bxaMcGuZ0nKy12AI1ADVbQCnTEYCW8x6sZw5LHf swosGQU3GLtniWvcJI4wmlvYHBK+66H9QMYN525ultlXbwRbA4ASAbU321RuWuI0adY3bQ5x91v H X-Received: by 2002:a05:600c:4705:b0:421:2918:3d97 with SMTP id 5b1f17b1804b1-4212e0add57mr103467795e9.30.1717495020665; Tue, 04 Jun 2024 02:57:00 -0700 (PDT) Received: from m1x-phil.lan ([176.176.159.34]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212705692csm178091885e9.10.2024.06.04.02.56.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 04 Jun 2024 02:57:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 09/32] util/hexdump: Remove b parameter from qemu_hexdump_line Date: Tue, 4 Jun 2024 11:55:45 +0200 Message-ID: <20240604095609.12285-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240604095609.12285-1-philmd@linaro.org> References: <20240604095609.12285-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 From: Richard Henderson Require that the caller output the offset and increment bufptr. Use QEMU_HEXDUMP_LINE_BYTES in vhost_vdpa_dump_config instead of raw integer. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240412073346.458116-2-richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 2 +- hw/virtio/vhost-vdpa.c | 4 ++-- util/hexdump.c | 13 ++++++------- hw/virtio/trace-events | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 741dade7cf..d7715f7a33 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -287,7 +287,7 @@ int parse_debug_env(const char *name, int max, int initial); */ #define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */ #define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */ -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned int len, bool ascii); /* diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index ed99ab8745..f3a86c1a8c 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -949,8 +949,8 @@ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, for (b = 0; b < config_len; b += 16) { len = config_len - b; - qemu_hexdump_line(line, b, config, len, false); - trace_vhost_vdpa_dump_config(dev, line); + qemu_hexdump_line(line, config + b, len, false); + trace_vhost_vdpa_dump_config(dev, b, line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 9921114b3c..7324e7b126 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,7 +16,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned int len, bool ascii) { const char *buf = bufptr; @@ -26,13 +26,12 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, len = QEMU_HEXDUMP_LINE_BYTES; } - line += snprintf(line, 6, "%04x:", b); for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { - if ((i % 4) == 0) { + if (i != 0 && (i % 4) == 0) { *line++ = ' '; } if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[b + i]); + line += sprintf(line, " %02x", (unsigned char)buf[i]); } else { line += sprintf(line, " "); } @@ -40,7 +39,7 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, if (ascii) { *line++ = ' '; for (i = 0; i < len; i++) { - c = buf[b + i]; + c = buf[i]; if (c < ' ' || c > '~') { c = '.'; } @@ -58,8 +57,8 @@ void qemu_hexdump(FILE *fp, const char *prefix, for (b = 0; b < size; b += QEMU_HEXDUMP_LINE_BYTES) { len = size - b; - qemu_hexdump_line(line, b, bufptr, len, true); - fprintf(fp, "%s: %s\n", prefix, line); + qemu_hexdump_line(line, bufptr + b, len, true); + fprintf(fp, "%s: %04x: %s\n", prefix, b, line); } } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 96632fd026..3cf84e04a7 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -50,7 +50,7 @@ vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id %"PRI vhost_vdpa_reset_device(void *dev) "dev: %p" vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d vq idx: %d" vhost_vdpa_set_vring_enable_one(void *dev, unsigned i, int enable, int r) "dev: %p, idx: %u, enable: %u, r: %d" -vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" +vhost_vdpa_dump_config(void *dev, unsigned ofs, const char *line) "dev: %p 0x%04x: %s" vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: %p config: %p config_len: %"PRIu32 vhost_vdpa_suspend(void *dev) "dev: %p"