On Fri, May 07, 2021 at 02:45:21PM +0200, Paolo Bonzini wrote: > On 07/05/21 07:24, Yang Zhong wrote: > > Paolo, i will revert this patch, but in order to disable sgx epc memory > > region > > as DMA target, we still need to skip this memory region while adding this > > memory > > region. > > > > So, my plan is to revert this patch, and then add one new bool variable > > in the > > struct MemoryRegion. > > > > The new patch as below and it will be as patch 2 in the next version > > > > diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c > > index 0c98812f0d..316e1ee688 100644 > > --- a/backends/hostmem-epc.c > > +++ b/backends/hostmem-epc.c > > @@ -67,6 +67,7 @@ void sgx_memory_backend_reset(HostMemoryBackend > > *backend, int fd, > > } > > > > sgx_epc_backend_memory_alloc(backend, errp); > > + mr->sgx_epc_device = true; > > } > > > > static void sgx_epc_backend_instance_init(Object *obj) > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > > index 5bc5d29358..7a53855436 100644 > > --- a/hw/vfio/common.c > > +++ b/hw/vfio/common.c > > @@ -538,7 +538,7 @@ static bool > > vfio_listener_skipped_section(MemoryRegionSection *section) > > { > > return (!memory_region_is_ram(section->mr) && > > !memory_region_is_iommu(section->mr)) || > > + section->mr->sgx_epc_device || > > /* > > * Sizing an enabled 64-bit BAR can cause spurious mappings > > to > > * addresses in the upper part of the 64-bit address space. > > These > > diff --git a/include/exec/memory.h b/include/exec/memory.h > > index 2816e52be3..9bba0a1590 100644 > > --- a/include/exec/memory.h > > +++ b/include/exec/memory.h > > @@ -463,6 +463,7 @@ struct MemoryRegion { > > bool readonly; /* For RAM regions */ > > bool nonvolatile; > > bool rom_device; > > + bool sgx_epc_device; > > bool flush_coalesced_mmio; > > uint8_t dirty_log_mask; > > bool is_iommu; > > If this patch is not suitable to skip this memory region, any suggestion > > is > > appreciated, thanks! > > No, you can keep RAM_PROTECTED. I was just remarking on the new > bool argument, and suggesting passing the flags (RAM_SHARED and > RAM_PROTECTED) directly tot he memory_region_init* functions. >
Paolo, thanks! If there is no new comments from community, i will send the V2 in the next week. thanks! Yang > Paolo