? cr3_pa(v->arch.hvm.guest_cr[3]) >> PAGE_SHIFT
: pagetable_get_pfn(v->arch.guest_table));
-#if GUEST_PAGING_LEVELS == 3 /* PAE */
- return guest_walk_tables(v, p2m_get_hostp2m(v->domain), va, gw, pfec,
- root_gfn, INVALID_MFN, v->arch.paging.shadow.gl3e);
-#else /* 32 or 64 */
+#if GUEST_PAGING_LEVELS != 3 /* 32 or 64 */
const struct domain *d = v->domain;
mfn_t root_mfn = (v->arch.flags & TF_kernel_mode
? pagetable_get_mfn(v->arch.guest_table)
unmap_domain_page(root_map);
return ok;
+#elif !defined(CONFIG_HVM)
+ ASSERT_UNREACHABLE();
+ (void)root_gfn;
+ memset(gw, 0, sizeof(*gw));
+ return false;
+#else /* PAE */
+ return guest_walk_tables(v, p2m_get_hostp2m(v->domain), va, gw, pfec,
+ root_gfn, INVALID_MFN, v->arch.paging.shadow.gl3e);
#endif
}
l3p = map_domain_page(gw->l3mfn);
mismatch |= (gw->l3e.l3 != l3p[guest_l3_table_offset(va)].l3);
unmap_domain_page(l3p);
-#else
+#elif defined(CONFIG_HVM)
mismatch |= (gw->l3e.l3 !=
v->arch.paging.shadow.gl3e[guest_l3_table_offset(va)].l3);
#endif
}
/* Now follow it down a level. Guaranteed to succeed. */
return sh_linear_l2_table(v) + shadow_l2_linear_offset(gw->va);
+#elif !defined(CONFIG_HVM)
+ return NULL;
#elif GUEST_PAGING_LEVELS == 3 /* PAE... */
/* We never demand-shadow PAE l3es: they are only created in
* sh_update_cr3(). Check if the relevant sl3e is present. */
if ( !(shadow_l3e_get_flags(sl3e) & _PAGE_PRESENT) )
return false;
}
+#elif !defined(CONFIG_HVM)
+ return false;
#else /* SHADOW_PAGING_LEVELS == 3 */
if ( !(l3e_get_flags(v->arch.paging.shadow.l3table[shadow_l3_linear_offset(linear)])
& _PAGE_PRESENT) )
pagetable_get_pfn(v->arch.hvm.monitor_table) == 0 )
return;
-#if SHADOW_PAGING_LEVELS == 4
+#if !defined(CONFIG_HVM)
+ return;
+#elif SHADOW_PAGING_LEVELS == 4
/* For HVM, just need to update the l4e that points to the shadow l4. */
{
struct domain *d = v->domain;
mfn_t gmfn;
-#if GUEST_PAGING_LEVELS == 3
+#if GUEST_PAGING_LEVELS == 3 && defined(CONFIG_HVM)
const guest_l3e_t *gl3e;
unsigned int i, guest_idx;
#endif
#endif
gmfn = pagetable_get_mfn(v->arch.guest_table);
-#if GUEST_PAGING_LEVELS == 3
+#if GUEST_PAGING_LEVELS == 3 && defined(CONFIG_HVM)
/*
* On PAE guests we don't use a mapping of the guest's own top-level
* table. We cache the current state of that table and shadow that,
/* We revoke write access to the new guest toplevel page(s) before we
* replace the old shadow pagetable(s), so that we can safely use the
* (old) shadow linear maps in the writeable mapping heuristics. */
-#if GUEST_PAGING_LEVELS == 2
- if ( sh_remove_write_access(d, gmfn, 2, 0) != 0 )
+#if GUEST_PAGING_LEVELS == 4
+ if ( sh_remove_write_access(d, gmfn, 4, 0) != 0 )
guest_flush_tlb_mask(d, d->dirty_cpumask);
- sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l2_shadow, sh_make_shadow);
+ sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l4_shadow, sh_make_shadow);
+ if ( !shadow_mode_external(d) && !is_pv_32bit_domain(d) )
+ {
+ mfn_t smfn = pagetable_get_mfn(v->arch.paging.shadow.shadow_table[0]);
+
+ if ( !(v->arch.flags & TF_kernel_mode) && VM_ASSIST(d, m2p_strict) )
+ zap_ro_mpt(smfn);
+ else if ( (v->arch.flags & TF_kernel_mode) &&
+ !VM_ASSIST(d, m2p_strict) )
+ fill_ro_mpt(smfn);
+ }
+#elif !defined(CONFIG_HVM)
+ ASSERT_UNREACHABLE();
#elif GUEST_PAGING_LEVELS == 3
/* PAE guests have four shadow_table entries, based on the
* current values of the guest's four l3es. */
gfn_t gl2gfn;
mfn_t gl2mfn;
p2m_type_t p2mt;
- const guest_l3e_t *gl3e = v->arch.paging.shadow.gl3e;
+
+ gl3e = v->arch.paging.shadow.gl3e;
/* First, make all four entries read-only. */
for ( i = 0; i < 4; i++ )
sh_set_toplevel_shadow(v, i, INVALID_MFN, 0, sh_make_shadow);
}
}
-#elif GUEST_PAGING_LEVELS == 4
- if ( sh_remove_write_access(d, gmfn, 4, 0) != 0 )
+#elif GUEST_PAGING_LEVELS == 2
+ if ( sh_remove_write_access(d, gmfn, 2, 0) != 0 )
guest_flush_tlb_mask(d, d->dirty_cpumask);
- sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l4_shadow, sh_make_shadow);
- if ( !shadow_mode_external(d) && !is_pv_32bit_domain(d) )
- {
- mfn_t smfn = pagetable_get_mfn(v->arch.paging.shadow.shadow_table[0]);
-
- if ( !(v->arch.flags & TF_kernel_mode) && VM_ASSIST(d, m2p_strict) )
- zap_ro_mpt(smfn);
- else if ( (v->arch.flags & TF_kernel_mode) &&
- !VM_ASSIST(d, m2p_strict) )
- fill_ro_mpt(smfn);
- }
+ sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l2_shadow, sh_make_shadow);
#else
#error This should never happen
#endif
+#ifdef CONFIG_HVM
///
/// v->arch.paging.shadow.l3table
///
}
}
#endif /* SHADOW_PAGING_LEVELS == 3 */
-
+#endif /* CONFIG_HVM */
///
/// v->arch.cr3
#endif
+#ifdef CONFIG_HVM
///
/// v->arch.hvm.hw_cr[3]
///
#endif
hvm_update_guest_cr3(v, noflush);
}
+#endif /* CONFIG_HVM */
/* Fix up the linear pagetable mappings */
sh_update_linear_entries(v);