From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org 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 7337221B02822 for ; Tue, 27 Nov 2018 09:26:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6310D80F93; Tue, 27 Nov 2018 17:26:25 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-96.rdu2.redhat.com [10.10.120.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 154B45D9CA; Tue, 27 Nov 2018 17:26:23 +0000 (UTC) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Andrew Jones , Auger Eric References: <20181127145418.11992-1-ard.biesheuvel@linaro.org> <20181127145418.11992-3-ard.biesheuvel@linaro.org> From: Laszlo Ersek Message-ID: <761d65bc-2e63-b061-258a-d7f6915371cf@redhat.com> Date: Tue, 27 Nov 2018 18:26:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181127145418.11992-3-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 27 Nov 2018 17:26:25 +0000 (UTC) Subject: Re: [PATCH v2 2/2] ArmVirtPkg/QemuVirtMemInfoLib: remove 1:1 mapping of top of PA range X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2018 17:26:26 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/27/18 15:54, Ard Biesheuvel wrote: > Currently, we map DRAM as EFI_MEMORY_WB, and the remainder of the > entire virtual address space is mapped with EFI_MEMORY_UC attributes, > regardless of whether any devices actually reside there. > > Now that we are relaxing the address space limit to more than 40 bits, > mapping all that address space actually takes up more space in page > tables than we have so far made available as temporary RAM. So let's > get rid of the mapping rather than increasing the available RAM, given > that the mapping is not particularly useful anyway. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c > index 815ca145b644..70863abb2e7b 100644 > --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c > +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c > @@ -73,21 +73,14 @@ ArmVirtGetMemoryMap ( > VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase; > VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; > > - // Peripheral space after DRAM > - VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length; > - VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase; > - VirtualMemoryTable[2].Length = TopOfAddressSpace - > - VirtualMemoryTable[2].PhysicalBase; > - VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; > - > // Remap the FD region as normal executable memory > - VirtualMemoryTable[3].PhysicalBase = PcdGet64 (PcdFdBaseAddress); > - VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase; > - VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize); > - VirtualMemoryTable[3].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > + VirtualMemoryTable[2].PhysicalBase = PcdGet64 (PcdFdBaseAddress); > + VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase; > + VirtualMemoryTable[2].Length = FixedPcdGet32 (PcdFdSize); > + VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > // End of Table > - ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR)); > + ZeroMem (&VirtualMemoryTable[3], sizeof (ARM_MEMORY_REGION_DESCRIPTOR)); > > *VirtualMemoryMap = VirtualMemoryTable; > } > (1) This supplants your other series "[PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit" minimally due to a contextual conflict; is that right? (2) Regarding the patch itself. Currently we have: - VirtualMemoryTable[0]: "System DRAM" - VirtualMemoryTable[1]: "Peripheral space before DRAM" - VirtualMemoryTable[2]: "Peripheral space after DRAM" - VirtualMemoryTable[3]: "Remap the FD region as normal executable memory" Let's see what is affected, from the physical map in QEMU's "hw/arm/virt.c", if we evict VirtualMemoryTable[2]: /* Additional 64 MB redist region (can contain up to 512 redistributors) */ [VIRT_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, [VIRT_PCIE_ECAM_HIGH] = { 0x4010000000ULL, 0x10000000 }, /* Second PCIe window, 512GB wide at the 512GB boundary */ [VIRT_PCIE_MMIO_HIGH] = { 0x8000000000ULL, 0x8000000000ULL }, I have no idea about VIRT_GIC_REDIST2, but, given that in ArmVirtQemu we do uniprocessor only, it doesn't seem worrisome. VIRT_PCIE_ECAM_HIGH should be handled by patch #1. (VIRT_PCIE_ECAM_HIGH *replaces* [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, if memory serves.) VIRT_PCIE_MMIO_HIGH is *in addition* to [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, but we need not do anything about that specifically, because we advertize it to PciHostBridgeDxe via our FdtPciHostBridgeLib instance, and PciHostBridgeDxe handles the GCD aspects for the range automatically. So, together with patch #1, I think this is safe. If we catch a data abort anyway, we'll have to clean up the GCD handling in other drivers. Reviewed-by: Laszlo Ersek Thanks LAszlo