From patchwork Fri Jun 15 12:42:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138678 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp798836lji; Fri, 15 Jun 2018 05:44:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/FTbod7ID8jymc0dnwOriYpS8lJuUf9Fkw/qV7pDkrwLCSHJic1ZGMk8K+h9VAxb8Lb/G X-Received: by 2002:a50:a666:: with SMTP id d93-v6mr1761271edc.294.1529066641391; Fri, 15 Jun 2018 05:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066641; cv=none; d=google.com; s=arc-20160816; b=C8xPf6NfNA5C77Lk8bQZrAcNXkX3mBpn2iRLoOI3vA1pYn/2DgUEnHHPmzbvmu2T5E 9/iveQMqWgnhzNjuP55oLGGeNWtnM+H9HYejziNlpa6+UqX/5eguGqMm7/yZsoawJEdE JYcc0aEpzq5o0DgYDWZKOXjYgZemAXXQCr8SoQv1GAxotwFGwf3KplgmskdRWo28m4AH RFUBqcpiS7ShettVsz6aLg/oCRdKPc/SpDzQ1m9g32xaSiJIAynpwNDtuqDywzBBdH1S um2uTbsKPcg0FCCPWRFvTpEWHn/pGJMAupdarS6io1zSnFvZCWYcyRlEyX7iZ1HCaBuc J4NQ== 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=CvRrI0zXDXVvVSkHEV4+LyjZlR3w4oYtRsCfXoK3lWw=; b=ogGmjVwE+KFkyCFzmuN8Ee2rGWjaDe8RCLElazWxEb85ZMyYHmcI1Y81wzFUB6dr/q +UsHh52c5HiDdI7Mim+URovgjjMLHpcEcw9HMMbfaFy45ToKFVT0rIqL8ZuAeIV7I0H+ k+Iz/CDLu4G549ualMSt0uAzNfxDbowKAqRaxtelGYpNf23gZtL+kfy4xRJCNSVnvzk3 yzNw+y70E0N4HvMoo06KepCLuKAEyATb7r4bbUjIHJjQaqBc6CT4y1W82KGjeFzisaJN eskqer1AhX+BALWpAnE56ISdFcYPI7Xf/N+kqM+Je9XXAiw2FYxfEczFj5J4m89uiMT5 wXOQ== 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 19-v6si4882671edz.385.2018.06.15.05.44.01; Fri, 15 Jun 2018 05:44:01 -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 EC3D0C21E85; Fri, 15 Jun 2018 12:43:28 +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 EADD1C21EB9; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DD239C21E29; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id A061CC21E68 for ; Fri, 15 Jun 2018 12:42:31 +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 0133CAF85; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:19 +0200 Message-Id: <20180615124229.35310-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 07/17] 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 --- 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..23d8b70648 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) ; } + +#ifdef CONFIG_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