From: Keir Fraser <keir@xen.org>
To: Dongxiao Xu <dongxiao.xu@intel.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH] nvmx: fix resource relinquish for nested VMX
Date: Fri, 24 Aug 2012 09:45:56 +0100 [thread overview]
Message-ID: <CC5CFDD4.4A084%keir@xen.org> (raw)
In-Reply-To: <1345691481-6862-1-git-send-email-dongxiao.xu@intel.com>
On 23/08/2012 04:11, "Dongxiao Xu" <dongxiao.xu@intel.com> wrote:
> The previous order of relinquish resource is:
> relinquish_domain_resources() -> vcpu_destroy() -> nvmx_vcpu_destroy().
> However some L1 resources like nv_vvmcx and io_bitmaps are free in
> nvmx_vcpu_destroy(), therefore the relinquish_domain_resources()
> will not reduce the refcnt of the domain to 0, therefore the latter
> vcpu release functions will not be called.
>
> To fix this issue, we need to release the nv_vvmcx and io_bitmaps in
> relinquish_domain_resources().
>
> Besides, after destroy the nested vcpu, we need to switch the vmx->vmcs
> back to the L1 and let the vcpu_destroy() logic to free the L1 VMCS page.
>
> Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Couple of comments below.
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> index 2e0b79d..1f610eb 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -57,6 +57,9 @@ void nvmx_vcpu_destroy(struct vcpu *v)
> {
> struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
>
> + if ( nvcpu->nv_n1vmcx )
> + v->arch.hvm_vmx.vmcs = nvcpu->nv_n1vmcx;
Okay, this undoes the fork in nvmx_handle_vmxon()? A small code comment to
explain that would be handy.
> nvmx_purge_vvmcs(v);
This call of nvmx_purge_vvmcs() is no longer needed, and should be removed?
-- Keir
> if ( nvcpu->nv_n2vmcx ) {
> __vmpclear(virt_to_maddr(nvcpu->nv_n2vmcx));
> @@ -65,6 +68,14 @@ void nvmx_vcpu_destroy(struct vcpu *v)
> }
> }
>
> +void nvmx_domain_relinquish_resources(struct domain *d)
> +{
> + struct vcpu *v;
> +
> + for_each_vcpu ( d, v )
> + nvmx_purge_vvmcs(v);
> +}
> +
> int nvmx_vcpu_reset(struct vcpu *v)
> {
> return 0;
> diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
> index 7243c4e..3592a8c 100644
> --- a/xen/include/asm-x86/hvm/hvm.h
> +++ b/xen/include/asm-x86/hvm/hvm.h
> @@ -179,6 +179,7 @@ struct hvm_function_table {
> bool_t (*nhvm_vmcx_hap_enabled)(struct vcpu *v);
>
> enum hvm_intblk (*nhvm_intr_blocked)(struct vcpu *v);
> + void (*nhvm_domain_relinquish_resources)(struct domain *d);
> };
>
> extern struct hvm_function_table hvm_funcs;
> diff --git a/xen/include/asm-x86/hvm/vmx/vvmx.h
> b/xen/include/asm-x86/hvm/vmx/vvmx.h
> index 995f9f4..bbc34e7 100644
> --- a/xen/include/asm-x86/hvm/vmx/vvmx.h
> +++ b/xen/include/asm-x86/hvm/vmx/vvmx.h
> @@ -96,6 +96,7 @@ uint32_t nvmx_vcpu_asid(struct vcpu *v);
> enum hvm_intblk nvmx_intr_blocked(struct vcpu *v);
> int nvmx_intercepts_exception(struct vcpu *v,
> unsigned int trap, int error_code);
> +void nvmx_domain_relinquish_resources(struct domain *d);
>
> int nvmx_handle_vmxon(struct cpu_user_regs *regs);
> int nvmx_handle_vmxoff(struct cpu_user_regs *regs);
next prev parent reply other threads:[~2012-08-24 8:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 3:11 [PATCH] nvmx: fix resource relinquish for nested VMX Dongxiao Xu
2012-08-24 8:45 ` Keir Fraser [this message]
2012-08-27 0:55 ` Xu, Dongxiao
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=CC5CFDD4.4A084%keir@xen.org \
--to=keir@xen.org \
--cc=dongxiao.xu@intel.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).