Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1798207pxv; Sat, 26 Jun 2021 00:30:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsgk05KWgRVVIKrHHRqk/zhvegBWEGui631ymSI+cabNhOElIffOaSmpI8JJIcM/a0tlyy X-Received: by 2002:a17:906:4b0a:: with SMTP id y10mr15289569eju.388.1624692626211; Sat, 26 Jun 2021 00:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624692626; cv=none; d=google.com; s=arc-20160816; b=EoAa28HqhbRNitW4bt6jRdRUH5PHVZ5wd1URhm6At5CLxVPQ/2ehlXIEzb3eCE56DA ChP6Qm+pYhoVrsWftTty9BLSTCGEucfAdkhLWhbzrHKzVrCwbls0GvJsjgeTit9lKu1p PwW4PRDdmZDQQ4oUBkFu3icheEjPgaZJgHY1cbHxsYXdGqc2z6mqnmrF+cQU0frQwp0e uL6b/fi7BLEJRDIxq5KldSavAxkef8ArjZ4DwqP00tIpVavD8Zhn3UHF5jk4AM1DkRA5 q1VEb1/72pC6vFefz8fEW/TV/bXkWc1JIqEKjfRB+MlOjmC3P0uJK0GvvJVnjooVT8yF PoIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0P8xL3Yqbw/EsxsJ+pxq8dIFj62D9qSERbsRIaliW0k=; b=NpoxcJ8LHz7UKnHf1Gam1r9ZG9B3v0ORaY407kBOTdEhJqe4e0TRItTk1W3Xw68Nvx kMFF2awgNNVvBwaNLTmDqoRluQyVHq977BlbgflmxVQRsxyBsU23qKrjB1UNu3DQha1B HdADt+eixrW44OY+ERNxOXoz39VgDj5Z70ebpVWFO8YWNwKZkIqLsa+lQXzqRQEJnRRI h7/5iTFq0zXdtkRg0PJ1q/QoVxb2a+GfZaxQ3Hyv+Ms/YbHH+1G+dcg5JCPaWfJoKhid Y+H2tGUO1PwCRmLj7HSyulgng3uCiDbXe94TUyg17i84DaTIq/sC/gm54k72JW6/6s1U tWdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb9si8150303ejc.250.2021.06.26.00.30.02; Sat, 26 Jun 2021 00:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbhFZH3p (ORCPT + 99 others); Sat, 26 Jun 2021 03:29:45 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:5433 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbhFZH30 (ORCPT ); Sat, 26 Jun 2021 03:29:26 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GBljC6LNLz74VJ; Sat, 26 Jun 2021 15:23:43 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 15:26:59 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 15:26:59 +0800 From: Kefeng Wang To: Arnd Bergmann , , CC: Kefeng Wang , Ingo Molnar , Thomas Gleixner , Subject: [PATCH 4/9] sections: Move is_kernel_inittext() into sections.h Date: Sat, 26 Jun 2021 15:34:34 +0800 Message-ID: <20210626073439.150586-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210626073439.150586-1-wangkefeng.wang@huawei.com> References: <20210626073439.150586-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The is_kernel_inittext() and init_kernel_text() are with same functionality, let's just keep is_kernel_inittext() and move it into sections.h, then update all the callers. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: x86@kernel.org Signed-off-by: Kefeng Wang --- arch/x86/kernel/unwind_orc.c | 2 +- include/asm-generic/sections.h | 14 ++++++++++++++ include/linux/kallsyms.h | 8 -------- include/linux/kernel.h | 1 - kernel/extable.c | 12 ++---------- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index a1202536fc57..d92ec2ced059 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -175,7 +175,7 @@ static struct orc_entry *orc_find(unsigned long ip) } /* vmlinux .init slow lookup: */ - if (init_kernel_text(ip)) + if (is_kernel_inittext(ip)) return __orc_find(__start_orc_unwind_ip, __start_orc_unwind, __stop_orc_unwind_ip - __start_orc_unwind_ip, ip); diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 5727e67f4b7a..9d622416a59c 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -170,4 +170,18 @@ static inline bool is_kernel_rodata(unsigned long addr) addr < (unsigned long)__end_rodata; } +/** + * is_kernel_inittext - checks if the pointer address is located in the + * .init.text section + * + * @addr: address to check + * + * Returns: true if the address is located in .init.text, false otherwise. + */ +static inline bool is_kernel_inittext(unsigned long addr) +{ + return addr >= (unsigned long)_sinittext && + addr < (unsigned long)_einittext; +} + #endif /* _ASM_GENERIC_SECTIONS_H_ */ diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index c44c26977805..3e172fc65fae 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -23,14 +23,6 @@ struct cred; struct module; -static inline int is_kernel_inittext(unsigned long addr) -{ - if (addr >= (unsigned long)_sinittext - && addr < (unsigned long)_einittext) - return 1; - return 0; -} - static inline int is_kernel_text(unsigned long addr) { if ((addr >= (unsigned long)_stext && addr < (unsigned long)_etext)) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 0622418bafbc..d4ba46cf4737 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -229,7 +229,6 @@ extern bool parse_option_str(const char *str, const char *option); extern char *next_arg(char *args, char **param, char **val); extern int core_kernel_text(unsigned long addr); -extern int init_kernel_text(unsigned long addr); extern int __kernel_text_address(unsigned long addr); extern int kernel_text_address(unsigned long addr); extern int func_ptr_is_kernel_text(void *ptr); diff --git a/kernel/extable.c b/kernel/extable.c index da26203841d4..98ca627ac5ef 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -62,14 +62,6 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr) return e; } -int init_kernel_text(unsigned long addr) -{ - if (addr >= (unsigned long)_sinittext && - addr < (unsigned long)_einittext) - return 1; - return 0; -} - int notrace core_kernel_text(unsigned long addr) { if (addr >= (unsigned long)_stext && @@ -77,7 +69,7 @@ int notrace core_kernel_text(unsigned long addr) return 1; if (system_state < SYSTEM_RUNNING && - init_kernel_text(addr)) + is_kernel_inittext(addr)) return 1; return 0; } @@ -94,7 +86,7 @@ int __kernel_text_address(unsigned long addr) * Since we are after the module-symbols check, there's * no danger of address overlap: */ - if (init_kernel_text(addr)) + if (is_kernel_inittext(addr)) return 1; return 0; } -- 2.26.2