From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web09.6658.1634200486546201442 for ; Thu, 14 Oct 2021 01:34:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dGXnZNOR; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634200485; 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: in-reply-to:in-reply-to:references:references; bh=wyLh2mCnPoJKW1Yq4rLMyfcBTI/Va9rgZRPVp9BzQ0Y=; b=dGXnZNOROcJK4zPxcfNKBe/WDhGHKGEfV9svMofVrb6Q+1+JE+h79A3pW9MtzIyzDcRU73 8MXbGUu6sTt47GIfar5N2u5z0nOVPMe8jvFbJmcrsr+L2/NYIzvp2a7c4+1Z51YRjl7RuE 8CmmgMqSvOnvt2AzgiuzRmN+/RnlBD8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-SEUYk-qjN1y0cYe0oxr3rg-1; Thu, 14 Oct 2021 04:34:40 -0400 X-MC-Unique: SEUYk-qjN1y0cYe0oxr3rg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DECF1054F97; Thu, 14 Oct 2021 08:34:38 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 247A1100164A; Thu, 14 Oct 2021 08:34:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 36EBF18007AC; Thu, 14 Oct 2021 10:34:36 +0200 (CEST) Date: Thu, 14 Oct 2021 10:34:36 +0200 From: "Gerd Hoffmann" To: Brijesh Singh Cc: devel@edk2.groups.io, James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Erdem Aktas , Michael Roth Subject: Re: [PATCH v9 19/32] OvmfPkg/PlatformPei: validate the system RAM when SNP is active Message-ID: <20211014083436.hcrr3zlfophkc2ue@sirius.home.kraxel.org> References: <20211013165713.727815-1-brijesh.singh@amd.com> <20211013165713.727815-20-brijesh.singh@amd.com> MIME-Version: 1.0 In-Reply-To: <20211013165713.727815-20-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 13, 2021 at 11:57:00AM -0500, Brijesh Singh wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3275 > > When SEV-SNP is active, a memory region mapped encrypted in the page > table must be validated before access. There are two approaches that > can be taken to validate the system RAM detected during the PEI phase: > > 1) Validate on-demand > OR > 2) Validate before access > > On-demand > ========= > If memory is not validated before access, it will cause a #VC > exception with the page-not-validated error code. The VC exception > handler can perform the validation steps. > > The pages that have been validated will need to be tracked to avoid > the double validation scenarios. The range of memory that has not > been validated will need to be communicated to the OS through the > recently introduced unaccepted memory type > https://github.com/microsoft/mu_basecore/pull/66, so that OS can > validate those ranges before using them. > > Validate before access > ====================== > Since the PEI phase detects all the available system RAM, use the > MemEncryptSevSnpValidateSystemRam() function to pre-validate the > system RAM in the PEI phase. > > For now, choose option 2 due to the dependency and the complexity > of the on-demand validation. Acked-by: Gerd Hoffmann