Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5d77a73 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge commit 'upstream-x86-virt' into WIP.x86/mm



Merge a minimal set of virt cleanups, for a base for the MM isolation patches.

Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 2ec077c1 03b2a320
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -113,7 +113,7 @@ void hyperv_init(void)
	u64 guest_id;
	u64 guest_id;
	union hv_x64_msr_hypercall_contents hypercall_msr;
	union hv_x64_msr_hypercall_contents hypercall_msr;


	if (x86_hyper != &x86_hyper_ms_hyperv)
	if (x86_hyper_type != X86_HYPER_MS_HYPERV)
		return;
		return;


	/* Allocate percpu VP index */
	/* Allocate percpu VP index */
+18 −28
Original line number Original line Diff line number Diff line
@@ -23,11 +23,22 @@
#ifdef CONFIG_HYPERVISOR_GUEST
#ifdef CONFIG_HYPERVISOR_GUEST


#include <asm/kvm_para.h>
#include <asm/kvm_para.h>
#include <asm/x86_init.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypervisor.h>


/*
/*
 * x86 hypervisor information
 * x86 hypervisor information
 */
 */

enum x86_hypervisor_type {
	X86_HYPER_NATIVE = 0,
	X86_HYPER_VMWARE,
	X86_HYPER_MS_HYPERV,
	X86_HYPER_XEN_PV,
	X86_HYPER_XEN_HVM,
	X86_HYPER_KVM,
};

struct hypervisor_x86 {
struct hypervisor_x86 {
	/* Hypervisor name */
	/* Hypervisor name */
	const char	*name;
	const char	*name;
@@ -35,40 +46,19 @@ struct hypervisor_x86 {
	/* Detection routine */
	/* Detection routine */
	uint32_t	(*detect)(void);
	uint32_t	(*detect)(void);


	/* Platform setup (run once per boot) */
	/* Hypervisor type */
	void		(*init_platform)(void);
	enum x86_hypervisor_type type;

	/* X2APIC detection (run once per boot) */
	bool		(*x2apic_available)(void);


	/* pin current vcpu to specified physical cpu (run rarely) */
	/* init time callbacks */
	void		(*pin_vcpu)(int);
	struct x86_hyper_init init;


	/* called during init_mem_mapping() to setup early mappings. */
	/* runtime callbacks */
	void		(*init_mem_mapping)(void);
	struct x86_hyper_runtime runtime;
};
};


extern const struct hypervisor_x86 *x86_hyper;
extern enum x86_hypervisor_type x86_hyper_type;

/* Recognized hypervisors */
extern const struct hypervisor_x86 x86_hyper_vmware;
extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
extern const struct hypervisor_x86 x86_hyper_xen_pv;
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
extern const struct hypervisor_x86 x86_hyper_kvm;

extern void init_hypervisor_platform(void);
extern void init_hypervisor_platform(void);
extern bool hypervisor_x2apic_available(void);
extern void hypervisor_pin_vcpu(int cpu);

static inline void hypervisor_init_mem_mapping(void)
{
	if (x86_hyper && x86_hyper->init_mem_mapping)
		x86_hyper->init_mem_mapping();
}
#else
#else
static inline void init_hypervisor_platform(void) { }
static inline void init_hypervisor_platform(void) { }
static inline bool hypervisor_x2apic_available(void) { return false; }
static inline void hypervisor_init_mem_mapping(void) { }
#endif /* CONFIG_HYPERVISOR_GUEST */
#endif /* CONFIG_HYPERVISOR_GUEST */
#endif /* _ASM_X86_HYPERVISOR_H */
#endif /* _ASM_X86_HYPERVISOR_H */
+24 −0
Original line number Original line Diff line number Diff line
@@ -114,6 +114,18 @@ struct x86_init_pci {
	void (*fixup_irqs)(void);
	void (*fixup_irqs)(void);
};
};


/**
 * struct x86_hyper_init - x86 hypervisor init functions
 * @init_platform:		platform setup
 * @x2apic_available:		X2APIC detection
 * @init_mem_mapping:		setup early mappings during init_mem_mapping()
 */
struct x86_hyper_init {
	void (*init_platform)(void);
	bool (*x2apic_available)(void);
	void (*init_mem_mapping)(void);
};

