Module Name:    src
Committed By:   maxv
Date:           Wed Mar  8 18:00:49 UTC 2017

Modified Files:
        src/sys/arch/amd64/conf: ALL
        src/sys/arch/i386/conf: ALL
        src/sys/arch/xen/include: xenpmap.h
        src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
A few changes:
 * Use markers to reduce false sharing.
 * Remove XENDEBUG_SYNC and several debug messages, they are just useless.
 * Remove xen_vcpu_*. They are unused and not optimized: if we really
   wanted to flush ranges we should pack the VAs in a mmuext_op array
   instead of performing several hypercalls in a loop.
 * Start removing PG_k.
 * KNF, reorder, simplify and remove stupid comments.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.414 -r1.415 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.53 src/sys/arch/amd64/conf/ALL:1.54
--- src/sys/arch/amd64/conf/ALL:1.53	Sun Feb 26 12:03:14 2017
+++ src/sys/arch/amd64/conf/ALL	Wed Mar  8 18:00:49 2017
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.53 2017/02/26 12:03:14 rin Exp $
+# $NetBSD: ALL,v 1.54 2017/03/08 18:00:49 maxv Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.53 $"
+#ident		"ALL-$Revision: 1.54 $"
 
 maxusers	64		# estimated number of users
 
@@ -2334,7 +2334,6 @@ options XDEBUG
 options XENDEBUG
 options XENDEBUG_LOW
 options XENDEBUG_NET
-options XENDEBUG_SYNC
 options XENDEBUG_VBD
 options XENNET_DEBUG
 options XENNET_DEBUG_DUMP

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.414 src/sys/arch/i386/conf/ALL:1.415
--- src/sys/arch/i386/conf/ALL:1.414	Sun Feb 26 12:03:14 2017
+++ src/sys/arch/i386/conf/ALL	Wed Mar  8 18:00:49 2017
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.414 2017/02/26 12:03:14 rin Exp $
+# $NetBSD: ALL,v 1.415 2017/03/08 18:00:49 maxv Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.414 $"
+#ident		"ALL-$Revision: 1.415 $"
 
 maxusers	64		# estimated number of users
 
@@ -2533,7 +2533,6 @@ options XDEBUG
 options XENDEBUG
 options XENDEBUG_LOW
 options XENDEBUG_NET
-options XENDEBUG_SYNC
 options XENDEBUG_VBD
 options XENNET_DEBUG
 options XENNET_DEBUG_DUMP

Index: src/sys/arch/xen/include/xenpmap.h
diff -u src/sys/arch/xen/include/xenpmap.h:1.38 src/sys/arch/xen/include/xenpmap.h:1.39
--- src/sys/arch/xen/include/xenpmap.h:1.38	Tue May  6 04:26:24 2014
+++ src/sys/arch/xen/include/xenpmap.h	Wed Mar  8 18:00:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenpmap.h,v 1.38 2014/05/06 04:26:24 cherry Exp $	*/
+/*	$NetBSD: xenpmap.h,v 1.39 2017/03/08 18:00:49 maxv Exp $	*/
 
 /*
  *
@@ -49,8 +49,6 @@ void xpq_queue_tlb_flush(void);
 void xpq_queue_pin_table(paddr_t, int);
 void xpq_queue_unpin_table(paddr_t);
 int  xpq_update_foreign(paddr_t, pt_entry_t, int);
-void xen_vcpu_mcast_invlpg(vaddr_t, vaddr_t, kcpuset_t *);
-void xen_vcpu_bcast_invlpg(vaddr_t, vaddr_t);
 void xen_mcast_tlbflush(kcpuset_t *);
 void xen_bcast_tlbflush(void);
 void xen_mcast_invlpg(vaddr_t, kcpuset_t *);

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.71 src/sys/arch/xen/x86/x86_xpmap.c:1.72
--- src/sys/arch/xen/x86/x86_xpmap.c:1.71	Thu Feb  2 08:57:04 2017
+++ src/sys/arch/xen/x86/x86_xpmap.c	Wed Mar  8 18:00:49 2017
@@ -1,4 +1,33 @@
-/*	$NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.72 2017/03/08 18:00:49 maxv Exp $	*/
+
+/*
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 /*
  * Copyright (c) 2006 Mathieu Ropert <[email protected]>
@@ -66,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.72 2017/03/08 18:00:49 maxv Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -87,7 +116,6 @@ __KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,
 #include <machine/isa_machdep.h>
 
 #undef	XENDEBUG
-/* #define XENDEBUG_SYNC */
 
 #ifdef XENDEBUG
 #define	XENPRINTF(x) printf x
