Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp641287ybh; Tue, 10 Mar 2020 05:42:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvbYPYTlYpAWiyOgnvY7/lxqO5Qvmhsi5PmDqU5bFSZ30njCtRev9lbSboABwstO3+mFszs X-Received: by 2002:aca:3c45:: with SMTP id j66mr995302oia.62.1583844122816; Tue, 10 Mar 2020 05:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583844122; cv=none; d=google.com; s=arc-20160816; b=Ddt+HzARxVQYJR0H6vxs1/I5D/q6p4ICROrEmDuN3dChCLfTgU7QZ5Irl9XIdXsTAv xTO9QgorZXXUlTJlgyyykcmK05Nm0FSggZJu5GtX0DFg+xt1aD3i3h9hELJ3oCpmFIcC D61bSYjB2GGsSSIvoF2taf7VijuInB5oDRzDzN1dmYMBp3eK75K1vobkLlCBm923jXnr 1rggNmYLvsQScZRaaWAcANRZi9u/LwLQ2J1C793QjuEdDtYZH2I6xryRsFT12763ePbE Q6shyuWXcEZSqoYRIHKGTSNfv2MrzEh0GzcEXWVUxJExlq+kwxmshtuSb3VPh+cjkg+C SHCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JNxa356xMiMYcOhZxcJVg2pdOP2CCzDRhw8kQvxntFE=; b=jsF5r9Aat3AtL9iad8aeBeen+EHx3PAt5v1mysuiHm1nGrnyIjNgbQ03aeblnegDpX 1nUegZUSyl1pUSzEmfd9MqJstpOVFzF64c8jkcNFRsNchnSNj5R++peAMDKB6U1FRplW dslQ87VQ+1L8AMoZKKOLWN0Vf6wJspPRfbZu4bD10s+V6OCyp1q5m+aezeHamyltya2m zkWcxDdVc/5GOYyhDPvYS21JbCTGSIa1ZyPV0i3uIrRM/kTlpnOpS5HLAKOw9pFpjpqQ EVi7JZnp/Mdzpl+z4PfIW2vwwMfSxdxa0iC/RwC7oQNIZJ6JqNR2lyL9hPsllp03zTo+ WsXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=M+1KJt5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si7806339ote.183.2020.03.10.05.41.51; Tue, 10 Mar 2020 05:42:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=M+1KJt5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbgCJMkB (ORCPT + 99 others); Tue, 10 Mar 2020 08:40:01 -0400 Received: from mail.skyhub.de ([5.9.137.197]:35664 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbgCJMkA (ORCPT ); Tue, 10 Mar 2020 08:40:00 -0400 Received: from zn.tnic (p200300EC2F09B400B9A98D8D0B62C6C9.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:b400:b9a9:8d8d:b62:c6c9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id A30A51EC0CD1; Tue, 10 Mar 2020 13:39:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1583843998; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=JNxa356xMiMYcOhZxcJVg2pdOP2CCzDRhw8kQvxntFE=; b=M+1KJt5fj95okOKnzkUz0LTHzVcELFFy3zXGL4rWgw9FhLmqGtVxHOlM6h6722fvTU8YUF 22OW56yTfootMxs8nUT83Pls1jOXkOqlsDVHkq5eTT60bxZ5IZeo1fEsJz5Jm1dolSNNlE yGt8xjj4gt1psneh6e92loQbj9CCLSI= Date: Tue, 10 Mar 2020 13:40:03 +0100 From: Borislav Petkov To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Bruce Rogers , Joerg Roedel Subject: Re: [PATCH] x86/ioremap: Map EFI runtime services data as encrypted for SEV Message-ID: <20200310124003.GE29372@zn.tnic> References: <2d9e16eb5b53dc82665c95c6764b7407719df7a0.1582645327.git.thomas.lendacky@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2d9e16eb5b53dc82665c95c6764b7407719df7a0.1582645327.git.thomas.lendacky@amd.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 25, 2020 at 09:42:07AM -0600, Tom Lendacky wrote: > The dmidecode program fails to properly decode the SMBIOS data supplied > by OVMF/UEFI when running on an SEV guest. The SMBIOS area, under SEV, is > encrypted and resides in reserved memory that is marked as EFI runtime > services data. As a result, when memremap() is attempted for the SMBIOS > data, it can't be mapped as regular RAM (through try_ram_remap()) and, > since the address isn't part of the iomem resources list, it isn't mapped > encrypted through the fallback ioremap(). > > Update __ioremap_check_mem() to set the IORES_MAP_ENCRYPTED flag if SEV is > active and the memory being mapped is part of EFI runtime services data. > This allows any runtime services data, which has been created encrypted, > to be mapped encrypted. > > Cc: Bruce Rogers > Cc: Joerg Roedel > Signed-off-by: Tom Lendacky > --- > arch/x86/mm/ioremap.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c > index 44e4beb4239f..382b6ca66820 100644 > --- a/arch/x86/mm/ioremap.c > +++ b/arch/x86/mm/ioremap.c > @@ -135,6 +135,13 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size, > memset(desc, 0, sizeof(struct ioremap_desc)); > > walk_mem_res(start, end, desc, __ioremap_collect_map_flags); > + > + /* > + * The EFI runtime services data area is not covered by walk_mem_res(), > + * but must be mapped encrypted when SEV is active. > + */ > + if (sev_active() && efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA) > + desc->flags |= IORES_MAP_ENCRYPTED; > } Why isn't this done in __ioremap_check_encrypted() which is exactly for SEV stuff like that? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette