Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp236792rdg; Thu, 12 Oct 2023 04:25:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGoQgEcPCqKDH+s7Itb9PrqutVNmylTNA0z4UJOuxVC2/D/Q9fVoFvVUSN/7BNKlD2Ml1/ X-Received: by 2002:a05:6808:2209:b0:3ae:614:a788 with SMTP id bd9-20020a056808220900b003ae0614a788mr32179882oib.47.1697109957818; Thu, 12 Oct 2023 04:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697109957; cv=none; d=google.com; s=arc-20160816; b=mYzgSEaaJB7wFlGLquxpf48Wvv/w0wjEBrbn9sqLnfSUtnEMKHcEwe12Y9ixYlAd0r WFldAIID95FD0lgC9KJ35BzmCQHlMIkpzIbFcXmG8n6H9vwPDr6nkhsXP0d1bV9kyj5U pS9g+5aSbJ8BxyMGBoZi2B0fCI4HBIRMQ0Htc3UYkJGNKJp/GfTtrKK8b/fBKP2vutb8 uHrEhUtb50W13ZVUy1USH5UQCQ85BvWC+ywc/ej+oWb4fcUKTpB+8qkPZrRAQUglv5tT u4gXshGjqyM64STPWK/A5et5Dra+RHTjHMm7Xj+ia5aHktq2jTl73MwjnpBwicdUcOAz E4QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1gPzNYsJ2BH2wIb3Jv3iNBCCtDqGSaSzjBjPGDIMQSA=; fh=XBhBNqXahCQYrClVKLVoP+N4FTQFAxGzI62uT9iiwwI=; b=Im3XgZ5NRC+anehcLHZsPOEFFQsbHQ3acmjzNYdqwXCqWrWUh9ZfoUj2Kn5/I4iEOg tNyUh632UBkLVWMSYUFt3r/dcnqJ9Mne+nZrJbU5DMaJzGVNrIMJRpLmxqo93XeVwyZO wOtRqQjmd63i+LWfJ5o9zVyHtwHsPDO69EF10eomvBqVlllIHHs8mzyR/T7AFOJm1CHH TnQW07nwf9nRdPVgL4R3fsB72Gayq4fxTy8qH4+5hEfPSifaxXMcQF6QTjsesAHuDhnC 9z6eK0KsTAzoHwUh7PTm0V18PfbHlP3wvjhSxA/owu6HCaj8Vm4FQLJAnepUTpAWBeWe tMAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="bh/rByC8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id e65-20020a636944000000b00578b26be643si2081329pgc.606.2023.10.12.04.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:25:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="bh/rByC8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C17428065E25; Thu, 12 Oct 2023 04:25:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343849AbjJLLZa (ORCPT + 99 others); Thu, 12 Oct 2023 07:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343812AbjJLLZ3 (ORCPT ); Thu, 12 Oct 2023 07:25:29 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93F091; Thu, 12 Oct 2023 04:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697109927; x=1728645927; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=oJ16RQQC6qiRD4UY3lzsspj/62XsaNODkFID0iZfpso=; b=bh/rByC8qy/JaE+twRevfZRfUkc0WyyVBSRFKMHN01g0bHiyGoe4fR69 R7LSDACZCF7xpW6kSu04f8hIHKY/0Tsxs53mat1xiji+tUOZKhKFNz9jP MTZhGB3Vl6uGMQ/XmvxYtQbrbCUvkVO36a6sqwjiqB1Lu648mM3c9Y7+P M764vx/IpcKpho+98YbdZQk/7d4Zj3jQq0i9EzvF47tP+8ds6M4TNiKHV Ou+yz2GGPrMJ7rs1aGyrClTMNIbMlmWiSpcPtLgWdF+BKU7lVnAhddvzX OjVEDYiSRl9rZxfJaql+gqjsGgXojuhOZurPdgk3cN39EInmsqZFWNNcC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="387734532" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="387734532" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 04:25:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783665676" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="783665676" Received: from nmalinin-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.58.130]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 04:25:26 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 63E6E10A1B1; Thu, 12 Oct 2023 14:25:23 +0300 (+03) Date: Thu, 12 Oct 2023 14:25:23 +0300 From: kirill.shutemov@linux.intel.com To: Nikolay Borisov Cc: ardb@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/efistub: Don't try to print after ExitBootService() Message-ID: <20231012112523.6koxkdrk72srx5og@box.shutemov.name> References: <20231011192528.262425-1-nik.borisov@suse.com> <20231012101456.goamenepqlte65jv@box.shutemov.name> <8e36be57-58a6-404e-8828-6c777b8d2196@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8e36be57-58a6-404e-8828-6c777b8d2196@suse.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:25:43 -0700 (PDT) On Thu, Oct 12, 2023 at 01:51:13PM +0300, Nikolay Borisov wrote: > > > On 12.10.23 г. 13:14 ч., kirill.shutemov@linux.intel.com wrote: > > On Wed, Oct 11, 2023 at 10:25:28PM +0300, Nikolay Borisov wrote: > > > setup_e820() is executed after UEFI's ExitBootService has been called. > > > This causes the firmware to throw an exception because Console IO > > > protocol handler is supposed to work only during boot service > > > environment. As per UEFI 2.9, section 12.1: > > > > > > "This protocol isused to handle input and output of text-based > > > information intended for the system user during the operation of code > > > in the boot services environment." > > > > > > Running a TDX guest with TDVF with unaccepted memory disabled results in > > > the following output: > > > > Oh. My bad. > > > > But there's other codepath that does the same. If setup_e820() fails with > > EFI_BUFFER_TOO_SMALL, efi_stub_entry() would try to print "exit_boot() > > failed\n". > > > > I wouldner if it is feasible to hook up earlyprintk console into > > efi_printk() machinery for after ExitBootService() case? Silent boot > > failure is not the best UX. > > > > > In my testing I was able to transpose setup_e820 and efi exit_boot_service > by calling exit_boot_func before setup_e820 which ensures the various memory > variables are populated. Is there any specific reason why ExitBootServices > is called before setting up the e820 table? AFAIU this is an arbitrary > choice? Because if you allocate memory with EFI service it can alter EFI memory map and we need the last version to convert it to e820. -- Kiryl Shutsemau / Kirill A. Shutemov