@@ -98,19 +126,24 @@ static char XBUF[256];
 #define	XENPRINTK2(x)
 #endif
 
-volatile shared_info_t *HYPERVISOR_shared_info;
 /* Xen requires the start_info struct to be page aligned */
 union start_info_union start_info_union __aligned(PAGE_SIZE);
-unsigned long *xpmap_phys_to_machine_mapping;
-kmutex_t pte_lock;
-vaddr_t xen_dummy_page;
 
+volatile shared_info_t *HYPERVISOR_shared_info __read_mostly;
+unsigned long *xpmap_phys_to_machine_mapping __read_mostly;
+kmutex_t pte_lock __cacheline_aligned;
+vaddr_t xen_dummy_page;
 pt_entry_t xpmap_pg_nx __read_mostly;
 
-void xen_failsafe_handler(void);
+#define XPQUEUE_SIZE 2048
+static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
+static int xpq_idx_array[MAXCPUS];
+
+#ifdef XENDEBUG
+void xpq_debug_dump(void);
+#endif
 
-#define HYPERVISOR_mmu_update_self(req, count, success_count) \
-	HYPERVISOR_mmu_update((req), (count), (success_count), DOMID_SELF)
+void xen_failsafe_handler(void);
 
 extern volatile struct xencons_interface *xencons_interface; /* XXX */
 extern struct xenstore_domain_interface *xenstore_interface; /* XXX */
@@ -166,33 +199,17 @@ xen_set_ldt(vaddr_t base, uint32_t entri
 	splx(s);
 }
 
-#ifdef XENDEBUG
-void xpq_debug_dump(void);
-#endif
-
-#define XPQUEUE_SIZE 2048
-static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
-static int xpq_idx_array[MAXCPUS];
-
-#ifdef i386
-extern union descriptor tmpgdt[];
-#endif
-
 void
 xpq_flush_queue(void)
 {
-	int i, ok = 0, ret;
-
-	mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
-	int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
+	mmu_update_t *xpq_queue;
+	int i, ok = 0, ret, xpq_idx;
 
-	XENPRINTK2(("flush queue %p entries %d\n", xpq_queue, xpq_idx));
-	for (i = 0; i < xpq_idx; i++)
-		XENPRINTK2(("%d: 0x%08" PRIx64 " 0x%08" PRIx64 "\n", i,
-		    xpq_queue[i].ptr, xpq_queue[i].val));
+	xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
+	xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
 
 retry:
-	ret = HYPERVISOR_mmu_update_self(xpq_queue, xpq_idx, &ok);
+	ret = HYPERVISOR_mmu_update(xpq_queue, xpq_idx, &ok, DOMID_SELF);
 
 	if (xpq_idx != 0 && ret < 0) {
 		struct cpu_info *ci;
@@ -242,45 +259,32 @@ xpq_increment_idx(void)
 void
 xpq_queue_machphys_update(paddr_t ma, paddr_t pa)
 {
-
 	mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
 	int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
 
-	XENPRINTK2(("xpq_queue_machphys_update ma=0x%" PRIx64 " pa=0x%" PRIx64
-	    "\n", (int64_t)ma, (int64_t)pa));
-
 	xpq_queue[xpq_idx].ptr = ma | MMU_MACHPHYS_UPDATE;
 	xpq_queue[xpq_idx].val = pa >> PAGE_SHIFT;
 	xpq_increment_idx();
-#ifdef XENDEBUG_SYNC
-	xpq_flush_queue();
-#endif
 }
 
 void
 xpq_queue_pte_update(paddr_t ptr, pt_entry_t val)
 {
-
 	mmu_update_t *xpq_queue = xpq_queue_array[curcpu()->ci_cpuid];
 	int xpq_idx = xpq_idx_array[curcpu()->ci_cpuid];
 
-	KASSERT((ptr & 3) == 0);
-	xpq_queue[xpq_idx].ptr = (paddr_t)ptr | MMU_NORMAL_PT_UPDATE;
+	xpq_queue[xpq_idx].ptr = ptr | MMU_NORMAL_PT_UPDATE;
 	xpq_queue[xpq_idx].val = val;
 	xpq_increment_idx();
-#ifdef XENDEBUG_SYNC
-	xpq_flush_queue();
-#endif
 }
 
 void
 xpq_queue_pt_switch(paddr_t pa)
 {
 	struct mmuext_op op;
+
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_pt_switch: 0x%" PRIx64 " 0x%" PRIx64 "\n",
-	    (int64_t)pa, (int64_t)pa));
 	op.cmd = MMUEXT_NEW_BASEPTR;
 	op.arg1.mfn = pa >> PAGE_SHIFT;
 	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
@@ -294,12 +298,8 @@ xpq_queue_pin_table(paddr_t pa, int lvl)
 
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_pin_l%d_table: %#" PRIxPADDR "\n",
-	    lvl + 1, pa));
-
 	op.arg1.mfn = pa >> PAGE_SHIFT;
 	op.cmd = lvl;
