Skip to content
paravirt.h 25.7 KiB
Newer Older
#ifndef _ASM_X86_PARAVIRT_H
#define _ASM_X86_PARAVIRT_H
/* Various instructions on x86 need to be replaced for
 * para-virtualization: those hooks are defined here. */
#include <asm/pgtable_types.h>
#include <asm/paravirt_types.h>
	return pv_info.paravirt_enabled;
static inline void load_sp0(struct tss_struct *tss,
			     struct thread_struct *thread)
{
	PVOP_VCALL2(pv_cpu_ops.load_sp0, tss, thread);
}

static inline unsigned long get_wallclock(void)
{
	return PVOP_CALL0(unsigned long, pv_time_ops.get_wallclock);
}

static inline int set_wallclock(unsigned long nowtime)
{
	return PVOP_CALL1(int, pv_time_ops.set_wallclock, nowtime);
static inline void (*choose_time_init(void))(void)
}

/* The paravirtualized CPUID instruction. */
static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
			   unsigned int *ecx, unsigned int *edx)
{
	PVOP_VCALL4(pv_cpu_ops.cpuid, eax, ebx, ecx, edx);
}

/*
 * These special macros can be used to get or set a debugging register
 */
static inline unsigned long paravirt_get_debugreg(int reg)
{
	return PVOP_CALL1(unsigned long, pv_cpu_ops.get_debugreg, reg);
}
#define get_debugreg(var, reg) var = paravirt_get_debugreg(reg)
static inline void set_debugreg(unsigned long val, int reg)
{
	PVOP_VCALL2(pv_cpu_ops.set_debugreg, reg, val);
	return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr0);
	PVOP_VCALL1(pv_cpu_ops.write_cr0, x);
	return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr2);
	PVOP_VCALL1(pv_mmu_ops.write_cr2, x);
	return PVOP_CALL0(unsigned long, pv_mmu_ops.read_cr3);
	PVOP_VCALL1(pv_mmu_ops.write_cr3, x);
	return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4);
	return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4_safe);
	PVOP_VCALL1(pv_cpu_ops.write_cr4, x);
static inline unsigned long read_cr8(void)
{
	return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr8);
}

static inline void write_cr8(unsigned long x)
{
	PVOP_VCALL1(pv_cpu_ops.write_cr8, x);
}
static inline void raw_safe_halt(void)
{
	PVOP_VCALL0(pv_irq_ops.safe_halt);
	PVOP_VCALL0(pv_irq_ops.safe_halt);
	PVOP_VCALL0(pv_cpu_ops.wbinvd);
#define get_kernel_rpl()  (pv_info.kernel_rpl)
static inline u64 paravirt_read_msr(unsigned msr, int *err)
{
	return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err);
Yinghai Lu's avatar
Yinghai Lu committed
static inline u64 paravirt_read_msr_amd(unsigned msr, int *err)
{
	return PVOP_CALL2(u64, pv_cpu_ops.read_msr_amd, msr, err);
}
static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
{
	return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
/* These should all do BUG_ON(_err), but our headers are too tangled. */
#define rdmsr(msr, val1, val2)			\
do {						\
	int _err;				\
	u64 _l = paravirt_read_msr(msr, &_err);	\
	val1 = (u32)_l;				\
	val2 = _l >> 32;			\
#define wrmsr(msr, val1, val2)			\
do {						\
#define rdmsrl(msr, val)			\
do {						\
#define wrmsrl(msr, val)	wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32)
#define wrmsr_safe(msr, a, b)	paravirt_write_msr(msr, a, b)

/* rdmsr with exception handling */
#define rdmsr_safe(msr, a, b)			\
({						\
	int _err;				\
	u64 _l = paravirt_read_msr(msr, &_err);	\
	(*a) = (u32)_l;				\
	(*b) = _l >> 32;			\
Andi Kleen's avatar
Andi Kleen committed
static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
{
	int err;

	*p = paravirt_read_msr(msr, &err);
	return err;
}
Yinghai Lu's avatar
Yinghai Lu committed
static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
{
	int err;

	*p = paravirt_read_msr_amd(msr, &err);
	return err;
}
Loading
Loading full blame...