Merge branch 'x86/mm' into x86/asm, to unify the two branches for simplicity
authorIngo Molnar <mingo@kernel.org>
Thu, 8 Sep 2016 06:41:52 +0000 (08:41 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 8 Sep 2016 06:41:52 +0000 (08:41 +0200)
Signed-off-by: Ingo Molnar <mingo@kernel.org>
27 files changed:
arch/x86/include/asm/desc.h
arch/x86/include/asm/fpu/xstate.h
arch/x86/include/asm/kaslr.h
arch/x86/include/asm/pgtable_64_types.h
arch/x86/kernel/apic/apic_flat_64.c
arch/x86/kernel/apic/apic_noop.c
arch/x86/kernel/apic/bigsmp_32.c
arch/x86/kernel/apic/msi.c
arch/x86/kernel/apic/probe_32.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/mtrr/main.c
arch/x86/kernel/cpu/mtrr/mtrr.h
arch/x86/kernel/ksysfs.c
arch/x86/kernel/kvmclock.c
arch/x86/kernel/paravirt.c
arch/x86/kernel/ptrace.c
arch/x86/kernel/reboot.c
arch/x86/kernel/setup.c
arch/x86/kernel/setup_percpu.c
arch/x86/kernel/x86_init.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/mm/kaslr.c
arch/x86/pci/pcbios.c

index 4e10d73cf01844edc201ed23f51d28a72a537521..12080d87da3b189f421d421c5d6a3cca5dc83014 100644 (file)
@@ -36,7 +36,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
 
 extern struct desc_ptr idt_descr;
 extern gate_desc idt_table[];
-extern struct desc_ptr debug_idt_descr;
+extern const struct desc_ptr debug_idt_descr;
 extern gate_desc debug_idt_table[];
 
 struct gdt_page {
index ae55a43e09c0f20846919680f85a1c15538432bc..d4957ac72b488245880a8fb7c5885db558cd66c7 100644 (file)
@@ -45,7 +45,8 @@
 extern u64 xfeatures_mask;
 extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
 
-extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
+extern void __init update_regset_xstate_info(unsigned int size,
+                                            u64 xstate_mask);
 
 void fpu__xstate_clear_all_cpu_caps(void);
 void *get_xsave_addr(struct xregs_state *xsave, int xstate);
index 2674ee3de7486afde5a37ffc8309d9aac51a2e9b..1052a797d71d0b488eb6973b1ec512005afbe757 100644 (file)
@@ -6,6 +6,7 @@ unsigned long kaslr_get_random_long(const char *purpose);
 #ifdef CONFIG_RANDOMIZE_MEMORY
 extern unsigned long page_offset_base;
 extern unsigned long vmalloc_base;
+extern unsigned long vmemmap_base;
 
 void kernel_randomize_memory(void);
 #else
index 6fdef9eef2d51d58aad4ff2f2ef9248585093d73..3a264200c62fd2067c387ffaecb27309727ff1de 100644 (file)
@@ -57,11 +57,13 @@ typedef struct { pteval_t pte; } pte_t;
 #define MAXMEM         _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
 #define VMALLOC_SIZE_TB        _AC(32, UL)
 #define __VMALLOC_BASE _AC(0xffffc90000000000, UL)
-#define VMEMMAP_START  _AC(0xffffea0000000000, UL)
+#define __VMEMMAP_BASE _AC(0xffffea0000000000, UL)
 #ifdef CONFIG_RANDOMIZE_MEMORY
 #define VMALLOC_START  vmalloc_base
+#define VMEMMAP_START  vmemmap_base
 #else
 #define VMALLOC_START  __VMALLOC_BASE
+#define VMEMMAP_START  __VMEMMAP_BASE
 #endif /* CONFIG_RANDOMIZE_MEMORY */
 #define VMALLOC_END    (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
 #define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
index 5b2ae106bd4ac7c3ae519a6e5ee6c191431ada74..8862da76ef6fef6366daac680891e8fca3a8b9fa 100644 (file)
@@ -25,7 +25,7 @@
 static struct apic apic_physflat;
 static struct apic apic_flat;
 
-struct apic __read_mostly *apic = &apic_flat;
+struct apic *apic __ro_after_init = &apic_flat;
 EXPORT_SYMBOL_GPL(apic);
 
 static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
@@ -154,7 +154,7 @@ static int flat_probe(void)
        return 1;
 }
 
-static struct apic apic_flat  {
+static struct apic apic_flat __ro_after_init = {
        .name                           = "flat",
        .probe                          = flat_probe,
        .acpi_madt_oem_check            = flat_acpi_madt_oem_check,
@@ -248,7 +248,7 @@ static int physflat_probe(void)
        return 0;
 }
 
-static struct apic apic_physflat  {
+static struct apic apic_physflat __ro_after_init = {
 
        .name                           = "physical flat",
        .probe                          = physflat_probe,
index c05688b2deff7248473b91d8d9fe953e7395f67e..b109e4389c928d2efcc2df0b83df3c4b7872fe28 100644 (file)
@@ -108,7 +108,7 @@ static void noop_apic_write(u32 reg, u32 v)
        WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
 }
 
-struct apic apic_noop = {
+struct apic apic_noop __ro_after_init = {
        .name                           = "noop",
        .probe                          = noop_probe,
        .acpi_madt_oem_check            = NULL,
index 06dbaa458bfef4bfd052c5b4e7d72b59ce0410d8..56012010332c84d1c5d6276aa20734661b020ad0 100644 (file)
@@ -142,7 +142,7 @@ static int probe_bigsmp(void)
        return dmi_bigsmp;
 }
 
-static struct apic apic_bigsmp = {
+static struct apic apic_bigsmp __ro_after_init = {
 
        .name                           = "bigsmp",
        .probe                          = probe_bigsmp,
index ade25320df96479193fe850e8747f9acad758b2d..015bbf30e3e325f5a9211a62f40f529f11801fe9 100644 (file)
@@ -269,7 +269,7 @@ static void hpet_msi_write_msg(struct irq_data *data, struct msi_msg *msg)
        hpet_msi_write(irq_data_get_irq_handler_data(data), msg);
 }
 
-static struct irq_chip hpet_msi_controller = {
+static struct irq_chip hpet_msi_controller __ro_after_init = {
        .name = "HPET-MSI",
        .irq_unmask = hpet_msi_unmask,
        .irq_mask = hpet_msi_mask,
index 7c43e716c158de0799760a5537ec05a5bd272a9f..e5fb2f08646097c8ed8d880b97cde89ecb28b83f 100644 (file)
@@ -72,7 +72,7 @@ static int probe_default(void)
        return 1;
 }
 
-static struct apic apic_default = {
+static struct apic apic_default __ro_after_init = {
 
        .name                           = "default",
        .probe                          = probe_default,
@@ -126,7 +126,7 @@ static struct apic apic_default = {
 
 apic_driver(apic_default);
 
-struct apic *apic = &apic_default;
+struct apic *apic __ro_after_init = &apic_default;
 EXPORT_SYMBOL_GPL(apic);
 
 static int cmdline_apic __initdata;
index 54f35d988025b6d867f4915d5d4aeecf9461f352..200af5ae96626e1610c7c946bb0a33c5360f9bcb 100644 (file)
@@ -227,7 +227,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
                cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
 }
 
-static struct apic apic_x2apic_cluster = {
+static struct apic apic_x2apic_cluster __ro_after_init = {
 
        .name                           = "cluster x2apic",
        .probe                          = x2apic_cluster_probe,
index 4f13f54f1b1f47ba75fb95cae226e1fe4978f241..ff111f05a3145242e7bd89cb1404e00d5825abff 100644 (file)
@@ -98,7 +98,7 @@ static int x2apic_phys_probe(void)
        return apic == &apic_x2apic_phys;
 }
 
-static struct apic apic_x2apic_phys = {
+static struct apic apic_x2apic_phys __ro_after_init = {
 
        .name                           = "physical x2apic",
        .probe                          = x2apic_phys_probe,
index cb0673c1e940a2fe0e92f04304972f83aad3bacb..b9f6157d42717010821b80b7ee53947208525a7f 100644 (file)
@@ -560,7 +560,7 @@ static int uv_probe(void)
        return apic == &apic_x2apic_uv_x;
 }
 
-static struct apic __refdata apic_x2apic_uv_x = {
+static struct apic apic_x2apic_uv_x __ro_after_init = {
 
        .name                           = "UV large system",
        .probe                          = uv_probe,
index e374c19b9ddcff0ee67ad1017922179801d08290..06919427d4518b2eaa9b777063512b838b420a25 100644 (file)
@@ -1265,9 +1265,14 @@ static __init int setup_disablecpuid(char *arg)
 __setup("clearcpuid=", setup_disablecpuid);
 
 #ifdef CONFIG_X86_64
-struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
-struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
-                                   (unsigned long) debug_idt_table };
+struct desc_ptr idt_descr __ro_after_init = {
+       .size = NR_VECTORS * 16 - 1,
+       .address = (unsigned long) idt_table,
+};
+const struct desc_ptr debug_idt_descr = {
+       .size = NR_VECTORS * 16 - 1,
+       .address = (unsigned long) debug_idt_table,
+};
 
 DEFINE_PER_CPU_FIRST(union irq_stack_union,
                     irq_stack_union) __aligned(PAGE_SIZE) __visible;
index 28f1b54b7fadce321bec098792e6dc4977429445..24e87e74990df40d6ed8d18dbb51439e7dd4286a 100644 (file)
@@ -72,14 +72,14 @@ static DEFINE_MUTEX(mtrr_mutex);
 u64 size_or_mask, size_and_mask;
 static bool mtrr_aps_delayed_init;
 
-static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __ro_after_init;
 
 const struct mtrr_ops *mtrr_if;
 
 static void set_mtrr(unsigned int reg, unsigned long base,
                     unsigned long size, mtrr_type type);
 
-void set_mtrr_ops(const struct mtrr_ops *ops)
+void __init set_mtrr_ops(const struct mtrr_ops *ops)
 {
        if (ops->vendor && ops->vendor < X86_VENDOR_NUM)
                mtrr_ops[ops->vendor] = ops;
index 6c7ced07d16d1181c6ef21f4f2252ef63019a77b..ad8bd763efa52bd0426f2d756783c00f257b1f2a 100644 (file)
@@ -54,7 +54,7 @@ void fill_mtrr_var_range(unsigned int index,
 bool get_mtrr_state(void);
 void mtrr_bp_pat_init(void);
 
-extern void set_mtrr_ops(const struct mtrr_ops *ops);
+extern void __init set_mtrr_ops(const struct mtrr_ops *ops);
 
 extern u64 size_or_mask, size_and_mask;
 extern const struct mtrr_ops *mtrr_if;
index c2bedaea11f7b929709e64979e17e15ca4d8d60a..4afc67f5facc497606e2fb898ba7b7d402f04caa 100644 (file)
@@ -184,7 +184,7 @@ out:
 
 static struct kobj_attribute type_attr = __ATTR_RO(type);
 
-static struct bin_attribute data_attr = {
+static struct bin_attribute data_attr __ro_after_init = {
        .attr = {
                .name = "data",
                .mode = S_IRUGO,
index 1d39bfbd26bb3d0918271f13af86c94385983150..0964399ef942125580e84fe124b5817ed52d0e9f 100644 (file)
@@ -29,7 +29,7 @@
 #include <asm/x86_init.h>
 #include <asm/reboot.h>
 
-static int kvmclock = 1;
+static int kvmclock __ro_after_init = 1;
 static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
 static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
 static cycle_t kvm_sched_clock_offset;
index ad5bc9578a7336f031bf580b415fe8354780d060..b8e4680a2e0bad1cb3ee922bc3c9a1ee1ae21df0 100644 (file)
@@ -389,7 +389,7 @@ NOKPROBE_SYMBOL(native_load_idt);
 #define PTE_IDENT      __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
 #endif
 
-struct pv_mmu_ops pv_mmu_ops = {
+struct pv_mmu_ops pv_mmu_ops __ro_after_init = {
 
        .read_cr2 = native_read_cr2,
        .write_cr2 = native_write_cr2,
index a1606eadd9ce84d452407d07694e67f72f905daa..5b88a1b26fc747cf0cdb533384a014c0ac9f3e93 100644 (file)
@@ -1250,7 +1250,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 #ifdef CONFIG_X86_64
 
-static struct user_regset x86_64_regsets[] __read_mostly = {
+static struct user_regset x86_64_regsets[] __ro_after_init = {
        [REGSET_GENERAL] = {
                .core_note_type = NT_PRSTATUS,
                .n = sizeof(struct user_regs_struct) / sizeof(long),
@@ -1291,7 +1291,7 @@ static const struct user_regset_view user_x86_64_view = {
 #endif /* CONFIG_X86_64 */
 
 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
-static struct user_regset x86_32_regsets[] __read_mostly = {
+static struct user_regset x86_32_regsets[] __ro_after_init = {
        [REGSET_GENERAL] = {
                .core_note_type = NT_PRSTATUS,
                .n = sizeof(struct user_regs_struct32) / sizeof(u32),
@@ -1344,7 +1344,7 @@ static const struct user_regset_view user_x86_32_view = {
  */
 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
 
-void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
+void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
 {
 #ifdef CONFIG_X86_64
        x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
index 63bf27d972b77bfcb59997b473474ddbe41af5d0..e244c19a2451aa7d4dfa8bf34b1834e48f68ec54 100644 (file)
@@ -705,7 +705,7 @@ static void native_machine_power_off(void)
        tboot_shutdown(TB_SHUTDOWN_HALT);
 }
 
-struct machine_ops machine_ops = {
+struct machine_ops machine_ops __ro_after_init = {
        .power_off = native_machine_power_off,
        .shutdown = native_machine_shutdown,
        .emergency_restart = native_machine_emergency_restart,
index 0fa60f5f5a1641dc8eb2c82968dbadd650ed6e37..44c868ebc31411a55300f560aae8ab0f54a10331 100644 (file)
@@ -210,9 +210,9 @@ EXPORT_SYMBOL(boot_cpu_data);
 
 
 #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
-__visible unsigned long mmu_cr4_features;
+__visible unsigned long mmu_cr4_features __ro_after_init;
 #else
-__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
+__visible unsigned long mmu_cr4_features __ro_after_init = X86_CR4_PAE;
 #endif
 
 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
index d182799c42648f987a1102ebdf6c8af125a611d2..2bbd27f8980217bc443ac4d202d6658328061a81 100644 (file)
@@ -33,7 +33,7 @@ EXPORT_PER_CPU_SYMBOL(cpu_number);
 DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
 
-unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
+unsigned long __per_cpu_offset[NR_CPUS] __ro_after_init = {
        [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
 };
 EXPORT_SYMBOL(__per_cpu_offset);
index 76c5e52436c454b42602ce91758d4ec6acb8ef03..0bd9f1287f3962380f9f0f03470ce25f9ce8932b 100644 (file)
@@ -91,7 +91,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
 static void default_nmi_init(void) { };
 static int default_i8042_detect(void) { return 1; };
 
-struct x86_platform_ops x86_platform = {
+struct x86_platform_ops x86_platform __ro_after_init = {
        .calibrate_cpu                  = native_calibrate_cpu,
        .calibrate_tsc                  = native_calibrate_tsc,
        .get_wallclock                  = mach_get_cmos_time,
@@ -108,7 +108,7 @@ struct x86_platform_ops x86_platform = {
 EXPORT_SYMBOL_GPL(x86_platform);
 
 #if defined(CONFIG_PCI_MSI)
-struct x86_msi_ops x86_msi = {
+struct x86_msi_ops x86_msi __ro_after_init = {
        .setup_msi_irqs         = native_setup_msi_irqs,
        .teardown_msi_irq       = native_teardown_msi_irq,
        .teardown_msi_irqs      = default_teardown_msi_irqs,
@@ -137,7 +137,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
 }
 #endif
 
-struct x86_io_apic_ops x86_io_apic_ops = {
+struct x86_io_apic_ops x86_io_apic_ops __ro_after_init = {
        .read                   = native_io_apic_read,
        .disable                = native_disable_io_apic,
 };
index af523d84d102fde15d9194010ef7335495680670..1e6b84b96ea697d7a047f9c6583b42807209e952 100644 (file)
@@ -4961,7 +4961,7 @@ static inline void avic_post_state_restore(struct kvm_vcpu *vcpu)
        avic_handle_ldr_update(vcpu);
 }
 
-static struct kvm_x86_ops svm_x86_ops = {
+static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .cpu_has_kvm_support = has_svm,
        .disabled_by_bios = is_disabled,
        .hardware_setup = svm_hardware_setup,
index a45d8580f91e7e8459666d7c1f0076ab1803b821..87eaa6bfc26a387ea7ee49915df0575bcae24467 100644 (file)
@@ -11175,7 +11175,7 @@ static void vmx_setup_mce(struct kvm_vcpu *vcpu)
                        ~FEATURE_CONTROL_LMCE;
 }
 
-static struct kvm_x86_ops vmx_x86_ops = {
+static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
        .cpu_has_kvm_support = cpu_has_kvm_support,
        .disabled_by_bios = vmx_disabled_by_bios,
        .hardware_setup = hardware_setup,
index ec8654f117d8e5152f359c66a23740f9d1a85160..aec03aa96312f75b738749ec49dfcf223bf9c64d 100644 (file)
  * You need to add an if/def entry if you introduce a new memory region
  * compatible with KASLR. Your entry must be in logical order with memory
  * layout. For example, ESPFIX is before EFI because its virtual address is
- * before. You also need to add a BUILD_BUG_ON in kernel_randomize_memory to
+ * before. You also need to add a BUILD_BUG_ON() in kernel_randomize_memory() to
  * ensure that this order is correct and won't be changed.
  */
 static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;
-static const unsigned long vaddr_end = VMEMMAP_START;
+
+#if defined(CONFIG_X86_ESPFIX64)
+static const unsigned long vaddr_end = ESPFIX_BASE_ADDR;
+#elif defined(CONFIG_EFI)
+static const unsigned long vaddr_end = EFI_VA_START;
+#else
+static const unsigned long vaddr_end = __START_KERNEL_map;
+#endif
 
 /* Default values */
 unsigned long page_offset_base = __PAGE_OFFSET_BASE;
 EXPORT_SYMBOL(page_offset_base);
 unsigned long vmalloc_base = __VMALLOC_BASE;
 EXPORT_SYMBOL(vmalloc_base);
+unsigned long vmemmap_base = __VMEMMAP_BASE;
+EXPORT_SYMBOL(vmemmap_base);
 
 /*
  * Memory regions randomized by KASLR (except modules that use a separate logic
@@ -63,6 +72,7 @@ static __initdata struct kaslr_memory_region {
 } kaslr_regions[] = {
        { &page_offset_base, 64/* Maximum */ },
        { &vmalloc_base, VMALLOC_SIZE_TB },
+       { &vmemmap_base, 1 },
 };
 
 /* Get size in bytes used by the memory region */
@@ -89,6 +99,18 @@ void __init kernel_randomize_memory(void)
        struct rnd_state rand_state;
        unsigned long remain_entropy;
 
+       /*
+        * All these BUILD_BUG_ON checks ensures the memory layout is
+        * consistent with the vaddr_start/vaddr_end variables.
+        */
+       BUILD_BUG_ON(vaddr_start >= vaddr_end);
+       BUILD_BUG_ON(config_enabled(CONFIG_X86_ESPFIX64) &&
+                    vaddr_end >= EFI_VA_START);
+       BUILD_BUG_ON((config_enabled(CONFIG_X86_ESPFIX64) ||
+                     config_enabled(CONFIG_EFI)) &&
+                    vaddr_end >= __START_KERNEL_map);
+       BUILD_BUG_ON(vaddr_end > __START_KERNEL_map);
+
        if (!kaslr_memory_enabled())
                return;
 
index 9770e55e768fde446cff8482e7c903a5ba6a61e0..1d97cea3b3a44efb3152e32278573970c2c0c2c3 100644 (file)
@@ -120,9 +120,12 @@ static unsigned long __init bios32_service(unsigned long service)
 static struct {
        unsigned long address;
        unsigned short segment;
-} pci_indirect = { 0, __KERNEL_CS };
+} pci_indirect __ro_after_init = {
+       .address = 0,
+       .segment = __KERNEL_CS,
+};
 
-static int pci_bios_present;
+static int pci_bios_present __ro_after_init;
 
 static int __init check_pcibios(void)
 {