From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47831C64ED8 for ; Thu, 23 Feb 2023 20:02:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F60C85283; Thu, 23 Feb 2023 21:02:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LIhkRY/u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC79C85283; Thu, 23 Feb 2023 21:02:46 +0100 (CET) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 25EA4854E2 for ; Thu, 23 Feb 2023 21:02:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x529.google.com with SMTP id ec43so45983191edb.8 for ; Thu, 23 Feb 2023 12:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=v1Y5roOBaDywVTccmlHPvSmuZVjLfmlrAmZ2SWKEBP8=; b=LIhkRY/uNwaSEc2u3P/G7YftAF0puLXLxfpokcQklaqDTMTiAT3adPaZ/l8+9uSkXb csLWlRJJH+5yaPK1ouE2Pb11Ad9Lnyvzq9VJNhOPHJW19z8/a5h6TOViyVEdnYm6NyY3 d/g1FBBDpUHb7lwvVzH7hYhVjZTbfkP1oEJ8Rjvar/dS8Qw4yhHxqOaFjC1DdDhA03tL U40ORywJmIDVNKQAg+9LG3rU4QOywPEihrkiBDub3dUpTPnEb/xRhhSvXZY/ENd5dYKZ tLRcT3ZgqA+TPyALKGc45SvbFEl8nCW5elt4q8DY08Zn6OFEpgMQmBAOM7scfqDb93H6 P6DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=v1Y5roOBaDywVTccmlHPvSmuZVjLfmlrAmZ2SWKEBP8=; b=jMV1AR1QE6NhYtoK6aL3c+tJXRq0sJ3F1vOcqEoo6J8GtR0IxGzfYIoS5dprxp4oIZ EjTXGISkZeMrCk0Boc0PCwA8o7yu3C5bDTIn0fyR4U1eaR4HTglVRIRQvR2WtXti4jvB aIESOXELuHkeZgGN41UVCX+hQDIbYvxgMl1U55tRBZDQq1adNtjGG2bEMu2aNFyjfIwr boW48O2LSvceg2NAEYkw4BqHEzX/JHd71aa8RT1HiRdw3E0PrhzrmeGM02m+lX/erFFP lHe3iwI8sZmId4VhoAiasJhhgb/XHzGLwj16PaRgO+lf7rINMwGK2GD5JE0k6o9LcBMw 4zSw== X-Gm-Message-State: AO0yUKUwDxoN3VP6VHKoWjqCwKYRyP0b0vrBEDjrVCZzWuFGGoUYcMXN XKF5/DCGAGgQrdh+BNJKucE01A== X-Google-Smtp-Source: AK7set+RPpjlY0I32rQ32DI66/jYVh7JG/cZNhOqM9Qc6Lnn9NjQPjbvihahdcnM3pGx+RysnrTtUQ== X-Received: by 2002:aa7:d705:0:b0:4ac:b2c8:aeaf with SMTP id t5-20020aa7d705000000b004acb2c8aeafmr14672071edq.26.1677182563632; Thu, 23 Feb 2023 12:02:43 -0800 (PST) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id z17-20020a5096d1000000b004ad7cecaa56sm5560600eda.19.2023.02.23.12.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:02:25 -0800 (PST) Date: Thu, 23 Feb 2023 22:02:19 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Alexandre Ghiti Subject: Re: [PATCH v2 1/1] cmd: bootefi: allocate device-tree copy from high memory Message-ID: References: <20230223192739.6292-1-heinrich.schuchardt@canonical.com> <20230223192739.6292-2-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230223192739.6292-2-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich, On Thu, Feb 23, 2023 at 08:27:39PM +0100, Heinrich Schuchardt wrote: > The bootefi command creates a copy of the device-tree within the first > 127 MiB of memory. This may lead to overwriting previously loaded binaries > (e.g. kernel, initrd). > > Linux EFI stub itself copies U-Boot's copy of the device-tree. This means > there is not restriction for U-Boot to place the device-tree copy to any > address. (Restrictions existed for 32bit ARM before Linux commit > 7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region") > for legacy booting. > > Reported-by: Alexandre Ghiti > Signed-off-by: Heinrich Schuchardt > Tested-by: Alexandre Ghiti > --- > v2: > remove superfluous comment > --- > cmd/bootefi.c | 19 +++---------------- > 1 file changed, 3 insertions(+), 16 deletions(-) > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 6618335ddf..8aa15a64c8 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -204,25 +204,12 @@ static efi_status_t copy_fdt(void **fdtp) > fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); > fdt_size = fdt_pages << EFI_PAGE_SHIFT; > > - /* > - * Safe fdt location is at 127 MiB. > - * On the sandbox convert from the sandbox address space. > - */ > - new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f00000 + > - fdt_size, 0); > - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, > + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, > EFI_ACPI_RECLAIM_MEMORY, fdt_pages, > &new_fdt_addr); > if (ret != EFI_SUCCESS) { > - /* If we can't put it there, put it somewhere */ > - new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size); > - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, > - EFI_ACPI_RECLAIM_MEMORY, fdt_pages, > - &new_fdt_addr); > - if (ret != EFI_SUCCESS) { > - log_err("ERROR: Failed to reserve space for FDT\n"); > - goto done; > - } > + log_err("ERROR: Failed to reserve space for FDT\n"); > + goto done; > } > new_fdt = (void *)(uintptr_t)new_fdt_addr; > memcpy(new_fdt, fdt, fdt_totalsize(fdt)); > -- > 2.38.1 > Reviewed-by: Ilias Apalodimas