Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3071534rwa; Mon, 22 Aug 2022 20:46:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR4j+atep13Y2xfIEPpYV8PdT+SgQoo5svXDwQRtHpMs1TicISI+d6qUL5tmEsmpjinicpmG X-Received: by 2002:a17:902:ced2:b0:16e:e19b:c5c9 with SMTP id d18-20020a170902ced200b0016ee19bc5c9mr23699298plg.136.1661226382708; Mon, 22 Aug 2022 20:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661226382; cv=none; d=google.com; s=arc-20160816; b=avVvl45rim4ntVGg9Abh05IvStKdqAQ8sSOLvVHqKB2AXhCU+tHY4MU46z5VcvBzAS s+j70N+vTFclNICZkRHIJ5UbvMRy1kDKnRMgp7cHye1Ds1BYQ4i5vF9+LCb0PbPLoj1J k+SBa/jsP7a/wm/Eawldk9hxRz8f7Oz4gx4OclDRdav5CzbX5pkifLn4/7eGRsuAbBuM rKht/B8lp9w08fcB+2eUDUsj6PbGtn5htf7BEgP04bJKs/uQPqVJqwDX6SzKDGb82AJ4 C9TpnJXeEPdsUq7Ytoj1FufMrEjgbln4Z8BmwpXBXX0WrGdaIJ+XbjZn5VUxus5Oe8GM tu5A== 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=xWRgLQXm9q7CKzbsKFuDGBF+mqKoBiOjGcP+au+AxI0=; b=QMN7L+Rf1labqVYH7SIMl8lwqvnuImrpNTsB2j4VDadet06nUV8Mo1dCwdAC6z9pS0 sZrFjefURu7PHTSsoj59vk3rgDlJWJLVvg/g7TquJXBQ2nMfKH4ne09Wr+s1Ml2bhRlK U2ixiTFgM2ycIdDp8qZUamhSKXDgnMt5YWzLzvrWXj6XLPUmy6oiZs8BM0UCX+Ffg3mz cFxusJp1400t67+2TlO0/OCtJCzfX+X8OghRMLZhxo/6jXUcqHs3fY3CGXZd7XTnKFdG 6MAw82UujTd61POCEFyLUvGfHGBjExYFJ1WMSVfN5iHLvdAejtkV74L56sx83zWZodls jFeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cqC+FgFf; 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 pf6-20020a17090b1d8600b001f561cba131si16977658pjb.179.2022.08.22.20.46.11; Mon, 22 Aug 2022 20:46:22 -0700 (PDT) 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=cqC+FgFf; 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 S239856AbiHWDMF (ORCPT + 99 others); Mon, 22 Aug 2022 23:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240360AbiHWDLb (ORCPT ); Mon, 22 Aug 2022 23:11:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF01C27E; Mon, 22 Aug 2022 20:11:30 -0700 (PDT) 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 8D692612B5; Tue, 23 Aug 2022 03:11:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F082AC43470; Tue, 23 Aug 2022 03:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661224290; bh=xWRgLQXm9q7CKzbsKFuDGBF+mqKoBiOjGcP+au+AxI0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cqC+FgFfzi+hlqGtjVWRTRufP32Fi+D+TNJ64Yuk++Mzi2UJYdwINrEV5pxDwTVq9 nHFEmRrK1dyftnuEK+pItaQHzzRrMzaFrzkXWqXlwq5k8gMytNUdvqEPN6Xzb2+0si tR8CiycLDRBQRahG8lFuRIoTWG1rHLoZZmpqCNrGWVxBmP91Y9On7JaC8wZqhfx9eN HDS/j1Jq/qxsa80xPepvCV7MnzUSBa77nVkSV7bWbZF5HlgGWbI1Tn05FaN1eZTtNr oG2UEEeXzBlEitJZ2EwZZmbpupisU5nOn3k+5J1S5HWyyS10WyJJGG7gXdFa+9X8EJ 4tfEagMm1l4gw== Received: by mail-vs1-f50.google.com with SMTP id n125so13197437vsc.5; Mon, 22 Aug 2022 20:11:29 -0700 (PDT) X-Gm-Message-State: ACgBeo1a3Lkge+iGyrZB3qRAtWywcPtewerH9G+np6xwDpd/dLFdf8ib Y+OFjgU5i59iAXOEWJQ6AuOzwSEbDwExMpGdGZU= X-Received: by 2002:a05:6102:3a70:b0:390:81fc:3f39 with SMTP id bf16-20020a0561023a7000b0039081fc3f39mr214676vsb.84.1661224288952; Mon, 22 Aug 2022 20:11:28 -0700 (PDT) MIME-Version: 1.0 References: <20220819102037.2697798-1-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Tue, 23 Aug 2022 11:11:16 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3] LoongArch: Add efistub booting support To: Ard Biesheuvel Cc: Huacai Chen , Arnd Bergmann , loongarch@lists.linux.dev, linux-arch , Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-efi , LKML , Xi Ruoyao Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 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 Hi, Ard, On Tue, Aug 23, 2022 at 2:03 AM Ard Biesheuvel wrote: > > On Mon, 22 Aug 2022 at 12:44, Ard Biesheuvel wrote: > > > > On Fri, 19 Aug 2022 at 12:20, Huacai Chen wrote: > > > > > > This patch adds efistub booting support, which is the standard UEFI boot > > > protocol for us to use. > > > > > > We use generic efistub, which means we can pass boot information (i.e., > > > system table, memory map, kernel command line, initrd) via a light FDT > > > and drop a lot of non-standard code. > > > > > > We use a flat mapping to map the efi runtime in the kernel's address > > > space. In efi, VA = PA; in kernel, VA = PA + PAGE_OFFSET. As a result, > > > flat mapping is not identity mapping, SetVirtualAddressMap() is still > > > needed for the efi runtime. > > > > > > Tested-by: Xi Ruoyao > > > Signed-off-by: Huacai Chen > > > --- > > > V1 --> V2: > > > 1, Call SetVirtualAddressMap() in stub; > > > 2, Use core kernel data directly in alloc_screen_info(); > > > 3, Remove the magic number in MS-DOS header; > > > 4, Disable EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER; > > > 5, Some other small changes suggested by Ard Biesheuvel. > > > > > > V2 --> V3: > > > 1, Adjust Makefile to adapt zboot; > > > 2, Introduce EFI_RT_VIRTUAL_OFFSET instead of changing flat_va_mapping. > > > > > > > Thanks for the update. > > > > I am going to queue this up in the efi/next tree. However, due to the > > many changes to arch/loongarch in this patch, conflicts are not > > unlikely, so I created a signed stable tag for the patch that you can > > merge into the loongarch arch tree if you want. > > > > *However*, you must *not* rebase your tree after merging this tag. > > Therefore, it is probably best that the merge of this tag appears as > > the very first change on your PR to Linus for v6.1. Everything after > > can be rebased at will (assuming there are no other impediments to > > doing so) > > > > You can fetch it and merge it like so: > > > > git fetch -t git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git > > git verify-tag efi-loongarch-for-v6.1 # if you like > > git merge efi-loongarch-for-v6.1 > > > > and all your other v6.1 changes can go on top. > > > > This way, you can resolve conflicts locally without affecting the EFI > > changes going via the other tree. The EFI stub for LoongArch change > > will arrive into Linus's tree via whichever tree he pulls first: the > > LoongArch one or the EFI one. > > > > I will rebase my zboot decompressor changes on top of this - I will cc > > you again, as the LoongArch builds ok but still does not boot. > > > > I have pushed a branch here that includes EFI decompressor support for LoongArch > > https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=efi-decompressor-v4 > > You will need to enable CONFIG_EFI_ZBOOT and build the zImage.efi > target. The resulting image should be bootable jus tlike the > vmlinux.efi but for some reason, it produces the crash I reported > earlier. > > Please give it a try, and if you manage to figure out what's wrong > with my code, please let me know :-) I will try zboot on my real machine. For the code, I prefer vmlinuz.efi rather than zImage.efi for LoongArch since it keeps the naming consistency. Huacai > > Thanks, > Ard.