ia64/xen-unstable

view xen/include/asm-x86/hap.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 7953164cebb6
children 43833a6d50a5
line source
1 /******************************************************************************
2 * include/asm-x86/hap.h
3 *
4 * hardware-assisted paging
5 * Copyright (c) 2007 Advanced Micro Devices (Wei Huang)
6 *
7 * Parts of this code are Copyright (c) 2006 by XenSource Inc.
8 * Parts of this code are Copyright (c) 2006 by Michael A Fetterman
9 * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
26 #ifndef _XEN_HAP_H
27 #define _XEN_HAP_H
29 #define HAP_PRINTK(_f, _a...) \
30 debugtrace_printk("hap: %s(): " _f, __func__, ##_a)
31 #define HAP_ERROR(_f, _a...) \
32 printk("hap error: %s(): " _f, __func__, ##_a)
34 /************************************************/
35 /* hap domain page mapping */
36 /************************************************/
37 static inline void *
38 hap_map_domain_page(mfn_t mfn)
39 {
40 return map_domain_page(mfn_x(mfn));
41 }
43 static inline void
44 hap_unmap_domain_page(void *p)
45 {
46 unmap_domain_page(p);
47 }
49 /************************************************/
50 /* locking for hap code */
51 /************************************************/
52 #define hap_lock_init(_d) \
53 do { \
54 spin_lock_init(&(_d)->arch.paging.hap.lock); \
55 (_d)->arch.paging.hap.locker = -1; \
56 (_d)->arch.paging.hap.locker_function = "nobody"; \
57 } while (0)
59 #define hap_locked_by_me(_d) \
60 (current->processor == (_d)->arch.paging.hap.locker)
62 #define hap_lock(_d) \
63 do { \
64 if ( unlikely((_d)->arch.paging.hap.locker == current->processor) )\
65 { \
66 printk("Error: hap lock held by %s\n", \
67 (_d)->arch.paging.hap.locker_function); \
68 BUG(); \
69 } \
70 spin_lock(&(_d)->arch.paging.hap.lock); \
71 ASSERT((_d)->arch.paging.hap.locker == -1); \
72 (_d)->arch.paging.hap.locker = current->processor; \
73 (_d)->arch.paging.hap.locker_function = __func__; \
74 } while (0)
76 #define hap_unlock(_d) \
77 do { \
78 ASSERT((_d)->arch.paging.hap.locker == current->processor); \
79 (_d)->arch.paging.hap.locker = -1; \
80 (_d)->arch.paging.hap.locker_function = "nobody"; \
81 spin_unlock(&(_d)->arch.paging.hap.lock); \
82 } while (0)
84 /************************************************/
85 /* hap domain level functions */
86 /************************************************/
87 void hap_domain_init(struct domain *d);
88 int hap_domctl(struct domain *d, xen_domctl_shadow_op_t *sc,
89 XEN_GUEST_HANDLE(void) u_domctl);
90 int hap_enable(struct domain *d, u32 mode);
91 void hap_final_teardown(struct domain *d);
92 void hap_teardown(struct domain *d);
93 void hap_vcpu_init(struct vcpu *v);
95 extern struct paging_mode hap_paging_real_mode;
96 extern struct paging_mode hap_paging_protected_mode;
97 extern struct paging_mode hap_paging_pae_mode;
98 extern struct paging_mode hap_paging_long_mode;
100 #endif /* XEN_HAP_H */
102 /*
103 * Local variables:
104 * mode: C
105 * c-set-style: "BSD"
106 * c-basic-offset: 4
107 * indent-tabs-mode: nil
108 * End:
109 */