On 4/22/22 12:56, Chao Peng wrote:
/* memfile notifier flags */ #define MFN_F_USER_INACCESSIBLE 0x0001 /* memory allocated in the file is inaccessible from userspace (e.g. read/write/mmap) */ #define MFN_F_UNMOVABLE 0x0002 /* memory allocated in the file is unmovable */ #define MFN_F_UNRECLAIMABLE 0x0003 /* memory allocated in the file is unreclaimable (e.g. via kswapd or any other pathes) */
You probably mean BIT(0/1/2) here. Paolo
When memfile_notifier is being registered, memfile_register_notifier will need check these flags. E.g. for MFN_F_USER_INACCESSIBLE, it fails when previous mmap-ed mapping exists on the fd (I'm still unclear on how to do this). When multiple consumers are supported it also need check all registered consumers to see if any conflict (e.g. all consumers should have MFN_F_USER_INACCESSIBLE set). Only when the register succeeds, the fd is converted into a private fd, before that, the fd is just a normal (shared) one. During this conversion, the previous data is preserved so you can put some initial data in guest pages (whether the architecture allows this is architecture-specific and out of the scope of this patch).