summaryrefslogtreecommitdiffstats
path: root/sys/amd64/vmm/vmm_msr.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2012-11-28 13:10:18 +0000
committerneel <neel@FreeBSD.org>2012-11-28 13:10:18 +0000
commit308122a0f1279a0305554f864d6b01f9c132511a (patch)
tree5f19842a5c240b93e3f6cfbdee50f247157d04cf /sys/amd64/vmm/vmm_msr.c
parent36ab9a2e1ab7d2b1884270275584f989cfd65e2b (diff)
downloadFreeBSD-src-308122a0f1279a0305554f864d6b01f9c132511a.zip
FreeBSD-src-308122a0f1279a0305554f864d6b01f9c132511a.tar.gz
Change emulate_rdmsr() and emulate_wrmsr() to return 0 on sucess and errno on
failure. The conversion from the return value to HANDLED or UNHANDLED can be done locally in vmx_exit_process(). Obtained from: NetApp
Diffstat (limited to 'sys/amd64/vmm/vmm_msr.c')
-rw-r--r--sys/amd64/vmm/vmm_msr.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/sys/amd64/vmm/vmm_msr.c b/sys/amd64/vmm/vmm_msr.c
index bc67f98..d97c819 100644
--- a/sys/amd64/vmm/vmm_msr.c
+++ b/sys/amd64/vmm/vmm_msr.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#define VMM_MSR_F_EMULATE 0x01
#define VMM_MSR_F_READONLY 0x02
-#define VMM_MSR_F_INVALID 0x04
+#define VMM_MSR_F_INVALID 0x04 /* guest_msr_valid() can override this */
struct vmm_msr {
int num;
@@ -137,20 +137,15 @@ msr_num_to_idx(u_int num)
int
emulate_wrmsr(struct vm *vm, int cpu, u_int num, uint64_t val)
{
- int handled, idx;
+ int idx;
uint64_t *guest_msrs;
- handled = 0;
-
if (lapic_msr(num))
return (lapic_wrmsr(vm, cpu, num, val));
idx = msr_num_to_idx(num);
- if (idx < 0)
- goto done;
-
- if (invalid_msr(idx))
- goto done;
+ if (idx < 0 || invalid_msr(idx))
+ return (EINVAL);
if (!readonly_msr(idx)) {
guest_msrs = vm_guest_msrs(vm, cpu);
@@ -163,31 +158,26 @@ emulate_wrmsr(struct vm *vm, int cpu, u_int num, uint64_t val)
wrmsr(vmm_msr[idx].num, val);
}
- handled = 1;
-done:
- return (handled);
+ return (0);
}
int
emulate_rdmsr(struct vm *vm, int cpu, u_int num)
{
- int error, handled, idx;
+ int error, idx;
uint32_t eax, edx;
uint64_t result, *guest_msrs;
- handled = 0;
-
if (lapic_msr(num)) {
- handled = lapic_rdmsr(vm, cpu, num, &result);
+ error = lapic_rdmsr(vm, cpu, num, &result);
goto done;
}
idx = msr_num_to_idx(num);
- if (idx < 0)
- goto done;
-
- if (invalid_msr(idx))
+ if (idx < 0 || invalid_msr(idx)) {
+ error = EINVAL;
goto done;
+ }
guest_msrs = vm_guest_msrs(vm, cpu);
result = guest_msrs[idx];
@@ -202,10 +192,10 @@ emulate_rdmsr(struct vm *vm, int cpu, u_int num)
result, rdmsr(num));
}
- handled = 1;
+ error = 0;
done:
- if (handled) {
+ if (error == 0) {
eax = result;
edx = result >> 32;
error = vm_set_register(vm, cpu, VM_REG_GUEST_RAX, eax);
@@ -215,7 +205,7 @@ done:
if (error)
panic("vm_set_register(rdx) error %d", error);
}
- return (handled);
+ return (error);
}
void
OpenPOWER on IntegriCloud