Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3380260rwl; Mon, 27 Mar 2023 13:12:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bmIkitkGiofuHd1PyrgVhw2CUXNYLuPtI9mF/Lr57eZcMa2YVEv+Xka3FBTQMQUX16u/hY X-Received: by 2002:a17:906:e08b:b0:933:3aa7:57a6 with SMTP id gh11-20020a170906e08b00b009333aa757a6mr14080582ejb.12.1679947926092; Mon, 27 Mar 2023 13:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679947926; cv=none; d=google.com; s=arc-20160816; b=u9k9hs1lO4nkJzY5V95lRzSj09w2pr4Jc7RPVBtmEmbILoaZ5FMiqTQbW9wmwWQ4LT fgFPNfklMlng6O+3TEo4mAD5phSP6MbDgtzXf5lOIMU3fz0AASpqltMoztGh3E+Uxaad QZm/RB53Iy0hwEdLL+KoNrneqiw85v9CjMZokH8+aWBf6xKnmDwPFCH6HbuDbTIlCJbK kfiZY3iP9QOuItK96zMCzd0VklImPkEVc9BA1z7cHU37lyyUxAEwhdzrIbRAur6v7BAm NEJ7dPUeKP60SZUXDPUVK01pl7CoKutKAtekRJdtopoFKU4GTMMN085/SZ+Jmatgn7T6 PosQ== 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=B+c5GdlWj1yBxvFb1qVwQW6Ns/qLp2fdd2CY1LbeZ3w=; b=Q8+2HA5iX5wgKjjzQUSJoyGRYHqhLFKBCnIkwX5LHqeUHR9KkSM4XS/WKLd3ABk5Df qWvSUuHb5XkLTF8NsLUENQpOGa1tNVMMDm//GtKjqqFkAWacaBf+Se9NmH9qkl1+12fN DYzjUOgr+kVw0nuSRjFN3ufPl8LIqAdKE/+oX+OsfNAPYQbObqzzwPIWQaXwHxE5X/Vn UUbMLdWV+izvJqr87eG7YlCRUYA3Z9rdvOQXGXnuuZI6eVoCXEonRjnhUWwe6ZV5nQVh neAw7becGB/M/IFmrPjgWmjjHYB/wiMYt8GlYT8YdF+z1hMYh7x9hPG0riOFV3JPTZ8w 4whw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UPB4pYqJ; dkim=neutral (no key) header.i=@linutronix.de header.b=V2bvNWBN; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a170906014200b008ca8e21134esi30833831ejh.281.2023.03.27.13.11.41; Mon, 27 Mar 2023 13:12:06 -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=UPB4pYqJ; dkim=neutral (no key) header.i=@linutronix.de header.b=V2bvNWBN; 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 S232489AbjC0UKC (ORCPT + 99 others); Mon, 27 Mar 2023 16:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232200AbjC0UJ6 (ORCPT ); Mon, 27 Mar 2023 16:09:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CDFE198D; Mon, 27 Mar 2023 13:09:55 -0700 (PDT) Date: Mon, 27 Mar 2023 20:09:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679947793; 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=B+c5GdlWj1yBxvFb1qVwQW6Ns/qLp2fdd2CY1LbeZ3w=; b=UPB4pYqJK32LmtsStt47YBM5CDrySrZmFa05YJxi6WH/xF2894Fr1R47DJbeNiubHoplfk FYvcP+iyC7OH01QT/pk9xoIT/9xEzYA1VOl/mu7uLsOa0jtKqaOEtWDJgDEkF3xrxqnyO2 RacJxgU1cnOeOb5gJ3eJmniHZTbfEjhTgP/9SNDz+5PJlUkdbiHyaeECnXzRn8iOkdteoA ke+qTQe3rQP10Hg53nheUj3FSTxE+awlmuH2g6EmgXI2Ej9nM1eh9qelpX4fxNW1Vb7Fku EmXdBHv4k3N/jDymuswibbBjMXZZWUgDaHmkFx6PZ1Xq3/hwl+tsSzbbLu74xA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679947793; 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=B+c5GdlWj1yBxvFb1qVwQW6Ns/qLp2fdd2CY1LbeZ3w=; b=V2bvNWBNqq6K5bMlp+hxHd+GH0OokcOZLZxr4rQZQ0S7l4+QlQg1xbnqXtD0ICARWAyeLN fOavEpzc43CGUpAw== From: "tip-bot2 for Michael Kelley" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] init: Call mem_encrypt_init() after Hyper-V hypercall init is done Cc: Michael Kelley , "Borislav Petkov (AMD)" , Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1678329614-3482-6-git-send-email-mikelley@microsoft.com> References: <1678329614-3482-6-git-send-email-mikelley@microsoft.com> MIME-Version: 1.0 Message-ID: <167994779275.5837.4752888881557420711.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/sev branch of tip: Commit-ID: e45e761b77bc0739e7e23258c4394013bbb919c7 Gitweb: https://git.kernel.org/tip/e45e761b77bc0739e7e23258c4394013bbb919c7 Author: Michael Kelley AuthorDate: Wed, 08 Mar 2023 18:40:06 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 27 Mar 2023 09:24:01 +02:00 init: Call mem_encrypt_init() after Hyper-V hypercall init is done Full Hyper-V initialization, including support for hypercalls, is done as an apic_post_init callback via late_time_init(). mem_encrypt_init() needs to make hypercalls when it marks swiotlb memory as decrypted. But mem_encrypt_init() is currently called a few lines before late_time_init(), so the hypercalls don't work. Fix this by moving mem_encrypt_init() after late_time_init() and related clock initializations. The intervening initializations don't do any I/O that requires the swiotlb, so moving mem_encrypt_init() slightly later has no impact. Signed-off-by: Michael Kelley Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/1678329614-3482-6-git-send-email-mikelley@microsoft.com --- init/main.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/init/main.c b/init/main.c index 4425d17..7e9c0ca 100644 --- a/init/main.c +++ b/init/main.c @@ -1088,14 +1088,6 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) */ locking_selftest(); - /* - * 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. - */ - mem_encrypt_init(); - #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && !initrd_below_start_ok && page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) { @@ -1112,6 +1104,17 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) late_time_init(); sched_clock_init(); calibrate_delay(); + + /* + * 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