Re: [PATCH v11 00/13] Intel SGX1 support

From: Sean Christopherson
Date: Tue Dec 11 2018 - 13:31:07 EST


On Tue, Dec 11, 2018 at 10:10:38AM -0800, Dave Hansen wrote:
> On 12/10/18 3:12 PM, Josh Triplett wrote:
> >> Or maybe even python/shell scripts? It looked to me like virtual
> >> memory will be "interesting" for enclaves.
> > Memory management doesn't seem that hard to deal with.
>
> The problems are:
>
> 1. SGX enclave memory (EPC) is statically allocated at boot and can't
> grow or shrink
> 2. EPC is much smaller than regular RAM
> 3. The core VM has no comprehension of EPC use, thus can not help
> with its algorithms, like the LRU
> 4. The SGX driver implements its own VM which is substantially simpler
> than the core VM, but less feature-rich, fast, or scalable

I'd also add:

5. Swapping EPC pages can only be done through SGX specific ISA that
has strict concurrency requirements and enforces TLB flushing.
6. There are specialized types of EPC pages that have different
swapping requirements than regular EPC pages.
7. EPC pages that are exposed to a KVM guest have yet another set of
swapping requirements.

In other words, extending the core VM to SGX EPC is painfully difficult.