Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2129640pxm; Fri, 4 Mar 2022 09:55:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOU3/+DDyqzI/97EYGqdXSyx38YDQOvXseoCSyIoO9GMCKqjbP+749YPMqErVNbX40zpaR X-Received: by 2002:a17:90b:314b:b0:1bf:7c7:d304 with SMTP id ip11-20020a17090b314b00b001bf07c7d304mr11936287pjb.224.1646416509173; Fri, 04 Mar 2022 09:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646416509; cv=none; d=google.com; s=arc-20160816; b=U7t/g4+D1okqt0i7Ca07ZOArWnNCS4BIwBBp6TAIPZc6CJAbJODvTY/OP8hbunKXZw aonwsxS3tIf5qsA3Ut4B3FgzZs1a25sWs4dz/NgTIzmbhf4aA9cjUA+VXr4kRGS8WoC6 vvom7TCTfbDRedxoAvRm+qXVZR3TnkFPRrL0SxYCF+vPpXOIs1FaNpdNAKBQfXVMnobp 90uR9N8c4uiHYb2lvs1h+p25EYQ3h1cS2A7RFQO1gO0oOprTAInEr/YOM+I5LMa6Jh5M NpkQ1voNCD86btrj2N1rYvSBvFzXO7YbUkWCKOBCTcLMUjouLWun+BNTx1t8OyFnlfVG A7EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PwCgFrKVYtlfIz8CnnCvaOjD8UASRKkBxkcuQcJ6l6A=; b=O/VaZm+bPDXZoPtetVOnWIxPqgT7XQN5yYsEpV5+UXU9Wz356vhQdT8UnQcFMjdPhP 1Q0RnvjwqgmizELiM3uV3Ke3KLETurfXgJqbn7leAnEO3vLb8OMUGh6dzNLgffV39E6k ulWjQJ1Sz6kWYnPc3cqYSSrPmSnK1s9nZY28mPLnhFHaWqQfp7bCikRjOp03RDAcGL26 EMIYybbo9rTILFYknx4eCWrHmHiashRbjNFuCKuQECwcIIzB1r9Zxy7gn+17WmeivCeM 41y674WsuVyIt8CWm+blOKoQzuCOISres1/X8gKmGY5CM/1+zjBhEiwLjlx8VYyN0iqT lD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y9ZO8AtQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h189-20020a6383c6000000b0037fef3193f5si359787pge.873.2022.03.04.09.54.52; Fri, 04 Mar 2022 09:55:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y9ZO8AtQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233539AbiCDKYw (ORCPT + 99 others); Fri, 4 Mar 2022 05:24:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiCDKYu (ORCPT ); Fri, 4 Mar 2022 05:24:50 -0500 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 223F14EA21; Fri, 4 Mar 2022 02:24:01 -0800 (PST) Received: by mail-vs1-xe36.google.com with SMTP id d11so8548656vsm.5; Fri, 04 Mar 2022 02:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PwCgFrKVYtlfIz8CnnCvaOjD8UASRKkBxkcuQcJ6l6A=; b=Y9ZO8AtQhlGhlG5+TkZj1HExcNwp0f+E3W8wnWfIr4KqgBPS/5xha/nzqSzOI3zEJZ UjJpihIQgM2LlKg7Z34ZqN4eZAJUIIxth9d1cGuUY8aWp6JU1GyoVbK5LCxpxOi6XQ7S vgE69sJ8/qUPLWVVla3cbDWlG1v0LDZ1gdLky3Dyj+YjfZ/0eWjUukSgy7smOIoRdFXz h8AcwYHbPD0Ci1h9YpAWfxGIiyi3w+0bCPn0w0V8QSw3USqvlfBO5KyUWn+l6WtJQBAT 7PnjX9LjGoEJ+pn2X84Ifk9IsswPhyNO8ANgBc5htWze+QvGJYtzS8Qxhf7QZ2REgyVy aRjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PwCgFrKVYtlfIz8CnnCvaOjD8UASRKkBxkcuQcJ6l6A=; b=tysw6Ca0OodzcMuqDeHGaEIimmcZvPDSTuPH4TiffL36x6fnrr2LGPWfjRDNNP7h1P qAWLWE2GR6wAvuJ4ZfxH2D8BLUSaDjJQYX0uRk7XmTrKdb07s+VPdmOGUiKT5teytrsI 3kFcUmcShqPz4ShDI1ID8f9fRwO0cWu4zzov+afHScIKIU8mAGDruWjHfDT3XtUE23OA HMPFDpjvLPsRhaitsN69fBOyzOAYfovOmYXW8vnkcp/NbUybA3JLqnBIHJ9fM7giPeWG 5Sq9MYMNlvh9kdCJNj3lqZHINRArSlrhRr+/NYQ9Ffd8QveoJAlG3O6vI+H7xtomvC1k XU4w== X-Gm-Message-State: AOAM532jhVcpwxOlrnQtGGA8OP8oJVucyXjmxUYf/SHy2E5bJCecNClv hTvv+mOR3Jf1A3PcvYlug6xOcEwIkVe64SWPpOo= X-Received: by 2002:a05:6102:5589:b0:31b:dff9:3ddb with SMTP id dc9-20020a056102558900b0031bdff93ddbmr16907830vsb.62.1646389440179; Fri, 04 Mar 2022 02:24:00 -0800 (PST) MIME-Version: 1.0 References: <20220226110338.77547-1-chenhuacai@loongson.cn> <20220226110338.77547-10-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Fri, 4 Mar 2022 18:23:47 +0800 Message-ID: Subject: Re: [PATCH V6 09/22] LoongArch: Add boot and setup routines To: Ard Biesheuvel Cc: Arnd Bergmann , Greg Kroah-Hartman , Huacai Chen , "Rafael J. Wysocki" , Len Brown , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch , Linux Doc Mailing List , Linux Kernel Mailing List , Xuefeng Li , Yanteng Si , Jiaxun Yang , linux-efi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Ard & Arnd, On Thu, Mar 3, 2022 at 5:54 PM Ard Biesheuvel wrote: > > On Thu, 3 Mar 2022 at 07:26, Huacai Chen wrote: > > > > Hi, Ard & Arnd, > > > > On Wed, Mar 2, 2022 at 5:20 PM Huacai Chen wrote: > > > > > > Hi, Ard, > > > > > > On Wed, Mar 2, 2022 at 4:58 PM Ard Biesheuvel wrote: > > > > > > > > On Wed, 2 Mar 2022 at 09:56, Huacai Chen wrote: > > > > > > > > > > Hi, Arnd & Ard, > > > > > > > > > > On Tue, Mar 1, 2022 at 6:19 PM Arnd Bergmann wrote: > > > > > > > > > > > > On Tue, Mar 1, 2022 at 5:17 AM Huacai Chen wrote: > > > > > > > On Mon, Feb 28, 2022 at 7:35 PM Ard Biesheuvel wrote: > > > > > > > > On Mon, 28 Feb 2022 at 12:24, Arnd Bergmann wrote: > > > > > > > > > On Mon, Feb 28, 2022 at 11:42 AM Huacai Chen wrote: > > > > > > > > > Can't you just use the UEFI protocol for kernel entry regardless > > > > > > > > > of the bootloader? It seems odd to use a different protocol for loading > > > > > > > > > grub and the kernel, especially if that means you end up having to > > > > > > > > > support both protocols inside of u-boot and grub, in order to chain-load > > > > > > > > > a uefi application like grub. > > > > > > > > > > > > > > > > > > > > > > > > > I think this would make sense. Now that the EFI stub has generic > > > > > > > > support for loading the initrd via a UEFI specific protocol (of which > > > > > > > > u-boot already carries an implementation), booting via UEFI only would > > > > > > > > mean that no Linux boot protocol would need to be defined outside of > > > > > > > > the kernel at all (i.e., where to load the kernel, where to put the > > > > > > > > command line, where to put the initrd, other arch specific rules etc > > > > > > > > etc) UEFI already supports both ACPI and DT boot > > > > > > > > > > > > > > After one night thinking, I agree with Ard that we can use RISCV-style > > > > > > > fdt to support the raw elf kernel at present, and add efistub support > > > > > > > after new UEFI SPEC released. > > > > > > > > > > > > I think that is the opposite of what Ard and I discussed above. > > > > > Hmm, I thought that new UEFI SPEC is a requirement of efistub, maybe I'm wrong? > > > > > > > > > > > > > > > > > > If I'm right, it seems that RISC-V passes a0 (hartid) and a1 (fdt > > > > > > > pointer, which contains cmdline, initrd, etc.) to the raw elf kernel. > > > > > > > And in my opinion, the main drawback of current LoongArch method > > > > > > > (a0=argc a1=argv a2=bootparamsinterface pointer) is it uses a > > > > > > > non-standard method to pass kernel args and initrd. So, can the below > > > > > > > new solution be acceptable? > > > > > > > > > > > > > > a0=bootparamsinterface pointer (the same as a2 in current method) > > > > > > > a1=fdt pointer (contains cmdline, initrd, etc., like RISC-V, I think > > > > > > > this is the standard method) > > > > > > > > > > > > It would seem more logical to me to keep those details as part of the > > > > > > interface between the EFI stub and the kernel, rather than the > > > > > > documented boot interface. > > > > > > > > > > > > You said that there is already grub support using the UEFI > > > > > > loader, so I assume you have a working draft of the boot > > > > > > protocol. Are there still open questions about the interface > > > > > > definition for that preventing you from using it as the only > > > > > > way to enter the kernel from a bootloader? > > > > > Things become simple if we only consider efistub rather than raw elf. > > > > > But there are still some problems: > > > > > 1, We want the first patch series as minimal as possible, efistub > > > > > support will add a lot of code. > > > > > 2, EFISTUB hides the interface between bootloader and raw kernel, but > > > > > the interface does actually exist (efistub itself is also a > > > > > bootloader, though it binds with the raw kernel). In the current > > > > > implementation (a0=argc a1=argv a2=bootparaminterface), we should > > > > > select EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER which is marked as > > > > > deprecated. Is this acceptable? If not, we still need to change the > > > > > bootloader-kernel interface, maybe use the method in my previous > > > > > email? > > > > > > > > Why do you need this? > > > Because in the current implementation (a0=argc a1=argv > > > a2=bootparaminterface), initrd should be passed by cmdline > > > (initrd=xxxx). If without that option, efi_load_initrd_cmdline() will > > > not call handle_cmdline_files(). > > It seems I'm wrong. EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER controls > > "initrd=xxxx" from BIOS to EFISTUB, but has nothing to do with > > a0/a1/a2 usage (which controls the "initrd=xxxx" from efistub to raw > > kernel). The real reason is our UEFI BIOS has an old codebase without > > LoadFile2 support. > > > > The problem with initrd= is that it can only load the initrd from the > same EFI block device that the kernel was loaded from, which is highly > restrictive, and doesn't work with bootloaders that call LoadImage() > on a kernel image loaded into memory. This is why x86 supports passing > the initrd in memory, and provide the base/size via struct bootparams, > and arm64 supports the same using DT. > > The LoadImage2 protocol based method intends to provide a generic > alternative to this, as it uses a pure EFI abstraction, and therefore > does not rely on struct bootparams or DT at all. > > So the LoadImage2() based method is preferred, but if your > architecture implements DT support already, there is nothing > preventing you from passing initrd information directly to the kernel > via the /chosen node. > > > Then, my new questions are: > > 1, Is EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER an unacceptable option > > for a new Arch? If yes, we should backport LoadFile2 support to our > > BIOS. > > See above. > > > 2, We now all agree that EFISTUB is the standard and maybe the only > > way in future. But, can we do the efistub work in the second series, > > in order to make the first series as minimal as possible? (I will > > update the commit message to make it clear that a0/a1/a2 usage is only > > an internal interface between efistub and raw kernel). > > > > I think it would be better to drop the UEFI and ACPI pieces for now, > and resubmit it once the dust has settled around this. FDT support is our future goal, at present we only have ACPI firmware and kernel. I mentioned FDT just wants to replace a0/a1 to pass cmdline, not means we already have FDT support. So, let's keep the existing a0/a1/a2 usage as an internal interface for now, then backport LoadFile2 and add efistub support. Huacai