From patchwork Thu Jun 14 16:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138579 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2336066lji; Thu, 14 Jun 2018 09:34:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMymvjQJtKE92yregtnrLsJ25B5GHupATsyjyM0j8EXf4OuGO7VHUa3Aff7fKZbfyj8WgG X-Received: by 2002:a50:ccc8:: with SMTP id b8-v6mr3250693edj.98.1528994081488; Thu, 14 Jun 2018 09:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528994081; cv=none; d=google.com; s=arc-20160816; b=PDR/PQpAMlB/1laKBfTnSYZyDeRKMOIoLZp8LuWy3T0pKHATYxbV9mPsIdUbvg5ze9 wcEZotpn7MaM0SrIqKxkhBw/212B75WHoGeFAgPUCaRzNON/t9WrDivx8E7nYWWSPFGC ZJd3DnWEP0D/62AKShkw3R4YueH2Cw8uEXtEcu+6Txg2BDdZ6mo6MRubhID2YLv6GAGf 2Wb+ao3xHzNPsLnNfi+8ba8UFWyUZuztHUnbzij5ab/lTCkEEAt6rTkDzN70hbZj2pLv eqQ5N9X8lkkSPgsC61ZouZxdXsd2OLhVvbih5qGSSQQCS2tDqzfDSDEPPjt/cJtFrOOo nXkA== 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=uGAk8kFg6LURcHy3QGbkFwr9HqH/h2jfCcBBvU4IIM8=; b=g9Tg9QwkrGFDN6fvtMmwe4tFWn5WLm6u8/NjSF7XSoIjH0rnqQm58Boi2CeqYAmKaT PKIN33m5k/v0bLr0nRvAleGpXGOwdXw8BiSQBpIgp8aVzvFrsGnPEdyrq26mzflD+WcR 7AWGJrEULY7CNNCFjJCHYWpJ0/gMtTo00WYpv8M3m16PwpSmJ2Mt8BFeT/eyu6zZvhcF zwqG/STi59HL8XuJXPcH0RTW6uAiBINuQ5Y9tOncJ86DNrwbB2n7ktE/J8a0qjYn7cds K7cEDZp+oF5R6KZDWR5K2TZK07u+zD1dpqH2GaVhs5qeNSVHLZdeBL+kT1Z21dJgTnN8 oT/Q== 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 e36-v6si4372859eda.181.2018.06.14.09.34.32; Thu, 14 Jun 2018 09:34:41 -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 C2E52C21DF3; Thu, 14 Jun 2018 16:34:15 +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 40013C21E1A; Thu, 14 Jun 2018 16:33:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D8B54C21C2C; Thu, 14 Jun 2018 16:33:35 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 874FEC21DA2 for ; Thu, 14 Jun 2018 16:33:35 +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 BF45FAF7E; Thu, 14 Jun 2018 16:33:34 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Thu, 14 Jun 2018 18:33:30 +0200 Message-Id: <20180614163334.46827-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180614163334.46827-1-agraf@suse.de> References: <20180614163334.46827-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 07/11] 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 --- arch/sandbox/cpu/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index cde0b055a6..b4f1e22cb2 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,18 @@ void longjmp(jmp_buf jmp, int ret) while (1) ; } + +/* + * 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); +}