From patchwork Mon Jun 18 15:23:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139008 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4087242lji; Mon, 18 Jun 2018 08:29:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJC34niHNaWYfc4djVxkfQWSkC3fFb4/yFVeBEA8wSHhYsf2btAJKFQGHzWvRcedPuaUhVY X-Received: by 2002:a50:9dc3:: with SMTP id l3-v6mr11583524edk.234.1529335760712; Mon, 18 Jun 2018 08:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335760; cv=none; d=google.com; s=arc-20160816; b=SwXPeqvnuyfCn9vjQXGCavMM5EEAU2KiJCqoOEgjV8DGjfKIoYNtztYm0SyRoYs4vi JSZStEh/Ctgmp0WjMN5ZIbCBm+CO4N4HsujUKRmCPtvMX67O8IiXwDT4BaQmasjFjs+v 9A7AniT8Hh0z6rmdze0bVbZeHroQxozhLsIhObkmCzZb+zQptt3sYbihfPpHq2YkhmBq jehVbYSfne0sE9KdEH0+AEkgTPwzr7lAlPbs5NH7HoS92EJxvCnHnKyHeHbf973YjCo5 ZuW14sRQNPHtkR9nAXXPKzCnfiYQNmOpz1oVtoww7D8+92wazrxiIzG7vX0ldtdsLftT Y6Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=hJTepjo+VifVHoq9iCQB+KP7VG8wdfvOW45L96lMNNg=; b=RfVBermfIBdhVTwZeJD8obPZU8ivEL0TpA+WE2zJL2N8HkGLw9B33Vrof0/p6t+MVe /oXjSYG+DxIA/9WUCqqy8OHBjBJhXyRe+tpfZyGQsRomGTzgd2oimv/wlaIfV9wf5SP1 XJ7qlfDvj7UHhHmlmmu2AlMAgeLaV98fCXlJEMF5xzROdE+pvk4fW4NOQ9CsdmAYrUUu 6oHOdbHraBuFH3CkVU3yrEaP6RS4s62Z9qnugG2gtQHNg0xW8OTYdpJg7vqq2xDU1VKr Wqd0qOEKEjF8lPIaLdflBtjBfTpZkAARIOm+CJ2hCk5I8GT4QxfgZEQYeC6yd8tRuaqm +7UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 32-v6si8272477edr.363.2018.06.18.08.29.20; Mon, 18 Jun 2018 08:29:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 4013FC21EDE; Mon, 18 Jun 2018 15:25:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D4573C21F21; Mon, 18 Jun 2018 15:23:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 62D20C21E63; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id BE130C21DFD for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D103FAF6E; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:01 +0200 Message-Id: <20180618152315.34233-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 07/21] sandbox: Map host memory for efi_loader X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With efi_loader we do not control payload applications, so we can not teach them about the difference between virtual and physical addresses. Instead, let's just always map host virtual addresses in the efi memory map. That way we can be sure that all memory allocation functions always return consumable pointers. Signed-off-by: Alexander Graf --- v1 -> v2: - only compile efi_add_known_memory if efi_loader is enabled v3 -> v4: - don't compile efi mapping code in for spl --- arch/sandbox/cpu/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index cde0b055a6..29dac8dfda 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -5,6 +5,7 @@ #define DEBUG #include #include +#include #include #include #include @@ -177,3 +178,22 @@ void longjmp(jmp_buf jmp, int ret) while (1) ; } + +#if CONFIG_IS_ENABLED(EFI_LOADER) + +/* + * In sandbox, we don't have a 1:1 map, so we need to expose + * process addresses instead of U-Boot addresses + */ +void efi_add_known_memory(void) +{ + u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size); + u64 ram_size = gd->ram_size; + u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; + u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + + efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY, + false); +} + +#endif