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 BA6EEC7618A for ; Sun, 19 Mar 2023 19:33:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D572A85C98; Sun, 19 Mar 2023 20:31:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="F7qkI06M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B89285C75; Sun, 19 Mar 2023 20:31:10 +0100 (CET) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 377DA85ABB for ; Sun, 19 Mar 2023 20:30:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pj1-x102f.google.com with SMTP id e15-20020a17090ac20f00b0023d1b009f52so14365175pjt.2 for ; Sun, 19 Mar 2023 12:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679254257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R1LbPbM30yAwiDHDP4WCOC806D6CMn7EINq7agoAHq4=; b=F7qkI06Mlzfi6xRiTvxVxxwaBH/gaXYBKJcWJ+B4IwFMRed1qoDmjbouMzJwQZL+YL 4kNXh3n2iIpTjGnWxV+Lp7HB4Lv1EKslQUDBfekuz0wRTm0NcGeT9HMPnUpr9wC3mAPY 5LdqOS5Dn3umVzm4jrWie6wh2DNgIAB+8plJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679254257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R1LbPbM30yAwiDHDP4WCOC806D6CMn7EINq7agoAHq4=; b=0BWqC7vfQcf10sa6bPsmqnC3DiZON/M/T27LSG6P9dOPygtDUUn5sEc5KnRtdH/d7u OaO7Q2E2DnF/F4+8gXJT24CUGO69yBnSgOiVtTqUaw1Lr8EtIzwMkCRwSFrnC4EVhi3T QaaUUmcmXEFgbEVdWuRVTQSAl2EDUK/+8NOb1WYlX5cWZy7MA5yqH163KoqTfwfJ4rXb hzPuouf1AwbHvp74M2U5EvO4bkiIceB/GB061a8k4sJgwTnnY1JBePj98iP+sBMu2EoC ZB7xy2FlXrDzt5C3KAo8D+hMqFVSE5NbQ/HXFNdjatBi9SfmDYpRQr92CbPQWSU9sAmb A+Qw== X-Gm-Message-State: AO0yUKVaV+kc8e0EkhX7zNEbz1k/YlxP4Xl+F5LqfkjRbnXi8K4B5QEr /Sr5Nz9yz++fSS+vej7iHaw+623//QGO0JytUaQ= X-Google-Smtp-Source: AK7set9hFQMIHjycVLascYU7ErBOzTW8UpKjvQCWR3HNnM/WrmVgsyh1B0/ctxUvmCCm6Ph15zbT4A== X-Received: by 2002:a17:903:11c7:b0:19e:f315:98d with SMTP id q7-20020a17090311c700b0019ef315098dmr18162191plh.43.1679254256921; Sun, 19 Mar 2023 12:30:56 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id v12-20020a1709029a0c00b0019a75ea08e5sm5090651plp.33.2023.03.19.12.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:30:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Simon Glass , Bin Meng Subject: [PATCH v3 05/12] x86: Exit EFI boot services before starting kernel Date: Mon, 20 Mar 2023 08:30:09 +1300 Message-Id: <20230319193017.1084764-6-sjg@chromium.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230319193017.1084764-1-sjg@chromium.org> References: <20230319193017.1084764-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean When running the EFI app, we need to exit boot services before jumping to Linux. At some point it may be possible to jump to Linux and pass on the system table, and: * install the device-tree as configuration table * use LoadImage() to load the kernel image (e.g. from memory) * start the image with StartImage() This should allow the Linux efistub to be used. For now, this is not implemented. Signed-off-by: Simon Glass --- Changes in v3: - Update commit message based on Heinrich's comments arch/x86/lib/bootm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 9beb376bb9c2..61cb7bc61168 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,23 @@ int boot_linux_kernel(ulong setup_base, ulong entry, bool image_64bit) #ifdef CONFIG_SYS_COREBOOT timestamp_add_now(TS_U_BOOT_START_KERNEL); #endif + + /* + * Exit EFI boot services just before jumping, after all console + * output, since the console won't be available afterwards. + */ + if (IS_ENABLED(CONFIG_EFI_APP)) { + int ret; + + ret = efi_store_memory_map(efi_get_priv()); + if (ret) + return ret; + printf("Exiting EFI boot services\n"); + ret = efi_call_exit_boot_services(); + if (ret) + return ret; + } + if (image_64bit) { if (!cpu_has_64bit()) { puts("Cannot boot 64-bit kernel on 32-bit machine\n"); -- 2.40.0.rc1.284.g88254d51c5-goog