|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v1 1/2] x86: add p2m_ram_wp
Add a new p2m type p2m_ram_wp. Page of p2m_ram_wp is read only, and
write will go to the device model for emulation.
Signed-off-by: Wei Ye <wei.ye@xxxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 8 +++++++-
xen/arch/x86/mm/p2m-ept.c | 1 +
xen/include/asm-x86/p2m.h | 8 +++++++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 17ff011..0f20b62 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2738,7 +2738,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa,
* If this GFN is emulated MMIO or marked as read-only, pass the fault
* to the mmio handler.
*/
- if ( (p2mt == p2m_mmio_dm) ||
+ if ( (p2mt == p2m_mmio_dm) ||
+ (p2mt == p2m_ram_wp) ||
(access_w && (p2mt == p2m_ram_ro)) )
{
put_gfn(p2m->domain, gfn);
@@ -3829,6 +3830,11 @@ static enum hvm_copy_result __hvm_copy(
put_page(page);
return HVMCOPY_unhandleable;
}
+ if ( p2m_is_wp_ram(p2mt) )
+ {
+ put_page(page);
+ return HVMCOPY_bad_gfn_to_mfn;
+ }
p = (char *)__map_domain_page(page) + (addr & ~PAGE_MASK);
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 15c6e83..1b4a83e 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -125,6 +125,7 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry,
p2m_type_t type, p2m_acces
entry->mfn);
break;
case p2m_ram_logdirty:
+ case p2m_ram_wp:
case p2m_ram_ro:
case p2m_ram_shared:
entry->r = entry->x = 1;
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 0ddbadb..bbec847 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -71,6 +71,7 @@ typedef enum {
p2m_ram_shared = 12, /* Shared or sharable memory */
p2m_ram_broken = 13, /* Broken page, access cause domain crash */
p2m_map_foreign = 14, /* ram pages from foreign domain */
+ p2m_ram_wp = 15, /* Read-only; write go to the device model */
} p2m_type_t;
/*
@@ -116,7 +117,8 @@ typedef unsigned int p2m_query_t;
| p2m_to_mask(p2m_ram_paging_out) \
| p2m_to_mask(p2m_ram_paged) \
| p2m_to_mask(p2m_ram_paging_in) \
- | p2m_to_mask(p2m_ram_shared))
+ | p2m_to_mask(p2m_ram_shared) \
+ | p2m_to_mask(p2m_ram_wp))
/* Types that represent a physmap hole that is ok to replace with a shared
* entry */
@@ -167,6 +169,9 @@ typedef unsigned int p2m_query_t;
* and must not be touched. */
#define P2M_BROKEN_TYPES (p2m_to_mask(p2m_ram_broken))
+/* Write protection types */
+#define P2M_WP_TYPES (p2m_to_mask(p2m_ram_wp))
+
/* Useful predicates */
#define p2m_is_ram(_t) (p2m_to_mask(_t) & P2M_RAM_TYPES)
#define p2m_is_hole(_t) (p2m_to_mask(_t) & P2M_HOLE_TYPES)
@@ -191,6 +196,7 @@ typedef unsigned int p2m_query_t;
#define p2m_is_any_ram(_t) (p2m_to_mask(_t) & \
(P2M_RAM_TYPES | P2M_GRANT_TYPES | \
p2m_to_mask(p2m_map_foreign)))
+#define p2m_is_wp_ram(_t) (p2m_to_mask(_t) & P2M_WP_TYPES)
/* Per-p2m-table state */
struct p2m_domain {
--
1.7.9.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |