From patchwork Tue Jan 9 03:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13514268 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 6C3CAC46CD2 for ; Tue, 9 Jan 2024 03:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9B536B008A; Mon, 8 Jan 2024 22:49:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4B256B008C; Mon, 8 Jan 2024 22:49:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEBE46B0092; Mon, 8 Jan 2024 22:49:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ACD356B008A for ; Mon, 8 Jan 2024 22:49:42 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7D6931C0F0B for ; Tue, 9 Jan 2024 03:49:42 +0000 (UTC) X-FDA: 81658393404.29.6F43CD8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 8DB0C40012 for ; Tue, 9 Jan 2024 03:49:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gizkvhvs; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.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=1704772180; 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=9pcW2dMN2ZTTnbNrLvy1EmevrgR/jRo6sIe8/KvAytk=; b=swub6cTtJBJq4gqX8yoijE2nF82Bawy520S03qvcj/DQlBgPJhwQ1KW4LioaccK/0m9T3i Lo3ip51hG6TAEO/0Ai3xm80TsagZ2OXGU29cZePvp52KtAstbwtorEnvdlAQK57Nzqqpdt D67/eOtGO0sBHQyqLQBdoQqvDSuK2pc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gizkvhvs; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704772180; a=rsa-sha256; cv=none; b=7ulufvay9oL0aci/hSc1i9MdevuveK6/A6AGg9mSSZNh0nYIzQWsSk2Q/lTcaPWCx8u4pD LJknlA9R5aZtss3644ELFWyTM0o+g2q2bmw3/6IMgPqoE5udy8/BwStN54bLjvHdxngPhO qAdBbelPQyQpiz9pr0tFI360ywwlNwk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704772179; 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=9pcW2dMN2ZTTnbNrLvy1EmevrgR/jRo6sIe8/KvAytk=; b=GizkvhvsLQwkxKIQPyyaiFqSdaWVxjdeaw/2jWLDBFw7sBhY8XEDwtIssZAYYJ59M77amr befd8TGSIpAssnBz3KVJrjHP4m2nNgGur5YoW9EvpYpj/AmfaZz9AfSJdLWQlPwdu6+mrB B2Oz/sJ6xAj/ZeWiJS7QFl/CYsqlL8w= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-AGkJG4PJOnm6QV0yyBY6kA-1; Mon, 08 Jan 2024 22:49:38 -0500 X-MC-Unique: AGkJG4PJOnm6QV0yyBY6kA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6800e52d47aso65921626d6.1 for ; Mon, 08 Jan 2024 19:49:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704772178; x=1705376978; 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=9pcW2dMN2ZTTnbNrLvy1EmevrgR/jRo6sIe8/KvAytk=; b=olupXgHK8fDqpI5Y+SxQivZN5oUDOxoZt567FVJcy9TQr+3bU99kXnDE4byz3tor19 xr8ql2DF3QeQC9OQZA6ZNITcXFQLLWrS2TqzSnsCDx8YaMxfMLZz+T6s+wA6FLloIj6y 9SoSXiu9/chmEQVaS426FcJAKb0z9/S10fFyd5yRsfGwvnJ6XEKa60PD3OW9lLYdap2D nBBvmledQNgCpKiWR5zzakW9wmkOOEE/mMIO1wYP9003FJvXJGurjKvEAV2ZtV18kw9R dTSOTP8QGOwdwq/7D+aiMHQ7umJ9yUfuXEtozMGqe8pCErAYj1M984MoyxOuhEW8c7EW jq6w== X-Gm-Message-State: AOJu0YxBJTNGVw8v87eWx1Ev4OsS/3NFtKsXTw97h4MlOkePUlibkMJW dg5KEJEYuXaz7+MOImj1pQfKxafYfnNvoUGsfJ1BztkjsFc9YTMGz9FOjNgm3xm0pGbwCQ1OmT5 CHyofDpp7m4kVCZ3vhgA= X-Received: by 2002:a05:6214:e67:b0:680:d06b:6734 with SMTP id jz7-20020a0562140e6700b00680d06b6734mr157681qvb.4.1704772178016; Mon, 08 Jan 2024 19:49:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgO6lHdt9lUqFyrJyBCNn6MpcN9eeknRp+QwwMqF1QJVBsyy9aCS5Siiq8Ba4VTJaFfMSnWg== X-Received: by 2002:a05:6214:e67:b0:680:d06b:6734 with SMTP id jz7-20020a0562140e6700b00680d06b6734mr157669qvb.4.1704772177747; Mon, 08 Jan 2024 19:49:37 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:26a5:3f32:e12b:5335:3c2d]) by smtp.gmail.com with ESMTPSA id b4-20020a056214114400b0067f7c11651esm545117qvt.128.2024.01.08.19.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 19:49:37 -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 v3 1/1] arm64: remove unnecessary ifdefs around is_compat_task() Date: Tue, 9 Jan 2024 00:46:50 -0300 Message-ID: <20240109034651.478462-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: 8DB0C40012 X-Stat-Signature: bqpbsiqomfpxehz16dzoy4jqegw4t3w1 X-Rspam-User: X-HE-Tag: 1704772180-496761 X-HE-Meta: U2FsdGVkX18Fh8mMM7JdtGkcKAWjEJjEbLODekhs3c02FyTq0h0iMnU1sc4HRdck/hqWIkUBvRRCe2Y4Wn6SZPt+oHmCssL4HqZvu3VGb5xJ2UU3a60Cby+FSSGEEakFH4wtrexQ3Ik+ACvdjJ9SDuUayzkdUcN0i8o9nF4BBUMGYhmSNxtS5e+w4cjWTaUoCazUyQl5NNNgZ1WB/QB3scGWTd3Uozo1D6gemCClL7bO3APm/Jmp29z+nYlJwAE/NpXDzDG8sKuxSJ8bBPp7brTzZrw0SwEEB4nfluENiN3JX8C6Z+PEl38DFWQgY7nt4vPIPsLKN3Y/L4x6j5bqHBy7v69GCMtilZAPqvxfzpv2ull0MlR3zQWApxU8ILPshi+TfVCT1+w/FywcXcfpyJAfIGzTUj2YUC/bHV74ulM4sbShIpqWth8I+3/pL1erE7SHfP8Rju519QmlUQxv80UrYqmkTYhKG67fNbb7FP4yMj2jPTxfzXuQWIjOtP1UmD+mNbqjOEC2DAzDGhV+uaQKT3PB7IURjyugm8L3ABFcqWxi9q09K7cqCMAJO62aZj4l+lZt3S+CYf8iAg4b7wwj6CGNlLHHBnLSMg08lOmyBO1f+PuOklVy3zurHqhh8QrBvcqp/BAr7P8shq/Ty3lOcv3NEWa4VKU1FiCD4mpEQjZXlC81Q1pqi+Gl7iL0YOmS4Ye8ZDjSvDn+ZlpUiW5+Dyuv/mnQ4wPGjUH48c4gabm5NRaRYwa04FHSt8us36r8BYavNopBITLmWjoTREsQbdwf9fTRY66lzDSdIAJXaDMSrCD1dqxjkI8776gifQ8duhu4HRJp3UxnsTico3LHL5TfgFqNtVGdidkXvm9R2EjTvyiOFGm8zIndEjHERbIh5je5TwXLkF3J/CkoTx9HbFFkOWLSpJpDce5rdh4b4hSIS9xpwgSAbtWr+glxcJ7TQgZJDazbcHfCAa8 JGsvT5BN x23OwsjG2EP9LgXgSApVZL8Ucb+BnLdLugGZVlglCFAGYiDLThXIgHPPgyaj/o8SAsiJUWU7waHPTxx9dOv5YWKMqKew0EG9DGVuLGS+urgjzha08ijey4A9StiyfF/uYSX4F8ANYI+zbsWw= 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 v2: - Added Reviewd-by from Arnd Link: https://lore.kernel.org/all/20240108174330.472996-2-leobras@redhat.com/ 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(); }