From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.221.65; helo=mail-wr1-f65.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D16921191F5E for ; Tue, 27 Nov 2018 07:28:41 -0800 (PST) Received: by mail-wr1-f65.google.com with SMTP id t27so15168680wra.6 for ; Tue, 27 Nov 2018 07:28:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eLc1y/AepUVHp84VNj92SbaFTO+0+7qdv/7YJxY4XbU=; b=qhUFa04HFwA8umyRPRu/yu71WZ12+4m0RsSEAabSxVf1HsdYn6CHKMeteFJ7cPFdeo Gjt8lDO53dVUvSIRz2EeEsnaOIlr/1KYmCjdX6JUTcstru6ydqonkHGT6W7zS4AnVSuO 751oL0Bs25J7mbWvxahmtR7xRiZszV+++aXzjTE913ITm9mIAV6RQ3UQ2j9SjR5P0DWs HIaxXe5U2ygeBQ3AqSNf928dk95ahWsMv89GYQCRyJPGaDpdI5bvr2xuGSeVYjkiXzff xEeYF1FWlZJJThyBzaBN88I7LvyEXoH1ZoDDzA3DoSaxYrvDb63+V5Fqtllc6mRRrWFU Z2hQ== X-Gm-Message-State: AA+aEWYxftzP+r7KbVSmgUdG1bkLNl33R55t9Lt8LPXuoG9XuYtamw5Z ZQw6kSUWneZJ1DQFuUW1+JgWQA== X-Google-Smtp-Source: AFSGD/W41klRgiq7ffLtdw/TE1z+xaE4fOGo2LpT2rWEL5uPvORq9/UeKfXomstJ0vMLJF6Fxiqc+A== X-Received: by 2002:adf:be0f:: with SMTP id n15mr28972091wrh.267.1543332519904; Tue, 27 Nov 2018 07:28:39 -0800 (PST) Received: from ?IPv6:2a01:e35:8a1f:dc10:bc9e:f614:2d6b:7cc9? ([2a01:e35:8a1f:dc10:bc9e:f614:2d6b:7cc9]) by smtp.gmail.com with ESMTPSA id p125-v6sm2568188wmp.2.2018.11.27.07.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 07:28:38 -0800 (PST) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Laszlo Ersek , Eric Auger , Andrew Jones References: <20181127145418.11992-1-ard.biesheuvel@linaro.org> <20181127145418.11992-2-ard.biesheuvel@linaro.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <569e1e92-7cd5-be5d-9361-39b116622761@redhat.com> Date: Tue, 27 Nov 2018 16:28:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181127145418.11992-2-ard.biesheuvel@linaro.org> Subject: Re: [PATCH v2 1/2] ArmVirtPkg/FdtPciHostBridgeLib: map ECAM and I/O spaces in GCD memory map 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 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 X-List-Received-Date: Tue, 27 Nov 2018 15:28:41 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 27/11/18 15:54, Ard Biesheuvel wrote: > Up until now, we have been getting away with not declaring the ECAM > and translated I/O spaces at all in the GCD memory map, simply because > we map the entire address space with device attributes in the early PEI > code, and so these regions will be mapped wherever they end up. > > Now that we are about to make changes to how ArmVirtQemu reasons > about the size of the address space, it would be better to get rid > of this mapping of the entire address space, since it can get > arbitrarily large without real benefit. > > So start by mapping the ECAM and translated I/O spaces explicitly, > instead of relying on the early PEI mapping. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf | 1 + > ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 46 +++++++++++++++++++- > 2 files changed, 46 insertions(+), 1 deletion(-) > > diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf > index 0995f4b7a156..4011336a353b 100644 > --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf > +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf > @@ -42,6 +42,7 @@ [Packages] > [LibraryClasses] > DebugLib > DevicePathLib > + DxeServicesTableLib > MemoryAllocationLib > PciPcdProducerLib > > diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c > index 5b9c887db35d..ba177353122e 100644 > --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c > +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -82,6 +83,33 @@ typedef struct { > #define DTB_PCI_HOST_RANGE_IO BIT24 > #define DTB_PCI_HOST_RANGE_TYPEMASK (BIT31 | BIT30 | BIT29 | BIT25 | BIT24) > > +STATIC > +EFI_STATUS > +MapGcdMmioSpace ( > + IN UINT64 Base, > + IN UINT64 Size > + ) > +{ > + EFI_STATUS Status; > + > + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, Base, Size, > + EFI_MEMORY_UC); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, > + "%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n", > + __FUNCTION__, Base, Size)); > + return Status; > + } > + > + Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, > + "%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n", > + __FUNCTION__, Base, Size)); > + } > + return Status; > +} > + > STATIC > EFI_STATUS > ProcessPciHost ( > @@ -266,7 +294,23 @@ ProcessPciHost ( > "Io[0x%Lx+0x%Lx)@0x%Lx Mem32[0x%Lx+0x%Lx)@0x0 Mem64[0x%Lx+0x%Lx)@0x0\n", > __FUNCTION__, ConfigBase, ConfigSize, *BusMin, *BusMax, *IoBase, *IoSize, > IoTranslation, *Mmio32Base, *Mmio32Size, *Mmio64Base, *Mmio64Size)); > - return EFI_SUCCESS; > + > + // Map the ECAM space in the GCD memory map > + Status = MapGcdMmioSpace (ConfigBase, ConfigSize); > + ASSERT_EFI_ERROR (Status); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Map the MMIO window that provides I/O access - the PCI host bridge code > + // is not aware of this translation and so it will only map the I/O view > + // in the GCD I/O map. > + // > + Status = MapGcdMmioSpace (IoTranslation, *IoSize); > + ASSERT_EFI_ERROR (Status); > + > + return Status; > } > > STATIC PCI_ROOT_BRIDGE mRootBridge; > LGTM: Reviewed-by: Philippe Mathieu-Daudé