linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Prakhya, Sai Praneeth" <sai.praneeth.prakhya@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: "linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chun-Yi Lee <jlee@suse.com>, "Luck, Tony" <tony.luck@intel.com>,
	Will Deacon <will.deacon@arm.com>,
	"Hansen, Dave" <dave.hansen@intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Bhupesh Sharma <bhsharma@redhat.com>,
	"Neri, Ricardo" <ricardo.neri@intel.com>,
	"Shankar, Ravi V" <ravi.v.shankar@intel.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	"Zijlstra, Peter" <peter.zijlstra@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	"Williams, Dan J" <dan.j.williams@intel.com>
Subject: RE: [PATCH V2 2/3] efi: Introduce efi_rts_workqueue and some infrastructure to invoke all efi_runtime_services()
Date: Sat, 10 Mar 2018 00:33:35 +0000	[thread overview]
Message-ID: <FFF73D592F13FD46B8700F0A279B802F2E5821F9@ORSMSX114.amr.corp.intel.com> (raw)
In-Reply-To: <20180309111157.GC10753@pd.tnic>

> > That's true! AFAIK, we don't have any issues handling NMI while in efi_pgd.
> > We might have issues only when, we are already in efi_pgd, NMI comes
> > along
> 
> Can you trigger this? Or is it something hypothetical?
> 

AFAIK, it's hypothetical. I did try to trigger the issue, but failed [1].
Maybe, I need to have some more constraints [2].

[1] https://lkml.org/lkml/2017/8/23/715
[2] https://lkml.org/lkml/2017/8/25/469

> > and NMI handler tries to touch the regions that are not mapped in
> > efi_pgd
> 
> If it is not hypothetical, the NMI handler should learn to look at CR3 first and
> return if CR3 has the efi pgd.

This solution and it's variants were discussed here [1], [2] and for varied reasons 
the community had decided to go with "Everything EFI as kthread" approach [3] [4].

Although the discussions were off my understanding, the present issue I see is, 
(and also the motivation for me to do the patch is)
when a thread tries to execute any  efi_runtime_service() we switch to efi_pgd 
(which doesn't have user space mappings) and all other subsystems in kernel 
aren't aware of this switch. This looks like a perfect case for kthread.

Kthread by definition doesn’t have user space mappings and if we run efi_runtime_services()
in a kthread context and if any other subsystem tries to access user space mappings 
while in efi_kthread, it's terminally broken [5].

There were several issues Andy, Peter and Mark raised.
One such (hypothetical) case is accessing user space from the back of an interrupt (NMI).
Others include
1. Issue specific to ARM because it runs efi_runtime_services() with interrupts enabled [6]
2. Interrupt taken while mmap_sem() is held for write that tries to access user memory [7]
3. If EFI were to have IO memory mapped at a "user" address, perf could end up reading it [8]

[1] https://lkml.org/lkml/2017/8/15/757
[2] https://lkml.org/lkml/2017/8/16/487
[3] https://lkml.org/lkml/2017/8/21/573
[4] https://lkml.org/lkml/2017/8/16/540

[5] https://lkml.org/lkml/2017/8/17/667
[6] https://lkml.org/lkml/2017/8/16/176
[7] https://lkml.org/lkml/2017/8/17/667
[8] https://lkml.org/lkml/2017/8/21/427

Regards,
Sai

  reply	other threads:[~2018-03-10  0:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 23:23 [PATCH V2 0/3] Use efi_rts_workqueue to invoke EFI Runtime Services Sai Praneeth Prakhya
2018-03-05 23:23 ` [PATCH V2 1/3] x86/efi: Call efi_delete_dummy_variable() during efi subsystem initialization Sai Praneeth Prakhya
2018-03-08  7:43   ` Ard Biesheuvel
2018-03-08 18:06     ` Prakhya, Sai Praneeth
2018-03-05 23:23 ` [PATCH V2 2/3] efi: Introduce efi_rts_workqueue and some infrastructure to invoke all efi_runtime_services() Sai Praneeth Prakhya
2018-03-06 11:13   ` Mark Rutland
2018-03-08  4:00     ` Prakhya, Sai Praneeth
2018-03-07 11:55   ` Miguel Ojeda
2018-03-08  4:22     ` Prakhya, Sai Praneeth
2018-03-08  9:12       ` Miguel Ojeda
2018-03-08 18:09         ` Prakhya, Sai Praneeth
2018-03-07 12:11   ` Borislav Petkov
2018-03-08  5:31     ` Prakhya, Sai Praneeth
2018-03-08 14:08       ` Borislav Petkov
2018-03-08 17:05         ` Luck, Tony
2018-03-09 10:57           ` Borislav Petkov
2018-03-09  2:37         ` Prakhya, Sai Praneeth
2018-03-09 11:11           ` Borislav Petkov
2018-03-10  0:33             ` Prakhya, Sai Praneeth [this message]
2018-03-14 17:40               ` Borislav Petkov
2018-03-08  5:38     ` Prakhya, Sai Praneeth
2018-03-05 23:23 ` [PATCH V2 3/3] efi: Use efi_rts_workqueue to invoke EFI Runtime Services Sai Praneeth Prakhya
2018-03-06  0:05   ` Dan Williams
2018-03-06  0:56     ` Prakhya, Sai Praneeth
2018-03-06 11:26   ` Mark Rutland
2018-03-08  4:11     ` Prakhya, Sai Praneeth
2018-03-08  4:33       ` Dan Williams
2018-03-08  5:06         ` Prakhya, Sai Praneeth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FFF73D592F13FD46B8700F0A279B802F2E5821F9@ORSMSX114.amr.corp.intel.com \
    --to=sai.praneeth.prakhya@intel.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bhsharma@redhat.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=jlee@suse.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matt@codeblueprint.co.uk \
    --cc=peter.zijlstra@intel.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=ricardo.neri@intel.com \
    --cc=tony.luck@intel.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).