From: "Jan Beulich" Subject: Re: [PATCH] NPT: temporarily retain page table mapping in do_recalc() Date: Tue, 06 May 2014 11:02:15 +0100 Message-ID: <5368CF47020000780000F456@mail.emea.novell.com> References: <536784BB020000780000EF15@mail.emea.novell.com> <5368B152.4080303@citrix.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 1WhcCa-0006pE-BV for xen-devel@lists.xenproject.org; Tue, 06 May 2014 10:02:20 +0000 In-Reply-To: <5368B152.4080303@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 06.05.14 at 11:54, wrote: > On 05/05/14 11:31, Jan Beulich wrote: >> Commit b3e024f3 ("x86/NPT: don't walk page tables when changing types >> on a range") neglected the fact that p2m_next_level() replaces the >> previous level's mapping with the new level's one, hence dereferencing >> a stale pointer the translation for which may no longer be available >> (timing dependent). Add a parameter to that function allowing the >> caller to request that the mapping be retained (the unmapping will be >> taken care of by the caller then). >> >> Signed-off-by: Jan Beulich > > Given the new API for p2m_next_level(), it is important to note that the > mapping can only be safely left in place on the success path. In the > case of an error the page must be unmapped even if 'unmap' is false. > > While the current behaviour is safe, all it would take is an innocent > refactoring of the error paths to invalidate this requirement. But that's not a correct description of how this behaves: The function _always_ leaves a mapping in place. The new parameter is used to tell it to return with _two_ established mappings - the one that was there on entry and the one needed for the next level. Consequently no error path should ever reach this map/ unmap pair near the end of the function. Jan