ia64/xen-unstable

view xen/include/asm-x86/shadow.h @ 15812:86a154e1ef5d

[HVM] Shadow: don't shadow the p2m table.
For HVM vcpus with paging disabled, we used to shadow the p2m table,
and skip the p2m lookup to go from gfn to mfn. Instead, we now
provide a simple pagetable that gives a one-to-one mapping of 4GB, and
shadow that, making the translations from gfn to mfn via the p2m.
This removes the paging-disabled special-case code from the shadow
fault handler, and allows us to expand the p2m interface, since all HVM
translations now go through the same p2m lookups.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Aug 31 11:06:22 2007 +0100 (2007-08-31)
parents 3d5f39c610ad
children b6aa55ca599e
line source
1 /******************************************************************************
2 * include/asm-x86/shadow.h
3 *
4 * Parts of this code are Copyright (c) 2006 by XenSource Inc.
5 * Parts of this code are Copyright (c) 2006 by Michael A Fetterman
6 * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 #ifndef _XEN_SHADOW_H
24 #define _XEN_SHADOW_H
26 #include <public/domctl.h>
27 #include <xen/sched.h>
28 #include <xen/perfc.h>
29 #include <xen/domain_page.h>
30 #include <asm/flushtlb.h>
31 #include <asm/paging.h>
32 #include <asm/p2m.h>
34 /*****************************************************************************
35 * Macros to tell which shadow paging mode a domain is in*/
37 #define shadow_mode_enabled(_d) paging_mode_shadow(_d)
38 #define shadow_mode_refcounts(_d) (paging_mode_shadow(_d) && \
39 paging_mode_refcounts(_d))
40 #define shadow_mode_log_dirty(_d) (paging_mode_shadow(_d) && \
41 paging_mode_log_dirty(_d))
42 #define shadow_mode_translate(_d) (paging_mode_shadow(_d) && \
43 paging_mode_translate(_d))
44 #define shadow_mode_external(_d) (paging_mode_shadow(_d) && \
45 paging_mode_external(_d))
47 /* Xen traps & emulates all reads of all page table pages:
48 * not yet supported */
49 #define shadow_mode_trap_reads(_d) ({ (void)(_d); 0; })
51 /*****************************************************************************
52 * Entry points into the shadow code */
54 /* Set up the shadow-specific parts of a domain struct at start of day.
55 * Called from paging_domain_init(). */
56 void shadow_domain_init(struct domain *d);
58 /* Setup the shadow-specific parts of a vcpu struct. It is called by
59 * paging_vcpu_init() in paging.c */
60 void shadow_vcpu_init(struct vcpu *v);
62 /* Enable an arbitrary shadow mode. Call once at domain creation. */
63 int shadow_enable(struct domain *d, u32 mode);
65 /* Handler for shadow control ops: operations from user-space to enable
66 * and disable ephemeral shadow modes (test mode and log-dirty mode) and
67 * manipulate the log-dirty bitmap. */
68 int shadow_domctl(struct domain *d,
69 xen_domctl_shadow_op_t *sc,
70 XEN_GUEST_HANDLE(void) u_domctl);
72 /* Call when destroying a domain */
73 void shadow_teardown(struct domain *d);
75 /* Call once all of the references to the domain have gone away */
76 void shadow_final_teardown(struct domain *d);
78 /* shadow code to call when log dirty is enabled */
79 int shadow_enable_log_dirty(struct domain *d);
81 /* shadow code to call when log dirty is disabled */
82 int shadow_disable_log_dirty(struct domain *d);
84 /* shadow code to call when bitmap is being cleaned */
85 void shadow_clean_dirty_bitmap(struct domain *d);
87 /* Update all the things that are derived from the guest's CR0/CR3/CR4.
88 * Called to initialize paging structures if the paging mode
89 * has changed, and when bringing up a VCPU for the first time. */
90 void shadow_update_paging_modes(struct vcpu *v);
93 /* Remove all mappings of the guest page from the shadows.
94 * This is called from common code. It does not flush TLBs. */
95 int sh_remove_all_mappings(struct vcpu *v, mfn_t target_mfn);
96 static inline void
97 shadow_drop_references(struct domain *d, struct page_info *p)
98 {
99 if ( unlikely(shadow_mode_enabled(d)) )
100 /* See the comment about locking in sh_remove_all_mappings */
101 sh_remove_all_mappings(d->vcpu[0], _mfn(page_to_mfn(p)));
102 }
104 /* Remove all shadows of the guest mfn. */
105 void sh_remove_shadows(struct vcpu *v, mfn_t gmfn, int fast, int all);
106 static inline void shadow_remove_all_shadows(struct vcpu *v, mfn_t gmfn)
107 {
108 /* See the comment about locking in sh_remove_shadows */
109 sh_remove_shadows(v, gmfn, 0 /* Be thorough */, 1 /* Must succeed */);
110 }
112 #define guest_physmap_max_mem_pages(d, n) (0)
114 #endif /* _XEN_SHADOW_H */
116 /*
117 * Local variables:
118 * mode: C
119 * c-set-style: "BSD"
120 * c-basic-offset: 4
121 * indent-tabs-mode: nil
122 * End:
123 */