From patchwork Fri Jun 16 09:24:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 108975 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1196865vqr; Fri, 16 Jun 2023 02:29:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wG9BJpyTngkv/7Wq8r22+K2ZWzokhc+RwpHm4hte9r6W048mnWhj/3nrHlNJ5qiX/h+dd X-Received: by 2002:a17:902:f542:b0:1ac:b449:3528 with SMTP id h2-20020a170902f54200b001acb4493528mr1661217plf.46.1686907770389; Fri, 16 Jun 2023 02:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907770; cv=none; d=google.com; s=arc-20160816; b=icoHikPLU2eEb0LNbNzXVoYaINC0LPKnVe+4tejRJce6clwGXN2o1AX3CQCM1CiEGb 4dwkudYjzyoi0+wQWeG/+TXx0kiFjNI0AjwxQfvID1UnKF07CsK3m4u1RAsF5MocCgTT jN77rwbzhwWhoJKbNhz2PPMV6QAv70XT14dJF/VkkQAEJJPR7lGJjAHPNHTHyc5p8lM0 ZJFVxxKiPsF7a/+EZoxeXFQgyzp/MMEheVy8Ax8DFTFBjpmuZGE95VMHwJQa3tE1Jbs6 PrtufbZm9s/p8WRPwNZwsw59Gpn44unoSdOXMJQvs8jg1Vghwo/v6LAJXs74C018q+e4 vMMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=f7gy6MsfQJ3FW/zAGe1eR+9fJ/Ctzbfikdo/p5Z0QRA=; b=s/puSlrMr/ncVHi0iHkdd8TEmVaVFrqmlz9wt4JZdLrZ90VaBQGCQJatkAIIxF1tK7 7hD6ZrCX7IvJ0xGNDa7HzwhZpbYmjxTDnzL35CDK+ugaVKcKDZU0HfgZxjgNGnS/0hQi uyiNMClKKGagCvJHMPNFEphX36gesyew49N7ukYc/2Elx43xkZjJluwFEF+gp/DABQE3 ub/Kr4JKKw8cWb1Z2gS229eUICiYvorvjmsiQVg+XVfSDkCRvLNu9RCzng3nj36UQ3WW e6c8XJx4D1ex1S6EEsaLaXMMgBfkjB2SIKzlES1UI++5w7HSCEYskcvim7jU5ru7iJbZ Hafw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VbZjNOps; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=V0nEWxFU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170903235100b001b22c8d0dc5si15261693plh.437.2023.06.16.02.29.14; Fri, 16 Jun 2023 02:29:30 -0700 (PDT) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VbZjNOps; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=V0nEWxFU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343983AbjFPJZS (ORCPT + 99 others); Fri, 16 Jun 2023 05:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344018AbjFPJYu (ORCPT ); Fri, 16 Jun 2023 05:24:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C12EA2728; Fri, 16 Jun 2023 02:24:45 -0700 (PDT) Date: Fri, 16 Jun 2023 09:24:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686907484; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=f7gy6MsfQJ3FW/zAGe1eR+9fJ/Ctzbfikdo/p5Z0QRA=; b=VbZjNOpswXEA2d9yw8dRJPGO8TAVmBjWK2IeU+p/qBydwXzsuTRxl+WctLiQBiTUbm3Ind YpEHzxNbZ/h/EoDN8AXPNUyRUF5fyPNqzPgOj6RVmU+6YkO/BQH3OVnYn6ltx7pkEF69DL ypnBs+liKgqHPZGmelrqhesySuLLTaZXVaGqa4ChQg8H4ng2+rKNfOASyoxrgixxVJepb4 P3sromSpXixIOo+eH7ruv/NVYy3b1o9NTsCXiO6vuNVqHzBHNw54KKkuzUTwSFlwGGnUJr H8ODgL/OLkj4d9WE38hdD96Dxft+EwmoPPrSX/wiD+K0SI7oBRVkilfduZ/k4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686907484; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=f7gy6MsfQJ3FW/zAGe1eR+9fJ/Ctzbfikdo/p5Z0QRA=; b=V0nEWxFUBTJ8za2z6MlBiXGfNo4psneoHCSfFNGklFeSutdQWJCMVCJSmj7RVmuzEDjF52 AFJs2UpcjfdHE2AQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230613224545.670360645@linutronix.de> References: <20230613224545.670360645@linutronix.de> MIME-Version: 1.0 Message-ID: <168690748383.404.8801319601606683604.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1768633237326742715?= X-GMAIL-MSGID: =?utf-8?q?1768851002273013380?= The following commit has been merged into the x86/boot branch of tip: Commit-ID: 439e17576eb47f26b78c5bbc72e344d4206d2327 Gitweb: https://git.kernel.org/tip/439e17576eb47f26b78c5bbc72e344d4206d2327 Author: Thomas Gleixner AuthorDate: Wed, 14 Jun 2023 01:39:41 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00 init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Invoke the X86ism mem_encrypt_init() from X86 arch_cpu_finalize_init() and remove the weak fallback from the core code. No functional change. Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230613224545.670360645@linutronix.de --- arch/x86/include/asm/mem_encrypt.h | 7 ++++--- arch/x86/kernel/cpu/common.c | 11 +++++++++++ init/main.c | 13 ------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index b712670..98ce265 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -51,6 +51,8 @@ void __init mem_encrypt_free_decrypted_mem(void); void __init sev_es_init_vc_handling(void); +void __init mem_encrypt_init(void); + #define __bss_decrypted __section(".bss..decrypted") #else /* !CONFIG_AMD_MEM_ENCRYPT */ @@ -83,13 +85,12 @@ early_set_mem_enc_dec_hypercall(unsigned long vaddr, int npages, bool enc) {} static inline void mem_encrypt_free_decrypted_mem(void) { } +static inline void mem_encrypt_init(void) { } + #define __bss_decrypted #endif /* CONFIG_AMD_MEM_ENCRYPT */ -/* Architecture __weak replacement functions */ -void __init mem_encrypt_init(void); - void add_encrypt_protection_map(void); /* diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 18612e5..5ee8b31 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2414,4 +2415,14 @@ void __init arch_cpu_finalize_init(void) } else { fpu__init_check_bugs(); } + + /* + * This needs to be called before any devices perform DMA + * operations that might use the SWIOTLB bounce buffers. It will + * mark the bounce buffers as decrypted so that their usage will + * not cause "plain-text" data to be decrypted when accessed. It + * must be called after late_time_init() so that Hyper-V x86/x64 + * hypercalls work when the SWIOTLB bounce buffers are decrypted. + */ + mem_encrypt_init(); } diff --git a/init/main.c b/init/main.c index c968c19..32c65f2 100644 --- a/init/main.c +++ b/init/main.c @@ -95,7 +95,6 @@ #include #include #include -#include #include #include #include @@ -786,8 +785,6 @@ void __init __weak thread_stack_cache_init(void) } #endif -void __init __weak mem_encrypt_init(void) { } - void __init __weak poking_init(void) { } void __init __weak pgtable_cache_init(void) { } @@ -1043,16 +1040,6 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v arch_cpu_finalize_init(); - /* - * This needs to be called before any devices perform DMA - * operations that might use the SWIOTLB bounce buffers. It will - * mark the bounce buffers as decrypted so that their usage will - * not cause "plain-text" data to be decrypted when accessed. It - * must be called after late_time_init() so that Hyper-V x86/x64 - * hypercalls work when the SWIOTLB bounce buffers are decrypted. - */ - mem_encrypt_init(); - pid_idr_init(); anon_vma_init(); #ifdef CONFIG_X86