xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: suravee.suthikulpanit@amd.com
Cc: chegger@amazon.de, tim@xen.org, JBeulich@suse.com,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 2/2] x86/AMD: Inject #GP instead of #UD when unable to map vmcb
Date: Fri, 9 Aug 2013 10:22:50 -0500	[thread overview]
Message-ID: <5205094A.4060606@amd.com> (raw)
In-Reply-To: <1376060996-3584-2-git-send-email-suravee.suthikulpanit@amd.com>

Please ignore this one.  I forgot to rename the macro used for checking 
the efer.svme bit as Jan has suggested.

Suravee

On 8/9/2013 10:09 AM, suravee.suthikulpanit@amd.com wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>
> According to AMD Programmer's Manual vol2, vmrun, vmsave and vmload
> should inject #GP instead of #UD when unable to access memory
> location for vmcb.  Also, the code should make sure that L1 guest
> EFER.SVME is not zero.  Otherwise, #UD should be injected.
>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Reviewed-by: Tim Deegan <tim@xen.org>
> ---
>   xen/arch/x86/hvm/svm/svm.c |   22 ++++++++++++----------
>   1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index b27f224..e71ae08 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -1779,15 +1779,17 @@ static void
>   svm_vmexit_do_vmrun(struct cpu_user_regs *regs,
>                       struct vcpu *v, uint64_t vmcbaddr)
>   {
> -    if (!nestedhvm_enabled(v->domain)) {
> +    if ( !nestedhvm_enabled(v->domain) || !hvm_svm_enabled(v) )
> +    {
>           gdprintk(XENLOG_ERR, "VMRUN: nestedhvm disabled, injecting #UD\n");
>           hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
>           return;
>       }
>   
> -    if (!nestedsvm_vmcb_map(v, vmcbaddr)) {
> -        gdprintk(XENLOG_ERR, "VMRUN: mapping vmcb failed, injecting #UD\n");
> -        hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
> +    if ( !nestedsvm_vmcb_map(v, vmcbaddr) )
> +    {
> +        gdprintk(XENLOG_ERR, "VMRUN: mapping vmcb failed, injecting #GP\n");
> +        hvm_inject_hw_exception(TRAP_gp_fault, HVM_DELIVER_NO_ERROR_CODE);
>           return;
>       }
>   
> @@ -1833,7 +1835,7 @@ svm_vmexit_do_vmload(struct vmcb_struct *vmcb,
>       if ( (inst_len = __get_instruction_length(v, INSTR_VMLOAD)) == 0 )
>           return;
>   
> -    if ( !nestedhvm_enabled(v->domain) )
> +    if ( !nestedhvm_enabled(v->domain) || !hvm_svm_enabled(v) )
>       {
>           gdprintk(XENLOG_ERR, "VMLOAD: nestedhvm disabled, injecting #UD\n");
>           ret = TRAP_invalid_op;
> @@ -1844,8 +1846,8 @@ svm_vmexit_do_vmload(struct vmcb_struct *vmcb,
>       if ( !page )
>       {
>           gdprintk(XENLOG_ERR,
> -            "VMLOAD: mapping failed, injecting #UD\n");
> -        ret = TRAP_invalid_op;
> +            "VMLOAD: mapping failed, injecting #GP\n");
> +        ret = TRAP_gp_fault;
>           goto inject;
>       }
>   
> @@ -1875,7 +1877,7 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
>       if ( (inst_len = __get_instruction_length(v, INSTR_VMSAVE)) == 0 )
>           return;
>   
> -    if ( !nestedhvm_enabled(v->domain) )
> +    if ( !nestedhvm_enabled(v->domain) || !hvm_svm_enabled(v) )
>       {
>           gdprintk(XENLOG_ERR, "VMSAVE: nestedhvm disabled, injecting #UD\n");
>           ret = TRAP_invalid_op;
> @@ -1886,8 +1888,8 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
>       if ( !page )
>       {
>           gdprintk(XENLOG_ERR,
> -            "VMSAVE: mapping vmcb failed, injecting #UD\n");
> -        ret = TRAP_invalid_op;
> +            "VMSAVE: mapping vmcb failed, injecting #GP\n");
> +        ret = TRAP_gp_fault;
>           goto inject;
>       }
>   

      reply	other threads:[~2013-08-09 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 15:09 [PATCH 1/2 V6] x86/AMD: Fix nested svm crash due to assertion in __virt_to_maddr suravee.suthikulpanit
2013-08-09 15:09 ` [PATCH 2/2] x86/AMD: Inject #GP instead of #UD when unable to map vmcb suravee.suthikulpanit
2013-08-09 15:22   ` Suravee Suthikulpanit [this message]

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=5205094A.4060606@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=JBeulich@suse.com \
    --cc=chegger@amazon.de \
    --cc=tim@xen.org \
    --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).