From patchwork Fri Feb 17 00:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 58303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp616620wrn; Thu, 16 Feb 2023 16:53:23 -0800 (PST) X-Google-Smtp-Source: AK7set/+dy8g3SGZ4aleImZzDKV4cUEwaXTiDFQYFIs/NXblMWaL7tLy/4hI21OGGgYv36hD0AJQ X-Received: by 2002:a17:906:40c9:b0:8b1:75a0:57fa with SMTP id a9-20020a17090640c900b008b175a057famr2672908ejk.43.1676595203739; Thu, 16 Feb 2023 16:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676595203; cv=none; d=google.com; s=arc-20160816; b=hCani1EOMkYvJLXIXIVAfCwXZSth0/iUO2nqnibEzZvZ3alZqsk308wEkgW1tfIPNO flsCYo1gq9OcllYdA77mhRHx4McXUqwTDhMNFEQ/PaCxzMV4+OjZYBun9JqeF8p79j4b 75z3AM0SWqlslR+JjVchYiTFfA1l7WS4wjeYgJCw6THhE+R1n/12IXQ027hSNOdUALkh 9OrjpU53Gj4msLtZGV5/iOwMQAkzYv8A95Ds7DkYjFKcwfMar1pGAZkjuork+i8It9Gr g1ZAdFVoeOnaDjIqnDU5V9/ZuaRtrO/LGAh/tvXiyLzdVNkJLQ5zJluqUhgg6mszrl3H +/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=m1p7dnhEsRIVsnzK0e7I8OsbQqK8jj8CjHMvB1ks+Xo=; b=CLcWo5hNIs3T2mfc1lHlTLws+N7uwXebX8Sx/Yb9x8aecxVgQKT8zBgBvo8vIB3n+c hDW2oDqJzCTTbWGw7MYCTuQbPC5hWbmuCAnQSPGsV57qxQ9RgdTAmGUGPD4pNqh2ECGN SHJN3Oxc/C9G2EOjoYdXumItx1QQ4QTzA5ko+Vh1fbL0Bb6HfPLkXbabMbo0ZtBIeXoo avPQb3Z0z/fElhGdoEnAHWmUHzaBUfIdHungpkQwdBNgu50cI4QN1jV6ismnJ+UkVvnb 0X22HHaNl6od4I/AqjZN/bpmw80R//zBNZucJ5uppsV4kuNTRGVZb6zxtaUZT0cZiZyp 7J0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fc5-20020a1709073a4500b008b14709d699si3199680ejc.412.2023.02.16.16.52.59; Thu, 16 Feb 2023 16:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbjBQAuB (ORCPT + 99 others); Thu, 16 Feb 2023 19:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjBQAuA (ORCPT ); Thu, 16 Feb 2023 19:50:00 -0500 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F034F3C7B7; Thu, 16 Feb 2023 16:49:56 -0800 (PST) X-QQ-mid: bizesmtp76t1676594974t44ilj1c Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:31 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: znfcQSa1hKbHsodWWJ7dLyJeU0dQLSJ2PPtzz1iLzMNgSELCkUn2ujNlhycbg vLg03SNvb9EFMysNu9WjgjH2yYBaAi1fGVqPKaFhctNfTwt+bbxYpXQIVh9rDo/8cNrLyPt ToX08gVh/Po6w/uiFpE5NpG8RVgjCEHPEAjNBEvKB228hcFV2zJd7lPvufzHTfmfzprQ+fT BT5FvJHdZIQ0ZHz+hIneTfMRDTSLb6HDEunI+ke40/IGoYkdjw1kyDvwLpdYHmyCpkkWnqA O1Hes08eR/3n/SlY9lwkeFrEDn7M4DXKn75YILTWaoiJycDGTzD8fi1d+13MWbJyxm4+S3n g5P3PHo4ATnp0TD9593FPSzON//EjXHb6RjyzNWaKJfKxUqmS92Hopcemr0iQ8IBGReu7VW X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 1/5] syscall: Allow configure used system calls Date: Fri, 17 Feb 2023 08:49:21 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758037492434081883?= X-GMAIL-MSGID: =?utf-8?q?1758037492434081883?= A new CONFIG_SYSCALLS_USED is added to configure the system calls used in a target system (especially for the ultra small embedded systems), the other system calls will be disabled. If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the other ones (if also not used by kernel itself) will be removed automatically. The used system calls should be listed one by one like this: write exit reboot The architecture should implement it and then select the HAVE_SYSCALLS_USED option. Signed-off-by: Zhangjin Wu --- init/Kconfig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 44e90b28a30f..2c4b8b234168 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1502,6 +1502,10 @@ config BPF bool select CRYPTO_LIB_SHA1 +config HAVE_SYSCALLS_USED + bool + default n + menuconfig EXPERT bool "Configure standard kernel features (expert users)" # Unhide debug options, to make the on-by-default options visible @@ -1728,6 +1732,24 @@ config MEMBARRIER If unsure, say Y. +config SYSCALLS_USED + string "Configure used syscalls (EXPERIMENTAL)" if EXPERT + depends on HAVE_SYSCALLS_USED + default "" + help + This option allows to configure the system calls used in a target + system, the other system calls will be disabled. + + If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the + other ones (if also not used by kernel itself) will be removed + automatically. + + The used system calls should be listed one by one like this: + + write exit reboot + + If unsure, keep this empty. + config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EXPERT default y