direct-io.hg

changeset 8676:0eb38397e608

Introduce XENFEAT_writable_mmu_structures.

This feature flag indicates to the guest that it is allowable to
use writable LDT, GDT and page table pages.

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
Index: xen-features/xen/include/public/version.h
===================================================================
--- xen-features.orig/xen/include/public/version.h 2006-01-27 11:27:14.000000000 +0000
+++ xen-features/xen/include/public/version.h 2006-01-27 11:27:14.000000000 +0000
@@ -45,6 +45,9 @@
uint32_t submap; /* OUT: 32-bit submap */
} xen_feature_info_t;

+#define _XENFEAT_writable_mmu_structures 0
+#define XENFEAT_writable_mmu_structures (1UL<<_XENFEAT_writable_mmu_structures)
+
#define XENFEAT_NR_SUBMAPS 1

#endif /* __XEN_PUBLIC_VERSION_H__ */
Index: xen-features/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c
===================================================================
--- xen-features.orig/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c 2006-01-27 11:27:14.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c 2006-01-27 11:27:14.000000000 +0000
@@ -24,6 +24,7 @@
#include <asm/io.h>
#include <asm/mmu_context.h>

+#include <asm-xen/features.h>
#include <asm-xen/foreign_page.h>
#include <asm/hypervisor.h>

