On Fri, 2021-09-10 at 17:10 +0200, Paolo Bonzini wrote: > On 19/07/21 13:21, Yang Zhong wrote: > > +void sgx_memory_backend_reset(HostMemoryBackend *backend, int fd, > > + Error **errp) > > +{ > > + MemoryRegion *mr = &backend->mr; > > + > > + mr->enabled = false; > > + > > + /* destroy the old memory region if it exist */ > > + if (fd > 0 && mr->destructor) { > > + mr->destructor(mr); > > + } > > + > > + sgx_epc_backend_memory_alloc(backend, errp); > > +} > > + > > Jarkko, Sean, Kai, > > this I think is problematic because it has a race window while > /dev/sgx_vepc is closed and then reopened. First, the vEPC space could > be exhausted by somebody doing another mmap in the meanwhile. Second, > somebody might (for whatever reason) remove /dev/sgx_vepc while QEMU runs.
1: Why is it a problem that mmap() could fail? 2: Are you speaking about removing device node? If you have succesfully mapped /dev/sgx_vepc, that should not have much effect (file refcount). /Jarkko