-
 	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_pin_table");
 }
@@ -311,7 +311,6 @@ xpq_queue_unpin_table(paddr_t pa)
 
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_unpin_table: %#" PRIxPADDR "\n", pa));
 	op.arg1.mfn = pa >> PAGE_SHIFT;
 	op.cmd = MMUEXT_UNPIN_TABLE;
 	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
@@ -325,7 +324,6 @@ xpq_queue_set_ldt(vaddr_t va, uint32_t e
 
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_set_ldt\n"));
 	KASSERT(va == (va & ~PAGE_MASK));
 	op.cmd = MMUEXT_SET_LDT;
 	op.arg1.linear_addr = va;
@@ -341,7 +339,6 @@ xpq_queue_tlb_flush(void)
 
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_tlb_flush\n"));
 	op.cmd = MMUEXT_TLB_FLUSH_LOCAL;
 	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_tlb_flush");
@@ -354,7 +351,6 @@ xpq_flush_cache(void)
 
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_flush_cache\n"));
 	asm("wbinvd":::"memory");
 	splx(s); /* XXX: removeme */
 }
@@ -363,9 +359,9 @@ void
 xpq_queue_invlpg(vaddr_t va)
 {
 	struct mmuext_op op;
+
 	xpq_flush_queue();
 
-	XENPRINTK2(("xpq_queue_invlpg %#" PRIxVADDR "\n", va));
 	op.cmd = MMUEXT_INVLPG_LOCAL;
 	op.arg1.linear_addr = (va & ~PAGE_MASK);
 	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
@@ -380,18 +376,14 @@ xen_mcast_invlpg(vaddr_t va, kcpuset_t *
 
 	kcpuset_export_u32(kc, &xcpumask.xcpum_km[0], sizeof(xcpumask));
 
-	/* Flush pending page updates */
 	xpq_flush_queue();
 
 	op.cmd = MMUEXT_INVLPG_MULTI;
 	op.arg1.linear_addr = va;
 	op.arg2.vcpumask = &xcpumask.xcpum_xm;
 
-	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0) {
+	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_invlpg_all");
-	}
-
-	return;
 }
 
 void
@@ -399,17 +391,13 @@ xen_bcast_invlpg(vaddr_t va)
 {
 	mmuext_op_t op;
 
-	/* Flush pending page updates */
 	xpq_flush_queue();
 
 	op.cmd = MMUEXT_INVLPG_ALL;
 	op.arg1.linear_addr = va;
 
-	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0) {
+	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_invlpg_all");
-	}
-
-	return;
 }
 
 /* This is a synchronous call. */
@@ -421,17 +409,13 @@ xen_mcast_tlbflush(kcpuset_t *kc)
 
 	kcpuset_export_u32(kc, &xcpumask.xcpum_km[0], sizeof(xcpumask));
 
-	/* Flush pending page updates */
 	xpq_flush_queue();
 
 	op.cmd = MMUEXT_TLB_FLUSH_MULTI;
 	op.arg2.vcpumask = &xcpumask.xcpum_xm;
 
-	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0) {
+	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_invlpg_all");
-	}
-
-	return;
 }
 
 /* This is a synchronous call. */
@@ -440,59 +424,14 @@ xen_bcast_tlbflush(void)
 {
 	mmuext_op_t op;
 
-	/* Flush pending page updates */
 	xpq_flush_queue();
 
 	op.cmd = MMUEXT_TLB_FLUSH_ALL;
 
-	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0) {
+	if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0)
 		panic("xpq_queue_invlpg_all");
-	}
-
-	return;
 }
 
