Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6489762ybh; Thu, 8 Aug 2019 00:51:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlHEEyzsBIi1u6xRBeW11CKiQKral3R01ZN7G55uwOwmZXKT/bgDcwodTh1Y7E0km40b2T X-Received: by 2002:aa7:8555:: with SMTP id y21mr14079844pfn.104.1565250664001; Thu, 08 Aug 2019 00:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565250663; cv=none; d=google.com; s=arc-20160816; b=WMGUuWVmNDpGgxXWG+k52PPBZIp1GPehAlXbB9xCCFSct+tz4uNnTaJfVVSjDa5PWA YVVSmEJmm4yXHrnBQWgkAYlAyOVLmdnHg7q5wxMOONnUtr8X5p2fKqw+YECTqld2eSHV HVRB81+snz0dFV7YC07M+RXthARylwSw0qfZWAb2U+1NoIOd9Kvm+E+3utnHN3R5it8F SG+3RSs5/zFUVyIO1KoPTctdegG+TfZTMQ7LtZYgJxUCVNQlHtvk4X0o4A2cHaQB6OnA u3a720BAsc32IlqfvnsNmipIX5MKhZ+yapTn6YsJF3A+ZaeTphn/FL4UVwfdp42mhGzM /dqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=LRxvmgwRkkyGdgKxQIBGdxjMKi7K89T4sVppZ2S07cc=; b=leUu5vWIAQZ6CM/jGKRUtTbDxOc5KTtl5hSRvDNn74ko/Uc+61yr5ZR1CAStTs5BLq 86CPKzjXQvBIjUd0WTmykPXJ7/rFbJTsQ4PEzjtHx2FT0TCtouxf68XxO5KDAkbaycOK EDKBy1iYggwqhS7Z6YVxWT97GycgHKKL1O7WCL3WUJBFoPR82Hs6sHDLsb5iWqWZWOFk pWRN+RBzaqPTt1LMiVv+PbYdEdPMKD8LPsG4R+XvY+UVcDjsVDViu2SuVngd+N5pMv4/ lXjQqFM69oKFaLGrXXiZWw0PlerUtZ02aE9AtQSand0jjKQ8bpvE0PRxE265Wari2MWw VdPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si53947139pfh.50.2019.08.08.00.50.48; Thu, 08 Aug 2019 00:51:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731606AbfHHHtM (ORCPT + 99 others); Thu, 8 Aug 2019 03:49:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbfHHHtL (ORCPT ); Thu, 8 Aug 2019 03:49:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4D0B30EA180; Thu, 8 Aug 2019 07:49:10 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-94.pek2.redhat.com [10.72.12.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 484B95D70D; Thu, 8 Aug 2019 07:49:08 +0000 (UTC) Date: Thu, 8 Aug 2019 15:49:04 +0800 From: Dave Young To: Ard Biesheuvel Cc: linux-efi , Kexec Mailing List , Linux Kernel Mailing List , Matthew Garrett , Bhupesh Sharma Subject: Re: [PATCH] do not clean dummy variable in kexec path Message-ID: <20190808074904.GA5300@dhcp-128-65.nay.redhat.com> References: <20190805083553.GA27708@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 08 Aug 2019 07:49:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/05/19 at 06:55pm, Ard Biesheuvel wrote: > On Mon, 5 Aug 2019 at 11:36, Dave Young wrote: > > > > kexec reboot fails randomly in UEFI based kvm guest. The firmware > > just reset while calling efi_delete_dummy_variable(); Unfortunately > > I don't know how to debug the firmware, it is also possible a potential > > problem on real hardware as well although nobody reproduced it. > > > > The intention of efi_delete_dummy_variable is to trigger garbage collection > > when entering virtual mode. But SetVirtualAddressMap can only run once > > for each physical reboot, thus kexec_enter_virtual_mode is not necessarily > > a good place to clean dummy object. > > > > I would argue that this means it is not a good place to *create* the > dummy variable, and if we don't create it, we don't have to delete it > either. > > > Drop efi_delete_dummy_variable so that kexec reboot can work. > > > > Creating it and not deleting it is bad, so please try and see if we > can omit the creation on this code path instead. > Check the code for the dummy var, it is created only in below chunk: arch/x86/platform/efi/quirks.c: efi_query_variable_store(): [snip] /* * We account for that by refusing the write if permitting it would * reduce the available space to under 5KB. This figure was provided by * Samsung, so should be safe. */ if ((remaining_size - size < EFI_MIN_RESERVE) && !efi_no_storage_paranoia) { /* * Triggering garbage collection may require that the firmware * generate a real EFI_OUT_OF_RESOURCES error. We can force * that by attempting to use more space than is available. */ unsigned long dummy_size = remaining_size + 1024; void *dummy = kzalloc(dummy_size, GFP_KERNEL); if (!dummy) return EFI_OUT_OF_RESOURCES; status = efi.set_variable((efi_char16_t *)efi_dummy_name, &EFI_DUMMY_GUID, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, dummy_size, dummy); if (status == EFI_SUCCESS) { /* * This should have failed, so if it didn't make sure * that we delete it... */ efi_delete_dummy_variable(); } [snip] So the dummy var only be created when the if condition matched, also once creating succeeded it is deleted. The deleting while entering virtual mode is always deleting a non exist efi var. Please correct me if I miss something. If above is true, then at least in the kexec path can be dropped because we have a real bug which resets machine. Thanks Dave