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

Peter Krempa pkrempa at redhat.com
Tue Nov 8 13:16:30 UTC 2022


On Tue, Nov 08, 2022 at 12:25:26 +0000, Daniel P. Berrangé wrote:
> On Fri, Oct 14, 2022 at 01:12:28PM +0200, Michal Prívozník wrote:
> > On 10/8/22 06:00, Lin Yang wrote:

[...]

> > 
> > # ./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.

So even if the memory is not accessible as normal RAM, but still is
usable by the guest OS, the use of an <devices><memory> element is okay,
but the total memory size of a VM should account for it.

So in fact all the hacks which exclude it from the total memory size
should be removed.


More information about the libvir-list mailing list