mark pages in p2m_ram_paging_out state read-only
I was wondering why ept_p2m_type_to_flags() removes all permissions from a gfn in state p2m_ram_paging_out. If the guest happens to read or execute from that page while the pager writes that gfn to disk, wouldnt it be enough to remove the write bit to prevent writes from the guest? If the page is read-only the guest could continue to make progress until the gfn is really evicted and the p2mt changes to p2m_ram_paged.
I havent actually tried the patch below, but is there any reason it would break the guest?
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -75,7 +75,6 @@ static void ept_p2m_type_to_flags(ept_encase p2m_invalid:case p2m_mmio_dm:case p2m_populate_on_demand: -case p2m_ram_paging_out:case p2m_ram_paged:case p2m_ram_paging_in:case p2m_ram_paging_in_start:
@@ -92,6 +91,7 @@ static void ept_p2m_type_to_flags(ept_enbreak ;case p2m_ram_logdirty:case p2m_ram_ro: +case p2m_ram_paging_out:case p2m_ram_shared: entry->r = entry->x =1 ; entry->w =0 ;
Quoted 10 lines · Olaf Hering
I was wondering why
ept_p2m_type_to_flags()removes all permissions from a gfn in statep2m_ram_paging_out. If the guest happens to read or execute from that page while the pager writes that gfn to disk, wouldnt it be enough to remove the write bit to prevent writes from the guest? If the page is read-only the guest could continue to make progress until the gfn is really evicted and the p2mt changes top2m_ram_paged.I havent actually tried the patch below, but is there any reason it would break the guest?
As long as we change the p2m type before scrubbing or freeing the page, that seems like it shuold be fine.
Tim.