From: weiming Subject: Re: a quick question about _PAGE_GLOBAL flag in para virt mode Date: Sun, 15 Feb 2009 19:47:15 -0500 Message-ID: References: <4997E249.1050407@goop.org> <49989685.6020004@goop.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0689661120==" Return-path: In-Reply-To: <49989685.6020004@goop.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Fitzhardinge Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --===============0689661120== Content-Type: multipart/alternative; boundary=0016369fa25127b7730462fe8708 --0016369fa25127b7730462fe8708 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Oh, right! In 64-bit mode, both guest kernel and user processes are both in ring 3, so we can't pin the mapping of user kernel in TLB, otherwise, user code would have access to kernels. Thanks! On Sun, Feb 15, 2009 at 5:26 PM, Jeremy Fitzhardinge wrote: > weiming wrote: > >> When a normal context switch happens (like process switch), those tlb >> entries will still be flushed no matter if global bit is set or not, is it >> correct? >> > > Things would go very wrong if it didn't... I haven't checked in detail, > but presumably when the kernel does a user cr3 reload, Xen will do a global > tlb flush (or at least make sure one happens when needed). > > why not set global bit for user kernel pages? I guess this is because when >> domain switchs, all tlb entries will still be flushed, so it's not necessary >> for user kernel pages. Is my understanding right? >> > > 64-bit Xen uses paging to protect the guest kernel from guest usermode, and > protect Xen from the guest kernel, and as a result has to do a cr3 reload > for any user->kernel switch (which is why it has to go via Xen). We don't > want kernel mappings to be visible to usermode, so they have to only be in > tlb while we're actually running in guest kernel mode; setting global on the > kernel mappings wouldn't be useful because we always need to flush them > anyway when returning to usermode. > > Or to put it another way, it makes sense to set global on user mappings > because they're always mapped, regardless of what context we're in; the only > time they need to be flushed is either doing a user process context switch, > or a vcpu context switch. > > J > --0016369fa25127b7730462fe8708 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Oh, right!  In 64-bit mode, both guest kernel and user processes are b= oth in ring 3, so we can't pin the mapping of user kernel in TLB, other= wise, user code would have access to kernels. Thanks!



On Sun, Feb 15, 2009 at 5:26 PM, Jeremy Fitzhardinge <= jeremy@goop.org> wrote:
weiming wrote:
When a normal context switch happens (like process switch), those tlb entri= es will still be flushed no matter if global bit is set or not, is it corre= ct?

Things would go very wrong if it didn't...  I haven't checked = in detail, but presumably when the kernel does a user cr3 reload, Xen will = do a global tlb flush (or at least make sure one happens when needed).


why not set global bit for user kernel pages? I guess this is because when = domain switchs, all tlb entries will still be flushed, so it's not nece= ssary for user kernel pages. Is my understanding right?

64-bit Xen uses paging to protect the guest kernel from guest usermode, and= protect Xen from the guest kernel, and as a result has to do a cr3 reload = for any user->kernel switch (which is why it has to go via Xen).  W= e don't want kernel mappings to be visible to usermode, so they have to= only be in tlb while we're actually running in guest kernel mode; sett= ing global on the kernel mappings wouldn't be useful because we always = need to flush them anyway when returning to usermode.

Or to put it another way, it makes sense to set global on user mappings bec= ause they're always mapped, regardless of what context we're in; th= e only time they need to be flushed is either doing a user process context = switch, or a vcpu context switch.

  J

--0016369fa25127b7730462fe8708-- --===============0689661120== 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 --===============0689661120==--