示例#1
0
static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
{
    int ret;

    ret = 0;

    switch (msr) {
#ifdef CONFIG_X86_64
        unsigned which;
        u64 base;

    case MSR_FS_BASE:
        which = SEGBASE_FS;
        goto set;
    case MSR_KERNEL_GS_BASE:
        which = SEGBASE_GS_USER;
        goto set;
    case MSR_GS_BASE:
        which = SEGBASE_GS_KERNEL;
        goto set;

set:
        base = ((u64)high << 32) | low;
        if (HYPERVISOR_set_segment_base(which, base) != 0)
            ret = -EIO;
        break;
#endif

    case MSR_STAR:
    case MSR_CSTAR:
    case MSR_LSTAR:
    case MSR_SYSCALL_MASK:
    case MSR_IA32_SYSENTER_CS:
    case MSR_IA32_SYSENTER_ESP:
    case MSR_IA32_SYSENTER_EIP:
        /* Fast syscall setup is all done in hypercalls, so
           these are all ignored.  Stub them out here to stop
           Xen console noise. */
        break;

    default:
        ret = native_write_msr_safe(msr, low, high);
    }

    return ret;
}
static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
{
	int ret;

	ret = 0;

	switch (msr) {
#ifdef CONFIG_X86_64
		unsigned which;
		u64 base;

	case MSR_FS_BASE:		which = SEGBASE_FS; goto set;
	case MSR_KERNEL_GS_BASE:	which = SEGBASE_GS_USER; goto set;
	case MSR_GS_BASE:		which = SEGBASE_GS_KERNEL; goto set;

	set:
		base = ((u64)high << 32) | low;
		if (HYPERVISOR_set_segment_base(which, base) != 0)
			ret = -EIO;
		break;
#endif

	case MSR_STAR:
	case MSR_CSTAR:
	case MSR_LSTAR:
	case MSR_SYSCALL_MASK:
	case MSR_IA32_SYSENTER_CS:
	case MSR_IA32_SYSENTER_ESP:
	case MSR_IA32_SYSENTER_EIP:
		/*                                                 
                                                       
                        */
		break;

	case MSR_IA32_CR_PAT:
		if (smp_processor_id() == 0)
			xen_set_pat(((u64)high << 32) | low);
		break;

	default:
		ret = native_write_msr_safe(msr, low, high);
	}

	return ret;
}