Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2395427pxk; Sat, 3 Oct 2020 20:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy99H1lfQNDrQlVXTvraYBMm6tpWUEantkZ2USgWRcTrjmrsI00r8fDlYwOkynf0doCecAV X-Received: by 2002:a05:6402:1219:: with SMTP id c25mr11053498edw.220.1601782031701; Sat, 03 Oct 2020 20:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601782031; cv=none; d=google.com; s=arc-20160816; b=nTXFLPlmMEyS5fwh5drymXWdmkaTr8ZXBMbBtQ++PUwsa3mrfKOocAmWmM20woJlg1 qlIoHa2eLoGrhvM7oa1awSuFA0j9J5yn8kFhuQopNxRzt/7dhGL3g4lf3hCmEo0kDRYi fa+DBfpbPdgtZiCLidqKImTBiwpQ7A9reL1v63Cff/h6yfBB5VYtVftl/Ie1NqrPIc/B 0nCEwYq+9J0mzEE/9ga8hIhLgSVyaRvS34wfnAHAtgzR3EoKFDumCqSd7NZ/v2gyJbHD tckWR0Yfh8AHC6fOiW3a0xTRQwu04xXyu2whsq0uj4JwaNz1+yhhh27fdc/iX4Zx4F5L +ERA== 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; bh=PsRRHgFvK4drpu3fNkX3KNY0kcy5ABTP4j1wIZVKWPk=; b=L5kwmP/heU3GWU5s6JegJhmacOryqBlSyW6zB1dYBygd/op4ZAEp7JSpsBOZ49Fql7 ++e2Sa9I0bL3HMZ1nYQ5IuhAs62dOgCDybT05/EXGboyZycPjvdMaWdVj+hrE3JyKSCF MTKe9AHRi122JvBMiJNgZMz6BNxpZqaLPzocC8mTAY/8X+sArD91GszuINb9bv7yCVxv mxq6SWZ4DTCzD1ESy1XqleaZdcZFsYzjr0VRkvdj8YiZoMCkQLM/s5jz27bjv79XBnbw Jv09uQFYP+1OLFDEzul8tHXKGGW7JN3VFYTI3QHEd91M2fKAlrX9+KIg1rNmBDMGY52D /uoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc4si4289636ejb.526.2020.10.03.20.26.49; Sat, 03 Oct 2020 20:27:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbgJDDZt (ORCPT + 99 others); Sat, 3 Oct 2020 23:25:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:35002 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgJDDZt (ORCPT ); Sat, 3 Oct 2020 23:25:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id B730C29A6AD From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: hch@lst.de, hpa@zytor.com, bp@alien8.de, rric@kernel.org, peterz@infradead.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, sean.j.christopherson@intel.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v3 01/10] x86: events: Avoid TIF_IA32 when checking 64bit mode Date: Sat, 3 Oct 2020 23:25:27 -0400 Message-Id: <20201004032536.1229030-2-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201004032536.1229030-1-krisman@collabora.com> References: <20201004032536.1229030-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to remove TIF_IA32, stop using it in perf events code. Tested by running perf on 32-bit, 64-bit and x32 applications. Suggested-by: Andy Lutomirski Signed-off-by: Gabriel Krisman Bertazi Acked-by: Peter Zijlstra (Intel) --- arch/x86/events/core.c | 2 +- arch/x86/events/intel/ds.c | 2 +- arch/x86/events/intel/lbr.c | 2 +- arch/x86/kernel/perf_regs.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 1cbf57dc2ac8..4fe82d9d959b 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2499,7 +2499,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent struct stack_frame_ia32 frame; const struct stack_frame_ia32 __user *fp; - if (!test_thread_flag(TIF_IA32)) + if (user_64bit_mode(regs)) return 0; cs_base = get_segment_base(regs->cs); diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 86848c57b55e..94bd0d3acd15 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1261,7 +1261,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) old_to = to; #ifdef CONFIG_X86_64 - is_64bit = kernel_ip(to) || !test_thread_flag(TIF_IA32); + is_64bit = kernel_ip(to) || any_64bit_mode(regs); #endif insn_init(&insn, kaddr, size, is_64bit); insn_get_length(&insn); diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 8961653c5dd2..1aadb253d296 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -1221,7 +1221,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort) * on 64-bit systems running 32-bit apps */ #ifdef CONFIG_X86_64 - is64 = kernel_ip((unsigned long)addr) || !test_thread_flag(TIF_IA32); + is64 = kernel_ip((unsigned long)addr) || any_64bit_mode(current_pt_regs()); #endif insn_init(&insn, addr, bytes_read, is64); insn_get_opcode(&insn); diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c index bb7e1132290b..9332c49a64a8 100644 --- a/arch/x86/kernel/perf_regs.c +++ b/arch/x86/kernel/perf_regs.c @@ -123,7 +123,7 @@ int perf_reg_validate(u64 mask) u64 perf_reg_abi(struct task_struct *task) { - if (test_tsk_thread_flag(task, TIF_IA32)) + if (!user_64bit_mode(task_pt_regs(task))) return PERF_SAMPLE_REGS_ABI_32; else return PERF_SAMPLE_REGS_ABI_64; -- 2.28.0