All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <dunlapg@umich.edu>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/2] x86/mm: Use mfn_t for new_guest_cr3()
Date: Fri, 1 Sep 2017 18:29:23 +0100	[thread overview]
Message-ID: <CAFLBxZZzBReEkvMm6+G6rkL8=NpRMSshLDGWh5EtRa+2mpk7Wg@mail.gmail.com> (raw)
In-Reply-To: <1504095573-14153-1-git-send-email-andrew.cooper3@citrix.com>

On Wed, Aug 30, 2017 at 1:19 PM, Andrew Cooper
<andrew.cooper3@citrix.com> wrote:
> No functional change (as confirmed by diffing the assembly).
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: George Dunlap <george.dunlap@citrix.com>

> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
>
> For some reason best known to GCC, there is one single change:
>
> @@ -145835,7 +145835,7 @@
>  ffff82d0802864f8:      85 c0                   test   %eax,%eax
>  ffff82d0802864fa:      75 e0                   jne    ffff82d0802864dc <new_guest_cr3+0x7c>
>  ffff82d0802864fc:      4c 8b ad 08 0b 00 00    mov    0xb08(%rbp),%r13
> -ffff82d080286503:      49 39 dd                cmp    %rbx,%r13
> +ffff82d080286503:      4c 39 eb                cmp    %r13,%rbx
>  ffff82d080286506:      0f 84 74 01 00 00       je     ffff82d080286680 <new_guest_cr3+0x220>
>  ffff82d08028650c:      41 f6 84 24 19 06 00    testb  $0x8,0x619(%r12)
>  ffff82d080286513:      00 08
>
> This is from the mfn_eq() alteration, and must be a side effect from using an
> inline function.  The net result is still correct, as only the zero flag is
> checked.
> ---
>  xen/arch/x86/mm.c              | 35 ++++++++++++++++++-----------------
>  xen/arch/x86/pv/emul-priv-op.c |  2 +-
>  xen/include/asm-x86/mm.h       |  2 +-
>  3 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index 1f23470..dc07b4f 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -2772,23 +2772,23 @@ int vcpu_destroy_pagetables(struct vcpu *v)
>      return rc != -EINTR ? rc : -ERESTART;
>  }
>
> -int new_guest_cr3(unsigned long mfn)
> +int new_guest_cr3(mfn_t mfn)
>  {
>      struct vcpu *curr = current;
>      struct domain *d = curr->domain;
>      int rc;
> -    unsigned long old_base_mfn;
> +    mfn_t old_base_mfn;
>
>      if ( is_pv_32bit_domain(d) )
>      {
> -        unsigned long gt_mfn = pagetable_get_pfn(curr->arch.guest_table);
> -        l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
> +        mfn_t mmfn = pagetable_get_mfn(curr->arch.guest_table);
> +        l4_pgentry_t *pl4e = map_domain_page(mmfn);
>
>          rc = mod_l4_entry(pl4e,
> -                          l4e_from_pfn(mfn,
> +                          l4e_from_mfn(mfn,
>                                         (_PAGE_PRESENT | _PAGE_RW |
>                                          _PAGE_USER | _PAGE_ACCESSED)),
> -                          gt_mfn, 0, curr);
> +                          mfn_x(mmfn), 0, curr);
>          unmap_domain_page(pl4e);
>          switch ( rc )
>          {
> @@ -2800,7 +2800,7 @@ int new_guest_cr3(unsigned long mfn)
>          default:
>              gdprintk(XENLOG_WARNING,
>                       "Error while installing new compat baseptr %" PRI_mfn "\n",
> -                     mfn);
> +                     mfn_x(mfn));
>              return rc;
>          }
>
> @@ -2814,20 +2814,20 @@ int new_guest_cr3(unsigned long mfn)
>      if ( unlikely(rc) )
>          return rc;
>
> -    old_base_mfn = pagetable_get_pfn(curr->arch.guest_table);
> +    old_base_mfn = pagetable_get_mfn(curr->arch.guest_table);
>      /*
>       * This is particularly important when getting restarted after the
>       * previous attempt got preempted in the put-old-MFN phase.
>       */
> -    if ( old_base_mfn == mfn )
> +    if ( mfn_eq(old_base_mfn, mfn) )
>      {
>          write_ptbase(curr);
>          return 0;
>      }
>
>      rc = paging_mode_refcounts(d)
> -         ? (get_page_from_mfn(_mfn(mfn), d) ? 0 : -EINVAL)
> -         : get_page_and_type_from_mfn(_mfn(mfn), PGT_root_page_table, d, 0, 1);
> +         ? (get_page_from_mfn(mfn, d) ? 0 : -EINVAL)
> +         : get_page_and_type_from_mfn(mfn, PGT_root_page_table, d, 0, 1);
>      switch ( rc )
>      {
>      case 0:
> @@ -2837,22 +2837,23 @@ int new_guest_cr3(unsigned long mfn)
>          return -ERESTART;
>      default:
>          gdprintk(XENLOG_WARNING,
> -                 "Error while installing new baseptr %" PRI_mfn "\n", mfn);
> +                 "Error while installing new baseptr %" PRI_mfn "\n",
> +                 mfn_x(mfn));
>          return rc;
>      }
>
>      invalidate_shadow_ldt(curr, 0);
>
>      if ( !VM_ASSIST(d, m2p_strict) && !paging_mode_refcounts(d) )
> -        fill_ro_mpt(_mfn(mfn));
> -    curr->arch.guest_table = pagetable_from_pfn(mfn);
> +        fill_ro_mpt(mfn);
> +    curr->arch.guest_table = pagetable_from_mfn(mfn);
>      update_cr3(curr);
>
>      write_ptbase(curr);
>
> -    if ( likely(old_base_mfn != 0) )
> +    if ( likely(mfn_x(old_base_mfn) != 0) )
>      {
> -        struct page_info *page = mfn_to_page(_mfn(old_base_mfn));
> +        struct page_info *page = mfn_to_page(old_base_mfn);
>
>          if ( paging_mode_refcounts(d) )
>              put_page(page);
> @@ -3180,7 +3181,7 @@ long do_mmuext_op(
>              else if ( unlikely(paging_mode_translate(currd)) )
>                  rc = -EINVAL;
>              else
> -                rc = new_guest_cr3(op.arg1.mfn);
> +                rc = new_guest_cr3(_mfn(op.arg1.mfn));
>              break;
>
>          case MMUEXT_NEW_USER_BASEPTR: {
> diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
> index af1624a..54a63c2 100644
> --- a/xen/arch/x86/pv/emul-priv-op.c
> +++ b/xen/arch/x86/pv/emul-priv-op.c
> @@ -774,7 +774,7 @@ static int priv_op_write_cr(unsigned int reg, unsigned long val,
>          page = get_page_from_gfn(currd, gfn, NULL, P2M_ALLOC);
>          if ( !page )
>              break;
> -        rc = new_guest_cr3(mfn_x(page_to_mfn(page)));
> +        rc = new_guest_cr3(page_to_mfn(page));
>          put_page(page);
>
>          switch ( rc )
> diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
> index ec7ce3c..4c03a33 100644
> --- a/xen/include/asm-x86/mm.h
> +++ b/xen/include/asm-x86/mm.h
> @@ -539,7 +539,7 @@ void audit_domains(void);
>
>  #endif
>
> -int new_guest_cr3(unsigned long pfn);
> +int new_guest_cr3(mfn_t mfn);
>  void make_cr3(struct vcpu *v, unsigned long mfn);
>  void update_cr3(struct vcpu *v);
>  int vcpu_destroy_pagetables(struct vcpu *);
> --
> 2.1.4
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

      parent reply	other threads:[~2017-09-01 17:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 12:19 [PATCH 1/2] x86/mm: Use mfn_t for new_guest_cr3() Andrew Cooper
2017-08-30 12:19 ` [PATCH 2/2] x86/mm: Use mfn_t for make_cr3() Andrew Cooper
2017-08-30 13:08   ` Wei Liu
2017-08-30 15:47     ` Jan Beulich
2017-08-30 18:59   ` Tim Deegan
2017-09-01 17:30   ` George Dunlap
2017-08-30 13:08 ` [PATCH 1/2] x86/mm: Use mfn_t for new_guest_cr3() Wei Liu
2017-08-30 15:45 ` Jan Beulich
2017-08-30 15:57   ` Andrew Cooper
2017-08-30 16:04     ` Jan Beulich
2017-09-01 17:29 ` George Dunlap [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='CAFLBxZZzBReEkvMm6+G6rkL8=NpRMSshLDGWh5EtRa+2mpk7Wg@mail.gmail.com' \
    --to=dunlapg@umich.edu \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=wei.liu2@citrix.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 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.