From nobody Fri Jun 17 19:40:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0B2A185CE4F; Fri, 17 Jun 2022 19:40:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPqBs6Wz7z3hVf; Fri, 17 Jun 2022 19:40:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+tkd7v72SztwfMb1/V0jgONFSJhTULx0KIL8yrl/+78=; b=TRzeFJHBbjjQvmuKRiXEwrHNw6cUoNnAtEk/J/nWWD2H/qb+RYC+mE7nKjqLPeRBbPvOx+ g7rc3nem73z1hxGtBwnKMZclSK/P+g0sh7puvp4WPBOMRjEYxiL6oN4bZuUEo5wMj2crWX kR59W5VLoOkM2tOI/5bMFflCf5/Uj3pt8q0qQ5PqdJ+Dr01XYuyFIAbE6fHG43Hv1TWTb2 OiPYSpIWDFI341iqSuASnFrVqHFPqY2fvbZsZSxmIDmr+gOP00KGh3HBB5WZfR0FyX9o1a oKty/t/4Mb+FwaD+It4IcRIsSF3peVncfFi3KDdA2BIg/Ua879AVyxXR2p2R3A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3CE5725A51; Fri, 17 Jun 2022 19:40:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJeLFm025162; Fri, 17 Jun 2022 19:40:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJeLqG025159; Fri, 17 Jun 2022 19:40:21 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:40:21 GMT Message-Id: <202206171940.25HJeLqG025159@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 6e2a3ed6a765 - stable/13 - kdump: Decode cpuset_t. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6e2a3ed6a76501452184098d6f29194972dec66f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+tkd7v72SztwfMb1/V0jgONFSJhTULx0KIL8yrl/+78=; b=yCS+drFcmG7fiGXpq4+VbdN4G/slPswBb5ZsmRsKrbbdxemp4duOsaD71KZ5gfH6I5yGO2 TEn1TsTp9DDglW+ikloSW+3guzP/sRjJZTUoL7udJKlYFAONQTYFPG8DCPX1DrcKnxeURA JaQ+i4wAt7cDtkkYdcF4gtHKlxGLGdBEx1LO4lLc+3Q72915+/p718XVcoCLtFdspKlQU5 MunEAxKf/SQTFeTvbyj1fl0cN2jb/u48PrRVpYb8t2QiV3qn8N7AVHG8akN0pxleVhtkV7 oHI27CKFChNlJ9i2duopArTwwhCZnLud4Wb8m56XoQo5Nlba8/eytiz1WOc99g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494822; a=rsa-sha256; cv=none; b=wbQCSm+RNc1DrIuvu4O14N7my6E5WqisN91/FmTCyqOBaJVE2X6iKyHJCXfRgxA4HuN9Ir 9aRoJcYaLYRkWmVj7k0wB2gnYie4UaGItEakrK1zqlWcC1g7qdRsE/Q2xjDTPFJBcbf5DL QCCpwcRQrfziqJ9Hsugx/HPlix21Y9BqBgDAtYKrlD0dbvKlf+CcPO5HppszryS8fVGhZm bAmc/H1syELAH1ti3cO+DrCStd0CXN1sFiVn7QbcRFzg8zFE+MUlygRNZ369pA2L1XJh09 tHBtYoPBKH09zhV0eZlpZ8Ft4w6x0OEDq0pvGlpUrKwKY1rVuUdQau/KnAkIzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6e2a3ed6a76501452184098d6f29194972dec66f commit 6e2a3ed6a76501452184098d6f29194972dec66f Author: Dmitry Chagin AuthorDate: 2022-05-11 07:40:39 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:15 +0000 kdump: Decode cpuset_t. Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D34982 MFC after: 2 weeks (cherry picked from commit 586ed321068b883e33df0e41ca913c074e6ea53d) --- sys/kern/kern_cpuset.c | 10 ++++++++++ sys/sys/ktrace.h | 2 ++ usr.bin/kdump/kdump.c | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 6cfc56294ab8..a5c644687241 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" +#include "opt_ktrace.h" #include #include @@ -62,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2001,6 +2003,10 @@ kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, cp++; } } +#ifdef KTRACE + if ( KTRPOINT(td, KTR_STRUCT)) + ktrcpuset(mask, size); +#endif } out: free(mask, M_TEMP); @@ -2034,6 +2040,10 @@ kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, struct proc *p; int error; +#ifdef KTRACE + if (KTRPOINT(td, KTR_STRUCT)) + ktrcpuset(mask, sizeof(cpuset_t)); +#endif error = cpuset_check_capabilities(td, level, which, id); if (error != 0) return (error); diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 739f5a5d7ea0..b9d80f7f94d0 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -307,6 +307,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *, ktrstruct("stat", (s), sizeof(struct stat)) #define ktrstat_error(s, error) \ ktrstruct_error("stat", (s), sizeof(struct stat), error) +#define ktrcpuset(s, l) \ + ktrstruct("cpuset_t", (s), l) extern u_int ktr_geniosize; #ifdef KTRACE extern int ktr_filesize_limit_signal; diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 19616338fc1f..c9344d001f32 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -48,8 +48,11 @@ __FBSDID("$FreeBSD$"); #define _WANT_KEVENT32 #endif #define _WANT_FREEBSD11_KEVENT +#define _WANT_FREEBSD_BITSET #include #include +#include +#include #include #include #include @@ -119,6 +122,7 @@ void ktrfault(struct ktr_fault *); void ktrfaultend(struct ktr_faultend *); void ktrkevent(struct kevent *); void ktrstructarray(struct ktr_struct_array *, size_t); +void ktrbitset(char *, struct bitset *, size_t); void usage(void); #define TIMESTAMP_NONE 0x0 @@ -1972,6 +1976,30 @@ ktrstat(struct stat *statp) printf(" }\n"); } +void +ktrbitset(char *name, struct bitset *set, size_t setlen) +{ + int i, maxi, c = 0; + + if (setlen > INT32_MAX) + setlen = INT32_MAX; + maxi = setlen * CHAR_BIT; + printf("%s [ ", name); + for (i = 0; i < maxi; i++) { + if (!BIT_ISSET(setlen, i, set)) + continue; + if (c == 0) + printf("%d", i); + else + printf(", %d", i); + c++; + } + if (c == 0) + printf(" empty ]\n"); + else + printf(" ]\n"); +} + void ktrstruct(char *buf, size_t buflen) { @@ -1982,6 +2010,7 @@ ktrstruct(char *buf, size_t buflen) struct itimerval it; struct stat sb; struct sockaddr_storage ss; + struct bitset *set; for (name = buf, namelen = 0; namelen < buflen && name[namelen] != '\0'; @@ -1997,7 +2026,7 @@ ktrstruct(char *buf, size_t buflen) goto invalid; /* sanity check */ for (i = 0; i < (int)namelen; ++i) - if (!isalpha(name[i])) + if (!isalpha(name[i]) && name[i] != '_') goto invalid; if (strcmp(name, "caprights") == 0) { if (datalen != sizeof(cap_rights_t)) @@ -2021,6 +2050,15 @@ ktrstruct(char *buf, size_t buflen) if (datalen != ss.ss_len) goto invalid; ktrsockaddr((struct sockaddr *)&ss); + } else if (strcmp(name, "cpuset_t") == 0) { + if (datalen < 1) + goto invalid; + set = malloc(datalen); + if (set == NULL) + errx(1, "%s", strerror(ENOMEM)); + memcpy(set, data, datalen); + ktrbitset(name, set, datalen); + free(set); } else { printf("unknown structure\n"); }