From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AB05E21AE30C7 for ; Thu, 1 Jun 2017 02:09:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4975780470; Thu, 1 Jun 2017 09:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4975780470 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4975780470 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-77.phx2.redhat.com [10.3.116.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11FC8171BC; Thu, 1 Jun 2017 09:10:49 +0000 (UTC) To: Jordan Justen , Brijesh Singh , edk2-devel@lists.01.org Cc: Thomas.Lendacky@amd.com, leo.duran@amd.com, Jeff Fan , Liming Gao , Jiewen Yao References: <1495809845-32472-1-git-send-email-brijesh.singh@amd.com> <149583274037.25973.13062338567511386932@jljusten-skl> <6ecd0138-454e-6a6e-d034-beaf63466120@redhat.com> <149609029319.5770.13917390389219314003@jljusten-skl> <14301d64-9fa3-8231-42c1-52c2dcd9f96f@amd.com> <149630284935.10663.16670660897918560882@jljusten-skl> From: Laszlo Ersek Message-ID: Date: Thu, 1 Jun 2017 11:10:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <149630284935.10663.16670660897918560882@jljusten-skl> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Jun 2017 09:10:52 +0000 (UTC) Subject: Re: [PATCH v6 00/17] x86: Secure Encrypted Virtualization (AMD) X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jun 2017 09:09:51 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 06/01/17 09:40, Jordan Justen wrote: > On 2017-05-29 14:59:46, Brijesh Singh wrote: >> >> >> On 5/29/17 3:38 PM, Jordan Justen wrote: >>> On 2017-05-29 04:16:15, Laszlo Ersek wrote: >>>> (looks like I was the one to comment as second reviewer after all :) ) >>>> >>>> On 05/26/17 23:05, Jordan Justen wrote: >>>>> On 2017-05-26 07:43:48, Brijesh Singh wrote: >>>>>> Changes since v4: >>>>>> - decouple IoMmu protocol implementation from AmdSevDxe into a seperate >>>>>> IoMmuDxe driver. And introduce a placeholder protocol to provide the >>>>>> dependency support for the dependent modules. >>>>> I think you split IoMmuDxe out from AmdSevDxe based on my feedback >>>>> regarding APRIORI, but I don't think this helped. >>>>> >>>>> Ideally I would like to see one driver named IoMmuDxe that is *not* in >>>>> APRIORI. >>>> There are two separate goals here: >>>> >>>> (1) Make sure that any driver that adds MMIO ranges will automatically >>>> add those ranges with the C bit cleared in the PTEs, without actually >>>> knowing about SEV. >>> Ok, this sounds reasonable. >>> >>> The APRIORI method looks like a hack. Why is this not being handled at >>> the time the page tables are being built, in DxeIpl? Couldn't we >>> define a platform Page Tables library to allow a platform to somehow >>> modify the page tables as they are built? Or, maybe just after? This >>> would also make sure it happens before DXE runs. >> >> Before introducing AmdSevDxe driver, we did proposed patches to clear >> the C-bit during the page table creation time. In the first patch [1], >> Leo tried to teach gcd.c to clear the C-bit from MMIO. IIRC, the main >> concern was -- typically Dxecore does not do any CPU specific thing >> hence we should try to find some alternative approach. > > DxeCore doesn't build the page tables. DxeIpl builds them. I agree > that DxeCore is not the right place to handle this. In > https://lists.01.org/pipermail/edk2-devel/2017-March/008987.html > Jiewen suggested that DxeIpl could be updated during page table > creation time. > > In https://lists.01.org/pipermail/edk2-devel/2017-April/009883.html > Leo said that DxeIpl won't work because new I/O ranges might be added. > I don't understand this, because isn't DxeIpl and an early APRIORI > entry are roughly equivalent in the boot sequence? I think you are right. I believe a patch for this exact idea hasn't been posted yet. Jiewen's message that you linked above contains the expression always clear SEV mask for MMIO *and all rest* (emphasis mine), which I think we may have missed *in combination with* the DxeIpl. So the idea would be to iterate over all the HOBs in the DxeIpl PEIM. Keep the C bit set for system memory regions. Clear the C bit for MMIO regions that are known from the HOB list. Also clear the C bit everywhere else in the address space (known from the CPU HOB) where no coverage is provided by any memory resource descriptor HOB. This is going to be harder than the current approach, because: - The current approach can work off of the GCD memory space map, which provides explicit NonExistent entries, covering the entire address space (according to the CPU HOB). - However, the DxeIpl method would take place before entering DXE, so no GCD memory space map would be available -- the "NonExistent" entries would have to be synthesized manually from the address space size (known from the CPU HOB) and the lack of coverage by memory resource descriptor HOBs. Basically, in order to move the current GCD memory space map traversal from early DXE to late PEI, the memory space map building logic of the DXE Core would have to be duplicated in the DxeIpl PEIM. If I understand correctly. (The DxeIpl PEIM may already contain very similar code, for the page table building, which might not be difficult to extend like this -- I haven't looked.) Is this what you have in mind? Thanks Laszlo > -Jordan > >> In second patch >> [2], Leo tried to introduce a new notify protocol to get MMIO add/remove >> events. During discussion Jiewen suggested to look into adding a new >> platform driver into APRIORI to avoid the need for any modifications >> inside the Gcdcore - this seems workable solution which did not require >> adding any CPU specific code inside the Gcd. >> >> [1] https://lists.01.org/pipermail/edk2-devel/2017-March/008974.html >> [2] https://lists.01.org/pipermail/edk2-devel/2017-April/009852.html >>