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

Commit e08cae41 authored by H. Peter Anvin's avatar H. Peter Anvin
Browse files

x86: Clean up the hypervisor layer



Clean up the hypervisor layer and the hypervisor drivers, using an ops
structure instead of an enumeration with if statements.

The identity of the hypervisor, if needed, can be tested by testing
the pointer value in x86_hyper.

The MS-HyperV private state is moved into a normal global variable
(it's per-system state, not per-CPU state).  Being a normal bss
variable, it will be left at all zero on non-HyperV platforms, and so
can generally be tested for HyperV-specific features without
additional qualification.

Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
Acked-by: default avatarGreg KH <greg@kroah.com>
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Ky Srinivasan <ksrinivasan@novell.com>
LKML-Reference: <4BE49778.6060800@zytor.com>
parent 9fa02317
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
#ifndef _ASM_X86_KVM_HYPERV_H
#define _ASM_X86_KVM_HYPERV_H
#ifndef _ASM_X86_HYPERV_H
#define _ASM_X86_HYPERV_H

#include <linux/types.h>

@@ -16,6 +16,7 @@

#define HYPERV_HYPERVISOR_PRESENT_BIT		0x80000000
#define HYPERV_CPUID_MIN			0x40000005
#define HYPERV_CPUID_MAX			0x4000ffff

/*
 * Feature identification. EAX indicates which features are available
+25 −2
Original line number Diff line number Diff line
@@ -17,10 +17,33 @@
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
#ifndef ASM_X86__HYPERVISOR_H
#define ASM_X86__HYPERVISOR_H
#ifndef _ASM_X86_HYPERVISOR_H
#define _ASM_X86_HYPERVISOR_H

extern void init_hypervisor(struct cpuinfo_x86 *c);
extern void init_hypervisor_platform(void);

/*
 * x86 hypervisor information
 */
struct hypervisor_x86 {
	/* Hypervisor name */
	const char	*name;

	/* Detection routine */
	bool		(*detect)(void);

	/* Adjust CPU feature bits (run once per CPU) */
	void		(*set_cpu_features)(struct cpuinfo_x86 *);

	/* Platform setup (run once per boot) */
	void		(*init_platform)(void);
};

extern const struct hypervisor_x86 *x86_hyper;

/* Recognized hypervisors */
extern const struct hypervisor_x86 x86_hyper_vmware;
extern const struct hypervisor_x86 x86_hyper_ms_hyperv;

#endif
+11 −4
Original line number Diff line number Diff line
#ifndef ASM_X86__MSHYPER_H
#define ASM_X86__MSHYPER_H
#ifndef _ASM_X86_MSHYPER_H
#define _ASM_X86_MSHYPER_H

int ms_hyperv_platform(void);
void __cpuinit ms_hyperv_set_feature_bits(struct cpuinfo_x86 *c);
#include <linux/types.h>
#include <asm/hyperv.h>

struct ms_hyperv_info {
	u32 features;
	u32 hints;
};

extern struct ms_hyperv_info ms_hyperv;

#endif
+0 −7
Original line number Diff line number Diff line
@@ -113,9 +113,6 @@ struct cpuinfo_x86 {
	/* Index into per_cpu list: */
	u16			cpu_index;
#endif
	unsigned int		x86_hyper_vendor;
	/* The layout of this field is hypervisor specific */
	unsigned int		x86_hyper_features;
} __attribute__((__aligned__(SMP_CACHE_BYTES)));

#define X86_VENDOR_INTEL	0
@@ -129,10 +126,6 @@ struct cpuinfo_x86 {

#define X86_VENDOR_UNKNOWN	0xff

#define X86_HYPER_VENDOR_NONE  0
#define X86_HYPER_VENDOR_VMWARE 1
#define X86_HYPER_VENDOR_MSFT	2

/*
 * capabilities of CPUs
 */

arch/x86/include/asm/vmware.h

deleted100644 → 0
+0 −27
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008, VMware, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 * NON INFRINGEMENT.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
#ifndef ASM_X86__VMWARE_H
#define ASM_X86__VMWARE_H

extern void vmware_platform_setup(void);
extern int vmware_platform(void);
extern void vmware_set_feature_bits(struct cpuinfo_x86 *c);

#endif
Loading