Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp237350rdg; Thu, 12 Oct 2023 04:27:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsYW60Wpgf/Es6eBQaX9AJg/JJWETYTb8NB2h6mNraaC2hd0aUz/iSiRBJygzwAqtltAgm X-Received: by 2002:a17:90a:52:b0:27d:1b04:d6a8 with SMTP id 18-20020a17090a005200b0027d1b04d6a8mr2258274pjb.37.1697110030960; Thu, 12 Oct 2023 04:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697110030; cv=none; d=google.com; s=arc-20160816; b=EYPX273WOq7zLGFcCBvxAXWgZSOLEfDaYm1SnnrSDNFq7TRvN0h6uGKK42M0RH8YdL cLS+meXtQ1tj9XK9cOH0w3nZgmUSx2xK2A4F40mqGOxcWG991O4W8uZhrU0lYJuLYG1L A80SW/xF8Pi1EGuunSrgX78ApIT2WrZ9e3HfzJQ5Cd5l/YCF6MZ/LA5rb97qAuHvmcEp UzW40/Ab7pIErEDZThgaSBYrAzvfi7An2cJLMKAz4BhKQCMCKBqYBtY4QDaDTMpY3m83 hdZoNUuuHdel79bM133G85StmaVwDZ8WQumE3d13qvC901udP314MY/H4jvoVKJREdlX eQ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iK+Tjmc0TTdfbce3c04ch3Mnnfe21bL27N82CyweZ3U=; fh=/rUkaQHXbQ6zL7q+5JrMl+fpLyESiM3Z7Gfhk2Vauvw=; b=BuSVG2b5w61Nrp1vwK4v7Ve8vgQs0k3PKNwZkoB4eO38JXnEJZNOX4C24NgAFTmg9F yy/K4x6fjWGQSc+iqHP7CiMYOKDblugkJ9wTdOgICDFHm2ldBn5xss2EkmwU0qHDapG0 xCHgH/ttil/MF+TbJtlmER3iwp3Hn23PVFDx4/QD6YMBMRmQiWbtx2eWn7kqXj1YrIir MC0pnJFB4uIMHGqgKDeOBR9D1ch74VI+aIkrKiXKP6izxRri2Sz7sjApUIMyp3l1R4J3 /G71xgaDHpBCKBADyyhuUozwYwM/vQK+hKhkGoI0shbrLtUYjMHie7gHVQ+c1c6PIfoY Njdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsXfkzPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id h5-20020a170902680500b001c60ec1e662si1994120plk.29.2023.10.12.04.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:27:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsXfkzPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2DAAF8127252; Thu, 12 Oct 2023 04:27:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343849AbjJLL05 (ORCPT + 99 others); Thu, 12 Oct 2023 07:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343649AbjJLL04 (ORCPT ); Thu, 12 Oct 2023 07:26:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B750E91; Thu, 12 Oct 2023 04:26:55 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D278C433C9; Thu, 12 Oct 2023 11:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697110015; bh=OxWBCI7wG0AAyQX192AstjQVB6dAwe2dWSg9uf6TuJ8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SsXfkzPORilFprGtIIa7c0uqk/VHWgk8cH68cYpiPp+o+6y7Q6QU/gqHbHpfEXO17 /TBxN+ahsU4+xzXW6K4eEef1K4bn3q3bLwiK734JwteSEpEKRkkhWNSFqS71aBzzaO RApg0f57xpkcikEce3mex9mXVmzk1IEZBclkn+PF8fFDpMDiPd9ZKTEX2XeGLJuYAS 63B/Mt1ssgpOE9U9utdN7mD5UT+wAO0CnMj4pk+0xtG4qJ827MAEA2J66VdlIGh/zg Gg0NWXpTc0skCNSZqcV8k8z4/3EDgEGYLWhnJMReQtoH08NW7FrAZozNcIDrlFXomp /iiXoziMSH+1w== Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2c4fdf94666so1930201fa.2; Thu, 12 Oct 2023 04:26:55 -0700 (PDT) X-Gm-Message-State: AOJu0Yzxe8vKf9DHOlyraTcPe2E8Z7OMzKYSG4NQSFZAgP9kCXmTvWDI 3rul+5EFVHBuEUTiAJOit2EQhqqkXbHrOWsKAaE= X-Received: by 2002:a2e:8e8c:0:b0:2c1:7fcf:c974 with SMTP id z12-20020a2e8e8c000000b002c17fcfc974mr20824603ljk.23.1697110013500; Thu, 12 Oct 2023 04:26:53 -0700 (PDT) MIME-Version: 1.0 References: <20231011192528.262425-1-nik.borisov@suse.com> <20231012101456.goamenepqlte65jv@box.shutemov.name> <8e36be57-58a6-404e-8828-6c777b8d2196@suse.com> <20231012112523.6koxkdrk72srx5og@box.shutemov.name> In-Reply-To: <20231012112523.6koxkdrk72srx5og@box.shutemov.name> From: Ard Biesheuvel Date: Thu, 12 Oct 2023 13:26:40 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/efistub: Don't try to print after ExitBootService() To: kirill.shutemov@linux.intel.com Cc: Nikolay Borisov , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:27:08 -0700 (PDT) On Thu, 12 Oct 2023 at 13:25, wrote: > > On Thu, Oct 12, 2023 at 01:51:13PM +0300, Nikolay Borisov wrote: > > > > > > On 12.10.23 =D0=B3. 13:14 =D1=87., kirill.shutemov@linux.intel.com wrot= e: > > > On Wed, Oct 11, 2023 at 10:25:28PM +0300, Nikolay Borisov wrote: > > > > setup_e820() is executed after UEFI's ExitBootService has been call= ed. > > > > 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 resul= ts 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_serv= ice > > by calling exit_boot_func before setup_e820 which ensures the various m= emory > > variables are populated. Is there any specific reason why ExitBootServi= ces > > 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. > Indeed, and note that the memory map may change due to asynchronous events, which only get shut down when ExitBootServices() is called. This is the reason for this complicated dance around ExitBootServices() with the callback etc