From: Wei Liu Subject: Re: [PATCH for 4.6 v3 4/5] libxc: don't populate same pfn more than once in populate_pfns Date: Mon, 7 Sep 2015 10:36:31 +0100 Message-ID: <20150907093631.GA6674@zion.uk.xensource.com> References: <1441569939-23562-1-git-send-email-wei.liu2@citrix.com> <1441569939-23562-5-git-send-email-wei.liu2@citrix.com> <55ED567402000078000A0422@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZYsqp-0005J5-W4 for xen-devel@lists.xenproject.org; Mon, 07 Sep 2015 09:36:36 +0000 Content-Disposition: inline In-Reply-To: <55ED567402000078000A0422@prv-mh.provo.novell.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: Jan Beulich Cc: Ian Jackson , Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On Mon, Sep 07, 2015 at 01:18:44AM -0600, Jan Beulich wrote: > >>> On 06.09.15 at 22:05, wrote: > > The original implementation of populate_pfns didn't consider the same > > pfn can be present multiple times in the array. The mechanism to prevent > > populating the same pfn multiple times only worked if the recurring pfn > > appeared in different batches. > > > > This bug is discovered by Linux 4.1 32 bit kernel save / restore test, > > which has several ptes pointing to same pfn, which results in an array > > containing recurring pfn. > > Since you must have debugged this, and since the bisector appears > to have fingered a patch of mine on the Linux side which triggered > this, would you mind explaining this a little more? In particular I'm > worried that this may point out some other bug in Linux, as in the > context of the change there - dealing with the 1:1 mapping - I can't > see a legitimate reason for multiple PTEs to reference the same PFN. > Sure. I can try to explain this as clear as possible. Note that I didn't even look at Linux side changes because at that point I was sure there was a bug in migration v2. So there is a step called normalise_page in migration v2. It's nop for HVM guest. For PV guest, it only cares about page table frames. To normalise a page table frame, the core idea is to replace all MFNs in page tables to PFNs inside the guest. When restoring, there is a step called localise_page, which again is a nop for HVM guest. For PV guest, it does the reverse of normalise_page. It goes through all page table frames, extract all PFNs pointed to by PTEs in such frames, populate them, then reconstruct page tables. What I discovered is that PTEs inside one page table frame contained the same PFN (something like fd42). The original implementation of toolstack populate_pfns didn't consider such scenario. As for what that PFN referred to, I wasn't sure and I didn't really care about that. Let me know if you need more information. Wei. > Thanks, Jan