From: Alexander Graf Date: Thu, 21 Jun 2018 12:13:04 +0200 Subject: [U-Boot] [PATCH v8 22/30] efi: sandbox: Tidy up copy_fdt() to work with sandbox In-Reply-To: References: <20180618140835.195901-1-sjg@chromium.org> <20180618140835.195901-23-sjg@chromium.org> <6c051da7-bd3e-3c27-c6c3-e490a1b21546@suse.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/21/2018 04:01 AM, Simon Glass wrote: > Hi Alex, > > On 18 June 2018 at 09:00, Alexander Graf wrote: >> On 06/18/2018 04:08 PM, Simon Glass wrote: >>> At present this function takes a pointer as its argument, then passes this >>> to efi_allocate_pages(), which actually takes an address. It uses casts, >>> which are not supported on sandbox. >> >> I think this is the big API misunderstanding that caused our disagreements: >> efi_allocate_pages(uint64_t *memory) gets a uint64_t *address as input >> parameter, but uses the same field to actually return a void * pointer. This >> is the function that really converts between virtual and physical address >> space. >> >> This is the explicit wording of the spec[1] page 168: >> >> The AllocatePages() function allocates the requested number of pages and >> returns a pointer to the base address of the page range in the location >> referenced by Memory. > The code at present uses *Memory as the address on both input and > output. The spec is confusing, but I suspect that is what it meant. The spec means *Memory on IN is an address, on OUT is a pointer. It's quite clear on that. Since the functions is available to payloads, we should follow that semantic. >> So yes, we have to cast. There is no other way around it without completely >> creating a trainwreck of the API. > efi_allocate_pages_ext() can do this though. We don't need to copy the > API to efi_allocate_pages(). Yikes. There's no way we'll create a frankenstein not-really-almost EFI API inside U-Boot. Either we stick to the standard or we don't. Alex