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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33E6ECDB47E for ; Wed, 18 Oct 2023 07:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344479AbjJRHOA (ORCPT ); Wed, 18 Oct 2023 03:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344574AbjJRHNz (ORCPT ); Wed, 18 Oct 2023 03:13:55 -0400 Received: from out0-213.mail.aliyun.com (out0-213.mail.aliyun.com [140.205.0.213]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE757FA for ; Wed, 18 Oct 2023 00:13:52 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047208;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.V1pyUc-_1697613227; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.V1pyUc-_1697613227) by smtp.aliyun-inc.com; Wed, 18 Oct 2023 15:13:48 +0800 Date: Wed, 18 Oct 2023 15:13:47 +0800 From: "Hou Wenlong" To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Tom Lendacky , Andrew Morton , Steve Rutherford , Michael Kelley , Alexander Shishkin , Arnd Bergmann Subject: Re: [PATCH 2/2] x86/sme: Mark the code as __head in mem_encrypt_identity.c Message-ID: <20231018071347.GA87734@k08j02272.eu95sqa> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 17, 2023 at 08:52:46PM +0800, Ingo Molnar wrote: > > * Hou Wenlong wrote: > > > The functions sme_enable() and sme_encrypt_kernel() are only called by > > the head code which runs in identity virtual address. Therefore, it's > > better to mark them as __head as well. > > > > Signed-off-by: Hou Wenlong > > --- > > arch/x86/include/asm/mem_encrypt.h | 8 ++++---- > > arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++++------------- > > 2 files changed, 18 insertions(+), 17 deletions(-) > > > > diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h > > index 359ada486fa9..48469e22a75e 100644 > > --- a/arch/x86/include/asm/mem_encrypt.h > > +++ b/arch/x86/include/asm/mem_encrypt.h > > @@ -46,8 +46,8 @@ void __init sme_unmap_bootdata(char *real_mode_data); > > > > void __init sme_early_init(void); > > > > -void __init sme_encrypt_kernel(struct boot_params *bp); > > -void __init sme_enable(struct boot_params *bp); > > +void sme_encrypt_kernel(struct boot_params *bp); > > +void sme_enable(struct boot_params *bp); > > > > int __init early_set_memory_decrypted(unsigned long vaddr, unsigned long size); > > int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size); > > @@ -75,8 +75,8 @@ static inline void __init sme_unmap_bootdata(char *real_mode_data) { } > > > > static inline void __init sme_early_init(void) { } > > > > -static inline void __init sme_encrypt_kernel(struct boot_params *bp) { } > > -static inline void __init sme_enable(struct boot_params *bp) { } > > +static inline void sme_encrypt_kernel(struct boot_params *bp) { } > > +static inline void sme_enable(struct boot_params *bp) { } > > So I think we should preserve the previous convention of marking functions > __init in the header-declaration and at the definition site as well, and do > the same with __head as well? > Hi Ingo, I tried to include into and mark the function declaration as __head, but it resulted in a build failure. This is because is not self-contained; the type "pgd_t" is defined in , which includes , leading to mutual inclusion of header files. To avoid the issue of complicated header file inclusion, I removed the annotation from the function declaration. Actually, initially, I noticed that the __init definition is in , so I first placed the __head definition in as well. However, this conflicted with the local variable in the "list_next_or_null_rcu" macro in . Then I realized that __head was only used in x86, so I made the decision to put it in the architecture-specific header. Considering simplicity, I chose to put the definition in . I also attempted to put the definition in other headers such as and , and included them in , but the build still failed. Thanks! > Thanks, > > Ingo