-/* This is a synchronous call. */
-void
-xen_vcpu_mcast_invlpg(vaddr_t sva, vaddr_t eva, kcpuset_t *kc)
-{
-	KASSERT(eva > sva);
-
-	/* Flush pending page updates */
-	xpq_flush_queue();
-
-	/* Align to nearest page boundary */
-	sva &= ~PAGE_MASK;
-	eva &= ~PAGE_MASK;
-
-	for ( ; sva <= eva; sva += PAGE_SIZE) {
-		xen_mcast_invlpg(sva, kc);
-	}
-
-	return;
-}
-
-/* This is a synchronous call. */
-void
-xen_vcpu_bcast_invlpg(vaddr_t sva, vaddr_t eva)
-{
-	KASSERT(eva > sva);
-
-	/* Flush pending page updates */
-	xpq_flush_queue();
-
-	/* Align to nearest page boundary */
-	sva &= ~PAGE_MASK;
-	eva &= ~PAGE_MASK;
-
-	for ( ; sva <= eva; sva += PAGE_SIZE) {
-		xen_bcast_invlpg(sva);
-	}
-
-	return;
-}
-
-/* Copy a page */
 void
 xen_copy_page(paddr_t srcpa, paddr_t dstpa)
 {
@@ -507,7 +446,6 @@ xen_copy_page(paddr_t srcpa, paddr_t dst
 	}
 }
 
