From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FF8CC47073 for ; Thu, 4 Jan 2024 19:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=kf0x82eNKD/GBcLygaIlteu95+pzVH6QJyI28LPom44=; b=zvEgy6Q95IxZQT yQBRFUWJqlOnKIblON/DYtVQcwOe+rpiADNrhfQUHYE/q9RRgrDb2TJSmBFXBfog/p6L9Yg1Inrdz 8RSr14a2AYnToRsWve8muXTGP/v9P5zh59Nnwh1ZZLAiY2ktE4NkUfNO9LyHHJOqqxdNPQSKLKvli SLKJT6Unu/JSlrtkaDibN4fKxsIUQWtarm5L5acycUQVdsA5DbaEUqSpwJx28Bi7K1BbfrlAevzkq 6digQUUCEn0VwC5vceZtMwn0meCOVZDMxPqBo/LrEggiuScI4EbZBh3LX/LrKgRwARgwtjCrrPMxF N2alMtQO0Qh4qDzsWB2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLTMt-00F4iO-22; Thu, 04 Jan 2024 19:27:03 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLTMq-00F4hJ-2o for linux-arm-kernel@lists.infradead.org; Thu, 04 Jan 2024 19:27:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704396414; 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=LU9xUiegOmOumXh+8uek9l0bXHiL/GZWlaOpQEk79Lc=; b=YH9BmcFLyOx72wg3WX3Rdxx/u9R0soZ/3rQigFpDlniPDTbwRg++p2abnudKD3VrzKHBSX PjazP+ZjG62lKmsIU945vB3q7VzyV3ERnqMtKV7ma1dqxhnKz3S07LAxkE4DdQslJ5LxT2 DgJI+J0oP0g4PTH9Cyn2T3+WZahBDrM= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-AsIZiP3hMh-D_f3AW9ZuaQ-1; Thu, 04 Jan 2024 14:26:53 -0500 X-MC-Unique: AsIZiP3hMh-D_f3AW9ZuaQ-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-28c391d255dso683718a91.2 for ; Thu, 04 Jan 2024 11:26:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704396412; x=1705001212; 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=LU9xUiegOmOumXh+8uek9l0bXHiL/GZWlaOpQEk79Lc=; b=RWd7TPRKZRhabE5BY63WDeoN3GJxXe/4iUolRSa+q8RbbyLEBLpLNNUtSKcpTnJegl /K/rmt5NTB+huVVbjFC79GdrgiQPAKGzL9yhxYNOfHKc+sblWU+fIJ/6JMIojq65+bBm BwU4rbdw8ahSHR17wAGxzU4lAgnXauqD7bwm9YLMWyhRPN4bAx/DMCgC8jbq0SyfNTWj RutFfB6bCW0IylevVYQHULtqjBZm7k6wDpnbAd40q63HEPdXjGSIGhxU+kRDlci+es19 C5gZbpRmHrUDKSJUchByBn77cmqLGZsKgjuv23SIMDfiLrDTlFifsXwP9xGMUScEZ27F o5Hw== X-Gm-Message-State: AOJu0YwUNiF/b+QNumyZaQEFeOX775XgzfHUdj3ADpGlFKmUdoOmHArF 2AlExK9yx2Q9Bkx01RPgQEkw9yLHh+tYkjpr5oGQ34zdZNLTiowYXIVLwSJfRX0NwDtLqGAFzRj Itx5T2B0wccG75yrZ80zREAoBL6zVSY6RjKDFGNCiQHc= X-Received: by 2002:a17:90a:4708:b0:28b:201f:c2be with SMTP id h8-20020a17090a470800b0028b201fc2bemr847147pjg.62.1704396412259; Thu, 04 Jan 2024 11:26:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJpreyuJq8dxKbbb/Wzl6SoxUvTxzqpMMpKEY+xBSplOYzaauEFvo9gxkx+SWJIbNue18+FA== X-Received: by 2002:a17:90a:4708:b0:28b:201f:c2be with SMTP id h8-20020a17090a470800b0028b201fc2bemr847133pjg.62.1704396411916; Thu, 04 Jan 2024 11:26:51 -0800 (PST) Received: from LeoBras.redhat.com ([2804:431:c7ec:3c39:8a36:75f0:8b6e:b898]) by smtp.gmail.com with ESMTPSA id z7-20020a17090ab10700b0028c9349c79esm70063pjq.36.2024.01.04.11.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 11:26:51 -0800 (PST) From: Leonardo Bras To: Catalin Marinas , Will Deacon , Oleg Nesterov , Arnd Bergmann , Ard Biesheuvel , Teo Couprie Diaz , Leonardo Bras , Mark Rutland , Mark Brown , "Steven Rostedt (Google)" , Guo Hui Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 1/1] arm64: add compile-time test into is_compat_task() Date: Thu, 4 Jan 2024 16:24:33 -0300 Message-ID: <20240104192433.109983-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240104_112701_029888_9D982C0F X-CRM114-Status: GOOD ( 17.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently some parts of the codebase will test for CONFIG_COMPAT before testing is_compat_task(), probably in order to avoid a run-time test into the task structure, while other parts of codebase will just test even when the option is not compiled in. Since is_compat_task() is an inlined function, it would be helpful to add a !CONFIG_COMPAT version of the helper, allowing compile-time optimization. With this, the compiler is able to understand in build-time that is_compat_task() will always return 0, and optimize-out some of the extra code introduced by the option. This allows optimizing-out code when the option is not selected, and otherwise removing a lot #ifdefs that were introduced, making the code more clean. Signed-off-by: Leonardo Bras --- arch/arm64/include/asm/compat.h | 5 +++++ arch/arm64/kernel/ptrace.c | 6 ++---- arch/arm64/kernel/syscall.c | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index ae904a1ad5293..3cc61cbbb9062 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -100,6 +100,11 @@ long compat_arm_syscall(struct pt_regs *regs, int scno); #else /* !CONFIG_COMPAT */ +static inline int is_compat_task(void) +{ + return 0; +} + static inline int is_compat_thread(struct thread_info *thread) { return 0; 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel