diff options
Diffstat (limited to 'arch/x86')
| -rw-r--r-- | arch/x86/Kconfig | 2 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/Makefile | 5 | ||||
| -rw-r--r-- | arch/x86/include/asm/bootparam_utils.h | 20 | ||||
| -rw-r--r-- | arch/x86/include/asm/kprobes.h | 1 | ||||
| -rw-r--r-- | arch/x86/include/asm/kvm_host.h | 4 | ||||
| -rw-r--r-- | arch/x86/include/asm/syscall.h | 4 | ||||
| -rw-r--r-- | arch/x86/include/asm/xen/hypercall.h | 4 | ||||
| -rw-r--r-- | arch/x86/include/uapi/asm/msr-index.h | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel.c | 4 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_ds.c | 10 | ||||
| -rw-r--r-- | arch/x86/kernel/kprobes/core.c | 5 | ||||
| -rw-r--r-- | arch/x86/kernel/microcode_intel_early.c | 30 | ||||
| -rw-r--r-- | arch/x86/kernel/setup.c | 10 | ||||
| -rw-r--r-- | arch/x86/kernel/smpboot.c | 3 | ||||
| -rw-r--r-- | arch/x86/kvm/lapic.c | 2 | ||||
| -rw-r--r-- | arch/x86/kvm/x86.c | 69 | ||||
| -rw-r--r-- | arch/x86/lib/usercopy_64.c | 4 | ||||
| -rw-r--r-- | arch/x86/mm/init.c | 5 | ||||
| -rw-r--r-- | arch/x86/mm/pat.c | 7 | ||||
| -rw-r--r-- | arch/x86/power/cpu.c | 2 | ||||
| -rw-r--r-- | arch/x86/xen/mmu.c | 3 | 
21 files changed, 119 insertions, 76 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a4f24f5b121..70c0f3da047 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -112,7 +112,7 @@ config X86  	select GENERIC_STRNLEN_USER  	select HAVE_CONTEXT_TRACKING if X86_64  	select HAVE_IRQ_TIME_ACCOUNTING -	select HAVE_VIRT_TO_BUS +	select VIRT_TO_BUS  	select MODULES_USE_ELF_REL if X86_32  	select MODULES_USE_ELF_RELA if X86_64  	select CLONE_BACKWARDS if X86_32 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 8a84501acb1..5ef205c5f37 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -4,7 +4,7 @@  # create a compressed vmlinux image from the original vmlinux  # -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo  KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2  KBUILD_CFLAGS += -fno-strict-aliasing -fPIC @@ -29,7 +29,6 @@ VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \  	$(obj)/piggy.o  $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone -$(obj)/efi_stub_$(BITS).o: KBUILD_CLFAGS += -fshort-wchar -mno-red-zone  ifeq ($(CONFIG_EFI_STUB), y)  	VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o @@ -43,7 +42,7 @@ OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S  $(obj)/vmlinux.bin: vmlinux FORCE  	$(call if_changed,objcopy) -targets += vmlinux.bin.all vmlinux.relocs +targets += $(patsubst $(obj)/%,%,$(VMLINUX_OBJS)) vmlinux.bin.all vmlinux.relocs  CMD_RELOCS = arch/x86/tools/relocs  quiet_cmd_relocs = RELOCS  $@ diff --git a/arch/x86/include/asm/bootparam_utils.h b/arch/x86/include/asm/bootparam_utils.h index 5b5e9cb774b..653668d140f 100644 --- a/arch/x86/include/asm/bootparam_utils.h +++ b/arch/x86/include/asm/bootparam_utils.h @@ -14,13 +14,29 @@   * analysis of kexec-tools; if other broken bootloaders initialize a   * different set of fields we will need to figure out how to disambiguate.   * + * Note: efi_info is commonly left uninitialized, but that field has a + * private magic, so it is better to leave it unchanged.   */  static void sanitize_boot_params(struct boot_params *boot_params)  { +	/*  +	 * IMPORTANT NOTE TO BOOTLOADER AUTHORS: do not simply clear +	 * this field.  The purpose of this field is to guarantee +	 * compliance with the x86 boot spec located in +	 * Documentation/x86/boot.txt .  That spec says that the +	 * *whole* structure should be cleared, after which only the +	 * portion defined by struct setup_header (boot_params->hdr) +	 * should be copied in. +	 * +	 * If you're having an issue because the sentinel is set, you +	 * need to change the whole structure to be cleared, not this +	 * (or any other) individual field, or you will soon have +	 * problems again. +	 */  	if (boot_params->sentinel) { -		/*fields in boot_params are not valid, clear them */ +		/* fields in boot_params are left uninitialized, clear them */  		memset(&boot_params->olpc_ofw_header, 0, -		       (char *)&boot_params->alt_mem_k - +		       (char *)&boot_params->efi_info -  			(char *)&boot_params->olpc_ofw_header);  		memset(&boot_params->kbd_status, 0,  		       (char *)&boot_params->hdr - diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h index d3ddd17405d..5a6d2873f80 100644 --- a/arch/x86/include/asm/kprobes.h +++ b/arch/x86/include/asm/kprobes.h @@ -77,6 +77,7 @@ struct arch_specific_insn {  	 * a post_handler or break_handler).  	 */  	int boostable; +	bool if_modifier;  };  struct arch_optimized_insn { diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 635a74d2240..4979778cc7f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -414,8 +414,8 @@ struct kvm_vcpu_arch {  	gpa_t time;  	struct pvclock_vcpu_time_info hv_clock;  	unsigned int hw_tsc_khz; -	unsigned int time_offset; -	struct page *time_page; +	struct gfn_to_hva_cache pv_time; +	bool pv_time_enabled;  	/* set guest stopped flag in pvclock flags field */  	bool pvclock_set_guest_stopped_request; diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 1ace47b6259..2e188d68397 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h @@ -29,13 +29,13 @@ extern const unsigned long sys_call_table[];   */  static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)  { -	return regs->orig_ax & __SYSCALL_MASK; +	return regs->orig_ax;  }  static inline void syscall_rollback(struct task_struct *task,  				    struct pt_regs *regs)  { -	regs->ax = regs->orig_ax & __SYSCALL_MASK; +	regs->ax = regs->orig_ax;  }  static inline long syscall_get_error(struct task_struct *task, diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h index c20d1ce62dc..e709884d0ef 100644 --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -382,14 +382,14 @@ HYPERVISOR_console_io(int cmd, int count, char *str)  	return _hypercall3(int, console_io, cmd, count, str);  } -extern int __must_check HYPERVISOR_physdev_op_compat(int, void *); +extern int __must_check xen_physdev_op_compat(int, void *);  static inline int  HYPERVISOR_physdev_op(int cmd, void *arg)  {  	int rc = _hypercall2(int, physdev_op, cmd, arg);  	if (unlikely(rc == -ENOSYS)) -		rc = HYPERVISOR_physdev_op_compat(cmd, arg); +		rc = xen_physdev_op_compat(cmd, arg);  	return rc;  } diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h index 892ce40a747..7a060f4b411 100644 --- a/arch/x86/include/uapi/asm/msr-index.h +++ b/arch/x86/include/uapi/asm/msr-index.h @@ -44,6 +44,7 @@  #define SNB_C1_AUTO_UNDEMOTE		(1UL << 27)  #define SNB_C3_AUTO_UNDEMOTE		(1UL << 28) +#define MSR_PLATFORM_INFO		0x000000ce  #define MSR_MTRRcap			0x000000fe  #define MSR_IA32_BBL_CR_CTL		0x00000119  #define MSR_IA32_BBL_CR_CTL3		0x0000011e diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index 529c8931fc0..dab7580c47a 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c @@ -101,6 +101,10 @@ static struct event_constraint intel_snb_event_constraints[] __read_mostly =  	FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */  	FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */  	FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */ +	INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf), /* CYCLE_ACTIVITY.CYCLES_NO_DISPATCH */ +	INTEL_UEVENT_CONSTRAINT(0x05a3, 0xf), /* CYCLE_ACTIVITY.STALLS_L2_PENDING */ +	INTEL_UEVENT_CONSTRAINT(0x02a3, 0x4), /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */ +	INTEL_UEVENT_CONSTRAINT(0x06a3, 0x4), /* CYCLE_ACTIVITY.STALLS_L1D_PENDING */  	INTEL_EVENT_CONSTRAINT(0x48, 0x4), /* L1D_PEND_MISS.PENDING */  	INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */  	INTEL_EVENT_CONSTRAINT(0xcd, 0x8), /* MEM_TRANS_RETIRED.LOAD_LATENCY */ diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index 826054a4f2e..b05a575d56f 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c @@ -729,3 +729,13 @@ void intel_ds_init(void)  		}  	}  } + +void perf_restore_debug_store(void) +{ +	struct debug_store *ds = __this_cpu_read(cpu_hw_events.ds); + +	if (!x86_pmu.bts && !x86_pmu.pebs) +		return; + +	wrmsrl(MSR_IA32_DS_AREA, (unsigned long)ds); +} diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 3f06e614998..7bfe318d3d8 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -375,6 +375,9 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)  	else  		p->ainsn.boostable = -1; +	/* Check whether the instruction modifies Interrupt Flag or not */ +	p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn); +  	/* Also, displacement change doesn't affect the first byte */  	p->opcode = p->ainsn.insn[0];  } @@ -434,7 +437,7 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,  	__this_cpu_write(current_kprobe, p);  	kcb->kprobe_saved_flags = kcb->kprobe_old_flags  		= (regs->flags & (X86_EFLAGS_TF | X86_EFLAGS_IF)); -	if (is_IF_modifier(p->ainsn.insn)) +	if (p->ainsn.if_modifier)  		kcb->kprobe_saved_flags &= ~X86_EFLAGS_IF;  } diff --git a/arch/x86/kernel/microcode_intel_early.c b/arch/x86/kernel/microcode_intel_early.c index 7890bc83895..d893e8ed8ac 100644 --- a/arch/x86/kernel/microcode_intel_early.c +++ b/arch/x86/kernel/microcode_intel_early.c @@ -90,13 +90,13 @@ microcode_phys(struct microcode_intel **mc_saved_tmp,  	struct microcode_intel ***mc_saved;  	mc_saved = (struct microcode_intel ***) -		   __pa_symbol(&mc_saved_data->mc_saved); +		   __pa_nodebug(&mc_saved_data->mc_saved);  	for (i = 0; i < mc_saved_data->mc_saved_count; i++) {  		struct microcode_intel *p;  		p = *(struct microcode_intel **) -			__pa(mc_saved_data->mc_saved + i); -		mc_saved_tmp[i] = (struct microcode_intel *)__pa(p); +			__pa_nodebug(mc_saved_data->mc_saved + i); +		mc_saved_tmp[i] = (struct microcode_intel *)__pa_nodebug(p);  	}  }  #endif @@ -562,7 +562,7 @@ scan_microcode(unsigned long start, unsigned long end,  	struct cpio_data cd;  	long offset = 0;  #ifdef CONFIG_X86_32 -	char *p = (char *)__pa_symbol(ucode_name); +	char *p = (char *)__pa_nodebug(ucode_name);  #else  	char *p = ucode_name;  #endif @@ -630,8 +630,8 @@ static void __cpuinit print_ucode(struct ucode_cpu_info *uci)  	if (mc_intel == NULL)  		return; -	delay_ucode_info_p = (int *)__pa_symbol(&delay_ucode_info); -	current_mc_date_p = (int *)__pa_symbol(¤t_mc_date); +	delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info); +	current_mc_date_p = (int *)__pa_nodebug(¤t_mc_date);  	*delay_ucode_info_p = 1;  	*current_mc_date_p = mc_intel->hdr.date; @@ -659,8 +659,8 @@ static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci)  }  #endif -static int apply_microcode_early(struct mc_saved_data *mc_saved_data, -				 struct ucode_cpu_info *uci) +static int __cpuinit apply_microcode_early(struct mc_saved_data *mc_saved_data, +					   struct ucode_cpu_info *uci)  {  	struct microcode_intel *mc_intel;  	unsigned int val[2]; @@ -741,15 +741,15 @@ load_ucode_intel_bsp(void)  #ifdef CONFIG_X86_32  	struct boot_params *boot_params_p; -	boot_params_p = (struct boot_params *)__pa_symbol(&boot_params); +	boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);  	ramdisk_image = boot_params_p->hdr.ramdisk_image;  	ramdisk_size  = boot_params_p->hdr.ramdisk_size;  	initrd_start_early = ramdisk_image;  	initrd_end_early = initrd_start_early + ramdisk_size;  	_load_ucode_intel_bsp( -		(struct mc_saved_data *)__pa_symbol(&mc_saved_data), -		(unsigned long *)__pa_symbol(&mc_saved_in_initrd), +		(struct mc_saved_data *)__pa_nodebug(&mc_saved_data), +		(unsigned long *)__pa_nodebug(&mc_saved_in_initrd),  		initrd_start_early, initrd_end_early, &uci);  #else  	ramdisk_image = boot_params.hdr.ramdisk_image; @@ -772,10 +772,10 @@ void __cpuinit load_ucode_intel_ap(void)  	unsigned long *initrd_start_p;  	mc_saved_in_initrd_p = -		(unsigned long *)__pa_symbol(mc_saved_in_initrd); -	mc_saved_data_p = (struct mc_saved_data *)__pa_symbol(&mc_saved_data); -	initrd_start_p = (unsigned long *)__pa_symbol(&initrd_start); -	initrd_start_addr = (unsigned long)__pa_symbol(*initrd_start_p); +		(unsigned long *)__pa_nodebug(mc_saved_in_initrd); +	mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data); +	initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start); +	initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p);  #else  	mc_saved_data_p = &mc_saved_data;  	mc_saved_in_initrd_p = mc_saved_in_initrd; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 84d32855f65..90d8cc930f5 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -171,9 +171,15 @@ static struct resource bss_resource = {  #ifdef CONFIG_X86_32  /* cpu data as detected by the assembly code in head.S */ -struct cpuinfo_x86 new_cpu_data __cpuinitdata = {0, 0, 0, 0, -1, 1, 0, 0, -1}; +struct cpuinfo_x86 new_cpu_data __cpuinitdata = { +	.wp_works_ok = -1, +	.fdiv_bug = -1, +};  /* common cpu data for all cpus */ -struct cpuinfo_x86 boot_cpu_data __read_mostly = {0, 0, 0, 0, -1, 1, 0, 0, -1}; +struct cpuinfo_x86 boot_cpu_data __read_mostly = { +	.wp_works_ok = -1, +	.fdiv_bug = -1, +};  EXPORT_SYMBOL(boot_cpu_data);  unsigned int def_to_bigsmp; diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index a6ceaedc396..9f190a2a00e 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1365,9 +1365,8 @@ static inline void mwait_play_dead(void)  	unsigned int eax, ebx, ecx, edx;  	unsigned int highest_cstate = 0;  	unsigned int highest_subcstate = 0; -	int i;  	void *mwait_ptr; -	struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info); +	int i;  	if (!this_cpu_has(X86_FEATURE_MWAIT))  		return; diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 02b51dd4e4a..f77df1c5de6 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1857,7 +1857,7 @@ int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data)  	if (!pv_eoi_enabled(vcpu))  		return 0;  	return kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.pv_eoi.data, -					 addr); +					 addr, sizeof(u8));  }  void kvm_lapic_init(void) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f71500af1f8..e1721324c27 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1406,25 +1406,15 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)  	unsigned long flags, this_tsc_khz;  	struct kvm_vcpu_arch *vcpu = &v->arch;  	struct kvm_arch *ka = &v->kvm->arch; -	void *shared_kaddr;  	s64 kernel_ns, max_kernel_ns;  	u64 tsc_timestamp, host_tsc; -	struct pvclock_vcpu_time_info *guest_hv_clock; +	struct pvclock_vcpu_time_info guest_hv_clock;  	u8 pvclock_flags;  	bool use_master_clock;  	kernel_ns = 0;  	host_tsc = 0; -	/* Keep irq disabled to prevent changes to the clock */ -	local_irq_save(flags); -	this_tsc_khz = __get_cpu_var(cpu_tsc_khz); -	if (unlikely(this_tsc_khz == 0)) { -		local_irq_restore(flags); -		kvm_make_request(KVM_REQ_CLOCK_UPDATE, v); -		return 1; -	} -  	/*  	 * If the host uses TSC clock, then passthrough TSC as stable  	 * to the guest. @@ -1436,6 +1426,15 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)  		kernel_ns = ka->master_kernel_ns;  	}  	spin_unlock(&ka->pvclock_gtod_sync_lock); + +	/* Keep irq disabled to prevent changes to the clock */ +	local_irq_save(flags); +	this_tsc_khz = __get_cpu_var(cpu_tsc_khz); +	if (unlikely(this_tsc_khz == 0)) { +		local_irq_restore(flags); +		kvm_make_request(KVM_REQ_CLOCK_UPDATE, v); +		return 1; +	}  	if (!use_master_clock) {  		host_tsc = native_read_tsc();  		kernel_ns = get_kernel_ns(); @@ -1463,7 +1462,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)  	local_irq_restore(flags); -	if (!vcpu->time_page) +	if (!vcpu->pv_time_enabled)  		return 0;  	/* @@ -1525,12 +1524,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)  	 */  	vcpu->hv_clock.version += 2; -	shared_kaddr = kmap_atomic(vcpu->time_page); - -	guest_hv_clock = shared_kaddr + vcpu->time_offset; +	if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time, +		&guest_hv_clock, sizeof(guest_hv_clock)))) +		return 0;  	/* retain PVCLOCK_GUEST_STOPPED if set in guest copy */ -	pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED); +	pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);  	if (vcpu->pvclock_set_guest_stopped_request) {  		pvclock_flags |= PVCLOCK_GUEST_STOPPED; @@ -1543,12 +1542,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)  	vcpu->hv_clock.flags = pvclock_flags; -	memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock, -	       sizeof(vcpu->hv_clock)); - -	kunmap_atomic(shared_kaddr); - -	mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT); +	kvm_write_guest_cached(v->kvm, &vcpu->pv_time, +				&vcpu->hv_clock, +				sizeof(vcpu->hv_clock));  	return 0;  } @@ -1827,7 +1823,8 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)  		return 0;  	} -	if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.apf.data, gpa)) +	if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.apf.data, gpa, +					sizeof(u32)))  		return 1;  	vcpu->arch.apf.send_user_only = !(data & KVM_ASYNC_PF_SEND_ALWAYS); @@ -1837,10 +1834,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)  static void kvmclock_reset(struct kvm_vcpu *vcpu)  { -	if (vcpu->arch.time_page) { -		kvm_release_page_dirty(vcpu->arch.time_page); -		vcpu->arch.time_page = NULL; -	} +	vcpu->arch.pv_time_enabled = false;  }  static void accumulate_steal_time(struct kvm_vcpu *vcpu) @@ -1947,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)  		break;  	case MSR_KVM_SYSTEM_TIME_NEW:  	case MSR_KVM_SYSTEM_TIME: { +		u64 gpa_offset;  		kvmclock_reset(vcpu);  		vcpu->arch.time = data; @@ -1956,14 +1951,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)  		if (!(data & 1))  			break; -		/* ...but clean it before doing the actual write */ -		vcpu->arch.time_offset = data & ~(PAGE_MASK | 1); - -		vcpu->arch.time_page = -				gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT); +		gpa_offset = data & ~(PAGE_MASK | 1); -		if (is_error_page(vcpu->arch.time_page)) -			vcpu->arch.time_page = NULL; +		if (kvm_gfn_to_hva_cache_init(vcpu->kvm, +		     &vcpu->arch.pv_time, data & ~1ULL, +		     sizeof(struct pvclock_vcpu_time_info))) +			vcpu->arch.pv_time_enabled = false; +		else +			vcpu->arch.pv_time_enabled = true;  		break;  	} @@ -1980,7 +1975,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)  			return 1;  		if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime, -							data & KVM_STEAL_VALID_BITS)) +						data & KVM_STEAL_VALID_BITS, +						sizeof(struct kvm_steal_time)))  			return 1;  		vcpu->arch.st.msr_val = data; @@ -2967,7 +2963,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,   */  static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)  { -	if (!vcpu->arch.time_page) +	if (!vcpu->arch.pv_time_enabled)  		return -EINVAL;  	vcpu->arch.pvclock_set_guest_stopped_request = true;  	kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); @@ -6718,6 +6714,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)  		goto fail_free_wbinvd_dirty_mask;  	vcpu->arch.ia32_tsc_adjust_msr = 0x0; +	vcpu->arch.pv_time_enabled = false;  	kvm_async_pf_hash_reset(vcpu);  	kvm_pmu_init(vcpu); diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c index 05928aae911..906fea31579 100644 --- a/arch/x86/lib/usercopy_64.c +++ b/arch/x86/lib/usercopy_64.c @@ -74,10 +74,10 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)  	char c;  	unsigned zero_len; -	for (; len; --len) { +	for (; len; --len, to++) {  		if (__get_user_nocheck(c, from++, sizeof(char)))  			break; -		if (__put_user_nocheck(c, to++, sizeof(char))) +		if (__put_user_nocheck(c, to, sizeof(char)))  			break;  	} diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 4903a03ae87..59b7fc45327 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -410,9 +410,8 @@ void __init init_mem_mapping(void)  	/* the ISA range is always mapped regardless of memory holes */  	init_memory_mapping(0, ISA_END_ADDRESS); -	/* xen has big range in reserved near end of ram, skip it at first */ -	addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, -			 PAGE_SIZE); +	/* xen has big range in reserved near end of ram, skip it at first.*/ +	addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE);  	real_end = addr + PMD_SIZE;  	/* step_size need to be small so pgt_buf from BRK could cover it */ diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 2610bd93c89..657438858e8 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -563,6 +563,13 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)  	if (base > __pa(high_memory-1))  		return 0; +	/* +	 * some areas in the middle of the kernel identity range +	 * are not mapped, like the PCI space. +	 */ +	if (!page_is_ram(base >> PAGE_SHIFT)) +		return 0; +  	id_sz = (__pa(high_memory-1) <= base + size) ?  				__pa(high_memory) - base :  				size; diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index 120cee1c3f8..3c68768d7a7 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -11,6 +11,7 @@  #include <linux/suspend.h>  #include <linux/export.h>  #include <linux/smp.h> +#include <linux/perf_event.h>  #include <asm/pgtable.h>  #include <asm/proto.h> @@ -228,6 +229,7 @@ static void __restore_processor_state(struct saved_context *ctxt)  	do_fpu_end();  	x86_platform.restore_sched_clock_state();  	mtrr_bp_restore(); +	perf_restore_debug_store();  }  /* Needed by apm.c */ diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index e8e34938c57..6afbb2ca9a0 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -1467,8 +1467,6 @@ static void __init xen_write_cr3_init(unsigned long cr3)  	__xen_write_cr3(true, cr3);  	xen_mc_issue(PARAVIRT_LAZY_CPU);  /* interrupts restored */ - -	pv_mmu_ops.write_cr3 = &xen_write_cr3;  }  #endif @@ -2122,6 +2120,7 @@ static void __init xen_post_allocator_init(void)  #endif  #ifdef CONFIG_X86_64 +	pv_mmu_ops.write_cr3 = &xen_write_cr3;  	SetPagePinned(virt_to_page(level3_user_vsyscall));  #endif  	xen_mark_init_mm_pinned();  |