From: Tim Deegan Subject: Re: [PATCH 10/10] p2m/ept: Enable PML in p2m-ept for log-dirty. Date: Thu, 9 Apr 2015 13:20:14 +0100 Message-ID: <20150409122014.GH17031@deinos.phlegethon.org> References: <1427423754-11841-1-git-send-email-kai.huang@linux.intel.com> <1427423754-11841-11-git-send-email-kai.huang@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1427423754-11841-11-git-send-email-kai.huang@linux.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Kai Huang Cc: yang.z.zhang@intel.com, andrew.cooper3@citrix.com, kevin.tian@intel.com, jbeulich@suse.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org At 10:35 +0800 on 27 Mar (1427452554), Kai Huang wrote: > @@ -118,6 +119,12 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry, p2m_type_t type, p2m_acces > break; > case p2m_ram_rw: > entry->r = entry->w = entry->x = 1; > + /* > + * This is about to avoid unnecessary GPA logging in PML buffer, > + * such as normal memory in partial log-dirty > + */ > + if ( vmx_domain_pml_enabled(p2m->domain) ) > + entry->d = 1; I think that both A and D should be set here, even when PML is not supported, to avoid the MMU having to write them later. And indeed not just for ram_rw, but for every present leaf type. You will still need to check whether the CPU supports the A/D bits, since AIUI those are reserved bits otherwise. > break; > case p2m_mmio_direct: > entry->r = entry->x = 1; > @@ -125,6 +132,26 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry, p2m_type_t type, p2m_acces > entry->mfn); > break; > case p2m_ram_logdirty: > + entry->r = entry->x = 1; > + if ( vmx_domain_pml_enabled(p2m->domain) ) > + { > + /* > + * In case of PML, we don't have to write protect 4K page, but > + * only need to clear D-bit for it. Note we still need to write > + * protect super page in order to split it to 4K pages in EPT > + * violation. > + */ > + if ( !is_epte_superpage(entry) ) > + { > + entry->w = 1; > + entry->d = 0; > + } > + else > + entry->w = 0; > + } > + else > + entry->w = 0; > + break; This can be folded into a neater form: if ( vmx_domain_pml_enabled(p2m->domain) && !is_epte_superpage(entry) ) { /* * In case of PML, we don't have to write protect 4K page, but * only need to clear D-bit for it. Note we still need to write * protect super page in order to split it to 4K pages in EPT * violation. */ entry->w = 1; entry->d = 0; } else entry->w = 0; Cheers, Tim.