Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3931843pxj; Mon, 21 Jun 2021 09:38:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWy4Z70Anq/UaPkX9hG++u3V155I6d/+z1LDgRM4dnrpcYuISmxrlry/BSEcbr7Ak+74jb X-Received: by 2002:a17:906:f899:: with SMTP id lg25mr23306253ejb.122.1624293493779; Mon, 21 Jun 2021 09:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293493; cv=none; d=google.com; s=arc-20160816; b=hC6agkwsP7SioN5/VGY1eo4KFJknbHKt14QJ1YbWhzdw1kDrpvaewGovjOAA0Zel2+ E0AVGzY9nnReyUr6kAPg5ggYfJVNjZMlekHMD/0aoIxEAV93seIRU6zdmmFBkRIbtUXQ J052CM3215tlW+HpFjgE7gUU966R7shL56QR+PSBsh0PCaAkxkVvRZqEqsYHirLBQDCK JXnhwRMiBz6eHPwM65txsVGfgTbe6Owkimuzthkh11rmhA9/Y54ToA6v9B1gdSrqjGVE VklNHIW+Mn0/qg3AB4+LdFcSHF9OAIHSV6IYpk/A4Llnzyi78aEVaJ0Zhm5if1W+6Uv1 okZg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J4+DGq/mbs/cd8owe8kVhxWcwBU8R09PKtQ9hu/9F8I=; b=unB0ITZnSZK0Q10jmEy3X4wZp8nrVpOHp590rv2C8bbFAa6qC/3gmZfUE+RDvhw9Yn RYh63r4oqpba26Pi7dpTTHPNJRekFCywgUzyXd09zibj3zecU4zXFPSoeRubPxQzt3AS yzfWP7hugAPk6o4UUCfXtDeS0fRqm54FQPl4gGMXaz54dJnm2IfutEcY4FAj/a5Z7w7i BS2xdUq1Iw8QS/1hXcc6okIRefBd+DQZqdZlHXjF13AaZpx3KGPxZ/M76BtR6TvFu7Yu uP4K2CpqtJEUS+Ne+q+94A3is55WvGgWFm0EYObl/LN6h5v6Od8V7OxfXADJEMg+S5cC bcNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LM5dbctu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n17si12834675edv.150.2021.06.21.09.37.49; Mon, 21 Jun 2021 09:38:13 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LM5dbctu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbhFUQjA (ORCPT + 99 others); Mon, 21 Jun 2021 12:39:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbhFUQew (ORCPT ); Mon, 21 Jun 2021 12:34:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D8DE6141A; Mon, 21 Jun 2021 16:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292837; bh=Kx5gsh0tLRYTOoK4Dnww7+GDnHFfBKKOzu5ZzMlGyaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LM5dbctuWvNXC1jn+06U8FdeE9v23tnVbEpLuQT5gH/U9MmDbzu8jK07R3XptpGjD lbeM9if3l+E+uXMW3fpxMHUr3/oul+TEyiq9Kz0Rar4MTqUJxvUHCVG/Kj5nK8AWvB 9JkHY5Ew9T7qG8+cJt5rP96dGE+1DIio8RYeDcPM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Tom Lendacky , Borislav Petkov Subject: [PATCH 5.10 120/146] x86/ioremap: Map EFI-reserved memory as encrypted for SEV Date: Mon, 21 Jun 2021 18:15:50 +0200 Message-Id: <20210621154919.000417060@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Lendacky commit 8d651ee9c71bb12fc0c8eb2786b66cbe5aa3e43b upstream. Some drivers require memory that is marked as EFI boot services data. In order for this memory to not be re-used by the kernel after ExitBootServices(), efi_mem_reserve() is used to preserve it by inserting a new EFI memory descriptor and marking it with the EFI_MEMORY_RUNTIME attribute. Under SEV, memory marked with the EFI_MEMORY_RUNTIME attribute needs to be mapped encrypted by Linux, otherwise the kernel might crash at boot like below: EFI Variables Facility v0.08 2004-May-17 general protection fault, probably for non-canonical address 0x3597688770a868b2: 0000 [#1] SMP NOPTI CPU: 13 PID: 1 Comm: swapper/0 Not tainted 5.12.4-2-default #1 openSUSE Tumbleweed Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:efi_mokvar_entry_next [...] Call Trace: efi_mokvar_sysfs_init ? efi_mokvar_table_init do_one_initcall ? __kmalloc kernel_init_freeable ? rest_init kernel_init ret_from_fork Expand the __ioremap_check_other() function to additionally check for this other type of boot data reserved at runtime and indicate that it should be mapped encrypted for an SEV guest. [ bp: Massage commit message. ] Fixes: 58c909022a5a ("efi: Support for MOK variable config table") Reported-by: Joerg Roedel Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel Signed-off-by: Borislav Petkov Tested-by: Joerg Roedel Cc: # 5.10+ Link: https://lkml.kernel.org/r/20210608095439.12668-2-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/ioremap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -118,7 +118,9 @@ static void __ioremap_check_other(resour if (!IS_ENABLED(CONFIG_EFI)) return; - if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA) + if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA || + (efi_mem_type(addr) == EFI_BOOT_SERVICES_DATA && + efi_mem_attributes(addr) & EFI_MEMORY_RUNTIME)) desc->flags |= IORES_MAP_ENCRYPTED; }