From: ken mark Subject: Re: Xen EPT modifications and interceptions Date: Wed, 3 Feb 2010 21:08:53 +0800 Message-ID: References: <20100203104959.GE7099@whitby.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1535254974==" Return-path: In-Reply-To: <20100203104959.GE7099@whitby.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Tim Deegan Cc: xen-devel List-Id: xen-devel@lists.xenproject.org --===============1535254974== Content-Type: multipart/alternative; boundary=001636e0a7699c3452047eb1ebed --001636e0a7699c3452047eb1ebed Content-Type: text/plain; charset=ISO-8859-1 Thanks for your inspiring explanation. We've searched the source code for the map/unmap implementation on 32-bit and 64-bit Xen and get a better understanding. Based on the map/unmap usage, we've guessed that the problem has much to do our ways of finding and updating the entry, though it turns out to be the same each time. And thank you for your reminding me of those important facts that may lead to the problem. We'll try to fix it in a few days and come back for more useful advice from you. 2010/2/3 Tim Deegan > Hi, > > At 03:00 +0000 on 03 Feb (1265166046), ken mark wrote: > > We use map_domain_page to map the ept table that contains the target > > entry. After changing the access bits in that entry, we use > > unmap_domain_page to activate the modification. > > unmap_domain_page() won't "activate" anything; it just indicates that > you're done with the mapping. On 64-bit Xen it's a no-op. > > > But it seems that when we again map the ept table and fetch the exact > > entry we've modified just before, our modifications haven't taken > > effect. > > Sorry to ask the obvious questions, but: > - Are you sure you're mapping the right entry? Is it the same MFN > both times? > - Have you tried tracking all other mappings of the same page to see if > it's put back in between? > - Are you running a multiprocessor system? Do you hve sufficient locking > around the operation to stop confusion from simultaneous changes on > other CPUs? The EPT code has historically been lacking in this area. > > > Any sometimes the modification will cause interception while in some > > cases it doesn'. Is there anything to do which our using of map/unmap > > functions? Or do we need to flush something when we have made the > > modifications? > > Yes, you need to flush the EPT entries from TLBs before changes will > take place. You need to call hvm_flush_guest_tlbs() on every CPU in the > guest's domain_dirty_cpumask. Xen's normal flush_tlb_mask() operation > does this as a side-effect. > > Cheers, > > Tim. > > -- > Tim Deegan > Principal Software Engineer, Citrix Systems (R&D) Ltd. > [Company #02300071, SL9 0DZ, UK.] > -- Kenmark --001636e0a7699c3452047eb1ebed Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for your inspiring explanation.
We've searched the source cod= e for the map/unmap implementation on 32-bit and 64-bit Xen and get a bette= r understanding.
Based on the map/unmap usage, we've guessed that th= e problem has much to do our ways of finding and updating the entry, though= it turns out to be the same each time.
And thank you for your reminding me of those important facts that may lead = to the problem.
We'll try to fix it in a few days and come back for = more useful advice from you.


2010/2/3= Tim Deegan <= Tim.Deegan@citrix.com>
Hi,

At 03:00 +0000 on 03 Feb (1265166046), ken mark wrote:
> We use map_domain_page to map the ept table that contains the target > entry. After changing the access bits in that entry, we use
> unmap_domain_page to activate the modification.

unmap_domain_page() won't "activate" anything; it just = indicates that
you're done with the mapping. =A0On 64-bit Xen it's a no-op.

> But it seems that when we again map the ept table and fetch the exact<= br> > entry we've modified just before, our modifications haven't ta= ken
> effect.

Sorry to ask the obvious questions, but:
=A0- Are you sure you're mapping the right entry? =A0Is it the same MFN=
=A0 both times?
=A0- Have you tried tracking all other mappings of the same page to see if<= br> =A0 it's put back in between?
=A0- Are you running a multiprocessor system? =A0Do you hve sufficient lock= ing
=A0 around the operation to stop confusion from simultaneous changes on =A0 other CPUs? =A0The EPT code has historically been lacking in this area= .

> Any sometimes the modification will cause interception while in some > cases it doesn'. Is there anything to do which our using of map/un= map
> functions? Or do we need to flush something when we have made the
> modifications?

Yes, you need to flush the EPT entries from TLBs before changes will<= br> take place. =A0You need to call hvm_flush_guest_tlbs() on every CPU in the<= br> guest's domain_dirty_cpumask. =A0Xen's normal flush_tlb_mask() oper= ation
does this as a side-effect.

Cheers,

Tim.

--
Tim Deegan <Tim.Deegan@citrix.c= om>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]



--
Kenmark
--001636e0a7699c3452047eb1ebed-- --===============1535254974== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1535254974==--