All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: elena.ufimtseva@oracle.com, xen-devel@lists.xen.org
Cc: keir@xen.org, jbeulich@suse.com, tim@xen.org,
	Aravind.Gopalakrishnan@amd.com, suravee.suthikulpanit@amd.com,
	Mukesh Rathor <mukesh.rathor@oracle.com>,
	roger.pau@citrix.com
Subject: Re: [PATCH 3/6] AMD-PVH: call hvm_emulate_one instead of handle_mmio
Date: Mon, 22 Jun 2015 15:29:49 -0400	[thread overview]
Message-ID: <5588622D.1030508@oracle.com> (raw)
In-Reply-To: <1434991058-6585-4-git-send-email-elena.ufimtseva@oracle.com>

On 06/22/2015 12:37 PM, elena.ufimtseva@oracle.com wrote:
> From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
>
> Certain IOIO instructions and CR access instructions like
> lmsw/clts etc need to be emulated. handle_mmio is incorrectly called to
> accomplish this. Create svm_emulate() to call hvm_emulate_one which is more
> appropriate, and works for pvh as well. handle_mmio call is
> forbidden for pvh.
>
> Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
> ---
>   xen/arch/x86/hvm/svm/svm.c | 27 +++++++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 28792fe..e7262c9 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -2289,6 +2289,23 @@ static struct hvm_function_table __initdata svm_function_table = {
>       .nhvm_hap_walk_L1_p2m = nsvm_hap_walk_L1_p2m,
>   };
>   
> +static void svm_emulate(struct cpu_user_regs *regs)
> +{
> +    int rc;
> +    struct hvm_emulate_ctxt ctxt;
> +
> +    hvm_emulate_prepare(&ctxt, regs);
> +    rc = hvm_emulate_one(&ctxt);
> +
> +    if ( rc != X86EMUL_OKAY )
> +    {
> +	if ( ctxt.exn_pending )
> +		hvm_inject_trap(&ctxt.trap);
> +	else
> +		hvm_inject_hw_exception(TRAP_gp_fault, 0);
> +    }
> +}
> +
>   void svm_vmexit_handler(struct cpu_user_regs *regs)
>   {
>       uint64_t exit_reason;
> @@ -2555,16 +2572,16 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
>               if ( handle_pio(port, bytes, dir) )
>                   __update_guest_eip(regs, vmcb->exitinfo2 - vmcb->rip);
>           }
> -        else if ( !handle_mmio() )
> -            hvm_inject_hw_exception(TRAP_gp_fault, 0);
> +        else
> +            svm_emulate(regs);
>           break;
>   
>       case VMEXIT_CR0_READ ... VMEXIT_CR15_READ:
>       case VMEXIT_CR0_WRITE ... VMEXIT_CR15_WRITE:
>           if ( cpu_has_svm_decode && (vmcb->exitinfo1 & (1ULL << 63)) )
>               svm_vmexit_do_cr_access(vmcb, regs);
> -        else if ( !handle_mmio() )
> -            hvm_inject_hw_exception(TRAP_gp_fault, 0);
> +        else
> +            svm_emulate(regs);
>           break;
>   
>       case VMEXIT_INVLPG:
> @@ -2575,6 +2592,8 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
>           }
>           else if ( !handle_mmio() )
>               hvm_inject_hw_exception(TRAP_gp_fault, 0);
> +	else
> +            svm_emulate(regs);
>           break;
>   
>       case VMEXIT_INVLPGA:


handle_mmio() will pop the assertion on PVH 
('ASSERT(!is_pvh_vcpu(curr))'). I think just calling svm_emulate() 
should be sufficient, just like it is for CR registers.

-boris

  reply	other threads:[~2015-06-22 19:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 16:37 [PATCH 0/6] AMD-PVH: DomU support elena.ufimtseva
2015-06-22 16:37 ` [PATCH 1/6] pvh: domu construct vmcb 64 bit mode start elena.ufimtseva
2015-06-22 19:00   ` Boris Ostrovsky
2015-06-23 12:02   ` Jan Beulich
2015-06-24 20:15     ` Elena Ufimtseva
2015-06-25  8:06       ` Jan Beulich
2015-06-24 20:18     ` Elena Ufimtseva
2015-06-22 16:37 ` [PATCH 2/6] AMD-PVH: cpuid intercept elena.ufimtseva
2015-06-23 12:09   ` Jan Beulich
2015-06-22 16:37 ` [PATCH 3/6] AMD-PVH: call hvm_emulate_one instead of handle_mmio elena.ufimtseva
2015-06-22 19:29   ` Boris Ostrovsky [this message]
2015-06-23 12:12   ` Jan Beulich
2015-06-22 16:37 ` [PATCH 4/6] AMD-PVH: Do not get/set vlapic TPR elena.ufimtseva
2015-06-23 12:17   ` Jan Beulich
2015-06-22 16:37 ` [PATCH 5/6] AMD-PVH: Support TSC_MODE_NEVER_EMULATE for PVH elena.ufimtseva
2015-06-22 17:12   ` Konrad Rzeszutek Wilk
2015-06-23 12:23   ` Jan Beulich
2015-06-22 16:37 ` [PATCH 6/6] AMD-PVH: enable pvh if requirements met elena.ufimtseva
2015-06-23 12:30   ` Jan Beulich
2015-06-24  2:34     ` Boris Ostrovsky
2015-06-24  7:49       ` Jan Beulich
2015-06-24 18:24         ` Andrew Cooper
2015-06-24 20:26           ` Elena Ufimtseva
2015-06-24 21:41             ` Mukesh Rathor
2015-06-25 14:11               ` Elena Ufimtseva
2015-06-23 11:58 ` [PATCH 0/6] AMD-PVH: DomU support Jan Beulich

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=5588622D.1030508@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=Aravind.Gopalakrishnan@amd.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=mukesh.rathor@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=suravee.suthikulpanit@amd.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.