Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp132816rdb; Fri, 5 Jan 2024 05:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrt/XPVz9kfXuryZIHnzmFoXY7yq4GUElfn80WrpO3Xxn7dTkWk7yOWU5tvJLERnH3w2Jz X-Received: by 2002:a05:6e02:1aa8:b0:35f:bfba:580a with SMTP id l8-20020a056e021aa800b0035fbfba580amr2191959ilv.46.1704460565739; Fri, 05 Jan 2024 05:16:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704460565; cv=none; d=google.com; s=arc-20160816; b=bDGYRjFEsyz03iECSahlj095aRrUtWPjXDL0SbBollE7JouSdzDnQ7L6SXtg9at1RT oumhTUut1hnGQnNe4Hcr/x1fVU3IhyaCj3N0RqZo/j+erMC/4TTUb1tFwnGs04VT4qcB NEhR+4POBxbHMtw9cCK2jOyCjb3GIagWCnV0KjE3+4VVGl8qRHCHDlOGrHLZpekzfgPO jxT4fbH8qbVwvMCh+BD1+N2uttRx2ndfEAEO6RrVGaguPPSNIYYNFKBOiEQs/A+PzHNe wWWyLT/YgewNIhz1LiLdJ9/XmvQ4GbCy1f8By9N0kZ9YM1iBzN2uoFxzGFCdipuDvTR+ LlWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=22M+IYjdHRBRl3RFcHL1resgKzufZ1qi4srpOmSZL8Q=; fh=HL4DDpCdwofR7qj+eM124a5PUkpFAi1cVoEb8/dyS5s=; b=YBInKtkqjkDN4ehlVBtP7YHfl9Marjw4aW73iAl5slytayGgDTMBEGiDlpUNVGV5rJ C+2JSukKTKcyv+h0XJp1N6nkgRazZkqpBgoOrKLgxPf/BdE/LgnzJXWqnsYP8RBdYVRg ovt6dqt30AsHImcdP+rOuszVWZtw8v6b4DHQwuo2pdiHKBMbBwKvr8aNXA6xX6IhyGfk mu1PLHYQpOsdTbgtlIL3z1vKN8xGDqm1h7M/SC1PfgL3JTAy3Y+pwAUxm8u4f+tRotG8 ITGMJMBpV7YUy5dtWw0qQnfPoWV07Rw3nUXgwa0L/g65jAzczjG2Ny8bp2epTF48otld knhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17867-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p34-20020a634f62000000b005ced4fbeabcsi1255018pgl.844.2024.01.05.05.16.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 05:16:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17867-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17867-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CC3D3287259 for ; Fri, 5 Jan 2024 13:15:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37CBB2D634; Fri, 5 Jan 2024 13:14:41 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88BD52D60F for ; Fri, 5 Jan 2024 13:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20F23C15; Fri, 5 Jan 2024 05:15:24 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.86.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 30D123F64C; Fri, 5 Jan 2024 05:14:36 -0800 (PST) Date: Fri, 5 Jan 2024 13:14:30 +0000 From: Mark Rutland To: Leonardo Bras Cc: Oleg Nesterov , Catalin Marinas , Will Deacon , Mark Brown , "Steven Rostedt (Google)" , Arnd Bergmann , Guo Hui , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/1] arm64: remove unnecessary ifdefs around is_compat_task() Message-ID: References: <20240105041458.126602-3-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240105041458.126602-3-leobras@redhat.com> On Fri, Jan 05, 2024 at 01:15:00AM -0300, Leonardo Bras wrote: > 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 > > Signed-off-by: Leonardo Bras I tried this atop the arm64 for-next/core branch, using GCC 13.2.0; building defconfig + CONFIG_COMPAT=n results in build errors: [mark@lakrids:~/src/linux]% usekorg 13.2.0 make ARCH=arm64 CROSS_COMPILE=aarch64-linux- Image CALL scripts/checksyscalls.sh CC arch/arm64/kernel/ptrace.o arch/arm64/kernel/ptrace.c: In function 'task_user_regset_view': arch/arm64/kernel/ptrace.c:2121:25: error: 'user_aarch32_view' undeclared (first use in this function); did you mean 'user_aarch64_view'? 2121 | return &user_aarch32_view; | ^~~~~~~~~~~~~~~~~ | user_aarch64_view arch/arm64/kernel/ptrace.c:2121:25: note: each undeclared identifier is reported only once for each function it appears in arch/arm64/kernel/ptrace.c:2123:25: error: 'user_aarch32_ptrace_view' undeclared (first use in this function) 2123 | return &user_aarch32_ptrace_view; | ^~~~~~~~~~~~~~~~~~~~~~~~ make[4]: *** [scripts/Makefile.build:243: arch/arm64/kernel/ptrace.o] Error 1 make[3]: *** [scripts/Makefile.build:480: arch/arm64/kernel] Error 2 make[2]: *** [scripts/Makefile.build:480: arch/arm64] Error 2 make[1]: *** [/home/mark/src/linux/Makefile:1911: .] Error 2 make: *** [Makefile:234: __sub-make] Error 2 ... and looking at the code, user_aarch32_view and user_aarch32_ptrace_view are both defined under ifdeffery for CONFIG_COMPAT, so that's obviously not going to work... That aside, removing ifdeffery is generally nice, so could you please try building with CONFIG_COMPAT=n and see where you get to? Thanks, Mark. > --- > 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/kernel/ptrace.c | 6 ++---- > arch/arm64/kernel/syscall.c | 5 +---- > 2 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c > index 20d7ef82de90a..9f8781f1fdfda 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); > } > > @@ -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(); > } > -- > 2.43.0 >