linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Zhiquan Li <zhiquan1.li@intel.com>,
	linux-sgx@vger.kernel.org, tony.luck@intel.com,
	jarkko@kernel.org, dave.hansen@linux.intel.com,
	kai.huang@intel.com
Cc: seanjc@google.com, fan.du@intel.com, cathy.zhang@intel.com,
	bp@suse.de, tglx@linutronix.de
Subject: Re: [PATCH v9 3/3] x86/sgx: Fine grained SGX MCA behavior for virtualization
Date: Wed, 12 Oct 2022 07:36:03 -0700	[thread overview]
Message-ID: <f8b49a6b-44ce-9477-b2ba-39abadfbd68f@intel.com> (raw)
In-Reply-To: <14fabc80-a9fc-05b4-eda1-62f2b265e66b@intel.com>

On 10/11/22 22:09, Zhiquan Li wrote:
>>> application inside the guest.
>>>
>>> To fix this, send a SIGBUS to host userspace (like QEMU) which can
>>> follow up by injecting a #MC to the guest.
>>
>> This doesn't make any sense to me.  It's *ALREADY* sending a SIGBUS.
>> So, whatever is making this better, it's not "send a SIGBUS" that's
>> doing it.
>>
>> What does this patch actually do to reduce the blast radius?
> 
> Thanks for your attention, Dave.
> 
> This part comes from your comments previously:
> 
> https://lore.kernel.org/linux-sgx/Yrf27fugD7lkyaek@kernel.org/T/#m6d62670eb530fab178eefaaaf31a22c4475e818d
> 
> The key is the SIGBUS should with code BUS_MCEERR_AR and virtual address
> of virtual EPC page. Hypervisor can identify it with the specific code
> and inject #MC to the guest.
> 
> Can we change the statement like this?
> 
>     To fix this, send a SIGBUS with code BUS_MCEERR_AR and virtual
>     address of virtual EPC page to host userspace (like QEMU) which can
>     follow up by injecting a #MC to the guest.

This is really just mechanically restating what the patch does.  It
doesn't help me understand how it achieves the goal.  I guess I'll just
go and write the changelog for you.  Here's what I was missing:

	There is already a signal-based ABI to tell userspace about
	machine checks.  But, SGX does not use that ABI.  Today, the
	kernel delivers a generic SIGBUS if a machine check occurs when
	accessing SGX memory.  Userspace can not differentiate that
	SIGBUS from <add example here>, so it is very unlikely to be
	able to recover from the signal and the app will die.

	To fix this, have the SGX machine check code generate a SIGBUS
	which leverages the existing BUS_MCEERR_AR ABI.  This enlightens
	userspace about why the SIGBUS was generated and gives it a
	chance of being able to handle the signal.

	QEMU, for instance, has code to handle these BUS_MCEERR_AR
	signals today.  Without this patch, QEMU will just die in the
	face of a generic SIGBUS, and take the whole VM with it.  With
	this patch <explain what QEMU actually does here>.

	In short, BUS_MCEERR_AR enables QEMU to reduce the blast radius
	down from the whole QEMU process to a single page.

This patch doesn't *actually* reduce the blast radius.  It enables QEMU
to do that.

>>> SGX virtual EPC driver doesn't explicitly prevent virtual EPC instance
>>> being shared by multiple VMs via fork().  However KVM doesn't support
>>> running a VM across multiple mm structures, and the de facto userspace
>>> hypervisor (Qemu) doesn't use fork() to create a new VM, so in practice
>>> this should not happen.
>>
>> This is out of the blue.  Why is this here?
>>
>> What happens if a hypervisor *DOES* fork()?  What's the fallout?
> 
> This part originates from below discussion:
> 
> https://lore.kernel.org/linux-sgx/52dc7f50b68c99cecb9e1c3383d9c6d88734cd67.camel@intel.com/#t
> 
> It intents to answer the question:
> 
>     Do you think the processes sharing the same enclave need to be
>     killed, even they had not touched the EPC page with hardware error?
> 
> Dave, do you mean it's not appropriate to be put here?

It's actually a pretty important point, but it's still out of the blue.

You also didn't answer my question.

  parent reply	other threads:[~2022-10-12 14:36 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  6:39 [PATCH v9 0/3] x86/sgx: fine grained SGX MCA behavior Zhiquan Li
2022-09-20  6:39 ` [PATCH v9 1/3] x86/sgx: Rename the owner field of struct sgx_epc_page as encl_owner Zhiquan Li
2022-09-20  6:39 ` [PATCH v9 2/3] x86/sgx: Introduce union with vepc_vaddr field for virtualization case Zhiquan Li
2022-10-10 23:10   ` Dave Hansen
2022-10-11  5:49     ` Zhiquan Li
2022-10-11 13:57       ` Dave Hansen
2022-10-12  4:42         ` Zhiquan Li
2022-10-12 11:17           ` Huang, Kai
2022-09-20  6:39 ` [PATCH v9 3/3] x86/sgx: Fine grained SGX MCA behavior for virtualization Zhiquan Li
2022-10-10 23:20   ` Dave Hansen
2022-10-11  4:44     ` Zhiquan Li
2022-10-11 14:04   ` Dave Hansen
2022-10-12  5:09     ` Zhiquan Li
2022-10-12 11:01       ` Huang, Kai
2022-10-12 11:54         ` jarkko
2022-10-12 20:56           ` Huang, Kai
2022-10-13  2:05         ` Zhiquan Li
2022-10-12 14:36       ` Dave Hansen [this message]
2022-10-13 14:40         ` Zhiquan Li
2022-10-13 15:39           ` Dave Hansen
2022-10-14  5:42             ` Zhiquan Li
2022-10-14  5:41               ` Dave Hansen
2022-10-13 15:44           ` Dave Hansen
2022-10-13 21:49             ` Huang, Kai
2022-10-13 22:02               ` Dave Hansen
2022-10-13 22:15                 ` Huang, Kai
2022-10-13 22:28                   ` Dave Hansen
2022-10-13 23:40                     ` Huang, Kai
2022-10-13 23:57                       ` Dave Hansen
2022-10-14  0:19                         ` Huang, Kai
2022-10-19 10:59                           ` Huang, Kai
2022-10-23 20:39                             ` jarkko
2022-10-24  1:32                               ` Zhiquan Li
2022-11-01  0:46                                 ` jarkko
2022-11-02  1:38                                   ` Zhiquan Li
2022-11-07 11:36                                     ` jarkko
2022-11-07 12:19                                       ` Zhiquan Li
2022-11-04 10:17                                   ` Huang, Kai
2022-11-04 16:26                                     ` Sean Christopherson
2022-11-04 16:34                                       ` Dave Hansen
2022-11-07  8:55                                         ` Huang, Kai
2022-11-07  8:54                                       ` Huang, Kai
2022-10-24 22:23                               ` Huang, Kai
2022-11-01  0:53                                 ` jarkko
2022-09-29  8:05 ` [PATCH v9 0/3] x86/sgx: fine grained SGX MCA behavior Zhiquan Li
2022-10-08  2:29 ` Zhiquan Li

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=f8b49a6b-44ce-9477-b2ba-39abadfbd68f@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@suse.de \
    --cc=cathy.zhang@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=fan.du@intel.com \
    --cc=jarkko@kernel.org \
    --cc=kai.huang@intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=zhiquan1.li@intel.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).