From: Tim Deegan Subject: Re: [PATCH RFC v2 1/4] x86/mm: Shadow and p2m changes for PV mem_access Date: Fri, 29 Aug 2014 11:52:47 +0200 Message-ID: <20140829095247.GB55783@deinos.phlegethon.org> References: <53D13457020000780002599B@mail.emea.novell.com> <97A500D504438F4ABC02EBA81613CC633188B795@xmb-aln-x02.cisco.com> <53D221270200007800025CEA@mail.emea.novell.com> <97A500D504438F4ABC02EBA81613CC633188BE3A@xmb-aln-x02.cisco.com> <20140828091442.GB60905@deinos.phlegethon.org> <97A500D504438F4ABC02EBA81613CC63318E4DD6@xmb-aln-x02.cisco.com> <20140828190030.GA2147@deinos.phlegethon.org> <97A500D504438F4ABC02EBA81613CC63318E4EE6@xmb-aln-x02.cisco.com> <20140828203726.GA8094@deinos.phlegethon.org> <97A500D504438F4ABC02EBA81613CC63318E5178@xmb-aln-x02.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XNIre-0005Wr-0s for xen-devel@lists.xenproject.org; Fri, 29 Aug 2014 09:53:03 +0000 Content-Disposition: inline In-Reply-To: <97A500D504438F4ABC02EBA81613CC63318E5178@xmb-aln-x02.cisco.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: "Aravindh Puthiyaparambil (aravindp)" Cc: "xen-devel@lists.xenproject.org" , Keir Fraser , Ian Jackson , Jan Beulich , Ian Campbell List-Id: xen-devel@lists.xenproject.org At 22:20 +0000 on 28 Aug (1409260838), Aravindh Puthiyaparambil (aravindp) wrote: > >>> In the PV case step 2 is problematic as the range of pages that belong > >>> to the PV guest is unknown to the mem-access listener. I tried adding > >>> another PV specific API for setting default access that will walk the > >>> page_list and set the shadow_flag to default. But Jan rightly pointed > >>> out issues surrounding hypercall preemption / continuation during > >>> which, the page_list could be modified. So my current plan is to blow > >>> all shadow pages every time the API for setting default access is > >>> called. The on the subsequent page-faults where the PTE is marked not > >>> present, set the shadow_flag to the default access as part of creating > >>> the PTE. > >> > >>How do you know when this step finishes? I.e. how can you tell the > >>difference between an access field in the shadow_flags that was set before > >>you enabled mem_access and one that was set since? > > > >What I was thinking of doing is, in p2m_mem_access_get_entry(), check if PTE > >for the page is marked present and return the access value in the > >shadow_flags if it is. If it is not present, then return the default access value. > > I realized this does not cover for the case when p2m_mem_access_set_entry() gets called for a non-present page. Subsequent p2m_mem_access_get_entry() will return the default access value. Even worse subsequent page fault will overwrite the access value in shadow flags with the default. Should I disallow p2m_mem_access_set_entry() for non-present pages to work around this? > Nope, I think you're in even deeper trouble than that -- shadow PTEs can be dropped at any time (e.g. because of memory pressure) so you can't rely on their being present or absent to mean anything. (Also, I suspect this plan might get tangled by pages that have multiple PTEs mapping them, but I haven't thought that all the way through yet.) Tim.