From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by mx.groups.io with SMTP id smtpd.web11.468.1572587836258200321 for ; Thu, 31 Oct 2019 22:57:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@solid-run-com.20150623.gappssmtp.com header.s=20150623 header.b=uk7lXKwb; spf=pass (domain: solid-run.com, ip: 209.85.166.46, mailfrom: jon@solid-run.com) Received: by mail-io1-f46.google.com with SMTP id 1so9767050iou.4 for ; Thu, 31 Oct 2019 22:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solid-run-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bbxE8yohyvikyP+D99EyZDwYdKm0CqBj+cNOC23hky8=; b=uk7lXKwbBgIeQ56J3Z8PuaMzoMICrnIAQRQkfcSIC4ew6MJuK3c+3QIvFRZ99BTCLD wb/DIzirlF5kbYGx/4jjyrBuk2vIfvED4t3PbcAhQ2iBz2l/CLHt8h3QS1bYSFV1rsS5 rxXLZBTCmWpQmIyY/9iLzghcGmJr5FDTOVoIxTgdLOTkcHUUir/0zJ3Xb9nTTtWSFmN3 mvkEJ/9hWOSRFr92lROUCIHVm8WRzEA3OZ2dPI4LJoYoyy5bdPIRQ+87kdclfWZIkrjo Ll7wX3ZlA/eXLSkuzkhw7HuJXoJobecihIxC3WnwypgbXbgRdHkHC4aqeBY5xwcuI91k h0cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bbxE8yohyvikyP+D99EyZDwYdKm0CqBj+cNOC23hky8=; b=IxdSodjINTQA5VWnPqWLFj14bpQXvif7Quu6/JUpGysi3N5Z0yJUSaCjjqz70z0CTV eOmyy/es4axGPLi3Ef+6Zs/tRXZmIoEmv2ZlNxKvHTJ1w75mLbMnzqKPz3LAbhIc8HmZ YeyenpZi1A1FNBZZ2hzp62gXdFBE64esqlEeSKFzV93sdtwz7WlgFhn00FAOq1zJI655 BkZKno6ig23BTZnFmvBnmFBlAnI2dbEog8JnZ+Hz2dP/UAXgi7RQfVBZVV3pLDzPYlh3 RMUIb7ImmhGhYUqHb5Zi2vSdOOM3IfsWKChZydVPx9+ULKEgJr6uo5xReUDR181tbU+w UqMQ== X-Gm-Message-State: APjAAAUQ8Scdwmu8CcSV2h2R2tiNXQy78KMS43rm8C5S6ufMh0ppfb1n g+LNIhMWP9kZz5Ab5J1ldW6b8sN9K/389z7yHEHOaw== X-Google-Smtp-Source: APXvYqyvRR88o0nalyA0LNAZ3QrmVxpV4XDK3OvLS2gEe4/uq10flptTVwJ1TJGjAJXWlbhNkZCQqxpIDHcQgmy4xqo= X-Received: by 2002:a6b:6c0e:: with SMTP id a14mr5800652ioh.181.1572587835590; Thu, 31 Oct 2019 22:57:15 -0700 (PDT) MIME-Version: 1.0 References: <40EC82CF-65F6-407D-BA67-09E284DB3EBC@apple.com> In-Reply-To: <40EC82CF-65F6-407D-BA67-09E284DB3EBC@apple.com> From: "Jon Nettleton" Date: Fri, 1 Nov 2019 06:56:38 +0100 Message-ID: Subject: Re: [edk2-devel] Question regarding MMIO address space exposed from GetMemoryMap To: "Andrew Fish via Groups.Io" Cc: devel@edk2.groups.io Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Oct 31, 2019 at 5:44 PM Andrew Fish via Groups.Io wrote: > > Jon, > > Its a little confusing but gBS->GetMemoryMap () only returns information= about DRAM and any address that requires a kernel virtual address mapping = in EFI. The OS calls EFI Runtime Services from a kernel virtual mapping so = the memory map is also involved in the hand shake to communicate the virtua= l address mappings to EFI. Thus any MMIO region in the EFI Memory Map shoul= d always have the EFI_MEMORY_RUNTIME attribute set. The most common MMIO r= egion to be mapped is the NOR FLASH to support the EFI Runtime Variable ser= vices. > > On a UEFI system MMIO regions are described to the OS via ACPI. Processi= ng the ACPI tables requires an interpreter, and source to an interpreter is= available at the ACPI CA site [1]. > > The PI (Platform Initialization) Spec has a concept called the Global Co= herency Domain (GCD) [2]. The GCD is the map for who owns the CPU address a= nd IO (x86 in/out instructions not MMIO) space. You can dump the GCD info v= ia gDS->GetMemorySpaceMap(). The idea is the DRAM controller would carve ou= t a EfiGcdMemoryTypeSystemMemory range, and the PCI Host Bridge would carve= out a EfiGcdMemoryTypeMemoryMappedIo range, etc. > > Note: A UEFI implementation is not required to be constructed out of PI = Spec components, but the EDKII UEFI implementation is constructed using the= PI Specification. > > [1] https://acpica.org/downloads/uefi-support > [2] Sorry I could not make up a better name at the time. > > Thanks, > > Andrew Fish > > > On Oct 31, 2019, at 1:32 AM, Jon Nettleton wrote: > > > > I am working on sorting out a failure on test 605 of the SBSA test. > > The test is "Where a memory access is to an unpopulated part of the > > addressable memory space, accesses must be terminated in a manner that > > is presented to the PE as either a precise Data Abort or that causes a > > system error interrupt or an SPI or LPI interrupt to be delivered to > > the GIC." The issue is that the random test address that was chosen > > 0x04200000 falls directly in the middle of the Qoriq configuration, > > control, and status register (CCSR) address space. This is an area in > > the memory space that provides CPU access to the device registers. > > > > An entry is added for this region in the VirtualMemoryMap, and > > registered with the attribute, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE. > > However only a handful of devices are being registered so only a > > couple of ranges are showing up in memmap as MMIO. > > > > The SBSA test in question gets the memorymap and starts at the address > > mentioned above and looks for the first chunk of memory that is free > > and then attempts to access the memory and is looking for a Data > > Abort. Of course a data abort is not generated because 0x04200000 is > > a valid address. If you offset this to 0x42000000 then a DA is > > generated as expected and the test passes. > > > > There is a very old thread started by Ard, "MMIO regions in > > GetMemoryMap ()", in which he questions if all the MMIO regions should > > be reported by GetMemoryMap() or only the ones being used by > > initialized devices, which is what the current implementation does. > > The end result of the thread was the current implementation is > > correct. That leaves me with the question, "What is the proper > > solution for the current implementation that I am working with?" > > > > To me it seems like I need a special Library that on boot goes through > > and claims and maps every valid MMIO slot in this region, and then > > have the drivers use this library for proxying requests to > > gDS->AddMemorySpace (), gDS->SetMemorySpaceAttributes () etc. If > > there is a standardized way to deal with this configuration I would > > much rather follow that. > > > > Thanks for any input, > > Jon > > > > > > > > >=20 > Andrew, Thanks for clearing this up. I definitely understand the relationships much better now. I am still uncertain of the proper way to fix this issue regarding the SBSA peripheral test. The test is using gBS->GetMemoryMap in order to look for available memory segments, which according to the earlier thread and your confirmation "gBS->GetMemoryMap () only returns information about DRAM and any address that requires a kernel virtual address mapping in EFI.", which means that this test will never work on this platform because the address that was randomly chosen just happens to fall right into the address range for the device addresses that are valid so won't produce a DA, but aren't being used by EFI therefore don't require a virtual address mapping in EFI. Is this something I should bring up with the SBSA group? -Jon