From: Avi Kivity <avi@qumranet.com>
To: Alexander Graf <agraf@suse.de>
Cc: KVM list <kvm@vger.kernel.org>, Joerg Roedel <joro@8bytes.org>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [PATCH 8/9] Add VMRUN handler
Date: Mon, 01 Sep 2008 16:41:43 +0300 [thread overview]
Message-ID: <48BBF117.30208@qumranet.com> (raw)
In-Reply-To: <1220270281-15720-9-git-send-email-agraf@suse.de>
Alexander Graf wrote:
> This patch implements VMRUN. VMRUN enters a virtual CPU and runs that
> in the same context as the normal guest CPU would run.
> So basically it is implemented the same way, a normal CPU would do it.
>
> We also prepare all intercepts that get OR'ed with the original
> intercepts, as we do not allow a level 2 guest to be intercepted less
> than the first level guest.
>
>
>
> +/* Not needed until device passthrough */
> +/* #define NESTED_KVM_MERGE_IOPM */
> +
>
I'd like to drop port 80 passthrough anyway. Device assignment is
unlikely to make heavy use of ioports.
> @@ -663,9 +674,21 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
> msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER);
> if (!msrpm_pages)
> goto uninit;
> +
> + nested_msrpm_pages = alloc_pages(GFP_KERNEL, MSRPM_ALLOC_ORDER);
> + if (!nested_msrpm_pages)
> + goto uninit;
> +
> + nested_iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
> + if (!nested_iopm_pages)
> + goto uninit;
> +
>
Maybe we should do that on the first time the guest enters nested svm,
to save a bit of memory.
We can do that in a later patch, though.
>
> +
> +static int nested_svm_vmrun_msrpm(struct vcpu_svm *svm, void *arg1,
> + void *arg2, void *opaque)
> +{
> + int i;
> + u32 *nested_msrpm = (u32*)arg1;
> + for (i=0; i< PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER) / 4; i++)
> + svm->nested_msrpm[i] = svm->msrpm[i] | nested_msrpm[i];
> + svm->vmcb->control.msrpm_base_pa = __pa(svm->nested_msrpm);
> +
> + return 0;
> +}
>
Hm. Have you verified that kvm actually has msr emulation for all the
msrs it allows through msrpm?
I guess it has to, since the msrs can be set through save/restore.
(vmrun emulation)
> +
> + force_new_asid(&svm->vcpu);
>
I would be nice not to do this (can be left for later of course; it
could be quite complex).
> +
> +static int vmrun_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
> +{
> + nsvm_printk("VMrun\n");
> +
> + svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
> + skip_emulated_instruction(&svm->vcpu);
> +
> + if (svm->vmcb->save.cpl) {
> + printk(KERN_ERR "%s: invalid cpl 0x%x at ip 0x%lx\n",
> + __func__, svm->vmcb->save.cpl, kvm_rip_read(&svm->vcpu));
> + kvm_queue_exception(&svm->vcpu, GP_VECTOR);
> + return 1;
> + }
>
Skip after check.
I think you also need special treatment for the guest's eflags.if. If
interrupts are enabled for the guest when vmrun is executed, and kvm
tries to inject a virtual interrupt, then it should result in a virtual
#VMEXIT.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2008-09-01 13:41 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 11:57 [PATCH 0/9] [RFC] Add support for nested SVM (kernel) Alexander Graf
2008-09-01 11:57 ` [PATCH 1/9] Add CPUID feature flag for SVM Alexander Graf
2008-09-01 11:57 ` [PATCH 2/9] Clean up VINTR setting Alexander Graf
2008-09-01 11:57 ` [PATCH 3/9] Implement GIF, clgi and stgi Alexander Graf
2008-09-01 11:57 ` [PATCH 4/9] Add helper functions for nested SVM Alexander Graf
2008-09-01 11:57 ` [PATCH 5/9] Allow setting the SVME bit Alexander Graf
2008-09-01 11:57 ` [PATCH 6/9] Implement hsave Alexander Graf
2008-09-01 11:57 ` [PATCH 7/9] Add VMLOAD and VMSAVE handlers Alexander Graf
2008-09-01 11:58 ` [PATCH 8/9] Add VMRUN handler Alexander Graf
2008-09-01 11:58 ` [PATCH 9/9] Add VMEXIT handler and intercepts Alexander Graf
2008-09-01 13:58 ` Avi Kivity
2008-09-02 16:15 ` Alexander Graf
2008-09-03 9:23 ` Avi Kivity
2008-09-03 9:33 ` Alexander Graf
2008-09-03 9:47 ` Avi Kivity
2008-09-03 11:55 ` Alexander Graf
2008-09-01 13:41 ` Avi Kivity [this message]
2008-09-02 15:38 ` [PATCH 8/9] Add VMRUN handler Alexander Graf
2008-09-01 13:27 ` [PATCH 7/9] Add VMLOAD and VMSAVE handlers Avi Kivity
2008-09-01 14:14 ` Alexander Graf
2008-09-01 14:27 ` Avi Kivity
2008-09-01 14:49 ` Alexander Graf
2008-09-01 13:15 ` [PATCH 6/9] Implement hsave Avi Kivity
2008-09-01 14:11 ` Alexander Graf
2008-09-01 14:26 ` Avi Kivity
2008-09-01 13:21 ` Avi Kivity
2008-09-01 13:14 ` [PATCH 5/9] Allow setting the SVME bit Avi Kivity
2008-09-01 13:11 ` [PATCH 3/9] Implement GIF, clgi and stgi Avi Kivity
2008-09-01 14:02 ` Alexander Graf
2008-09-01 14:25 ` Avi Kivity
2008-09-01 15:37 ` Alexander Graf
2008-09-01 16:05 ` Avi Kivity
2008-09-01 16:13 ` Alexander Graf
2008-09-01 16:17 ` Avi Kivity
2008-09-01 16:40 ` Alexander Graf
2008-09-02 9:15 ` Avi Kivity
2008-09-01 13:13 ` [PATCH 2/9] Clean up VINTR setting Avi Kivity
2008-09-01 12:09 ` [PATCH 0/9] [RFC] Add support for nested SVM (kernel) Avi Kivity
2008-09-01 12:21 ` Joerg Roedel
2008-09-01 13:41 ` Daniel P. Berrange
2008-09-01 14:17 ` Alexander Graf
2008-09-01 14:22 ` Avi Kivity
2008-09-01 14:47 ` Alexander Graf
2008-09-01 14:57 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48BBF117.30208@qumranet.com \
--to=avi@qumranet.com \
--cc=agraf@suse.de \
--cc=anthony@codemonkey.ws \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox