Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp467713rdf; Fri, 3 Nov 2023 06:12:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFni09zXHhbHS0ZTIvw+Vo+5ZQpDSsPgT49mSPR9VnqwpiUjcUz7Goy+T8e+5sZ6afw75s1 X-Received: by 2002:a17:90a:5381:b0:27f:fe79:eb6c with SMTP id y1-20020a17090a538100b0027ffe79eb6cmr17469661pjh.29.1699017161461; Fri, 03 Nov 2023 06:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699017161; cv=none; d=google.com; s=arc-20160816; b=RJxSRoofow9JCOyJL1MMVFuREuG+j7FvEsGtXW76UrgvuY81tSesKXXycSqZLT0N3e /tDBOjKu56SbyhlnajnlOQ0j26NXfXJGHjpoZJxpRnkZSe7WqddB6aYTDB0sXrKgiU/G aSVkXRBh4y1xXNKPknZXmDNxfkWqDzY1anb9BS1/IEW0kxxodx6736GdbOhMCFSD9TtY Zqr6O50QE84bXh6AHIEHE3L3mKiYEN0evrw9X1YjDAgs4xzIuvjXbP3QaUngyI6mjrI2 oy9nTNTWuqkd3myfVOL7Pspzi4qg+7mK8I8kHw73X5OCLV9gk9Ss4GtvNjDlhCLdPaqC TKew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sZSPUorn4pTdADZrPzHb8i7AO+zsH0qYfe7SAa+uJVc=; fh=Xr9EZaLbYspLudo3lCz3I6iQD6BKril0MIzT5DobTXc=; b=AMn3iw2bzEicjlDdx6hNjlHDrq2cTVN540oSk/jWlFCtiQjiEBP+iURHoK5hIqfW0y nzzGYGA1M0YpHOj9zpG8gwwmO/PrL5rz7zMxFrCWsx9B9do7JX172zFe2TYztzx8XgC9 Df0Yb4mjA1L6PrV7LEqCcdX8hS+RTFPtox+imQHV4eiYzwvjJdPksIOKeF8AqRtwQbdA ZCH8EypXmjTdSiMZgCiDXi7xjnc/+9kD6gwa4VJA2hy5HH5dTOJ9KAYwylDXwji4B+4C X/3VAjAwXSSczEQb7MvLFCRQhQJ5WAGoEYdoa9X+uhmEAPuvzouZvwpO0XpnJTYmAI3f YO/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b="OVwj/ta4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id nh16-20020a17090b365000b002683f507990si1650518pjb.109.2023.11.03.06.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b="OVwj/ta4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 823B5805F0BB; Fri, 3 Nov 2023 06:11:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377687AbjKCNLF (ORCPT + 99 others); Fri, 3 Nov 2023 09:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377612AbjKCNKh (ORCPT ); Fri, 3 Nov 2023 09:10:37 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C18FD51 for ; Fri, 3 Nov 2023 06:10:29 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50930f126b1so2496006e87.3 for ; Fri, 03 Nov 2023 06:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1699017027; x=1699621827; 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=sZSPUorn4pTdADZrPzHb8i7AO+zsH0qYfe7SAa+uJVc=; b=OVwj/ta4ja6sMcG5kOo50EXcyYnI1coX0VATo8UALsqhvhWOyDaPC2GRDGWxwQ3zX1 viFZIJZubLGF5M/thHIvE0Gi6jggVkpnWlTQ6LpZZXgTPjTCjcqP9QF3s8KBpyMEHaN+ C59/1J5ZXnTbNRvKZYb4JRCnJXqMIZLweiDA47q5P+ASj2jCPq4ARO2vXikMprIomIsj w8FGiWa31DJLP4B/TY5s2RwMegqz++F76Kwczohjc9Hikm4cnQp/Lt6Fd2G2exVrFPu3 /H9P8UWpa1Ar7mLpJlbdGiTuByPQGkX7dZWxR5vCzvxVpKtSVIRqt1De/FNOrqpKm6bU H7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699017027; x=1699621827; 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=sZSPUorn4pTdADZrPzHb8i7AO+zsH0qYfe7SAa+uJVc=; b=udM8Q9WwU0WTMO1U/lPDulfovUslncL2v12EwWlWWfV67DH+ORPeC+O5RFvCWb4F1a 9rMxGc4AZBHaLXHz6zFBon3VjNLVf0TuVnMeG9VOqxKgHlztOT2Arlz1EeVdyxd0WYKc 9R5k6R64MDYAb3Ym3YNiYB4RfHwCEC0Y6AdSxMn/SHkBWYDZzxmhB9TngnW3uXtOOEjt C5CzttXZxrpKWgxcgdEpGacBdC/d67VdNRlYxYvRtcUHzMgDpEkRy9CoCirE5C7zUTnm JhrO9GTHYQGiNooBQVh/BB+1Vz3/hTlA29B/BSh3l6tlV9hjAoL3lBRp0VYtGNzXwdcg p/7Q== X-Gm-Message-State: AOJu0Yx0WMCFgMTOTlC5AN3lTe3qJ3fCDIkqYA2i99nkveuGpqfLFTz8 QvOCoZZ4MVy4plGcfn8T0lox X-Received: by 2002:a19:6d03:0:b0:507:c763:27a5 with SMTP id i3-20020a196d03000000b00507c76327a5mr14710758lfc.62.1699017027390; Fri, 03 Nov 2023 06:10:27 -0700 (PDT) Received: from ukaszb-l.wifi.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id f21-20020ac25335000000b00507a69a4799sm216336lfh.270.2023.11.03.06.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:10:27 -0700 (PDT) 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 , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v1 12/12] dyndbg: add trace support for hexdump Date: Fri, 3 Nov 2023 14:10:11 +0100 Message-Id: <20231103131011.1316396-13-lb@semihalf.com> X-Mailer: git-send-email 2.38.3 In-Reply-To: <20231103131011.1316396-1-lb@semihalf.com> References: <20231103131011.1316396-1-lb@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 06:11:20 -0700 (PDT) Add support for writing hexdump debug logs to trace. Signed-off-by: Ɓukasz Bartosik --- include/linux/dynamic_debug.h | 16 ++++++++++------ lib/dynamic_debug.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 3084302876b4..e01b529dcd09 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 541d9d522b3b..fb2c6e2909bb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1128,6 +1128,41 @@ 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, "%s%s%p: %s\n", + level, prefix_str, ptr + i, linebuf); + break; + case DUMP_PREFIX_OFFSET: + ddebug_printk(descriptor, "%s%s%.8x: %s\n", + level, prefix_str, i, linebuf); + break; + default: + ddebug_printk(descriptor, "%s%s%s\n", + level, prefix_str, linebuf); + break; + } + } +} + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; -- 2.42.0.869.gea05f2083d-goog