hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/x86/xen/setup.c
....@@ -12,6 +12,7 @@
1212 #include <linux/memblock.h>
1313 #include <linux/cpuidle.h>
1414 #include <linux/cpufreq.h>
15
+#include <linux/memory_hotplug.h>
1516
1617 #include <asm/elf.h>
1718 #include <asm/vdso.h>
....@@ -19,6 +20,7 @@
1920 #include <asm/setup.h>
2021 #include <asm/acpi.h>
2122 #include <asm/numa.h>
23
+#include <asm/idtentry.h>
2224 #include <asm/xen/hypervisor.h>
2325 #include <asm/xen/hypercall.h>
2426
....@@ -30,7 +32,6 @@
3032 #include <xen/features.h>
3133 #include <xen/hvc-console.h>
3234 #include "xen-ops.h"
33
-#include "vdso.h"
3435 #include "mmu.h"
3536
3637 #define GB(x) ((uint64_t)(x) * 1024 * 1024 * 1024)
....@@ -58,13 +59,13 @@
5859 } xen_remap_buf __initdata __aligned(PAGE_SIZE);
5960 static unsigned long xen_remap_mfn __initdata = INVALID_P2M_ENTRY;
6061
61
-/*
62
+/*
6263 * The maximum amount of extra memory compared to the base size. The
6364 * main scaling factor is the size of struct page. At extreme ratios
6465 * of base:extra, all the base memory can be filled with page
6566 * structures for the extra memory, leaving no space for anything
6667 * else.
67
- *
68
+ *
6869 * 10x seems like a reasonable balance between scaling flexibility and
6970 * leaving a practically usable system.
7071 */
....@@ -411,7 +412,7 @@
411412
412413 remap_range_size = xen_find_pfn_range(&remap_pfn);
413414 if (!remap_range_size) {
414
- pr_warning("Unable to find available pfn range, not remapping identity pages\n");
415
+ pr_warn("Unable to find available pfn range, not remapping identity pages\n");
415416 xen_set_identity_and_release_chunk(cur_pfn,
416417 cur_pfn + left, nr_pages);
417418 break;
....@@ -493,7 +494,7 @@
493494 * The remap information (which mfn remap to which pfn) is contained in the
494495 * to be remapped memory itself in a linked list anchored at xen_remap_mfn.
495496 * This scheme allows to remap the different chunks in arbitrary order while
496
- * the resulting mapping will be independant from the order.
497
+ * the resulting mapping will be independent from the order.
497498 */
498499 void __init xen_remap_memory(void)
499500 {
....@@ -543,13 +544,10 @@
543544 {
544545 unsigned long limit;
545546
546
-#ifdef CONFIG_X86_32
547
- limit = GB(64) / PAGE_SIZE;
548
-#else
549547 limit = MAXMEM / PAGE_SIZE;
550548 if (!xen_initial_domain() && xen_512gb_limit)
551549 limit = GB(512) / PAGE_SIZE;
552
-#endif
550
+
553551 return limit;
554552 }
555553
....@@ -589,6 +587,14 @@
589587 if (type == E820_TYPE_RAM) {
590588 start = PAGE_ALIGN(start);
591589 end &= ~((phys_addr_t)PAGE_SIZE - 1);
590
+#ifdef CONFIG_MEMORY_HOTPLUG
591
+ /*
592
+ * Don't allow adding memory not in E820 map while booting the
593
+ * system. Once the balloon driver is up it will remove that
594
+ * restriction again.
595
+ */
596
+ max_mem_size = end;
597
+#endif
592598 }
593599
594600 e820__range_add(start, end - start, type);
....@@ -712,17 +718,8 @@
712718 if (!xen_is_e820_reserved(start, size))
713719 return;
714720
715
-#ifdef CONFIG_X86_32
716
- /*
717
- * Relocating the p2m on 32 bit system to an arbitrary virtual address
718
- * is not supported, so just give up.
719
- */
720
- xen_raw_console_write("Xen hypervisor allocated p2m list conflicts with E820 map\n");
721
- BUG();
722
-#else
723721 xen_relocate_p2m();
724722 memblock_free(start, size);
725
-#endif
726723 }
727724
728725 /**
....@@ -747,6 +744,10 @@
747744
748745 memmap.nr_entries = ARRAY_SIZE(xen_e820_table.entries);
749746 set_xen_guest_handle(memmap.buffer, xen_e820_table.entries);
747
+
748
+#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
749
+ xen_saved_max_mem_size = max_mem_size;
750
+#endif
750751
751752 op = xen_initial_domain() ?
752753 XENMEM_machine_memory_map :
....@@ -790,17 +791,10 @@
790791
791792 /*
792793 * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
793
- * factor the base size. On non-highmem systems, the base
794
- * size is the full initial memory allocation; on highmem it
795
- * is limited to the max size of lowmem, so that it doesn't
796
- * get completely filled.
794
+ * factor the base size.
797795 *
798796 * Make sure we have no memory above max_pages, as this area
799797 * isn't handled by the p2m management.
800
- *
801
- * In principle there could be a problem in lowmem systems if
802
- * the initial memory is also very large with respect to
803
- * lowmem, but we won't try to deal with that here.
804798 */
805799 extra_pages = min3(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
806800 extra_pages, max_pages - max_pfn);
....@@ -907,20 +901,6 @@
907901 return "Xen";
908902 }
909903
910
-/*
911
- * Set the bit indicating "nosegneg" library variants should be used.
912
- * We only need to bother in pure 32-bit mode; compat 32-bit processes
913
- * can have un-truncated segments, so wrapping around is allowed.
914
- */
915
-static void __init fiddle_vdso(void)
916
-{
917
-#ifdef CONFIG_X86_32
918
- u32 *mask = vdso_image_32.data +
919
- vdso_image_32.sym_VDSO32_NOTE_MASK;
920
- *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
921
-#endif
922
-}
923
-
924904 static int register_callback(unsigned type, const void *func)
925905 {
926906 struct callback_register callback = {
....@@ -937,26 +917,21 @@
937917 int ret;
938918 unsigned sysenter_feature;
939919
940
-#ifdef CONFIG_X86_32
941
- sysenter_feature = X86_FEATURE_SEP;
942
-#else
943920 sysenter_feature = X86_FEATURE_SYSENTER32;
944
-#endif
945921
946922 if (!boot_cpu_has(sysenter_feature))
947923 return;
948924
949
- ret = register_callback(CALLBACKTYPE_sysenter, xen_sysenter_target);
925
+ ret = register_callback(CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat);
950926 if(ret != 0)
951927 setup_clear_cpu_cap(sysenter_feature);
952928 }
953929
954930 void xen_enable_syscall(void)
955931 {
956
-#ifdef CONFIG_X86_64
957932 int ret;
958933
959
- ret = register_callback(CALLBACKTYPE_syscall, xen_syscall_target);
934
+ ret = register_callback(CALLBACKTYPE_syscall, xen_entry_SYSCALL_64);
960935 if (ret != 0) {
961936 printk(KERN_ERR "Failed to set syscall callback: %d\n", ret);
962937 /* Pretty fatal; 64-bit userspace has no other
....@@ -965,14 +940,13 @@
965940
966941 if (boot_cpu_has(X86_FEATURE_SYSCALL32)) {
967942 ret = register_callback(CALLBACKTYPE_syscall32,
968
- xen_syscall32_target);
943
+ xen_entry_SYSCALL_compat);
969944 if (ret != 0)
970945 setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
971946 }
972
-#endif /* CONFIG_X86_64 */
973947 }
974948
975
-void __init xen_pvmmu_arch_setup(void)
949
+static void __init xen_pvmmu_arch_setup(void)
976950 {
977951 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
978952 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
....@@ -980,7 +954,8 @@
980954 HYPERVISOR_vm_assist(VMASST_CMD_enable,
981955 VMASST_TYPE_pae_extended_cr3);
982956
983
- if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) ||
957
+ if (register_callback(CALLBACKTYPE_event,
958
+ xen_asm_exc_xen_hypervisor_callback) ||
984959 register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
985960 BUG();
986961
....@@ -1009,7 +984,6 @@
1009984 disable_cpuidle();
1010985 disable_cpufreq();
1011986 WARN_ON(xen_set_default_idle());
1012
- fiddle_vdso();
1013987 #ifdef CONFIG_NUMA
1014988 numa_off = 1;
1015989 #endif