[libvirt][PATCH v16 5/9] conf: Introduce SGX EPC element into device memory xml

Daniel P. Berrangé berrange at redhat.com
Tue Nov 8 12:25:26 UTC 2022


On Fri, Oct 14, 2022 at 01:12:28PM +0200, Michal Prívozník wrote:
> On 10/8/22 06:00, Lin Yang wrote:
> > With NUMA config:
> > 
> > <devices>
> >   ...
> >   <memory model='sgx-epc'>
> >     <source>
> >       <nodemask>0-1</nodemask>
> >     </source>
> >     <target>
> >       <size unit='KiB'>512</size>
> >       <node>0</node>
> >     </target>
> >   </memory>
> >   ...
> > </devices>
> > 
> > Without NUMA config:
> > 
> > <devices>
> >   ...
> >   <memory model='sgx-epc'>
> >     <target>
> >       <size unit='KiB'>512</size>
> >     </target>
> >   </memory>
> >   ...
> > </devices>
> 
> 
> Patches look good to me. And I'd like to merge them. However, in one of
> previous iterations Peter raised a concern whether this should be
> exposed as something else than <memory model='sgx-epc'/>. One fact that
> would support this is that SGX 'cuts' from guest memory. I mean, memory
> backend-epc does not add more RAM into the guest:
> 
> # ./qemu-system-x86_64 -S -nographic -nodefaults -m 128 \
> -machine pc,sgx-epc.0.memdev=memepc0,sgx-epc.0.node=0 \
> -object '{"qom-type":"memory-backend-epc","id":"memepc0","prealloc":true,"size":67108864,"host-nodes":[0],"policy":"bind"}' \
> -monitor stdio
> QEMU 7.1.50 monitor - type 'help' for more information
> (qemu) info memory-devices 
> Memory device [sgx-epc]: ""
>   memaddr: 0x100000000
>   size: 67108864
>   node: 0
>   memdev: /objects/memepc0
> (qemu) info memory_size_summary 
> base memory: 134217728
> plugged memory: 0
> (qemu)

I'm not sure this check is showing us the truth.

In backends/hostmem-epc.c, sgx_epc_backend_memory_alloc is
opening /dev/sgx_vepc and mmap()ing the requested size from
that file. IOW that's clearly in addition to whatever has
been mapped as the main RAM.

In hw/i386/sgx-epc.c, sgx_epc_md_get_plugged_size is  hardcoded
to always return 0, which is why 'plugged memory' is reported
as zero above. I don't know what it is reporting zero.

Is this because the SGX RAM is not accessible to the guest OS
as "normal" RAM perhaps, and thus to be reported differently.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


More information about the libvir-list mailing list