Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp139914lqn; Thu, 11 Apr 2024 17:18:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXP/JEy1Gp5s39H2Tm4RS28OEjcD9JetLdYFDmYSyJiRhVG1fmr7OLQF6Ri2pUfveUD0PvaNffwDwwv93QCVzNm+3jmpdteflzdBJUerg== X-Google-Smtp-Source: AGHT+IGXresCVYoQMVeFJC/1rKVD3aK8uc2Pmj1O+12/EECZTMhQPcg/IU++RFZaPpUPmZ6Khm2S X-Received: by 2002:ac2:5209:0:b0:516:d729:5c3a with SMTP id a9-20020ac25209000000b00516d7295c3amr702849lfl.50.1712881090902; Thu, 11 Apr 2024 17:18:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712881090; cv=pass; d=google.com; s=arc-20160816; b=zuCQBXX8cUEll6PDHl6hPU/UR5wDIoi0qgsZZV6DIahiPzva7GSV63VzcYmrvV0qt+ RB4c9YNruEwMzmTvd5TNL5qThfTOIPK8+sTA7Pr/3uAV4ntwtCeCnpaDW3Rr0BqCgeEN iCV3+M/U+deQ4yXTTSGq338xuFaBm312Q9c3FaVAerVJZEXmDgsJpk8UD+K58HTYw4EN CG652KEJ/bjRTEtV6vQZF/oWJhUSwRlHasKnhNABSBdnyIm1ZcNmfmV/wgR/dxQisqdV Btvwebrnrx415EqrD9XwjBjZwoEG3jTW2t/+GF4cQjmfLveLRXKgSqCmTAaLs29ETO99 wXDA== ARC-Message-Signature: i=2; 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:dkim-filter; bh=SwITDiVDGjFy3sgpbd7fUst/YZztJdWrz5P1Xp8PliE=; fh=OUw7AodoZ7bocVJt0cINE2rNtImLIOjLZSJIP5rxm48=; b=XNg+UDrIYLH+RHuklptcOnvJqTMyHvyn842deitVlck+IMDeFTz5BwlMHWmIfbZwgV zt8wJ1c2hsVq2lhZGT5f8ekODvdGcGF00VQhKjijzrnR7La86h7Dm0tgdI8mrrOGQbJ5 9xj8dPk6xzyO9izjdp0CrTX6LtotSoeOrudEnw4eBMRlRVwltCCMSVnB0eROTbpAscar nvmvhZYd5emGBdQWvoP3DkDz6Bawsw02GMNm95WseRDDvlV8TPtKe0AV/MP5CpDmte9f rX/jN3K+z/mNn8Eyl3PqzM4GIwoW3sbn5KM7eugRRafr5eQHhx2V9Rw2o/WmJYheBDW2 bQdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=J1y1zYHa; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-141747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y23-20020a170906471700b00a51bc6984f8si1142081ejq.733.2024.04.11.17.18.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 17:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=J1y1zYHa; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-141747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 987981F2328E for ; Fri, 12 Apr 2024 00:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2337F4A21; Fri, 12 Apr 2024 00:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="J1y1zYHa" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CB0C635; Fri, 12 Apr 2024 00:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712881072; cv=none; b=TeymST36GxKPudpYV1b5dG6ItMPIf18jJl9eRkgjEKD3dbpMGKyoMVKjAeE8upFxCdFtpDSR05ka9OdMeO/0VbhesWWirJg/FiZ1yL36dVY+4mut3TuDvxYEWR6cKfKgWzOUj/EJsARklWXqm4+aa/NzxWz3FxW/lViyYbJbdo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712881072; c=relaxed/simple; bh=fv6XGHb6Pnhi1qBITnZVPVYufjPcayV7v5fU19yiQ/U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KmPAScDn7ED4/ZioRW8Lm6ZkEQjivLAACHmlR7QYHbLExBh+Pd41BQyUIhR5qpvr6Cw/qu9snaNUnl6GsEw58cDFrStgB0nkxGzrPNk8i4hKph55MIYuoFinckcvqPbhf3SqFEOf6OhmcAFJkzJsTEyW/uEtcQM8FgJUDhu7PK0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=J1y1zYHa; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from localhost.localdomain (unknown [4.155.48.125]) by linux.microsoft.com (Postfix) with ESMTPSA id AB65920EC32E; Thu, 11 Apr 2024 17:17:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AB65920EC32E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712881070; bh=SwITDiVDGjFy3sgpbd7fUst/YZztJdWrz5P1Xp8PliE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1y1zYHalt+p0FSBl1FqKBKyTGUXK3M4VFLVLO5wheOrmxQftG+6sWc8eK42fLyIU F0r7lfL56lv1+qeqYtdfsaVTJTGWEmgYeyurv1SNzJ7qcsopEMeuAKpzjQ1LbVIZOX 5DKZ96qyI8RJTj8sXl/LfQfDR8TZo6UOBZ+qbD6g= From: Beau Belgrave To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, primiano@google.com, aahringo@redhat.com, dcook@linux.microsoft.com Subject: [RFC PATCH 4/4] perf/x86/core: Add tls dump support Date: Fri, 12 Apr 2024 00:17:32 +0000 Message-Id: <20240412001732.475-5-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412001732.475-1-beaub@linux.microsoft.com> References: <20240412001732.475-1-beaub@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that perf supports TLS dumps, x86-64 can provide the details for how to get TLS data for user threads. Enable HAVE_PERF_USER_TLS_DUMP Kconfig only for x86-64. I do not have access to x86 to validate 32-bit. Utilize mmap_is_ia32() to determine 32/64 bit threads. Use fsbase for 64-bit and gsbase for 32-bit with appropriate size. Signed-off-by: Beau Belgrave --- arch/x86/Kconfig | 1 + arch/x86/events/core.c | 14 ++++++++++++++ arch/x86/include/asm/perf_event.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4fff6ed46e90..8d46ec8ded0c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -263,6 +263,7 @@ config X86 select HAVE_PCI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_PERF_USER_TLS_DUMP if X86_64 select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT select MMU_GATHER_MERGE_VMAS select HAVE_POSIX_CPU_TIMERS_TASK_WORK diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 09050641ce5d..3f851db4c591 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "perf_event.h" @@ -3002,3 +3003,16 @@ u64 perf_get_hw_event_config(int hw_event) return 0; } EXPORT_SYMBOL_GPL(perf_get_hw_event_config); + +#ifdef CONFIG_X86_64 +void arch_perf_user_tls_pointer(struct perf_tls *tls) +{ + if (!mmap_is_ia32()) { + tls->base = current->thread.fsbase; + tls->size = sizeof(u64); + } else { + tls->base = current->thread.gsbase; + tls->size = sizeof(u32); + } +} +#endif diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index 3736b8a46c04..d0f65e572c20 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -628,4 +628,9 @@ static __always_inline void perf_lopwr_cb(bool lopwr_in) #define arch_perf_out_copy_user copy_from_user_nmi +#ifdef CONFIG_HAVE_PERF_USER_TLS_DUMP +struct perf_tls; +extern void arch_perf_user_tls_pointer(struct perf_tls *tls); +#endif + #endif /* _ASM_X86_PERF_EVENT_H */ -- 2.34.1