Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2595808pxm; Mon, 28 Feb 2022 02:13:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHxEF+1ZlfsBGOXgl8djHs8DeUBOShVbJLQd1FtYAN30UC/ucmGESHVn4nv4jb0KKG7y2r X-Received: by 2002:a17:906:1613:b0:6cf:1161:eab6 with SMTP id m19-20020a170906161300b006cf1161eab6mr14341603ejd.315.1646043213845; Mon, 28 Feb 2022 02:13:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646043213; cv=none; d=google.com; s=arc-20160816; b=FcJvGO7O/xkOn6PUqJ4arlnj5KpfwQGbPdKMQGZxAvakGL6Au5nJiLU4GBaqAQpkD+ rscVU0Smz92ofzemFNwQqluD0OUVtN++sIAWRRkFJWtOrmoID0WtjcpliXyhEsU3+NVE LcJ3ETHN9RtJ/w27Q+9vAHPdg75wbTh/yy33qT7XS3Na38C5nqSBi1i6C8OA0j8TxvID k/I0/mE9jvu+l7x87m3gEArPv5xOfmVI3zVV/yCZTRCnk8SjUmIthP7E6pUdzM4XrkZb 2aQ/+fuoVdGm0AiwFVStltymoq9UMyqN1ca13UH/PIWP1tZc9SA3LDzLpXLyq4p31YxK 5/wg== 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=wxppMdjI8V7Nntw1NEb8CW65vPq+VTi7aLoJ9Nzx9Uc=; b=Tj8cA63t4MfTWLuyTeJ2alGc7UaJxQw074AJbcvPin37MxuIGuW691KVp53aAaMsaZ PignMXZpe2UC4xySkU/+eHmxuQpw6P3EMc5VXtZkyzNI2+eIk/lHbDULbOG0/blol0As qM26pVeiudRbfvngd5tfudZ337BL5ks2Z77cJ3OOm/4QvDEiE0r1miolaIRuaKr8X5dc eiZ4JLltuClUZ6/ramdxwcKAE2qTDxD+J4Gc7Bh+uKl+uk1TLDRXhGNFxhUOcZv3izhN wRDf4qTxPhlY/MUFt2DOWf7fbr2IyTM4BqlQvCpWZ1CeY/E75/GwDEXxm36sKuod6XzT mdCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OmdX19ka; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a50bec5000000b00410f19a61a1si6992427edk.120.2022.02.28.02.13.11; Mon, 28 Feb 2022 02:13:33 -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=@kernel.org header.s=k20201202 header.b=OmdX19ka; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233542AbiB1IKE (ORCPT + 99 others); Mon, 28 Feb 2022 03:10:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbiB1IKA (ORCPT ); Mon, 28 Feb 2022 03:10:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3981B692B8; Mon, 28 Feb 2022 00:09:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C984F6112E; Mon, 28 Feb 2022 08:09:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33190C340F4; Mon, 28 Feb 2022 08:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646035761; bh=PExA9eVPgTY2q4PKJWJAKXGvdazs5vyTea5Swc8L/KU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OmdX19kaY0LUIEeh5kP/NeE6tESCaXCF3/uJGnILNjQW9u4pMRnLzC1o0WopwV7XW h4iz1fnDf/FTy8J/vHc19A9YDHeWx3jNb2d86kJwBCRAbKxjze4b+OepOulZtneiJN tdLt2cm6CV3NRptbMA/+rJaGl0Nsy7KIWbMUIIQ7PQeaLLhlbTNW0XAu3JaLbP/5ip PFI3tm+YqB8Wcps5a34G9UYzydFNt41uOr4qQ3VTJuMNRs9B+KJU+e8oxDfXDMx1IE 4RauivEOiRRl1633u7BRUQhPtOWSsj3Q7LzPtcNGfnu+hOHLeMUQ3mhTwPwp9ZM9wL XdVet7MTY8EAQ== Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-2d07c4a0d06so97952967b3.13; Mon, 28 Feb 2022 00:09:21 -0800 (PST) X-Gm-Message-State: AOAM530mcLDh3RCMWLQ4ednItkOC7r54ht+8b1sN3Sb17bVT7aQbwBbJ /+VqnPtxJYbyh0oESvl95Vput84FBdkMXCbkiKs= X-Received: by 2002:a81:84d5:0:b0:2d1:e85:bf04 with SMTP id u204-20020a8184d5000000b002d10e85bf04mr19223230ywf.465.1646035760199; Mon, 28 Feb 2022 00:09:20 -0800 (PST) MIME-Version: 1.0 References: <20220226110338.77547-1-chenhuacai@loongson.cn> <20220226110338.77547-10-chenhuacai@loongson.cn> In-Reply-To: From: Ard Biesheuvel Date: Mon, 28 Feb 2022 09:09:08 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V6 09/22] LoongArch: Add boot and setup routines To: Huacai Chen Cc: Greg Kroah-Hartman , Huacai Chen , "Rafael J. Wysocki" , Len Brown , Arnd Bergmann , 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=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Mon, 28 Feb 2022 at 07:34, Huacai Chen wrote: > > Hi, Ard and Greg, > > On Mon, Feb 28, 2022 at 12:40 AM Greg Kroah-Hartman > wrote: > > > > On Sun, Feb 27, 2022 at 03:14:30PM +0100, Ard Biesheuvel wrote: > > > (add Greg and ACPI maintainers) > > > > > > On Sat, 26 Feb 2022 at 12:11, Huacai Chen wrote: > > > > > > > > This patch adds basic boot, setup and reset routines for LoongArch. > > > > LoongArch uses UEFI-based firmware. The firmware uses ACPI and DMI/ > > > > SMBIOS to pass configuration information to the Linux kernel (in elf > > > > format). > > > > > > > > Now the boot information passed to kernel is like this: > > > > 1, kernel get 3 register values (a0, a1 and a2) from bootloader. > > > > 2, a0 is "argc", a1 is "argv", so "kernel cmdline" comes from a0/a1. > > > > 3, a2 is "environ", which is a pointer to "struct bootparamsinterface". > > > > 4, "struct bootparamsinterface" include a "systemtable" pointer, whose > > > > type is "efi_system_table_t". Most configuration information, include > > > > ACPI tables and SMBIOS tables, come from here. > > > > > > > > Cc: Ard Biesheuvel > > > > Cc: linux-efi@vger.kernel.org > > > > Signed-off-by: Huacai Chen > > > > --- > > > > arch/loongarch/include/asm/acenv.h | 17 + > > > > arch/loongarch/include/asm/acpi.h | 38 ++ > > > > arch/loongarch/include/asm/boot_param.h | 97 +++++ > > > > arch/loongarch/include/asm/bootinfo.h | 33 ++ > > > > arch/loongarch/include/asm/dmi.h | 24 ++ > > > > arch/loongarch/include/asm/efi.h | 33 ++ > > > > arch/loongarch/include/asm/fw.h | 18 + > > > > arch/loongarch/include/asm/reboot.h | 10 + > > > > arch/loongarch/include/asm/setup.h | 21 + > > > > arch/loongarch/kernel/acpi.c | 338 ++++++++++++++++ > > > > arch/loongarch/kernel/cacheinfo.c | 122 ++++++ > > > > arch/loongarch/kernel/cmdline.c | 31 ++ > > > > arch/loongarch/kernel/cpu-probe.c | 305 +++++++++++++++ > > > > arch/loongarch/kernel/efi.c | 208 ++++++++++ > > > > arch/loongarch/kernel/env.c | 176 +++++++++ > > > > arch/loongarch/kernel/head.S | 72 ++++ > > > > arch/loongarch/kernel/mem.c | 89 +++++ > > > > arch/loongarch/kernel/reset.c | 90 +++++ > > > > arch/loongarch/kernel/setup.c | 495 ++++++++++++++++++++++++ > > > > arch/loongarch/kernel/time.c | 220 +++++++++++ > > > > arch/loongarch/kernel/topology.c | 13 + > > > > 21 files changed, 2450 insertions(+) > > > > > > As I pointed out in response to an earlier revision of this code, I > > > don't think we should merge this until we decide on some ground rules > > > regarding the support level of this architecture in the UEFI and ACPI > > > subsystems. > > > > > > The problem is that loongarch does not exist in the ACPI or UEFI > > > specifications at all, and as I understand it, the firmware > > > implementations themselves do not implement UEFI or ACPI entirely, > > > they simply present data structures in memory that look similar enough > > > for the Linux UEFI and ACPI code to boot the OS. > > > > Why isn't this in the ACPI/UEFI specs? Is it a lack of access to the > > spec groups by the comapny making these devices, or something else? > We have tried our best to make LoongArch parts be in ACPI and UEFI SPECs. > > ECR for adding LoongArch support in ACPI: > https://mantis.uefi.org/mantis/view.php?id=2203 > > ECR for adding LoongArch support in ACPI (version update): > https://mantis.uefi.org/mantis/view.php?id=2268 > > ECR for adding LoongArch support in UEFI: > https://mantis.uefi.org/mantis/view.php?id=2313 > > ACPI changes of LoongArch have been approved in the last year, but the > new version of ACPI SPEC hasn't been made public yet. And UEFI changes > of LoongArch are under review now. > > Is it a must that the kernel code be merged after all SPECs are > public? If not, I think we can provide some snapshots (If it is legal, > I'm not sure) of mantis.uefi.org to prove the above. > Thanks for the links, those with access will be able to review, although it would of course be preferable if this was open access. In any case, if UEFI and ACPI support is going to be ratified in the respective specifications, we are in a much better place to support this in Linux going forward. However, that still doesn't mean you should be using the internal API used between the EFI stub and the core kernel as a boot interface. Instead, you should implement LoongArch support into the EFI stub, and build the kernel as a PE/COFF image that can boot from EFI directly, from UEFI compliant firmware (u-boot or EDK2 are the most common examples) that exposes all the UEFI stuff that the EFI stub relies on. RISC-V is a useful reference for the changes needed - this is the most recent addition to the EFI stub, and avoids some legacy stuff that new architectures have no need for. Alternatively, if ACPI is what you are after mostly, to describe the platform to the OS, you could expose the ACPI tables to the OS without relying on UEFI, although this should be part of the LoongArch bindings in the ACPI spec too. -- Ard.