@@ -391,24 +392,42 @@
#ifndef CONFIG_XEN_SHADOW_MODE
void make_lowmem_mmu_page_readonly(void *va)
{
- pte_t *pte = virt_to_ptep(va);
- int rc = HYPERVISOR_update_va_mapping(
+ pte_t *pte;
+ int rc;
+
+ if (xen_feature(writable_mmu_structures))
+ return;
+
+ pte = virt_to_ptep(va);
+ rc = HYPERVISOR_update_va_mapping(
(unsigned long)va, pte_wrprotect(*pte), 0);
BUG_ON(rc);
}

void make_lowmem_mmu_page_writable(void *va)
{
- pte_t *pte = virt_to_ptep(va);
- int rc = HYPERVISOR_update_va_mapping(
+ pte_t *pte;
+ int rc;
+
+ if (xen_feature(writable_mmu_structures))
+ return;
+
+ pte = virt_to_ptep(va);
+ rc = HYPERVISOR_update_va_mapping(
(unsigned long)va, pte_mkwrite(*pte), 0);
BUG_ON(rc);
}

void make_mmu_page_readonly(void *va)
{
- pte_t *pte = virt_to_ptep(va);
- int rc = HYPERVISOR_update_va_mapping(
+ pte_t *pte;
+ int rc;
+
+ if (xen_feature(writable_mmu_structures))
+ return;
+
+ pte = virt_to_ptep(va);
+ rc = HYPERVISOR_update_va_mapping(
(unsigned long)va, pte_wrprotect(*pte), 0);
if (rc) /* fallback? */
xen_l1_entry_update(pte, pte_wrprotect(*pte));
@@ -426,8 +445,14 @@

void make_mmu_page_writable(void *va)
{
- pte_t *pte = virt_to_ptep(va);
- int rc = HYPERVISOR_update_va_mapping(
+ pte_t *pte;
+ int rc;
+
+ if (xen_feature(writable_mmu_structures))
+ return;
+
+ pte = virt_to_ptep(va);
+ rc = HYPERVISOR_update_va_mapping(
(unsigned long)va, pte_mkwrite(*pte), 0);
if (rc) /* fallback? */
xen_l1_entry_update(pte, pte_mkwrite(*pte));
@@ -443,6 +468,9 @@

void make_mmu_pages_readonly(void *va, unsigned int nr)
{
+ if (xen_feature(writable_mmu_structures))
+ return;
+
while (nr-- != 0) {
make_mmu_page_readonly(va);
va = (void *)((unsigned long)va + PAGE_SIZE);
@@ -451,6 +479,8 @@

void make_mmu_pages_writable(void *va, unsigned int nr)
{
+ if (xen_feature(writable_mmu_structures))
+ return;
while (nr-- != 0) {
make_mmu_page_writable(va);
va = (void *)((unsigned long)va + PAGE_SIZE);
Index: xen-features/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c
===================================================================
--- xen-features.orig/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c 2006-01-27 11:27:14.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c 2006-01-27 11:27:18.000000000 +0000
@@ -40,6 +40,8 @@
#include <asm/proto.h>
#include <asm/smp.h>

+#include <asm-xen/features.h>
+
#ifndef Dprintk
#define Dprintk(x...)
#endif
@@ -72,6 +74,9 @@
pte_t pte, *ptep;
unsigned long *page = (unsigned long *) init_level4_pgt;

+ if (xen_feature(writable_mmu_structures))
+ return;
+
addr = (unsigned long) page[pgd_index(_va)];
addr_to_page(addr, page);

@@ -93,6 +98,9 @@
pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
unsigned long addr = (unsigned long) va;

+ if (xen_feature(writable_mmu_structures))
+ return;
+
pgd = pgd_offset_k(addr);
pud = pud_offset(pgd, addr);
pmd = pmd_offset(pud, addr);
@@ -111,6 +119,9 @@
pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
unsigned long addr = (unsigned long) va;

+ if (xen_feature(writable_mmu_structures))
+ return;
+
pgd = pgd_offset_k(addr);
pud = pud_offset(pgd, addr);
pmd = pmd_offset(pud, addr);
@@ -126,6 +137,9 @@

void make_mmu_pages_readonly(void *va, unsigned nr)
{
+ if (xen_feature(writable_mmu_structures))
+ return;
+
while (nr-- != 0) {
make_mmu_page_readonly(va);
va = (void*)((unsigned long)va + PAGE_SIZE);
@@ -134,6 +148,8 @@

void make_mmu_pages_writable(void *va, unsigned nr)
{
+ if (xen_feature(writable_mmu_structures))
+ return;
while (nr-- != 0) {
make_mmu_page_writable(va);
va = (void*)((unsigned long)va + PAGE_SIZE);
@@ -385,6 +401,9 @@
{
int readonly = 0;

+ if (xen_feature(writable_mmu_structures))
+ return 0;
+
/* Make old and new page tables read-only. */
if ((paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
&& (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
author Ian.Campbell@xensource.com
date Fri Jan 27 11:31:14 2006 +0000 (2006-01-27)
parents 31083f13ae47
children 60beade30a0c
files linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c xen/include/public/version.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Jan 27 11:31:12 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Jan 27 11:31:14 2006 +0000
     1.3 @@ -24,6 +24,7 @@
     1.4  #include <asm/io.h>
     1.5  #include <asm/mmu_context.h>
     1.6  
     1.7 +#include <asm-xen/features.h>
     1.8  #include <asm-xen/foreign_page.h>
     1.9  #include <asm/hypervisor.h>
    1.10  
    1.11 @@ -391,24 +392,42 @@ void pgd_free(pgd_t *pgd)
    1.12  #ifndef CONFIG_XEN_SHADOW_MODE
    1.13  void make_lowmem_mmu_page_readonly(void *va)
    1.14  {
    1.15 -	pte_t *pte = virt_to_ptep(va);
    1.16 -	int rc = HYPERVISOR_update_va_mapping(
    1.17 +	pte_t *pte;
    1.18 +	int rc;
    1.19 +
    1.20 +	if (xen_feature(writable_mmu_structures))
    1.21 +		return;
    1.22 +
    1.23 +	pte = virt_to_ptep(va);
    1.24 +	rc = HYPERVISOR_update_va_mapping(
    1.25  		(unsigned long)va, pte_wrprotect(*pte), 0);
    1.26  	BUG_ON(rc);
    1.27  }
    1.28  
    1.29  void make_lowmem_mmu_page_writable(void *va)
    1.30  {
    1.31 -	pte_t *pte = virt_to_ptep(va);
    1.32 -	int rc = HYPERVISOR_update_va_mapping(
    1.33 +	pte_t *pte;
    1.34 +	int rc;
    1.35 +
    1.36 +	if (xen_feature(writable_mmu_structures))
    1.37 +		return;
    1.38 +
    1.39 +	pte = virt_to_ptep(va);
    1.40 +	rc = HYPERVISOR_update_va_mapping(
    1.41  		(unsigned long)va, pte_mkwrite(*pte), 0);
    1.42  	BUG_ON(rc);
    1.43  }
    1.44  
    1.45  void make_mmu_page_readonly(void *va)
    1.46  {
    1.47 -	pte_t *pte = virt_to_ptep(va);
    1.48 -	int rc = HYPERVISOR_update_va_mapping(
    1.49 +	pte_t *pte;
    1.50 +	int rc;
    1.51 +
    1.52 +	if (xen_feature(writable_mmu_structures))
    1.53 +		return;
    1.54 +
    1.55 +	pte = virt_to_ptep(va);
    1.56 +	rc = HYPERVISOR_update_va_mapping(
    1.57  		(unsigned long)va, pte_wrprotect(*pte), 0);
    1.58  	if (rc) /* fallback? */
    1.59  		xen_l1_entry_update(pte, pte_wrprotect(*pte));
    1.60 @@ -426,8 +445,14 @@ void make_mmu_page_readonly(void *va)
    1.61  
    1.62  void make_mmu_page_writable(void *va)
    1.63  {
    1.64 -	pte_t *pte = virt_to_ptep(va);
    1.65 -	int rc = HYPERVISOR_update_va_mapping(
    1.66 +	pte_t *pte;
    1.67 +	int rc;
    1.68 +
    1.69 +	if (xen_feature(writable_mmu_structures))
    1.70 +		return;
    1.71 +
    1.72 +	pte = virt_to_ptep(va);
    1.73 +	rc = HYPERVISOR_update_va_mapping(
    1.74  		(unsigned long)va, pte_mkwrite(*pte), 0);
    1.75  	if (rc) /* fallback? */
    1.76  		xen_l1_entry_update(pte, pte_mkwrite(*pte));
    1.77 @@ -443,6 +468,9 @@ void make_mmu_page_writable(void *va)
    1.78  
    1.79  void make_mmu_pages_readonly(void *va, unsigned int nr)
    1.80  {
    1.81 +	if (xen_feature(writable_mmu_structures))
    1.82 +		return;
    1.83 +
    1.84  	while (nr-- != 0) {
    1.85  		make_mmu_page_readonly(va);
    1.86  		va = (void *)((unsigned long)va + PAGE_SIZE);
    1.87 @@ -451,6 +479,8 @@ void make_mmu_pages_readonly(void *va, u
    1.88  
    1.89  void make_mmu_pages_writable(void *va, unsigned int nr)
    1.90  {
    1.91 +	if (xen_feature(writable_mmu_structures))
    1.92 +		return;
    1.93  	while (nr-- != 0) {
    1.94  		make_mmu_page_writable(va);
    1.95  		va = (void *)((unsigned long)va + PAGE_SIZE);
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Jan 27 11:31:12 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Jan 27 11:31:14 2006 +0000
     2.3 @@ -40,6 +40,8 @@
     2.4  #include <asm/proto.h>
     2.5  #include <asm/smp.h>
     2.6  
     2.7 +#include <asm-xen/features.h>
     2.8 +
     2.9  #ifndef Dprintk
    2.10  #define Dprintk(x...)
    2.11  #endif
    2.12 @@ -72,6 +74,9 @@ static void early_make_mmu_page_readonly
    2.13  	pte_t pte, *ptep;
    2.14  	unsigned long *page = (unsigned long *) init_level4_pgt;
    2.15  
    2.16 +	if (xen_feature(writable_mmu_structures))
    2.17 +		return;
    2.18 +
    2.19  	addr = (unsigned long) page[pgd_index(_va)];
    2.20  	addr_to_page(addr, page);
    2.21  
    2.22 @@ -93,6 +98,9 @@ void make_mmu_page_readonly(void *va)
    2.23  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
    2.24  	unsigned long addr = (unsigned long) va;
    2.25  
    2.26 +	if (xen_feature(writable_mmu_structures))
    2.27 +		return;
    2.28 +
    2.29  	pgd = pgd_offset_k(addr);
    2.30  	pud = pud_offset(pgd, addr);
    2.31  	pmd = pmd_offset(pud, addr);
    2.32 @@ -111,6 +119,9 @@ void make_mmu_page_writable(void *va)
    2.33  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
    2.34  	unsigned long addr = (unsigned long) va;
    2.35  
    2.36 +	if (xen_feature(writable_mmu_structures))
    2.37 +		return;
    2.38 +
    2.39  	pgd = pgd_offset_k(addr);
    2.40  	pud = pud_offset(pgd, addr);
    2.41  	pmd = pmd_offset(pud, addr);
    2.42 @@ -126,6 +137,9 @@ void make_mmu_page_writable(void *va)
    2.43  
    2.44  void make_mmu_pages_readonly(void *va, unsigned nr)
    2.45  {
    2.46 +	if (xen_feature(writable_mmu_structures))
    2.47 +		return;
    2.48 +
    2.49  	while (nr-- != 0) {
    2.50  		make_mmu_page_readonly(va);
    2.51  		va = (void*)((unsigned long)va + PAGE_SIZE);
    2.52 @@ -134,6 +148,8 @@ void make_mmu_pages_readonly(void *va, u
    2.53  
    2.54  void make_mmu_pages_writable(void *va, unsigned nr)
    2.55  {
    2.56 +	if (xen_feature(writable_mmu_structures))
    2.57 +		return;
    2.58  	while (nr-- != 0) {
    2.59  		make_mmu_page_writable(va);
    2.60  		va = (void*)((unsigned long)va + PAGE_SIZE);
    2.61 @@ -385,6 +401,9 @@ static inline int make_readonly(unsigned
    2.62  {
    2.63  	int readonly = 0;
    2.64  
    2.65 +	if (xen_feature(writable_mmu_structures))
    2.66 +		return 0;
    2.67 +
    2.68  	/* Make old and new page tables read-only. */
    2.69  	if ((paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
    2.70  	    && (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
     3.1 --- a/xen/include/public/version.h	Fri Jan 27 11:31:12 2006 +0000
     3.2 +++ b/xen/include/public/version.h	Fri Jan 27 11:31:14 2006 +0000
     3.3 @@ -45,6 +45,9 @@ typedef struct xen_feature_info {
     3.4      uint32_t     submap;        /* OUT: 32-bit submap */
     3.5  } xen_feature_info_t;
     3.6  
     3.7 +#define _XENFEAT_writable_mmu_structures 0
     3.8 +#define XENFEAT_writable_mmu_structures (1UL<<_XENFEAT_writable_mmu_structures)
     3.9 +
    3.10  #define XENFEAT_NR_SUBMAPS 1
    3.11  
    3.12  #endif /* __XEN_PUBLIC_VERSION_H__ */