-/* Zero a physical page */
 void
 xen_pagezero(paddr_t pa)
 {
@@ -533,7 +471,7 @@ xpq_update_foreign(paddr_t ptr, pt_entry
 	op.val = val;
 	if (HYPERVISOR_mmu_update(&op, 1, &ok, dom) < 0)
 		return EFAULT;
-	return (0);
+	return 0;
 }
 
 #ifdef XENDEBUG
@@ -557,7 +495,7 @@ xpq_debug_dump(void)
 		if (++i < xpq_idx)
 			snprintf(XBUF + strlen(XBUF),
 			    sizeof(XBUF) - strlen(XBUF),
-			    "%" PRIx64 " %08" PRIx64, 
+			    "%" PRIx64 " %08" PRIx64,
 			    xpq_queue[i].ptr, xpq_queue[i].val);
 		if (++i < xpq_idx)
 			snprintf(XBUF + strlen(XBUF),
@@ -594,7 +532,7 @@ static const int l2_4_count = PTP_LEVELS
  *
  * Virtual address space of the kernel when leaving this function:
  * +--------------+------------------+-------------+------------+---------------
- * | KERNEL IMAGE | BOOTSTRAP TABLES | PROC0 UAREA | DUMMY PAGE | HYPER. SHARED 
+ * | KERNEL IMAGE | BOOTSTRAP TABLES | PROC0 UAREA | DUMMY PAGE | HYPER. SHARED
  * +--------------+------------------+-------------+------------+---------------
  *
  * ------+-----------------+-------------+
@@ -690,7 +628,7 @@ xen_locore(void)
 
 bootstrap_again:
 
-	/* 
+	/*
 	 * Xen space we'll reclaim may not be enough for our new page tables,
 	 * move bootstrap tables if necessary.
 	 */
@@ -702,7 +640,7 @@ bootstrap_again:
 	 * Make sure the number of L2 pages we have is enough to map everything
 	 * from KERNBASE to the bootstrap tables themselves.
 	 */
-	if (bootstrap_tables + ((oldcount + l2_4_count) * PAGE_SIZE) > 
+	if (bootstrap_tables + ((oldcount + l2_4_count) * PAGE_SIZE) >
 	    KERNBASE + (oldcount << L2_SHIFT)) {
 		oldcount++;
 		goto bootstrap_again;
@@ -745,6 +683,9 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	extern char __data_start;
 	extern char __kernel_end;
 	extern char *early_zerop; /* from pmap.c */
+#ifdef i386
+	extern union descriptor tmpgdt[];
+#endif
 
 	/*
 	 * Layout of RW area after the kernel image:
@@ -789,14 +730,14 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	__PRINTK(("console %#lx ", xen_start_info.console_mfn));
 	__PRINTK(("xenstore %#" PRIx32 "\n", xen_start_info.store_mfn));
 
-	/* 
+	/*
 	 * Create bootstrap page tables. What we need:
 	 * - a PGD (level 4)
 	 * - a PDTPE (level 3)
 	 * - a PDE (level 2)
 	 * - some PTEs (level 1)
 	 */
-	
+
 	bt_pgd = (pd_entry_t *)new_pgd;
 	memset(bt_pgd, 0, PAGE_SIZE);
 	avail = new_pgd + PAGE_SIZE;
@@ -816,7 +757,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 
 	addr = ((u_long)pdtpe) - KERNBASE;
 	bt_pgd[pl4_pi(KERNTEXTOFF)] = bt_cpu_pgd[pl4_pi(KERNTEXTOFF)] =
-	    xpmap_ptom_masked(addr) | PG_k | PG_V | PG_RW;
+	    xpmap_ptom_masked(addr) | PG_V | PG_RW;
 #else
 	pdtpe = bt_pgd;
 #endif
@@ -829,7 +770,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 
 	addr = ((u_long)pde) - KERNBASE;
 	pdtpe[pl3_pi(KERNTEXTOFF)] =
-	    xpmap_ptom_masked(addr) | PG_k | PG_V | PG_RW;
+	    xpmap_ptom_masked(addr) | PG_V | PG_RW;
 #elif defined(PAE)
 	/*
 	 * Our PAE-style level 2, 5 contiguous pages (4 L2 + 1 shadow).
@@ -849,10 +790,10 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	 */
 	addr = ((u_long)pde) - KERNBASE;
 	for (i = 0; i < 3; i++, addr += PAGE_SIZE) {
-		pdtpe[i] = xpmap_ptom_masked(addr) | PG_k | PG_V;
+		pdtpe[i] = xpmap_ptom_masked(addr) | PG_V;
 	}
 	addr += PAGE_SIZE;
-	pdtpe[3] = xpmap_ptom_masked(addr) | PG_k | PG_V;
+	pdtpe[3] = xpmap_ptom_masked(addr) | PG_V;
 #else
 	pde = bt_pgd;
 #endif
@@ -898,7 +839,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 			}
 #endif
 
-			pte[pl1_pi(page)] |= PG_k | PG_V;
+			pte[pl1_pi(page)] |= PG_V;
 			if (page < (vaddr_t)&__rodata_start) {
 				/* Map the kernel text RX. */
 				pte[pl1_pi(page)] |= PG_RO;
@@ -938,7 +879,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 
 		addr = ((u_long)pte) - KERNBASE;
 		pde[pl2_pi(cur_page)] =
-		    xpmap_ptom_masked(addr) | PG_k | PG_RW | PG_V;
+		    xpmap_ptom_masked(addr) | PG_RW | PG_V;
 
 		/* Mark readonly */
 		xen_bt_set_readonly((vaddr_t)pte);
@@ -960,7 +901,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	 */
 	addr = (u_long)pde - KERNBASE;
 	for (i = 0; i < 3; i++, addr += PAGE_SIZE) {
-		pde[PDIR_SLOT_PTE + i] = xpmap_ptom_masked(addr) | PG_k | PG_V |
+		pde[PDIR_SLOT_PTE + i] = xpmap_ptom_masked(addr) | PG_V |
 		    xpmap_pg_nx;
 	}
 
@@ -977,11 +918,11 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 
 	/* Recursive entry in pmap_kernel(). */
 	bt_pgd[PDIR_SLOT_PTE] = xpmap_ptom_masked((paddr_t)bt_pgd - KERNBASE)
-	    | PG_k | PG_RO | PG_V | xpmap_pg_nx;
+	    | PG_RO | PG_V | xpmap_pg_nx;
 #ifdef __x86_64__
 	/* Recursive entry in higher-level per-cpu PD. */
 	bt_cpu_pgd[PDIR_SLOT_PTE] = xpmap_ptom_masked((paddr_t)bt_cpu_pgd - KERNBASE)
-	    | PG_k | PG_RO | PG_V | xpmap_pg_nx;
+	    | PG_RO | PG_V | xpmap_pg_nx;
 #endif
 
 	/* Mark tables RO */
@@ -1024,7 +965,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 		addr = (u_long)pde - KERNBASE + PAGE_SIZE * 3;
 		xpq_queue_pte_update(
 		    xpmap_ptom(((vaddr_t)&pde[PDIR_SLOT_PTE + 3]) - KERNBASE),
-		    xpmap_ptom_masked(addr) | PG_k | PG_V);
+		    xpmap_ptom_masked(addr) | PG_V);
 		xpq_flush_queue();
 	}
 #elif defined(__x86_64__)
@@ -1052,7 +993,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 		addr = xpmap_ptom(((u_long)pte) - KERNBASE);
 		xpq_queue_pte_update(addr, *pte | PG_RW);
 		page += PAGE_SIZE;
-		/* 
+		/*
 		 * Our PTEs are contiguous so it's safe to just "++" here.
 		 */
 		pte++;
@@ -1069,7 +1010,7 @@ xen_bt_set_readonly(vaddr_t page)
 	pt_entry_t entry;
 
 	entry = xpmap_ptom_masked(page - KERNBASE);
-	entry |= PG_k | PG_V | xpmap_pg_nx;
+	entry |= PG_V | xpmap_pg_nx;
 
 	HYPERVISOR_update_va_mapping(page, entry, UVMF_INVLPG);
 }

Reply via email to