From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH] x86/HVM: honor p2m_ram_ro in hvm_map_guest_frame_rw() Date: Fri, 24 Jul 2015 11:41:09 +0100 Message-ID: <20150724104109.GC30594@zion.uk.xensource.com> References: <55B224660200007800095083@prv-mh.provo.novell.com> <20150724102647.GB30594@zion.uk.xensource.com> <55B231850200007800095110@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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIaQ0-00063E-Ae for xen-devel@lists.xenproject.org; Fri, 24 Jul 2015 10:41:32 +0000 Content-Disposition: inline In-Reply-To: <55B231850200007800095110@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: KevinTian , Wei Liu , suravee.suthikulpanit@amd.com, AndrewCooper , EddieDong , Aravind Gopalakrishnan , Jun Nakajima , xen-devel , Boris Ostrovsky , Keir Fraser List-Id: xen-devel@lists.xenproject.org On Fri, Jul 24, 2015 at 04:37:25AM -0600, Jan Beulich wrote: > >>> On 24.07.15 at 12:26, wrote: > > On Fri, Jul 24, 2015 at 03:41:26AM -0600, Jan Beulich wrote: > >> @@ -3618,7 +3618,12 @@ static void *__hvm_map_guest_frame(unsig > >> } > >> > >> if ( writable ) > > > > I don't claim I know this piece of code, but checking the pointer but > > not the content looks suspicious. > > > >> - paging_mark_dirty(d, page_to_mfn(page)); > >> + { > >> + if ( !p2m_is_discard_write(p2mt) ) > >> + paging_mark_dirty(d, page_to_mfn(page)); > >> + else > >> + *writable = 0; > > > > You then set *writable here, which makes it even more suspicious. > > Why? A caller _wanting_ a writable mapping passes non-NULL as > the pointer argument (pre-initialized to point to a variable holding > TRUE aka 1). Upon return the variable will have got set to FALSE > aka 0 if the page shouldn't be written to. > If this is the convention for using this function then the code you write is of course fine. Wei. > Jan