Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1162721rdb; Fri, 22 Dec 2023 17:55:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGroEibizE5IaqjGtRNKJ2swjyjiKQ3W6cfArOW9vQamZi1JDU88WMYYJ3udxYTuiMgZWVl X-Received: by 2002:ad4:4eed:0:b0:67f:3c4b:a9c9 with SMTP id dv13-20020ad44eed000000b0067f3c4ba9c9mr3360412qvb.22.1703296554623; Fri, 22 Dec 2023 17:55:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703296554; cv=none; d=google.com; s=arc-20160816; b=YjuDR/VMtjWaXYB+7dxioXBj69uqzL3I2vPl+PforblffvqSE2PBc/EY+OKHWcu06k 6zqQgY0seMj+nKz0Bmbxto+KYKSB/Uy1jXPQohrlXeDvJI4Pd4EqhZbW5DGAqosu8rc3 VUNHr/WOYhIvVwx+QkNMwnw1oknCe8iZBsiqE5U3Mz77iHT1abrqb810QaDk+lvWryXD CKMxaIGxx2HNhGexWuv+ms/RWDBcvNMEkJN7F/cFiGw7n4ZTQpnL15bLBGbX4+K1ybo6 WRBOMexpMvsC/YBy8L8o1f9oUo71SclQ6ApKTsbf5HcpT+xmpwz3HIQZNah6zEC8cM9l QReg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GCgim+Lzybt1bsnBJ1bdt7sK2jYxpNtF/tNI/IwIPIs=; fh=pC62+Xzu9rWxP3EwkFQHy3M37dHcdVo9RRC56IjE3s4=; b=OuPbdxNdvpqjXG3pQrcMPOoo2pWuN/aodtOXN8Jj8sW7J19DTkfTbfMGsArnw/sUo3 +KSnpOYOcDdEgL3/W69xesA60Fid2Vkg17aYNZQEkTRyOMx2/6YPZMqo25FFboIn02kf bgaqQPzrJHz3+hwCZUfqe5dKbMmoY1lz/Scox4stNjXskPH0DNnX8P+yePqmGWTNm7bN yZ2xeoSlF0XwvNU0DcSyS1VwMrqEE8BRbA4ieZywQqIiA/dGzO7UwiAQcjU4VLFH5124 OHz96zLsKdPuVTiqlA4S2F0SlCJaHgrXBvBumvbtoxZfdv3QMl0wp4wUOCDoNqL5/0fs nE0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=rYYvweEU; spf=pass (google.com: domain of linux-kernel+bounces-10175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u7-20020a0c8dc7000000b0067f9be29aeesi1875399qvb.448.2023.12.22.17.55.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:55:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=rYYvweEU; spf=pass (google.com: domain of linux-kernel+bounces-10175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 626761C21D8B for ; Sat, 23 Dec 2023 01:55:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91AE915EBE; Sat, 23 Dec 2023 01:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=semihalf.com header.i=@semihalf.com header.b="rYYvweEU" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36C1E12E5B for ; Sat, 23 Dec 2023 01:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=semihalf.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=semihalf.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-553ba2f0c8fso2609532a12.1 for ; Fri, 22 Dec 2023 17:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1703296335; x=1703901135; darn=vger.kernel.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=GCgim+Lzybt1bsnBJ1bdt7sK2jYxpNtF/tNI/IwIPIs=; b=rYYvweEUAIZAU52pyxYMt4MhDsQdjNZFak92AI8WOGhFJLFAZTsvAW4Jiq2ihG59Dg etPxLRCdotBRzYF3G7jFAwBa9iq7g/kmcWJf/v/yoTyfAzOrPAJ7ioCAkVIRQY1hyhAH bgcr7RefS29wydCRNjjwE/BnAFM0Qf0FOAfLQMMDDAO2cJjcOc87YQxO9iNmtnLqWq0U y33laAWOury1lFceMQaaa2XIGgon/reKBrYFb/Yw3E4FKVVdlAflfNB1NWPQo6+EsDug NPh2QRBDilykrzxeDAt9sWGwieItFuep7TiJ+iDMK9BSCDhdhjKj1CXJ+EFxAt9AQleC 3GWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703296335; x=1703901135; 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=GCgim+Lzybt1bsnBJ1bdt7sK2jYxpNtF/tNI/IwIPIs=; b=PKEtLM8lu/Y9yZKTQYi7dTL5AZ/HfmB6kCXv2wm+ozeWqPhfP/yxVFg8suum0iGSTM F+p7ngI336prnMAlqJYxgL2Ek3h53nWywXDesA4pDzoCwh8RXDjxJjLfHFSHoT/hVOL2 OIjKERcbQZQCdHnwZ5Oeyaiy40URaaQqgWi3oqNgkk7mz+yhOGAKOcGJJeYKCLIAunaR 9HQbPpVvWq4s3I45JDD/UkrACy9af4XJBUef8VYmHm3S2NJSY80xLTLwsYej/t5OhopC lfFmwSqpLODz4i0mjy2hm+DgB+KbnU/GuzTN2TcDItmN/yQGOGzsZ3wTT0Y1XmYULnsX GtKA== X-Gm-Message-State: AOJu0YzUv7WlatDfJqT1oSHQs8HbDUyJpIsTR9z8spqKL3dwDzklTNkj MfrSJj9saEGfD8/GSKt063Rwzr96fPPj X-Received: by 2002:aa7:c517:0:b0:553:9e98:5178 with SMTP id o23-20020aa7c517000000b005539e985178mr596272edq.132.1703296335604; Fri, 22 Dec 2023 17:52:15 -0800 (PST) Received: from ukaszb-l.semihalf.net (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id h2-20020a0564020e8200b005532a337d51sm3288494eda.44.2023.12.22.17.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:52:15 -0800 (PST) From: =?UTF-8?q?=C5=81ukasz=20Bartosik?= To: Jason Baron , Jim Cromie , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v3 15/22] dyndbg: add support for hex_dump output to trace Date: Sat, 23 Dec 2023 02:51:24 +0100 Message-ID: <20231223015131.2836090-16-lb@semihalf.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231223015131.2836090-1-lb@semihalf.com> References: <20231223015131.2836090-1-lb@semihalf.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for writing hex_dump debug logs to trace. Signed-off-by: Ɓukasz Bartosik Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 16 ++++++++++------ lib/dynamic_debug.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dc10c7535f13..76eec3f05be9 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -298,12 +298,16 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \ dev, fmt, ##__VA_ARGS__) -#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ - groupsize, buf, len, ascii) \ - _dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ - print_hex_dump, \ - KERN_DEBUG, prefix_str, prefix_type, \ - rowsize, groupsize, buf, len, ascii) +void _print_hex_dump(struct _ddebug *descriptor, const char *level, + const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii); + +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + _dynamic_func_call(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ + _print_hex_dump, \ + KERN_DEBUG, prefix_str, prefix_type, \ + rowsize, groupsize, buf, len, ascii) /* for test only, generally expect drm.debug style macro wrappers */ #define __pr_debug_cls(cls, fmt, ...) do { \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c382ea5dea19..65dafdec7b76 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1355,6 +1355,42 @@ static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, } } +void _print_hex_dump(struct _ddebug *descriptor, const char *level, + const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) +{ + const u8 *ptr = buf; + int i, linelen, remaining = len; + unsigned char linebuf[32 * 3 + 2 + 32 + 1]; + + if (rowsize != 16 && rowsize != 32) + rowsize = 16; + + for (i = 0; i < len; i += rowsize) { + linelen = min(remaining, rowsize); + remaining -= rowsize; + + hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize, + linebuf, sizeof(linebuf), ascii); + + switch (prefix_type) { + case DUMP_PREFIX_ADDRESS: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%p: %s\n", + level, prefix_str, ptr + i, linebuf); + break; + case DUMP_PREFIX_OFFSET: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%.8x: %s\n", + level, prefix_str, i, linebuf); + break; + default: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%s\n", + level, prefix_str, linebuf); + break; + } + } +} +EXPORT_SYMBOL(_print_hex_dump); + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; -- 2.43.0.472.g3155946c3a-goog