-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 80650 b: refs/heads/master c: 043405e h: refs/heads/master v: v3
- Loading branch information
Carsten Otte
authored and
Avi Kivity
committed
Jan 30, 2008
1 parent
4d8e7d6
commit d010ed8
Showing
6 changed files
with
127 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 6fc138d2278078990f597cb1f62fde9e5b458f96 | ||
refs/heads/master: 043405e10001fe7aae60c46a57189515f13a6468 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Kernel-based Virtual Machine driver for Linux | ||
* | ||
* derived from drivers/kvm/kvm_main.c | ||
* | ||
* Copyright (C) 2006 Qumranet, Inc. | ||
* | ||
* Authors: | ||
* Avi Kivity <avi@qumranet.com> | ||
* Yaniv Kamay <yaniv@qumranet.com> | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2. See | ||
* the COPYING file in the top-level directory. | ||
* | ||
*/ | ||
|
||
#include "x86.h" | ||
|
||
#include <asm/uaccess.h> | ||
|
||
/* | ||
* List of msr numbers which we expose to userspace through KVM_GET_MSRS | ||
* and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. | ||
* | ||
* This list is modified at module load time to reflect the | ||
* capabilities of the host cpu. | ||
*/ | ||
static u32 msrs_to_save[] = { | ||
MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, | ||
MSR_K6_STAR, | ||
#ifdef CONFIG_X86_64 | ||
MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, | ||
#endif | ||
MSR_IA32_TIME_STAMP_COUNTER, | ||
}; | ||
|
||
static unsigned num_msrs_to_save; | ||
|
||
static u32 emulated_msrs[] = { | ||
MSR_IA32_MISC_ENABLE, | ||
}; | ||
|
||
long kvm_arch_dev_ioctl(struct file *filp, | ||
unsigned int ioctl, unsigned long arg) | ||
{ | ||
void __user *argp = (void __user *)arg; | ||
long r; | ||
|
||
switch (ioctl) { | ||
case KVM_GET_MSR_INDEX_LIST: { | ||
struct kvm_msr_list __user *user_msr_list = argp; | ||
struct kvm_msr_list msr_list; | ||
unsigned n; | ||
|
||
r = -EFAULT; | ||
if (copy_from_user(&msr_list, user_msr_list, sizeof msr_list)) | ||
goto out; | ||
n = msr_list.nmsrs; | ||
msr_list.nmsrs = num_msrs_to_save + ARRAY_SIZE(emulated_msrs); | ||
if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list)) | ||
goto out; | ||
r = -E2BIG; | ||
if (n < num_msrs_to_save) | ||
goto out; | ||
r = -EFAULT; | ||
if (copy_to_user(user_msr_list->indices, &msrs_to_save, | ||
num_msrs_to_save * sizeof(u32))) | ||
goto out; | ||
if (copy_to_user(user_msr_list->indices | ||
+ num_msrs_to_save * sizeof(u32), | ||
&emulated_msrs, | ||
ARRAY_SIZE(emulated_msrs) * sizeof(u32))) | ||
goto out; | ||
r = 0; | ||
break; | ||
} | ||
default: | ||
r = -EINVAL; | ||
} | ||
out: | ||
return r; | ||
} | ||
|
||
static __init void kvm_init_msr_list(void) | ||
{ | ||
u32 dummy[2]; | ||
unsigned i, j; | ||
|
||
for (i = j = 0; i < ARRAY_SIZE(msrs_to_save); i++) { | ||
if (rdmsr_safe(msrs_to_save[i], &dummy[0], &dummy[1]) < 0) | ||
continue; | ||
if (j < i) | ||
msrs_to_save[j] = msrs_to_save[i]; | ||
j++; | ||
} | ||
num_msrs_to_save = j; | ||
} | ||
|
||
__init void kvm_arch_init(void) | ||
{ | ||
kvm_init_msr_list(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#/* | ||
* Kernel-based Virtual Machine driver for Linux | ||
* | ||
* This header defines architecture specific interfaces, x86 version | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2. See | ||
* the COPYING file in the top-level directory. | ||
* | ||
*/ | ||
|
||
#ifndef KVM_X86_H | ||
#define KVM_X86_H | ||
|
||
#include "kvm.h" | ||
|
||
#endif |