From patchwork Mon Jan 8 17:43:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13513748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F26F8C3DA6E for ; Mon, 8 Jan 2024 17:43:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B2E26B0080; Mon, 8 Jan 2024 12:43:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 762076B0083; Mon, 8 Jan 2024 12:43:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62A0B6B0085; Mon, 8 Jan 2024 12:43:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4DB966B0080 for ; Mon, 8 Jan 2024 12:43:54 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E8E3A1606ED for ; Mon, 8 Jan 2024 17:43:53 +0000 (UTC) X-FDA: 81656866746.18.E346FE1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id B244DA0017 for ; Mon, 8 Jan 2024 17:43:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V47QX1ZD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704735830; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=t/y+PG9wgXubwHyUj1TLPJKxwJGWndNGxiIdKZ4D+Io=; b=5yF8WdaGgVUEtZaIqakO5q+oihsW7v38WyDu3FaJ1HI4CkZU2gn+jTOtLQTeKNLRsRfKXw bKDZYI31Wl3zfsfH2Xx+tcexl7O9uI5q6oWntan9v3blEtwFl8jj5nh8b5OjfQNPpxLd2V TAOWVQhm/tAbAPtzuIZnTZqZCzNtY64= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V47QX1ZD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704735830; a=rsa-sha256; cv=none; b=SfOuRUtYOn6y0V1lUl+5UBFr4zRBnqSoansD1YRJt25yS9dUsT44YejJ9aVsiGJvQkugnK KbxFrIhO9dSSqWd/pf5vTH5mRhcuop/RoF8Fd3mLQYxqrHlQyVLZGIiKkXhC7j4wWozz0Q EJkxdYSCoNTZ1tUpqZN66J3IagYB82s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704735830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t/y+PG9wgXubwHyUj1TLPJKxwJGWndNGxiIdKZ4D+Io=; b=V47QX1ZD6pnCzwxEJ0F6jPi7kHNQC9RsOD66GHwsIDhK2cuNLu2hP5/4k5lUMUBtjgDm9m sqEQUrtW36ID/uRrrZfOpQxId9JxrDD9YIUVn2HdjC+nZmPUDvc1s8NegrpLWUONp+Ofpi 2xTUqFHvuz1+Li8mL36DHchI5XqpCTg= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-qi3LgKpUMMOZR6H1NRXn_Q-1; Mon, 08 Jan 2024 12:43:48 -0500 X-MC-Unique: qi3LgKpUMMOZR6H1NRXn_Q-1 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-1d3eff55aa5so20055815ad.2 for ; Mon, 08 Jan 2024 09:43:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704735827; x=1705340627; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t/y+PG9wgXubwHyUj1TLPJKxwJGWndNGxiIdKZ4D+Io=; b=btvaIq2DvIVp4wlQw2f5zVKIUOBm4kKLMZ37inhmCJD38Jky7TPBJwhNsBAc3XaBbp zoV6Zxh+4uRqq6k/kdcPOknXP1DBxK55GnENGFm+RKSjgf+p6fz99mW4mafyoeiEr8jM WQw0wfoLIEiwbvXZBqAxcY342csG/tH7bizI08Q1kiLjZqXxqSRHG94PcwdIQZLtSkPd z5+Nn4U7XU31kDwaEz+edthn0ZWmCxoIt/KDdupkxiTN5i3UBhrwUc61tmbhmjKKS73b YG+ZAZpY47eaHQifeBjsqZmkreYZt8qRUZKAWcHFb8zu5uZq4T8zqAwXEBZQilKW0yM7 +j8w== X-Gm-Message-State: AOJu0Yxgr8bF9UxFLsr7uqstv9+SS/N+Q1OiuLjFDhsYCIfD3OvuJtwG bjgORTtlKn8FxJ2hgG6fru3aSGFWr87Pemh9NhDbSms87KhnVLdPwa3ISiaKQ6zkNHjBbTIjdOU ox9fSM7q48TmsEyCfy0T4NIvugcc= X-Received: by 2002:a17:902:ec88:b0:1d4:e234:2a20 with SMTP id x8-20020a170902ec8800b001d4e2342a20mr4880712plg.67.1704735827398; Mon, 08 Jan 2024 09:43:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4CTdkRDEAC6hi56wa8KiLF9soDYufPpJbegkIWWFOdvjj5P1vTKeh78U57k/4CJ10BnT+kQ== X-Received: by 2002:a17:902:ec88:b0:1d4:e234:2a20 with SMTP id x8-20020a170902ec8800b001d4e2342a20mr4880699plg.67.1704735827135; Mon, 08 Jan 2024 09:43:47 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:26a5:3f32:e12b:5335:3c2d]) by smtp.gmail.com with ESMTPSA id y7-20020a170902864700b001c755810f89sm161905plt.181.2024.01.08.09.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 09:43:46 -0800 (PST) From: Leonardo Bras To: Catalin Marinas , Will Deacon , Eric Biederman , Kees Cook , Oleg Nesterov , Leonardo Bras , Mark Brown , Mark Rutland , "Steven Rostedt (Google)" , Guo Hui , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] arm64: remove unnecessary ifdefs around is_compat_task() Date: Mon, 8 Jan 2024 14:43:30 -0300 Message-ID: <20240108174330.472996-2-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B244DA0017 X-Stat-Signature: zos18hrceies3gi5j1tcorostmc7q3b4 X-Rspam-User: X-HE-Tag: 1704735830-832175 X-HE-Meta: U2FsdGVkX1/L9kXOk0UdpJOb1WplHGCfgqMA4ts5JGXHK9n1NeIGLdfoQ+Y2tp/fB4cCZ1LXLjR/Ae0oC2LTqiAC/nTW+LhvJ4JBlFYs7j2JuGeohFLhRi4RG7S/+PZqPUwcDolGcO8WFc2bC9eb+F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xDikBmxbNNgeKfAk+nk6KEQ89IIG/YZpc7d0Nr8SMWV+R4Y97Yi6PcaDuQ2mqw7arRdB8gON8uBfNf2i6UV62BzT824CDM0/yLKHxPlmP2Q1mL3Hgy6ZqhAJdMw9QirCw/t8Wr20LtrnVGgW+bS52pSO8Ew924cwnlcbDjRdYfkE6uuXG+fFGZE6WEMbpXmGkHFGJr2UKUUoUSOHqPF1Ar0gulbL3nSKuIS9xZwhCFkLJ/c2VfIV/FuZY5LzhXggl3jWD7sFtaHqzAv+42g3lE54kuuWIehrN7q+Av9MnN+w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently some parts of the codebase will test for CONFIG_COMPAT before testing is_compat_task(). is_compat_task() is a inlined function only present on CONFIG_COMPAT. On the other hand, for !CONFIG_COMPAT, we have in linux/compat.h: #define is_compat_task() (0) Since we have this define available in every usage of is_compat_task() for !CONFIG_COMPAT, it's unnecessary to keep the ifdefs, since the compiler is smart enough to optimize-out those snippets on CONFIG_COMPAT=n This requires some regset code as well as a few other defines to be made available on !CONFIG_COMPAT, so some symbols can get resolved before getting optimized-out. Signed-off-by: Leonardo Bras Reviewed-by: Arnd Bergmann --- Changes since v1: - Move some regset code and other defines outside of CONFIG_COMPAT - Closes: https://lore.kernel.org/oe-kbuild-all/202401061219.Y2LD7LTx-lkp@intel.com/ Link: https://lore.kernel.org/all/20240105041458.126602-3-leobras@redhat.com/ Changes since RFCv1: - Removed unnecessary new inlined is_compat_task() for arm64 - Adjusted commit text and title Link: https://lore.kernel.org/all/20240104192433.109983-2-leobras@redhat.com/ arch/arm64/include/asm/elf.h | 10 +++++----- arch/arm64/include/asm/fpsimd.h | 2 -- arch/arm64/kernel/ptrace.c | 8 +++----- arch/arm64/kernel/syscall.c | 5 +---- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 97932fbf973d1..3f93f4eef9530 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -201,16 +201,16 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #define COMPAT_ELF_PLATFORM ("v8l") #endif -#ifdef CONFIG_COMPAT - -/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */ -#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL - /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18 typedef unsigned int compat_elf_greg_t; typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; +#ifdef CONFIG_COMPAT + +/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */ +#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL + /* AArch32 EABI. */ #define EF_ARM_EABI_MASK 0xff000000 int compat_elf_check_arch(const struct elf32_hdr *); diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 50e5f25d3024c..94c7ed82fbada 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -21,7 +21,6 @@ #include #include -#ifdef CONFIG_COMPAT /* Masks for extracting the FPSR and FPCR from the FPSCR */ #define VFP_FPSCR_STAT_MASK 0xf800009f #define VFP_FPSCR_CTRL_MASK 0x07f79f00 @@ -30,7 +29,6 @@ * control/status register. */ #define VFP_STATE_SIZE ((32 * 8) + 4) -#endif static inline unsigned long cpacr_save_enable_kernel_sve(void) { diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 20d7ef82de90a..27efd66fc1e93 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -173,7 +173,6 @@ static void ptrace_hbptriggered(struct perf_event *bp, struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); const char *desc = "Hardware breakpoint trap (ptrace)"; -#ifdef CONFIG_COMPAT if (is_compat_task()) { int si_errno = 0; int i; @@ -195,7 +194,7 @@ static void ptrace_hbptriggered(struct perf_event *bp, desc); return; } -#endif + arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT, bkpt->trigger, desc); } @@ -1594,7 +1593,6 @@ static const struct user_regset_view user_aarch64_view = { .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) }; -#ifdef CONFIG_COMPAT enum compat_regset { REGSET_COMPAT_GPR, REGSET_COMPAT_VFP, @@ -1851,6 +1849,7 @@ static const struct user_regset_view user_aarch32_ptrace_view = { .regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets) }; +#ifdef CONFIG_COMPAT static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t __user *ret) { @@ -2112,7 +2111,6 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, const struct user_regset_view *task_user_regset_view(struct task_struct *task) { -#ifdef CONFIG_COMPAT /* * Core dumping of 32-bit tasks or compat ptrace requests must use the * user_aarch32_view compatible with arm32. Native ptrace requests on @@ -2123,7 +2121,7 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) return &user_aarch32_view; else if (is_compat_thread(task_thread_info(task))) return &user_aarch32_ptrace_view; -#endif + return &user_aarch64_view; } diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 9a70d9746b661..ad198262b9817 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -20,14 +20,11 @@ long sys_ni_syscall(void); static long do_ni_syscall(struct pt_regs *regs, int scno) { -#ifdef CONFIG_COMPAT - long ret; if (is_compat_task()) { - ret = compat_arm_syscall(regs, scno); + long ret = compat_arm_syscall(regs, scno); if (ret != -ENOSYS) return ret; } -#endif return sys_ni_syscall(); }