Received: by 10.223.185.116 with SMTP id b49csp5867096wrg; Wed, 7 Mar 2018 20:34:14 -0800 (PST) X-Google-Smtp-Source: AG47ELvHi8K/u+NHmyepr+/UQUBltIsc9r2m1IWK9HbGEbfThH9GHyKGB74yqmk9PPSFs13vXfE/ X-Received: by 10.99.106.71 with SMTP id f68mr20156684pgc.262.1520483654184; Wed, 07 Mar 2018 20:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520483654; cv=none; d=google.com; s=arc-20160816; b=rzOZbgOJNLa+emuJLw3pwmzoyygyRAYkVWBwifOz6yhzYpCkgZlOtcZPnDILPMlChw 6nyn2cOgXHvQXrXVc1H5YtvGufhOVaK7qWjfk+oDB9yHtshU4GBz4UGyUfm7bSa1Sdxg 73c1navcCSFtuSo2SkCabDQcuXvbx1AXjmukxfvLaHIpiz6ox+LhA+uSyaFmviDYTmef 5O1QbDdHBEdeRpcbJBlOiJ+xsi/NrdGNArkj3o5YqITKmxLMhjOw/RjRKErGnkNmbO4r TWDqRg52YHpJVZxUJ8NkL9pu2EkgLaGHblnWdl5lSzgOqKVS0Ed4Co3zwgWn2Ja45uyM KBxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=bTeiXaBhDBVAlxuQY9Fnflnv30I1Pw1YXcXYTu2rTxk=; b=Odc3EOcWaDtJPmED3Q3YWFFUP8XKhJ9e2QQJxkAjAAPykuOMPSuV5HIIYkCpj7IWwr ybS+n4ivUEnBRFVog8YkUKDRZAg2U6LSwadZlJmuJUjhC+WwYdxjmQcJyYKPauHAf+m3 GRRfA46xus7ptwEmDCcMQinmCVzZrkdzzX3phstjn1pointdQTSnmbxgvbqHY0WWF2cn 5+WHN1wl8xIpMJgWq5zXMiz5T4dK6TYRIPT7ZTAnV/5duL4dDH0uPrKxLCPUArz1pPsX UfGCAjHFZOit8LTO7ayHya5Rl1ABMmOVDNui8LCgKx5fwnxmxP2ZTGgPEtCqXzIBc2ZK Pxsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=yxh8yL6K; 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 p4-v6si635101pls.512.2018.03.07.20.33.59; Wed, 07 Mar 2018 20:34:14 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=yxh8yL6K; 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 S1754816AbeCHEdH (ORCPT + 99 others); Wed, 7 Mar 2018 23:33:07 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:42177 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754066AbeCHEdE (ORCPT ); Wed, 7 Mar 2018 23:33:04 -0500 Received: by mail-ot0-f193.google.com with SMTP id l5so4265887otf.9 for ; Wed, 07 Mar 2018 20:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=bTeiXaBhDBVAlxuQY9Fnflnv30I1Pw1YXcXYTu2rTxk=; b=yxh8yL6KS0gKlWixWGkYYyf4gQfVKow8bv1jJO6c7yUVUGmXZKQ7q20fz/3HOEWTcJ Wx+R1hd0apoGeWpeZgQiD6do6fAx/2P67a2N6aaoGbFn1O+IEbRFDI0C3oYSwTpVBbhj ub6mbBuxciDjniDgkWNEk9tnEEeB/+YtMOBJIDTDLPtqRuyWea8qqAB+VZIpC2nwLoEJ xuzIazuY3bT3vVrRAgvUOtcT+hR/HcDAigaAsOY15My5YdmMAPkeP/Z5/xGvNfEGTQ3K tYz9ahwELaAht89a/nN7WWbFU3guTNc+sKIUPNf5l1cBC6c6tBysu2SNe6Upx3jDJvWv qD0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=bTeiXaBhDBVAlxuQY9Fnflnv30I1Pw1YXcXYTu2rTxk=; b=HpaDZsXsZ4JUcqM8nBM0Bc/p21SmuKx+bB4qsFSrkq25oIi9eONW9M3BWW0hMtoIT+ hJmnOGp298w55m+5w9yihdaFxxpL2uy/vV1PX2T8EJQsMq2YsporubU+b2lFTU0p5Kka ksgLOf646Z2C9QkHjVGjICJEt07zBs643GFUaWZFlUzua5kLVdVWd4pHZyCNzw0+pOO9 5KyhRVQmXwIaalRmTfLEn4sIA75CIQBMfp5nCATfsq24pH3bhkuyDN3nazAKgHKUO+Z+ 5IFerd9yxKKOEe4CBsh6+uNskjILdw3JV3WTqeAo2tiHl4ajxb3xHCf1pc+x3+ASTKD0 58qQ== X-Gm-Message-State: AElRT7Ep0bt76wyhbAku0AgM1vLRQDWrMVe0raYAB1q9YtMPgEp6yGB5 kZwalcw2r+bRxh892fRry0quyM9w4fWdLwK3GNDPOw== X-Received: by 10.157.61.99 with SMTP id a90mr16310453otc.35.1520483584135; Wed, 07 Mar 2018 20:33:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.81.137 with HTTP; Wed, 7 Mar 2018 20:33:03 -0800 (PST) In-Reply-To: References: <1520292190-5027-1-git-send-email-sai.praneeth.prakhya@intel.com> <1520292190-5027-4-git-send-email-sai.praneeth.prakhya@intel.com> <20180306112610.7izxtuy33bt7ivfs@lakrids.cambridge.arm.com> From: Dan Williams Date: Wed, 7 Mar 2018 20:33:03 -0800 Message-ID: Subject: Re: [PATCH V2 3/3] efi: Use efi_rts_workqueue to invoke EFI Runtime Services To: "Prakhya, Sai Praneeth" Cc: Mark Rutland , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Lee@lakrids.cambridge.arm.com" , Chun-Yi , Borislav Petkov , "Luck, Tony" , Will Deacon , "Hansen, Dave" , Bhupesh Sharma , "Neri, Ricardo" , "Shankar, Ravi V" , Matt Fleming , "Zijlstra, Peter" , Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 7, 2018 at 8:11 PM, Prakhya, Sai Praneeth wrote: > 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). >> > > Sorry! I didn't get it. I would like to add this point, so could you please > explain it more? > >> [...] >> >> > 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? >> > > I think they can come. AFAIK, pstore (if enabled) runs only when we crashed. > Since, we are still executing stuff to log messages and NMI's can't be masked, > there is still a possibility for NMI's to occur (please correct me if I am wrong). > But, as you said earlier, I guess it doesn't matter because anyways we are going down. The problem is that we are not always in a "already going down" condition for typical set_variable and query_variable_info calls. So are we actually fixing anything with this patchset? In other words if the NMI vs EFI mapping problem requires the workqueue context then we can't have any EFI calls outside of that context. Am I missing how this scheme addresses that problem?