xen/xen.sles11sp1.bug684297.xen_oldmem_pfn_is_ram.patch

66 lines
1.7 KiB
Diff
Raw Normal View History

Use new Xen HVMOP_get_mem_type hvmop hypercall option and new Linux kernel
register_oldmem_pfn_is_ram interface.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
unmodified_drivers/linux-2.6/platform-pci/platform-pci.c | 31 +++++++++++++++
1 file changed, 31 insertions(+)
Index: xen-4.1.2-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
===================================================================
--- xen-4.1.2-testing.orig/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
+++ xen-4.1.2-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
@@ -30,6 +30,7 @@
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
+#include <linux/crash_dump.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
@@ -359,6 +360,32 @@ static int check_platform_magic(struct d
return -ENODEV;
}
+#if defined(HAVE_OLDMEM_PFN_IS_RAM) && defined(HVMOP_get_mem_type)
+static int xen_oldmem_pfn_is_ram(unsigned long pfn)
+{
+ struct xen_hvm_get_mem_type a;
+ int ram;
+
+ a.domid = DOMID_SELF;
+ a.pfn = pfn;
+ 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 int __devinit platform_pci_init(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -427,6 +454,10 @@ static int __devinit platform_pci_init(s
if ((ret = xen_panic_handler_init()))
goto out;
+#if defined(HAVE_OLDMEM_PFN_IS_RAM) && defined(HVMOP_get_mem_type)
+ register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
+#endif
+
out:
if (ret) {
pci_release_region(pdev, 0);