]> Git Repo - linux.git/blame - arch/x86/xen/mmu_hvm.c
proc/vmcore: convert oldmem_pfn_is_ram callback to more generic vmcore callbacks
[linux.git] / arch / x86 / xen / mmu_hvm.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
feef87eb
VK
2#include <linux/types.h>
3#include <linux/crash_dump.h>
4
5#include <xen/interface/xen.h>
6#include <xen/hvm.h>
7
8#include "mmu.h"
9
10#ifdef CONFIG_PROC_VMCORE
11/*
434b90f3
DH
12 * The kdump kernel has to check whether a pfn of the crashed kernel
13 * was a ballooned page. vmcore is using this function to decide
14 * whether to access a pfn of the crashed kernel.
cc5f2704 15 * Returns "false" if the pfn is not backed by a RAM page, the caller may
feef87eb
VK
16 * handle the pfn special in this case.
17 */
cc5f2704 18static bool xen_vmcore_pfn_is_ram(struct vmcore_cb *cb, unsigned long pfn)
feef87eb
VK
19{
20 struct xen_hvm_get_mem_type a = {
21 .domid = DOMID_SELF,
22 .pfn = pfn,
23 };
feef87eb 24
934fadf4
DH
25 if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a)) {
26 pr_warn_once("Unexpected HVMOP_get_mem_type failure\n");
cc5f2704 27 return true;
934fadf4 28 }
d452a489 29 return a.mem_type != HVMMEM_mmio_dm;
feef87eb 30}
cc5f2704
DH
31static struct vmcore_cb xen_vmcore_cb = {
32 .pfn_is_ram = xen_vmcore_pfn_is_ram,
33};
feef87eb
VK
34#endif
35
36static void xen_hvm_exit_mmap(struct mm_struct *mm)
37{
38 struct xen_hvm_pagetable_dying a;
39 int rc;
40
41 a.domid = DOMID_SELF;
42 a.gpa = __pa(mm->pgd);
43 rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
44 WARN_ON_ONCE(rc < 0);
45}
46
47static int is_pagetable_dying_supported(void)
48{
49 struct xen_hvm_pagetable_dying a;
50 int rc = 0;
51
52 a.domid = DOMID_SELF;
53 a.gpa = 0x00;
54 rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
55 if (rc < 0) {
56 printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n");
57 return 0;
58 }
59 return 1;
60}
61
62void __init xen_hvm_init_mmu_ops(void)
63{
64 if (is_pagetable_dying_supported())
5c83511b 65 pv_ops.mmu.exit_mmap = xen_hvm_exit_mmap;
feef87eb 66#ifdef CONFIG_PROC_VMCORE
cc5f2704 67 register_vmcore_cb(&xen_vmcore_cb);
feef87eb
VK
68#endif
69}
This page took 0.338459 seconds and 4 git commands to generate.