From 6548b34c3f6a5d42d42fb4357e1ea26ca43fb6f7 Mon Sep 17 00:00:00 2001
From: Baptiste Jonglez <git@bitsofnetworks.org>
Date: Sat, 15 Jul 2017 18:48:01 +0200
Subject: [PATCH] x86/64: add xen DomU support

Xen support for x86/generic was added in 1d6879ee.  This commit also
enables it for x86/64.

This was successfully tested with Xen 4.5, although the serial console
is broken in the same way as x86/generic (see FS#787)

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
---
 .../64/base-files/lib/preinit/45_mount_xenfs  |  9 +++
 target/linux/x86/64/config-default            | 60 ++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/x86/64/base-files/lib/preinit/45_mount_xenfs

diff --git a/target/linux/x86/64/base-files/lib/preinit/45_mount_xenfs b/target/linux/x86/64/base-files/lib/preinit/45_mount_xenfs
new file mode 100644
index 0000000000..ac484f6210
--- /dev/null
+++ b/target/linux/x86/64/base-files/lib/preinit/45_mount_xenfs
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2010 OpenWrt.org
+
+do_mount_xenfs() {
+	grep -q xenfs /proc/filesystems && \
+		mount -o noatime -t xenfs none /proc/xen
+}
+
+boot_hook_add preinit_mount_root do_mount_xenfs
diff --git a/target/linux/x86/64/config-default b/target/linux/x86/64/config-default
index 5d259d3656..35336e472d 100644
--- a/target/linux/x86/64/config-default
+++ b/target/linux/x86/64/config-default
@@ -5,7 +5,7 @@ CONFIG_ACPI_BATTERY=y
 # CONFIG_ACPI_BGRT is not set
 CONFIG_ACPI_BUTTON=y
 # CONFIG_ACPI_CMPC is not set
-# CONFIG_ACPI_CONTAINER is not set
+CONFIG_ACPI_CONTAINER=y
 CONFIG_ACPI_CPU_FREQ_PSS=y
 # CONFIG_ACPI_CUSTOM_DSDT is not set
 # CONFIG_ACPI_DEBUG is not set
@@ -13,6 +13,7 @@ CONFIG_ACPI_CPU_FREQ_PSS=y
 # CONFIG_ACPI_DOCK is not set
 # CONFIG_ACPI_EC_DEBUGFS is not set
 CONFIG_ACPI_FAN=y
+CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_HOTPLUG_IOAPIC=y
 CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y
 # CONFIG_ACPI_NFIT is not set
@@ -46,9 +47,11 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_GENERIC=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_BLK_DEV_INTEGRITY=y
+# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set
 CONFIG_CALGARY_IOMMU=y
 CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y
 CONFIG_CONNECTOR=y
+# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set
 CONFIG_CPU_RMAP=y
 CONFIG_CRC_T10DIF=y
 CONFIG_CRYPTO_ABLK_HELPER=y
@@ -89,6 +92,7 @@ CONFIG_CRYPTO_NULL2=y
 # CONFIG_CRYPTO_TWOFISH_X86_64 is not set
 # CONFIG_CRYPTO_TWOFISH_X86_64_3WAY is not set
 CONFIG_CRYPTO_XTS=y
+# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
 # CONFIG_DPTF_POWER is not set
 # CONFIG_EARLY_PRINTK_EFI is not set
 CONFIG_EFI=y
@@ -109,10 +113,15 @@ CONFIG_FB_CFB_COPYAREA=y
 CONFIG_FB_CFB_FILLRECT=y
 CONFIG_FB_CFB_IMAGEBLIT=y
 CONFIG_FB_CMDLINE=y
+CONFIG_FB_DEFERRED_IO=y
 CONFIG_FB_EFI=y
 CONFIG_FB_HYPERV=y
 CONFIG_FB_MODE_HELPERS=y
 CONFIG_FB_SIMPLE=y
+CONFIG_FB_SYS_COPYAREA=y
+CONFIG_FB_SYS_FILLRECT=y
+CONFIG_FB_SYS_FOPS=y
+CONFIG_FB_SYS_IMAGEBLIT=y
 CONFIG_FB_TILEBLITTING=y
 # CONFIG_FB_VESA is not set
 # CONFIG_FONTS is not set
@@ -122,6 +131,7 @@ CONFIG_FONT_SUPPORT=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
 # CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+CONFIG_FREEZER=y
 CONFIG_GART_IOMMU=y
 CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
 CONFIG_GENERIC_CPU=y
@@ -150,9 +160,11 @@ CONFIG_HAVE_LIVEPATCH=y
 CONFIG_HAVE_MEMORY_PRESENT=y
 CONFIG_HAVE_STACK_VALIDATION=y
 CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HIBERNATE_CALLBACKS=y
 CONFIG_HID_BATTERY_STRENGTH=y
 CONFIG_HID_GENERIC=y
 CONFIG_HID_HYPERV_MOUSE=y
+CONFIG_HOTPLUG_CPU=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_ACPI=y
 # CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
@@ -163,6 +175,9 @@ CONFIG_HPET=y
 CONFIG_HPET_MMAP=y
 # CONFIG_HP_ACCEL is not set
 CONFIG_HVC_DRIVER=y
+CONFIG_HVC_IRQ=y
+CONFIG_HVC_XEN=y
+CONFIG_HVC_XEN_FRONTEND=y
 CONFIG_HWMON=y
 CONFIG_HW_RANDOM_AMD=y
 CONFIG_HW_RANDOM_INTEL=y
@@ -177,6 +192,7 @@ CONFIG_HYPERV_UTILS=y
 # CONFIG_I7300_IDLE is not set
 # CONFIG_IA32_EMULATION is not set
 CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
+CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
 CONFIG_INTEL_IDLE=y
 # CONFIG_INTEL_IPS is not set
 # CONFIG_INTEL_MENLOW is not set
@@ -211,6 +227,7 @@ CONFIG_MMC_SDHCI_PCI=y
 # CONFIG_MMC_SDHCI_PLTFM is not set
 # CONFIG_MMC_TIFM_SD is not set
 # CONFIG_MMC_WBSD is not set
+CONFIG_MMU_NOTIFIER=y
 CONFIG_MODULES_USE_ELF_RELA=y
 # CONFIG_MPSC is not set
 CONFIG_MUTEX_SPIN_ON_OWNER=y
@@ -232,11 +249,17 @@ CONFIG_PATA_PLATFORM=y
 CONFIG_PATA_VIA=y
 CONFIG_PCIEAER=y
 CONFIG_PCIEPORTBUS=y
+CONFIG_PCIE_PME=y
 # CONFIG_PCI_HYPERV is not set
 # CONFIG_PCI_MMCONFIG is not set
+CONFIG_PCI_XEN=y
 CONFIG_PGTABLE_LEVELS=4
 CONFIG_PHYSICAL_ALIGN=0x1000000
+CONFIG_PM=y
 # CONFIG_PMIC_OPREGION is not set
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_PM_SLEEP_SMP=y
 CONFIG_PNP=y
 CONFIG_PNPACPI=y
 CONFIG_PNP_DEBUG_MESSAGES=y
@@ -268,6 +291,8 @@ CONFIG_SPARSEMEM_MANUAL=y
 # CONFIG_SPARSEMEM_VMEMMAP is not set
 CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
 # CONFIG_SURFACE_PRO3_BUTTON is not set
+CONFIG_SWIOTLB_XEN=y
+CONFIG_SYS_HYPERVISOR=y
 # CONFIG_THUNDER_NIC_BGX is not set
 # CONFIG_THUNDER_NIC_PF is not set
 # CONFIG_THUNDER_NIC_RGX is not set
@@ -303,6 +328,7 @@ CONFIG_VMWARE_VMCI=y
 CONFIG_VMWARE_VMCI_VSOCKETS=y
 CONFIG_VMXNET3=y
 CONFIG_VSOCKETS=y
+CONFIG_VT_CONSOLE_SLEEP=y
 CONFIG_WATCHDOG_CORE=y
 CONFIG_X86_64=y
 CONFIG_X86_64_SMP=y
@@ -325,5 +351,37 @@ CONFIG_X86_PM_TIMER=y
 # CONFIG_X86_VSYSCALL_EMULATION is not set
 CONFIG_X86_X2APIC=y
 # CONFIG_X86_X32 is not set
+CONFIG_XEN=y
+CONFIG_XENFS=y
+CONFIG_XEN_512GB=y
+CONFIG_XEN_ACPI=y
+CONFIG_XEN_ACPI_PROCESSOR=y
+CONFIG_XEN_AUTO_XLATE=y
+# CONFIG_XEN_BACKEND is not set
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_BLKDEV_FRONTEND=y
+CONFIG_XEN_COMPAT_XENFS=y
+CONFIG_XEN_DEBUG_FS=y
+CONFIG_XEN_DEV_EVTCHN=y
+CONFIG_XEN_DOM0=y
+CONFIG_XEN_EFI=y
+CONFIG_XEN_FBDEV_FRONTEND=y
+CONFIG_XEN_GNTDEV=y
+CONFIG_XEN_GRANT_DEV_ALLOC=y
+CONFIG_XEN_HAVE_PVMMU=y
+CONFIG_XEN_HAVE_VPMU=y
+# CONFIG_XEN_MCE_LOG is not set
+CONFIG_XEN_NETDEV_FRONTEND=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_PVH=y
+CONFIG_XEN_PVHVM=y
+CONFIG_XEN_SAVE_RESTORE=y
+CONFIG_XEN_SCRUB_PAGES=y
+CONFIG_XEN_SCSI_FRONTEND=y
+CONFIG_XEN_SYMS=y
+CONFIG_XEN_SYS_HYPERVISOR=y
+CONFIG_XEN_WDT=y
+CONFIG_XEN_XENBUS_FRONTEND=y
 CONFIG_XPS=y
 CONFIG_ZONE_DMA32=y
-- 
2.30.2