[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <46d9ee41d2a482b19b6a91b978b0154d4f0cbcaf.camel@kernel.org>
Date: Thu, 23 Sep 2021 23:33:16 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Paolo Bonzini <pbonzini@...hat.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: x86@...nel.org, linux-sgx@...r.kernel.org,
dave.hansen@...ux.intel.com, yang.zhong@...el.com
Subject: Re: [PATCH 1/2] x86: sgx_vepc: extract sgx_vepc_remove_page
On Thu, 2021-09-23 at 14:08 +0200, Paolo Bonzini wrote:
> On 21/09/21 21:44, Jarkko Sakkinen wrote:
> > "On bare-metal SGX, start of a power cycle zeros all of its reserved
> > memory. This happens after every reboot, but in addition to that
> > happens after waking up from any of the sleep states."
> >
> > I can speculate and imagine where this might useful, but no matter
> > how trivial or complex it is, this patch needs to nail a concrete
> > usage example. I'd presume you know well the exact changes needed for
> > QEMU, so from that knowledge it should be easy to write the
> > motivational part.
>
> Assuming that it's obvious that QEMU knows how to reset a machine (which
> includes writes to the ACPI reset register, or wakeup from sleep
> states), the question of "why does userspace reuse vEPC" should be
> answered by this paragraph:
>
> "One way to do this is to simply close and reopen the /dev/sgx_vepc file
> descriptor and re-mmap the virtual EPC. However, this is problematic
> because it prevents sandboxing the userspace (for example forbidding
> open() after the guest starts, or running in a mount namespace that
> does not have access to /dev; both are doable with pre-opened file
> descriptors and/or SCM_RIGHTS file descriptor passing)."
Right, this makes sense.
>
> > Even to a Linux guest, since EPC should stil be represented in the
> > state that matches the hardware. It'd be essentially a corrupted
> > state, even if there was measures to resist this. Windows guests
> > failing is essentially a side-effect of an issue, not an issue in the
> > Windows guests.
>
> Right, Linux is more liberal than it needs to be and ksgxd does the
> EREMOVE itself at the beginning (__sgx_sanitize_pages). Windows has
> stronger expectations of what can and cannot happen before it boots,
> which are entirely justified.
>
> Paolo
Yep. We do it for kexec(). Alternative would be to zero at the time
of kexec() but this way things are just way more simpler, e.g. the
whole behaviour is local to the driver...
/Jarkko
Powered by blists - more mailing lists