Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2788293rwd; Mon, 22 May 2023 04:30:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/pW08RM9nOc222kW9HWNEC4DIbrTQiYbIZYux/vxGQ+xTrc/juX78hThAiGh4TNo1tqKx X-Received: by 2002:a05:6a20:158e:b0:10b:92b8:9845 with SMTP id h14-20020a056a20158e00b0010b92b89845mr3488505pzj.7.1684755052010; Mon, 22 May 2023 04:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684755051; cv=none; d=google.com; s=arc-20160816; b=J967gzhlvAvTikLnLDedbXJX0mdRO0Xw3jk0b2wi0rIAPynBnhMniEk1aFUmHWd1QH 0bsiA6ZKq92wW/T1U+8Dq4kVNG7DKCY0bPySEeKRKcZu7tTGfXrhLHzKxtH1YOGKPe4+ PT+CuJBezYV2KYIWTt7mqPz1sFF4rCGJkBNPiasosb7H05KM01rQYo9t6x4lB5kb1/5W 9Ll+/lwCM9daHFs+n8jCUA7nra8gcGscLltS0jfJ6idfLBoE5B1B4uwgDM+i3F0GGBAI 4FoeP4UohwOQ4GN4t2visCYY84IXXOTbeJZu3uv7qsapC12QbsBDDh3H98SaQU6wYjuy yU8A== 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=ZdnfAW+Fb4PpsvvGmSAR3zR4aDUZ8MefMCa0ZRFQa78=; b=JKCHePK5nZ5r24X541e4lHZ878bdmrEcALtOunGfBIAL10FJmlrv3YxH224QXhxtwK pNsKhts+TX+kUS2oUYf63HYz/BDWZpjI1aVc7Kw4aOz/Pb7ZdhRWv0SVIMjHeHZMQtNj /2BjoZmUZmveSNE547ivXjtNj6ZMHu+aOUZnRHLxocgzYIUVfq/Pz4YGTtaSbjzOHV0b YhmCpEI6DNA0aYnA1Se2AbvMNPUcRklwGqERhQAKfNKBiZahp8t10HK0c+cX4aL7EMZ1 8+MNpBcEDh/S69XjbFlilp7PQrMxflZevSXfhkIDM+Ra6L7DeYokDYD7hajQ8LnEoFbP vjyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GJD6jDN8; 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 w128-20020a623086000000b0064388a82666si4571675pfw.378.2023.05.22.04.30.40; Mon, 22 May 2023 04:30:51 -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=GJD6jDN8; 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 S231138AbjEVLOD (ORCPT + 99 others); Mon, 22 May 2023 07:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232821AbjEVLNd (ORCPT ); Mon, 22 May 2023 07:13:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCEE119BD; Mon, 22 May 2023 04:08:42 -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 67EA8614C6; Mon, 22 May 2023 11:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C47E7C43329; Mon, 22 May 2023 11:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684753721; bh=dZzOa+0jKFOy2FXi+DrUaKGjHvbyRLYaSwG19Q0u4E0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GJD6jDN8N1fH8Sk1+KZCuXl3R0FNqMWXA5rHFwAwOa3B/Q9xfgsF1UeqY4zMbF87f A7dQB5Sj/pzo/ViW4bdXtBoHFIk28+YJIIf78BJ6rYoRR81UkTP/Y21elu87Z8AKSV Nd0jXFnBNo9Kvu+TpAN3l4C+15+ONqQkRT3KjB1BodGx/qmg7lXZmd6wEi3x4XmVw5 lpvGOOcYZC1Xr9Gg7d7OLx2ndfwzfOD8lGMzjE7qyBUOh2RiO2zycUcGt3tJFOdxlT e/PrvebA7SBHmiRm7PxdHUC52vP2hka4ThQKuwKDdZ1Fc4wCM27eolycrdAUv8kRz1 +ZQsvz7c31Atg== Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-4f3bb61f860so1826570e87.3; Mon, 22 May 2023 04:08:41 -0700 (PDT) X-Gm-Message-State: AC+VfDxo3jxqZ/Nz2yGmL/wi88r+Ph/adWlgl00yrnO8HmJBYk5lBPlh 6eZrxrPL/iH2HFV34W9pCVgYeq7eviHGEWkzg88= X-Received: by 2002:ac2:47ee:0:b0:4f3:ab4b:9015 with SMTP id b14-20020ac247ee000000b004f3ab4b9015mr3442452lfp.18.1684753719455; Mon, 22 May 2023 04:08:39 -0700 (PDT) MIME-Version: 1.0 References: <20230518231434.26080-1-kirill.shutemov@linux.intel.com> <20230518231434.26080-5-kirill.shutemov@linux.intel.com> <20230519101641.nka7ty3fttntymci@box.shutemov.name> <20230522110116.675nqxrztxbtmdl7@box.shutemov.name> In-Reply-To: <20230522110116.675nqxrztxbtmdl7@box.shutemov.name> From: Ard Biesheuvel Date: Mon, 22 May 2023 13:08:28 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv12 4/9] x86/boot/compressed: Handle unaccepted memory To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Dave Hansen , Sean Christopherson , Andrew Morton , Joerg Roedel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Liam Merwick 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 On Mon, 22 May 2023 at 13:01, Kirill A. Shutemov wrote: > > On Fri, May 19, 2023 at 01:16:41PM +0300, Kirill A. Shutemov wrote: > > On Fri, May 19, 2023 at 02:14:29AM +0300, Kirill A. Shutemov wrote: > > > diff --git a/arch/x86/boot/compressed/mem.c b/arch/x86/boot/compressed/mem.c > > > index 67594fcb11d9..87372b96d613 100644 > > > --- a/arch/x86/boot/compressed/mem.c > > > +++ b/arch/x86/boot/compressed/mem.c > > > @@ -1,9 +1,32 @@ > > > // SPDX-License-Identifier: GPL-2.0-only > > > > > > #include "error.h" > > > +#include "misc.h" > > > > > > void arch_accept_memory(phys_addr_t start, phys_addr_t end) > > > { > > > /* Platform-specific memory-acceptance call goes here */ > > > error("Cannot accept memory"); > > > } > > > + > > > +void init_unaccepted_memory(void) > > > +{ > > > + guid_t guid = LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID; > > > + struct efi_unaccepted_memory *unaccepted_table; > > > + unsigned long cfg_table_pa; > > > + unsigned int cfg_table_len; > > > + int ret; > > > + > > > + ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len); > > > + if (ret) > > > + error("EFI config table not found."); > > > + > > > + unaccepted_table = (void *)efi_find_vendor_table(boot_params, > > > + cfg_table_pa, > > > + cfg_table_len, > > > + guid); > > > + if (unaccepted_table->version != 1) > > > + error("Unknown version of unaccepted memory table\n"); > > > + > > > + set_unaccepted_table(unaccepted_table); > > > +} > > > > 0-day reported boot failure outdise TDX guest with CONFIG_INTEL_TDX_GUEST=y. > > 0-day folks reported one more issue: booting on non-EFI system fail. > > Updated fixup: > > diff --git a/arch/x86/boot/compressed/mem.c b/arch/x86/boot/compressed/mem.c > index 0108c97399a5..e7f7ef31e581 100644 > --- a/arch/x86/boot/compressed/mem.c > +++ b/arch/x86/boot/compressed/mem.c > @@ -46,8 +46,13 @@ void init_unaccepted_memory(void) > struct efi_unaccepted_memory *unaccepted_table; > unsigned long cfg_table_pa; > unsigned int cfg_table_len; > + enum efi_type et; > int ret; > > + et = efi_get_type(boot_params); > + if (et == EFI_TYPE_NONE) > + return; > + > ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len); > if (ret) > error("EFI config table not found."); > @@ -56,6 +61,9 @@ void init_unaccepted_memory(void) > cfg_table_pa, > cfg_table_len, > guid); > + if (!unaccepted_table) > + return; > + > if (unaccepted_table->version != 1) > error("Unknown version of unaccepted memory table\n"); > With these changes applied, Reviewed-by: Ard Biesheuvel