From patchwork Thu Jun 14 18:22:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138610 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2456202lji; Thu, 14 Jun 2018 11:28:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5g6BctW6mWCTS+cCu35CDs4VapQPoh+Q+6NrliYEGy4Rc8AP60hOfiUfG0a2aC71LAQz3 X-Received: by 2002:a50:d751:: with SMTP id i17-v6mr3625065edj.260.1529000908228; Thu, 14 Jun 2018 11:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529000908; cv=none; d=google.com; s=arc-20160816; b=d6gBsQ0u+xuDLXmkOHcrdV7JnCWkS3P6kP9jWeef3Q4MzrNUfaG6cXZehB+PEpawyd Mp+kt6pU253rTA/QAT/rzXnmVBYBl+D3peABHhXQ4Bb/C9Tw1k1aG6kTAe95hYVKuRF9 UR+1L/YpzAfXo71ziA55ORdgPU6qwd7cfAJ0aysTzxE4JT2O7Ic0G9gMAOzOnLcEtajs dRSvF+m9dg0EJ7Nk70kvGVGUMFGxkgPo5pAB/jxSEDBLyPqLU3iZIhOUplaEgK/HMCYo VwbGoiqv15WyfXxH3+OpkN7pCdojb8tORwMbhFZo66sQV18zwcFexd/3C6/pgskoqyjW WfWw== 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=xljZojAdnaiZBDfn8BtjShQhuS1OgefHH8DXhHtSlQC4cqsmrjZ1A5sa+kYphOGTtj olfi6BG+LTDoGejg1uNfJn2PiRxk5LlGEEgsXqz/R29rVPFnkf2ZGHF33HtSeOszm+aT zjb7HgUJRGklKAQDtlZMXLGo2ZnGSpuFmIZYeUL3ucc/0mGSuMQVDWJllj/8BSEaQKlg m/HWH1hHZnt2Rao6kl43jKsPYuAgBoYXNCw+pfBEZKmIf/ADy2U/9TxUMx9MZ7X/MmmS iSxjOs2M3ihdIscHoNByInDWE6+b6F8B3qZIAe+iRuv/3Vu/X0BLK8JlzAbWfOnULKNa ssXg== 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 g10-v6si3155393edf.328.2018.06.14.11.28.27; Thu, 14 Jun 2018 11:28:28 -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 A834FC21DE8; Thu, 14 Jun 2018 18:24:40 +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 1C86EC21E34; Thu, 14 Jun 2018 18:22:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 27748C21C2C; Thu, 14 Jun 2018 18:22:35 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 71563C21C27 for ; Thu, 14 Jun 2018 18:22:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D65F2AFBA; Thu, 14 Jun 2018 18:22:34 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Thu, 14 Jun 2018 20:22:28 +0200 Message-Id: <20180614182232.78201-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180614182232.78201-1-agraf@suse.de> References: <20180614182232.78201-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v2 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 --- 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