/**
/**
 * struct x86_init_ops - functions for platform specific setup
 * struct x86_init_ops - functions for platform specific setup
 *
 *
@@ -127,6 +139,7 @@ struct x86_init_ops {
	struct x86_init_timers		timers;
	struct x86_init_timers		timers;
	struct x86_init_iommu		iommu;
	struct x86_init_iommu		iommu;
	struct x86_init_pci		pci;
	struct x86_init_pci		pci;
	struct x86_hyper_init		hyper;
};
};


/**
/**
@@ -199,6 +212,15 @@ struct x86_legacy_features {
	struct x86_legacy_devices devices;
	struct x86_legacy_devices devices;
};
};


/**
 * struct x86_hyper_runtime - x86 hypervisor specific runtime callbacks
 *
 * @pin_vcpu:		pin current vcpu to specified physical cpu (run rarely)
 */
struct x86_hyper_runtime {
	void (*pin_vcpu)(int cpu);
};

/**
/**
 * struct x86_platform_ops - platform specific runtime functions
 * struct x86_platform_ops - platform specific runtime functions
 * @calibrate_cpu:		calibrate CPU
 * @calibrate_cpu:		calibrate CPU
@@ -218,6 +240,7 @@ struct x86_legacy_features {
 * 				possible in x86_early_init_platform_quirks() by
 * 				possible in x86_early_init_platform_quirks() by
 * 				only using the current x86_hardware_subarch
 * 				only using the current x86_hardware_subarch
 * 				semantics.
 * 				semantics.
 * @hyper:			x86 hypervisor specific runtime callbacks
 */
 */
struct x86_platform_ops {
struct x86_platform_ops {
	unsigned long (*calibrate_cpu)(void);
	unsigned long (*calibrate_cpu)(void);
@@ -233,6 +256,7 @@ struct x86_platform_ops {
	void (*apic_post_init)(void);
	void (*apic_post_init)(void);
	struct x86_legacy_features legacy;
	struct x86_legacy_features legacy;
	void (*set_legacy_features)(void);
	void (*set_legacy_features)(void);
	struct x86_hyper_runtime hyper;
};
};


struct pci_dev;
struct pci_dev;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1645,7 +1645,7 @@ static __init void try_to_enable_x2apic(int remap_mode)
		 * under KVM
		 * under KVM
		 */
		 */
		if (max_physical_apicid > 255 ||
		if (max_physical_apicid > 255 ||
		    !hypervisor_x2apic_available()) {
		    !x86_init.hyper.x2apic_available()) {
			pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
			pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
			x2apic_disable();
			x2apic_disable();
			return;
			return;
+2 −3
Original line number Original line Diff line number Diff line
@@ -920,9 +920,8 @@ static __init void uv_rtc_init(void)
/*
/*
 * percpu heartbeat timer
 * percpu heartbeat timer
 */
 */
static void uv_heartbeat(unsigned long ignored)
static void uv_heartbeat(struct timer_list *timer)
{
{
	struct timer_list *timer = &uv_scir_info->timer;
	unsigned char bits = uv_scir_info->state;
	unsigned char bits = uv_scir_info->state;


	/* Flip heartbeat bit: */
	/* Flip heartbeat bit: */
@@ -947,7 +946,7 @@ static int uv_heartbeat_enable(unsigned int cpu)
		struct timer_list *timer = &uv_cpu_scir_info(cpu)->timer;
		struct timer_list *timer = &uv_cpu_scir_info(cpu)->timer;


		uv_set_cpu_scir_bits(cpu, SCIR_CPU_HEARTBEAT|SCIR_CPU_ACTIVITY);
		uv_set_cpu_scir_bits(cpu, SCIR_CPU_HEARTBEAT|SCIR_CPU_ACTIVITY);
		setup_pinned_timer(timer, uv_heartbeat, cpu);
		timer_setup(timer, uv_heartbeat, TIMER_PINNED);
		timer->expires = jiffies + SCIR_CPU_HB_INTERVAL;
		timer->expires = jiffies + SCIR_CPU_HB_INTERVAL;
		add_timer_on(timer, cpu);
		add_timer_on(timer, cpu);
		uv_cpu_scir_info(cpu)->enabled = 1;
		uv_cpu_scir_info(cpu)->enabled = 1;
Loading