From d7c33b8655d70ee0ad96d4269319997e751cf2bc Mon Sep 17 00:00:00 2001 From: Diego Ongaro Date: Thu, 18 Dec 2008 23:54:54 -0600 Subject: [PATCH] Sets some kvm_run out flags before going to userspace. The out flags are: 1. exit_reason - this one was already handled 2. ready_for_interrupt_injection - true if * IF_FLAG of rflags is 1 * we're not in an interrupt shadow (MOV SS, etc) * kvm also checks its in-kernel interrupt queues, this commit just adds a TODO for that 3. if_flag - simply read from rflags 4. ready_for_nmi_injection - this commit just adds a TODO 5. cr8 - this was read (in) but not set (out) before 6. apic_base - we're not using this, so this commit drops it from kvm_run See also 99c9ffeefadb429accf27e11e558b89cb66eac04 for libfkvm, which assumed some of this functionality. --- sys/kern/kern_fkvm.c | 14 ++++++++++++++ sys/sys/fkvm.h | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_fkvm.c b/sys/kern/kern_fkvm.c index eeb32f145e9..45f32b1f554 100644 --- a/sys/kern/kern_fkvm.c +++ b/sys/kern/kern_fkvm.c @@ -2082,6 +2082,20 @@ fkvm_vm_run(struct thread *td, struct fkvm_vm_run_args *uap) // printf("\n\n"); + /* we're going up to userspace - set the out fields of kvm_run: */ + +#define IF_MASK 0x00000200 + kvm_run.if_flag = !!(vcpu->vmcb->save.rflags & IF_MASK); + + /* TODO: kvm adds a check to see if in-kernel interrupt queues are empty */ + kvm_run.ready_for_interrupt_injection = kvm_run.if_flag && + !vcpu->vmcb->control.intr_shadow; + + /* TODO kvm_run.ready_for_nmi_injection = ...; */ + + kvm_run.cr8 = fkvm_get_cr8(vcpu); + + /* TODO: check copyout ret val */ copyout(&kvm_run, uap->run, sizeof(struct kvm_run)); // printf("sizeof(struct kvm_run) = %" PRIu64 "\n", sizeof(struct kvm_run)); diff --git a/sys/sys/fkvm.h b/sys/sys/fkvm.h index 4d6b853c19f..3a0c921f75d 100644 --- a/sys/sys/fkvm.h +++ b/sys/sys/fkvm.h @@ -246,7 +246,6 @@ struct kvm_run { /* in (pre_kvm_run), out (post_kvm_run) */ uint64_t cr8; - uint64_t apic_base; union { /* KVM_EXIT_UNKNOWN */ -- 2.11.4.GIT