Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3691813rdg; Wed, 18 Oct 2023 03:21:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHY49nVIY8P5/y/lbLf2VyrVN5XrZ1JzrKNyxV76W15+SeSuz1QPWyD+y61nKlzyGbVxTTn X-Received: by 2002:a05:6359:1a47:b0:13a:a85b:a4dc with SMTP id ru7-20020a0563591a4700b0013aa85ba4dcmr4734265rwb.29.1697624466158; Wed, 18 Oct 2023 03:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697624466; cv=none; d=google.com; s=arc-20160816; b=lhwFYtq8WcOeoCX4xckpEi8zMEfzrP7k9akaNlTFmZ0HLJPGohVwBHUuMORzrtVazp P9EtqTt3M98Q3cth4wz+gY2dSnCQJ/nRYXtjYdT3J47MAqwEw+oJA3l8IYIDBw3HbvVc emnpAp6IGO/W8RS83AF9mvwxRba7KwrX6NfcbYk+KZ6P6MDMfcqzhso7N5BuJJHPCi4q 3FIXVTe7ukFFW9NhlIbzoe//nzpeQ9j0bLRmaVztlmEVHOwuePQUSkczi1Nmf7gngr4j GO9icD07A5E3P3Y2KfOtIqG0UeCJEFexCH2tAvGSSLAZW+/kHCrvZsZbMq+Djx8YjWlq FrUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=MtKsd5ATsOd1KMkyRCem0ZdPb7Hx7kw84A3vydeYqsg=; fh=voafQGsizWyXOSB7V1Tv2134UV+BtT4MbboO7HTeDe8=; b=fL/HmHcdqDRduYwrOyBxgNvzHd9c7J+Uq9AklwsEToTpohK3Rip6YOT+qi4t/Ln8qD 5MK6br6Mj/OrTE2OuOqBWzu/St+wpuhaf3A8nx1eZmRruxksPuAI6VSwGrzcIfTGpEov 7Ou8jajm3zN5C/pwBOQa3xIw2y7IqW0fvFE7N1pdP0VnWQIAkTGIZ3bG3pDeClsSoSoV bO8/CnbfDa0TARS6YY9UahvNb7GyFBOG+A3/9dC3uB6+s0ljIuABtMnrwJucprGyFedV HZ7IiJpVz6DnW/ZQIoonxxET6zLM9kPPkO87Qbr//soVuX/FYFtRVjMgg9oZaNJyYLmr ZQzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="J0Aq0Y/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r27-20020aa7963b000000b006bc2cf9872fsi2949694pfg.317.2023.10.18.03.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:21:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="J0Aq0Y/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9439C8160388; Wed, 18 Oct 2023 03:20:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230465AbjJRKU1 (ORCPT + 99 others); Wed, 18 Oct 2023 06:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbjJRKUY (ORCPT ); Wed, 18 Oct 2023 06:20:24 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50AFB0 for ; Wed, 18 Oct 2023 03:20:20 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9c53e8b7cf4so377863966b.1 for ; Wed, 18 Oct 2023 03:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697624419; x=1698229219; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=MtKsd5ATsOd1KMkyRCem0ZdPb7Hx7kw84A3vydeYqsg=; b=J0Aq0Y/391GD8Ol0MHJyIBae0fyMbhmWrGiNv4P8/a3xSYE2bptEpGYUW8y2N2gVe8 Hjw1dRhrzshJIo+VuuBjysX3/bEdJeR6BKg3pOv+vqoyu7J0IPbqSv7HcOt1O+7tRMxe pJ6F56wPcgZqnHzj5wdrsvCDWhtfcPqZ5y90xzFXuf82msHMfc//H482T0vA7aC/vnNE M9YVmNE1FhXNW7rAEXFCLHrjlriqmS2oq1Zi28+KVQcIj+yPw6AVPAO424V7f28xEEBX PDRgR9N6joyf/eUQmJtV8zgbiDoqJJkw6pzaafDP9StFVJnL/Rq5Pv1Wk0GAl3vaDTrT 2A+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697624419; x=1698229219; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MtKsd5ATsOd1KMkyRCem0ZdPb7Hx7kw84A3vydeYqsg=; b=sQE+UH7DujmQRzyRNFxnqhZeRgsKudvfcP9jsO53UhOniQaG2KWHZnErmVoaxV4ggp swpRbf77PiV55czOWt01P736TBuGUGMgh1J2q7RCEB4biTvqMO0faJq/4Hc1FqcRkweI +n+91pfLk7LL4wK9i5AKs+9t0a+W0hRDRZMKt/+/YtL/mdNANzrxjbCp/UnxjpHtrwmD PJM9G2Yvs52MC5DUjTFIrxLB5KabVCkGC0r/bWGEDOhptdHvsdG8fDfTpxKPUaYHwfoe vnipHY5NuZSgm9qiDSnJeFmr286/cHCy77fE0ZGEPrBGeyCHf69hvFViBX9ByV3RzSSW hKmw== X-Gm-Message-State: AOJu0YzzWC+kQoFy3/xfe3DrQGQDM1b3NzNqyUHjqGKzD3682eDk4EPh EQtnLNxdnEuppS6zGTrlIDc= X-Received: by 2002:a17:906:4784:b0:9be:ea59:1457 with SMTP id cw4-20020a170906478400b009beea591457mr3804310ejc.40.1697624419019; Wed, 18 Oct 2023 03:20:19 -0700 (PDT) Received: from gmail.com (1F2EF7B2.nat.pool.telekom.hu. [31.46.247.178]) by smtp.gmail.com with ESMTPSA id mc8-20020a170906eb4800b0098d2d219649sm1382751ejb.174.2023.10.18.03.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:20:18 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 18 Oct 2023 12:20:15 +0200 From: Ingo Molnar To: Hou Wenlong 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: References: <20231018071347.GA87734@k08j02272.eu95sqa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018071347.GA87734@k08j02272.eu95sqa> X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 03:20:34 -0700 (PDT) * Hou Wenlong wrote: > 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. The right solution at that point is to make self-contained... > 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. When exporting a localized definition you should consider namespace collisions - the name '__head' is way too generic, no wonder it caused problems elsewhere. I'd suggest naming it __init_head or so, but still keep it in a x86-only header. I presume keeping it all in the separate section and widening its usage has a specific purpose? Please outline that in the changelog as well. Ie. instead of mechanical patches that try to follow existing patterns cargo-cult style, this area of x86 code requires well-argued, well thought out patches that show background knowledge of the area. Thanks, Ingo