diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2010-06-17 09:22:52 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-07-27 02:13:26 -0400 |
commit | 5915100106b8f14a38053ad6c03a664d208aeaa2 (patch) | |
tree | 86117ec2860f0a1d1f16fd778ab2e53722871d33 | |
parent | c1c5413ad58cb73267d328e6020268aa2e50d8ca (diff) |
x86: Call HVMOP_pagetable_dying on exit_mmap.
When a pagetable is about to be destroyed, we notify Xen so that the
hypervisor can clear the related shadow pagetable.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
-rw-r--r-- | arch/x86/xen/enlighten.c | 1 | ||||
-rw-r--r-- | arch/x86/xen/mmu.c | 33 | ||||
-rw-r--r-- | arch/x86/xen/mmu.h | 1 | ||||
-rw-r--r-- | include/xen/interface/hvm/hvm_op.h | 11 |
4 files changed, 46 insertions, 0 deletions
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 157c93b62dd4..75b479a684fd 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1318,6 +1318,7 @@ static void __init xen_hvm_guest_init(void) | |||
1318 | have_vcpu_info_placement = 0; | 1318 | have_vcpu_info_placement = 0; |
1319 | x86_init.irqs.intr_init = xen_init_IRQ; | 1319 | x86_init.irqs.intr_init = xen_init_IRQ; |
1320 | xen_hvm_init_time_ops(); | 1320 | xen_hvm_init_time_ops(); |
1321 | xen_hvm_init_mmu_ops(); | ||
1321 | } | 1322 | } |
1322 | 1323 | ||
1323 | static bool __init xen_hvm_platform(void) | 1324 | static bool __init xen_hvm_platform(void) |
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 914f04695ce5..84648c1bf138 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include <xen/page.h> | 59 | #include <xen/page.h> |
60 | #include <xen/interface/xen.h> | 60 | #include <xen/interface/xen.h> |
61 | #include <xen/interface/hvm/hvm_op.h> | ||
61 | #include <xen/interface/version.h> | 62 | #include <xen/interface/version.h> |
62 | #include <xen/hvc-console.h> | 63 | #include <xen/hvc-console.h> |
63 | 64 | ||
@@ -1941,6 +1942,38 @@ void __init xen_init_mmu_ops(void) | |||
1941 | pv_mmu_ops = xen_mmu_ops; | 1942 | pv_mmu_ops = xen_mmu_ops; |
1942 | } | 1943 | } |
1943 | 1944 | ||
1945 | static void xen_hvm_exit_mmap(struct mm_struct *mm) | ||
1946 | { | ||
1947 | struct xen_hvm_pagetable_dying a; | ||
1948 | int rc; | ||
1949 | |||
1950 | a.domid = DOMID_SELF; | ||
1951 | a.gpa = __pa(mm->pgd); | ||
1952 | rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a); | ||
1953 | WARN_ON_ONCE(rc < 0); | ||
1954 | } | ||
1955 | |||
1956 | static int is_pagetable_dying_supported(void) | ||
1957 | { | ||
1958 | struct xen_hvm_pagetable_dying a; | ||
1959 | int rc = 0; | ||
1960 | |||
1961 | a.domid = DOMID_SELF; | ||
1962 | a.gpa = 0x00; | ||
1963 | rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a); | ||
1964 | if (rc < 0) { | ||
1965 | printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n"); | ||
1966 | return 0; | ||
1967 | } | ||
1968 | return 1; | ||
1969 | } | ||
1970 | |||
1971 | void __init xen_hvm_init_mmu_ops(void) | ||
1972 | { | ||
1973 | if (is_pagetable_dying_supported()) | ||
1974 | pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap; | ||
1975 | } | ||
1976 | |||
1944 | #ifdef CONFIG_XEN_DEBUG_FS | 1977 | #ifdef CONFIG_XEN_DEBUG_FS |
1945 | 1978 | ||
1946 | static struct dentry *d_mmu_debug; | 1979 | static struct dentry *d_mmu_debug; |
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h index 5fe6bc7f5ecf..fa938c4aa2f7 100644 --- a/arch/x86/xen/mmu.h +++ b/arch/x86/xen/mmu.h | |||
@@ -60,4 +60,5 @@ void xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr, | |||
60 | unsigned long xen_read_cr2_direct(void); | 60 | unsigned long xen_read_cr2_direct(void); |
61 | 61 | ||
62 | extern void xen_init_mmu_ops(void); | 62 | extern void xen_init_mmu_ops(void); |
63 | extern void xen_hvm_init_mmu_ops(void); | ||
63 | #endif /* _XEN_MMU_H */ | 64 | #endif /* _XEN_MMU_H */ |
diff --git a/include/xen/interface/hvm/hvm_op.h b/include/xen/interface/hvm/hvm_op.h index 73c8c7eba48d..a4827f46ee97 100644 --- a/include/xen/interface/hvm/hvm_op.h +++ b/include/xen/interface/hvm/hvm_op.h | |||
@@ -32,4 +32,15 @@ struct xen_hvm_param { | |||
32 | }; | 32 | }; |
33 | DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_param); | 33 | DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_param); |
34 | 34 | ||
35 | /* Hint from PV drivers for pagetable destruction. */ | ||
36 | #define HVMOP_pagetable_dying 9 | ||
37 | struct xen_hvm_pagetable_dying { | ||
38 | /* Domain with a pagetable about to be destroyed. */ | ||
39 | domid_t domid; | ||
40 | /* guest physical address of the toplevel pagetable dying */ | ||
41 | aligned_u64 gpa; | ||
42 | }; | ||
43 | typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t; | ||
44 | DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_pagetable_dying_t); | ||
45 | |||
35 | #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ | 46 | #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ |