From 0a959c9f2467ca5d925bbf2e5849353f603eb267 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Mon, 1 Oct 2012 21:18:01 +0200 Subject: [PATCH] --- yaml --- r: 333887 b: refs/heads/master c: 34b6f01a79bd65fbd06511d2cb7b28e33a506246 h: refs/heads/master i: 333885: d241df0d753e9bf70799701ec2598357ef32ddec 333883: 155853d5dbef283ac725deca2a464d849eb9fc02 333879: 883b79e414adab622672b37c5aac359f74194820 333871: e5ad334b609eeeaa6bd823419bbd7d6d13cd0349 333855: 88ced7231956a3dd7a081a33f41c2950452043af 333823: 57a241b461ab44410fb256eecf6c0280954c5313 v: v3 --- [refs] | 2 +- trunk/arch/x86/xen/mmu.c | 41 ++++++++++++++++++++++++ trunk/include/xen/interface/hvm/hvm_op.h | 19 +++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index f244b503df2c..4235a5581c2c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9b6934a3b449266850149b717597408354039e95 +refs/heads/master: 34b6f01a79bd65fbd06511d2cb7b28e33a506246 diff --git a/trunk/arch/x86/xen/mmu.c b/trunk/arch/x86/xen/mmu.c index 5a16824cc2b3..963cb2df636a 100644 --- a/trunk/arch/x86/xen/mmu.c +++ b/trunk/arch/x86/xen/mmu.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -2381,6 +2382,43 @@ void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region); #ifdef CONFIG_XEN_PVHVM +#ifdef CONFIG_PROC_VMCORE +/* + * This function is used in two contexts: + * - the kdump kernel has to check whether a pfn of the crashed kernel + * was a ballooned page. vmcore is using this function to decide + * whether to access a pfn of the crashed kernel. + * - the kexec kernel has to check whether a pfn was ballooned by the + * previous kernel. If the pfn is ballooned, handle it properly. + * Returns 0 if the pfn is not backed by a RAM page, the caller may + * handle the pfn special in this case. + */ +static int xen_oldmem_pfn_is_ram(unsigned long pfn) +{ + struct xen_hvm_get_mem_type a = { + .domid = DOMID_SELF, + .pfn = pfn, + }; + int ram; + + if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a)) + return -ENXIO; + + switch (a.mem_type) { + case HVMMEM_mmio_dm: + ram = 0; + break; + case HVMMEM_ram_rw: + case HVMMEM_ram_ro: + default: + ram = 1; + break; + } + + return ram; +} +#endif + static void xen_hvm_exit_mmap(struct mm_struct *mm) { struct xen_hvm_pagetable_dying a; @@ -2411,6 +2449,9 @@ void __init xen_hvm_init_mmu_ops(void) { if (is_pagetable_dying_supported()) pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap; +#ifdef CONFIG_PROC_VMCORE + register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram); +#endif } #endif diff --git a/trunk/include/xen/interface/hvm/hvm_op.h b/trunk/include/xen/interface/hvm/hvm_op.h index a4827f46ee97..956a04682865 100644 --- a/trunk/include/xen/interface/hvm/hvm_op.h +++ b/trunk/include/xen/interface/hvm/hvm_op.h @@ -43,4 +43,23 @@ struct xen_hvm_pagetable_dying { typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t; DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_pagetable_dying_t); +enum hvmmem_type_t { + HVMMEM_ram_rw, /* Normal read/write guest RAM */ + HVMMEM_ram_ro, /* Read-only; writes are discarded */ + HVMMEM_mmio_dm, /* Reads and write go to the device model */ +}; + +#define HVMOP_get_mem_type 15 +/* Return hvmmem_type_t for the specified pfn. */ +struct xen_hvm_get_mem_type { + /* Domain to be queried. */ + domid_t domid; + /* OUT variable. */ + uint16_t mem_type; + uint16_t pad[2]; /* align next field on 8-byte boundary */ + /* IN variable. */ + uint64_t pfn; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_get_mem_type); + #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */