All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Durrant, Paul" <pdurrant@amazon.co.uk>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Paul Durrant" <paul@xen.org>, "Wei Liu" <wl@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v4 7/7] x86/HVM: reduce scope of pfec in hvm_emulate_init_per_insn()
Date: Thu, 6 Feb 2020 13:43:19 +0000	[thread overview]
Message-ID: <947b56a1a504415e976a85f30dc483fa@EX13D32EUC003.ant.amazon.com> (raw)
In-Reply-To: <a2fabad3-2a05-da71-64b8-bd77ac955b82@suse.com>

> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Jan
> Beulich
> Sent: 31 January 2020 16:46
> To: xen-devel@lists.xenproject.org
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>; Andrew Cooper
> <andrew.cooper3@citrix.com>; Roger Pau Monné <roger.pau@citrix.com>; Wei
> Liu <wl@xen.org>; Paul Durrant <paul@xen.org>
> Subject: [Xen-devel] [PATCH v4 7/7] x86/HVM: reduce scope of pfec in
> hvm_emulate_init_per_insn()
> 
> It needs calculating only in one out of three cases. Re-structure the
> code a little such that the variable truly gets calculated only when we
> don't get any insn bytes from elsewhere, and hence need to (try to)
> fetch them. Also OR in PFEC_insn_fetch right in the initializer.
> 
> While in this mood, restrict addr's scope as well.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Paul Durrant <pdurrant@amazon.com>

> ---
> v4: New.
> 
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2762,8 +2762,6 @@ void hvm_emulate_init_per_insn(
>      unsigned int insn_bytes)
>  {
>      struct vcpu *curr = current;
> -    unsigned int pfec = PFEC_page_present;
> -    unsigned long addr;
> 
>      hvmemul_ctxt->ctxt.lma = hvm_long_mode_active(curr);
> 
> @@ -2778,14 +2776,23 @@ void hvm_emulate_init_per_insn(
>              hvmemul_ctxt->seg_reg[x86_seg_ss].db ? 32 : 16;
>      }
> 
> -    if ( hvmemul_ctxt->seg_reg[x86_seg_ss].dpl == 3 )
> -        pfec |= PFEC_user_mode;
> -
>      hvmemul_ctxt->insn_buf_eip = hvmemul_ctxt->ctxt.regs->rip;
> -    if ( !insn_bytes )
> +
> +    if ( insn_bytes )
>      {
> +        hvmemul_ctxt->insn_buf_bytes = insn_bytes;
> +        memcpy(hvmemul_ctxt->insn_buf, insn_buf, insn_bytes);
> +    }
> +    else if ( !(hvmemul_ctxt->insn_buf_bytes =
> +                hvm_get_insn_bytes(curr, hvmemul_ctxt->insn_buf)) )
> +    {
> +        unsigned int pfec = PFEC_page_present | PFEC_insn_fetch;
> +        unsigned long addr;
> +
> +        if ( hvmemul_ctxt->seg_reg[x86_seg_ss].dpl == 3 )
> +            pfec |= PFEC_user_mode;
> +
>          hvmemul_ctxt->insn_buf_bytes =
> -            hvm_get_insn_bytes(curr, hvmemul_ctxt->insn_buf) ?:
>              (hvm_virtual_to_linear_addr(x86_seg_cs,
>                                          &hvmemul_ctxt->seg_reg[x86_seg_cs],
>                                          hvmemul_ctxt->insn_buf_eip,
> @@ -2795,15 +2802,9 @@ void hvm_emulate_init_per_insn(
>                                          &addr) &&
>               hvm_copy_from_guest_linear(hvmemul_ctxt->insn_buf, addr,
>                                          sizeof(hvmemul_ctxt->insn_buf),
> -                                        pfec | PFEC_insn_fetch,
> -                                        NULL) == HVMTRANS_okay) ?
> +                                        pfec, NULL) == HVMTRANS_okay) ?
>              sizeof(hvmemul_ctxt->insn_buf) : 0;
>      }
> -    else
> -    {
> -        hvmemul_ctxt->insn_buf_bytes = insn_bytes;
> -        memcpy(hvmemul_ctxt->insn_buf, insn_buf, insn_bytes);
> -    }
>  }
> 
>  void hvm_emulate_writeback(
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      parent reply	other threads:[~2020-02-06 13:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 16:37 [Xen-devel] [PATCH v4 0/7] x86/HVM: implement memory read caching Jan Beulich
2020-01-31 16:42 ` [Xen-devel] [PATCH v4 1/7] SVM: drop asm/hvm/emulate.h inclusion from vmcb.h Jan Beulich
2020-01-31 16:47   ` Andrew Cooper
2020-02-03  9:22   ` Alexandru Stefan ISAILA
2020-02-03 11:51   ` Durrant, Paul
2020-02-18  5:05   ` Tian, Kevin
2020-01-31 16:42 ` [Xen-devel] [PATCH v4 2/7] x86/HVM: rename a variable in __hvm_copy() Jan Beulich
2020-02-03 15:04   ` Andrew Cooper
2020-01-31 16:43 ` [Xen-devel] [PATCH v4 3/7] x86/HVM: introduce "curr" into hvmemul_rep_{mov, sto}s() Jan Beulich
2020-02-03 15:05   ` Andrew Cooper
2020-02-06 13:26   ` Durrant, Paul
2020-02-06 13:35     ` Jan Beulich
2020-01-31 16:44 ` [Xen-devel] [PATCH v4 4/7] x86/HVM: implement memory read caching for insn emulation Jan Beulich
2020-02-03 19:48   ` Andrew Cooper
2020-02-04 11:13     ` Jan Beulich
2020-02-05  8:09     ` Jan Beulich
2020-01-31 16:45 ` [Xen-devel] [PATCH v4 5/7] x86/mm: use cache in guest_walk_tables() Jan Beulich
2020-01-31 16:45 ` [Xen-devel] [PATCH v4 6/7] x86/mm: drop p2mt parameter from map_domain_gfn() Jan Beulich
2020-02-03 15:51   ` Andrew Cooper
2020-01-31 16:46 ` [Xen-devel] [PATCH v4 7/7] x86/HVM: reduce scope of pfec in hvm_emulate_init_per_insn() Jan Beulich
2020-02-03 16:00   ` Andrew Cooper
2020-02-06 13:43   ` Durrant, Paul [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=947b56a1a504415e976a85f30dc483fa@EX13D32EUC003.ant.amazon.com \
    --to=pdurrant@amazon.co.uk \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.