From: "Jan Beulich" Subject: [PATCH] Re: grant table interface addition? Date: Mon, 03 Nov 2008 08:24:09 +0000 Message-ID: <490EC339.76E4.0078.0@novell.com> References: <490B3F18.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> Keir Fraser 31.10.08 18:00 >>> >On 31/10/08 16:23, "Jan Beulich" wrote: > >>>>> Keir Fraser 31.10.08 17:17 >>> >>> On 31/10/08 16:13, "Jan Beulich" wrote: >>>=20 >>>>> GRANT_PTE_FLAGS should include _PAGE_GUEST_KERNEL then? >>>>=20 >>>> No, it should uniformly include neither _PAGE_USER nor _PAGE_GUEST_KER= NEL. >>>> _PAGE_USER gets set when GNTMAP_application_map is specified, and >>>> based on this setting of _PAGE_USER, adjust_guest_l1e() will set = either >>>> _PAGE_GUEST_KERNEL or _PAGE_GLOBAL. >>>=20 >>> The grant code doesn't use adjust_l1e() though. >>=20 >> Both create_grant_pte_mapping() and create_grant_va_mapping() do >> afaics. > >Ah yes, indeed. Please send a patch to deal with this and _PAGE_NX. Since page table entries created through e.g. GNTTABOP_map_grant_ref are being passed through adjust_guest_l1e(), they must not generally get _PAGE_USER set - this will be taken care of by adjust_guest_l1e(), and it will ensure that these don't get _PAGE_GLOBAL set inadvertently. Due to the implied security aspect here (_PAGE_GLOBAL getting set on kernel pages for x86-64), I'd like to ask that this also be applied to older maintained branches. At the same time, set _PAGE_NX for pte-s created for grants (as long as hardware supports it), since it should be only data pages that remote domains are being given access to. Signed-off-by: Jan Beulich Index: 2008-10-27/xen/include/asm-x86/page.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/include/asm-x86/page.h 2008-09-29 09:45:32.0000000= 00 +0200 +++ 2008-10-27/xen/include/asm-x86/page.h 2008-10-31 16:58:13.0000000= 00 +0100 @@ -314,6 +314,9 @@ unsigned long clone_idle_pagetable(struc #define __PAGE_HYPERVISOR_NOCACHE \ (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED) =20 +#define GRANT_PTE_FLAGS \ + (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_NX | _PAGE_GNTTA= B) + #ifndef __ASSEMBLY__ =20 static inline int get_order_from_bytes(paddr_t size) Index: 2008-10-27/xen/include/asm-x86/x86_32/page.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/include/asm-x86/x86_32/page.h 2008-09-24 = 10:50:47.000000000 +0200 +++ 2008-10-27/xen/include/asm-x86/x86_32/page.h 2008-10-31 = 16:56:19.000000000 +0100 @@ -105,9 +105,6 @@ extern unsigned int PAGE_HYPERVISOR_NOCA #define get_pte_flags(x) (((int)((x) >> 32) & ~0xFFF) | ((int)(x) & = 0xFFF)) #define put_pte_flags(x) (((intpte_t)((x) & ~0xFFF) << 32) | ((x) & = 0xFFF)) =20 -#define GRANT_PTE_FLAGS \ - (_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_GNTTAB) - /* * Disallow unused flag bits plus PAT/PSE, PCD, PWT and GLOBAL. * Permit the NX bit if the hardware supports it. Index: 2008-10-27/xen/include/asm-x86/x86_64/page.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/include/asm-x86/x86_64/page.h 2008-09-29 = 09:45:32.000000000 +0200 +++ 2008-10-27/xen/include/asm-x86/x86_64/page.h 2008-10-31 = 16:56:35.000000000 +0100 @@ -124,9 +124,6 @@ typedef l4_pgentry_t root_pgentry_t; #define PAGE_HYPERVISOR (__PAGE_HYPERVISOR | _PAGE_GLOBAL)= #define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)= =20 -#define GRANT_PTE_FLAGS \ - (_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_GNTTAB|_PAGE_USER) - #define USER_MAPPINGS_ARE_GLOBAL #ifdef USER_MAPPINGS_ARE_GLOBAL /*