Received: by 10.223.185.116 with SMTP id b49csp3691803wrg; Tue, 6 Mar 2018 03:27:28 -0800 (PST) X-Google-Smtp-Source: AG47ELsTnXgMyZ8VJBL5M+mFWAfiqTy5qAflKhfU/NsDdnTfIYHtvY47omPFVd1lIdAUOoGhpKj7 X-Received: by 2002:a17:902:506:: with SMTP id 6-v6mr16787169plf.365.1520335648075; Tue, 06 Mar 2018 03:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520335648; cv=none; d=google.com; s=arc-20160816; b=KZEYIIKUOSfB0ZUYTz2vWuF1KZG4pxJpTq6dWOYF/5SzZAgbrSLAsDuFzvlWs5a6rw S9p/V2VzpjgaZYxacxgEF0t+qgpBsvwDTi+r8s3/5jyTBuRkIEKjrL1KyIchrkbF2SWn 9EIvwarT42jpo6C7zlhsZcdFnSwxG/In+EQEqua1xSsO1MYsZpnnF+e+rsnQJ5sliwgg B+pkpLOCgiBmPNH5ij60OHqDn/NKjRO888GLRvB27rqNCj3yli7x6er94C7pXLIyl/JE 9BkZXTs50qtOwxAZHl0jJjMwQyaWx229TsZ05LuzMQvuyljPPxRtViSITLILVh3HmMF8 v3Jw== 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:arc-authentication-results; bh=qhvO6w5G2fP5jvVyfBUelJ4rmirSETtF2wQQV9mldoM=; b=ht4Eg3JFslRWgFp8SKZZ+fCghEj9btx/Kce7ILIsTVJ8squr+IyPB+xs6dsiLy3XPM VBv9F6NUDIEQDwEkihbUw3ZauY6vPyBTOhdBzpgWFrGGrfuYhRUbqI1Atbl5fJFa4NhC WdBptDzCoPJEQe5RZcxPhF4FwJQGpTVz6xvcqbSkz1tehwR+JNj5LG2+Pwsp8bSwL6Mc qvtTqNCaStKXI7x1ldCt08+ujjDYLOGxmwxqJzkadJU2yESO0fXfM5XqcEIcTYVwdTyn vogG7VHRQQZPBMsUwCEUBWwG+Cb4lyp53hsDJKMfp1kv0uA0qpXnux5cU+dcCSg/4eP5 sDcg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6-v6si8632698plt.521.2018.03.06.03.27.13; Tue, 06 Mar 2018 03:27:28 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908AbeCFL0S (ORCPT + 99 others); Tue, 6 Mar 2018 06:26:18 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36868 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbeCFL0R (ORCPT ); Tue, 6 Mar 2018 06:26:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB2731435; Tue, 6 Mar 2018 03:26:16 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 097823F24A; Tue, 6 Mar 2018 03:26:13 -0800 (PST) Date: Tue, 6 Mar 2018 11:26:11 +0000 From: Mark Rutland To: Sai Praneeth Prakhya Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Lee@lakrids.cambridge.arm.com, Chun-Yi , Borislav Petkov , Tony Luck , Will Deacon , Dave Hansen , Bhupesh Sharma , Ricardo Neri , Ravi Shankar , Matt Fleming , Peter Zijlstra , Ard Biesheuvel , Dan Williams Subject: Re: [PATCH V2 3/3] efi: Use efi_rts_workqueue to invoke EFI Runtime Services Message-ID: <20180306112610.7izxtuy33bt7ivfs@lakrids.cambridge.arm.com> References: <1520292190-5027-1-git-send-email-sai.praneeth.prakhya@intel.com> <1520292190-5027-4-git-send-email-sai.praneeth.prakhya@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520292190-5027-4-git-send-email-sai.praneeth.prakhya@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 05, 2018 at 03:23:10PM -0800, Sai Praneeth Prakhya wrote: > From: Sai Praneeth > > Presently, efi_runtime_services() are executed by firmware in process > context. To execute efi_runtime_service(), kernel switches the page > directory from swapper_pgd to efi_pgd. However, efi_pgd doesn't have any > user space mappings. A potential issue could be, for instance, an NMI > interrupt (like perf) trying to profile some user data while in efi_pgd. It might be worth pointing out that this could result in disaster (e.g. if the frame pointer happens to point at MMIO in the EFI runtime services mappings). [...] > pstore writes could potentially be invoked in interrupt context and it > uses set_variable<>() and query_variable_info<>() to store logs. If we > invoke efi_runtime_services() through efi_rts_wq while in atomic() > kernel issues a warning ("scheduling wile in atomic") and prints stack > trace. One way to overcome this is to not make the caller process wait > for the worker thread to finish. This approach breaks pstore i.e. the > log messages aren't written to efi variables. Hence, pstore calls > efi_runtime_services() without using efi_rts_wq or in other words > efi_rts_wq will be used unconditionally for all the > efi_runtime_services() except set_variable<>() and > query_variable_info<>() Can't NMIs still come in during this? ... or do we assume that since something has already gone wrong, this doesn't matter? Otherwise, this doesn't seem to break basic stuff on arm64 platforms. I can boot up, read the EFI RTC, and reboot. I ahd lockdep and KASAN enabled, I received no splats from either. FWIW: Tested-by: Mark Rutland