xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Julien Grall <julien.grall@arm.com>,
	sstabellini@kernel.org, xen-devel@lists.xenproject.org
Cc: Jun Nakajima <jun.nakajima@intel.com>,
	Kevin Tian <kevin.tian@intel.com>, Wei Liu <wei.liu2@citrix.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julie.grall@arm.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Brian Woods <brian.woods@amd.com>
Subject: Re: [PATCH 8/8] xen: Swich parameter in get_page_from_gfn to use typesafe gfn
Date: Tue, 6 Nov 2018 20:11:39 +0000	[thread overview]
Message-ID: <479bb855-0bb7-dd30-a7a4-692b189cc7c5@citrix.com> (raw)
In-Reply-To: <20181106191454.22143-9-julien.grall@arm.com>

Hi - just some cosmetic suggestions.

Subject s/Swich/Switch/

> diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
> index f73ea4a163..a529ebcc3f 100644
> --- a/xen/arch/x86/pv/emul-priv-op.c
> +++ b/xen/arch/x86/pv/emul-priv-op.c
> @@ -760,12 +760,12 @@ static int write_cr(unsigned int reg, unsigned long val,
>      case 3: /* Write CR3 */
>      {
>          struct domain *currd = curr->domain;
> -        unsigned long gfn;
> +        gfn_t gfn;
>          struct page_info *page;
>          int rc;
>  
> -        gfn = !is_pv_32bit_domain(currd)
> -              ? xen_cr3_to_pfn(val) : compat_cr3_to_pfn(val);
> +        gfn = _gfn(!is_pv_32bit_domain(currd)
> +              ? xen_cr3_to_pfn(val) : compat_cr3_to_pfn(val));

Please re-indent.

>          page = get_page_from_gfn(currd, gfn, NULL, P2M_ALLOC);
>          if ( !page )
>              break;
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index 9471d89022..d967e49432 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -817,13 +817,14 @@ int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val)
>  
>              if ( p2m_is_paging(t) )
>              {
> -                p2m_mem_paging_populate(d, gmfn);
> +                p2m_mem_paging_populate(d, gfn_x(gfn));
>                  return X86EMUL_RETRY;
>              }
>  
>              gdprintk(XENLOG_WARNING,
> -                     "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n",
> -                     gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base);
> +                     "Bad GMFN %#"PRI_gfn" (MFN %#"PRI_mfn") to MSR %08x\n",

GMFN => GFN.

> +                     gfn_x(gfn), mfn_x(page ? page_to_mfn(page) : INVALID_MFN),
> +                     base);
>              return X86EMUL_EXCEPTION;
>          }
>  
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> index d08c595887..db1ec37610 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -489,18 +489,21 @@ struct page_info *p2m_get_page_from_gfn(struct p2m_domain *p2m, gfn_t gfn,
>                                          p2m_query_t q);
>  
>  static inline struct page_info *get_page_from_gfn(
> -    struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q)
> +    struct domain *d, gfn_t gfn, p2m_type_t *t, p2m_query_t q)
>  {
>      struct page_info *page;
> +    mfn_t mfn;
>  
>      if ( paging_mode_translate(d) )
> -        return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn), t, NULL, q);
> +        return p2m_get_page_from_gfn(p2m_get_hostp2m(d), gfn, t, NULL, q);
>  
>      /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */
>      if ( t )
>          *t = likely(d != dom_io) ? p2m_ram_rw : p2m_mmio_direct;
> -    page = mfn_to_page(_mfn(gfn));
> -    return mfn_valid(_mfn(gfn)) && get_page(page, d) ? page : NULL;
> +
> +    mfn = _mfn(gfn_x(gfn));
> +    page = mfn_to_page(mfn);
> +    return mfn_valid(mfn) && get_page(page, d) ? page : NULL;

This looks like it would be cleaner by not splitting mfn out into a
separate variable.

page = mfn_to_page(_mfn(gfn_x(gfn)));

return mfn_valid(mfn) && get_page(page, d) ? page : NULL;

The only reason this looks odd is because of the mfn => gfn equality,
but we are just beside a comment explaining that we are non-translated.

~Andrew

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

  reply	other threads:[~2018-11-06 20:11 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 19:14 [PATCH 0/8] xen/arm: Add xentrace support Julien Grall
2018-11-06 19:14 ` [PATCH 1/8] xen/page_alloc: Move get_pg_owner()/put_pg_owner() from x86 to common code Julien Grall
2018-11-07  9:28   ` Jan Beulich
2018-11-09 18:06     ` Julien Grall
2018-11-06 19:14 ` [PATCH 2/8] xen/arm: p2m: Introduce p2m_get_page_from_gfn Julien Grall
2018-11-15 13:31   ` Andrii Anisov
2018-11-15 13:35     ` Andrii Anisov
2018-11-15 15:22     ` Julien Grall
2018-12-20 11:20       ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 3/8] xen/arm: Rename p2m_map_foreign to p2m_map_foreign_rw Julien Grall
2018-11-15 11:42   ` Andrii Anisov
2018-11-15 12:07     ` Julien Grall
2018-11-06 19:14 ` [PATCH 4/8] xen/arm: Add support for read-only foreign mappings Julien Grall
2018-11-15 11:33   ` Andrii Anisov
2018-11-15 11:40     ` Julien Grall
2018-11-15 12:02       ` Andrii Anisov
2018-11-15 12:09         ` Julien Grall
2018-11-15 13:19           ` Andrii Anisov
2018-11-15 15:05             ` Julien Grall
2018-11-15 18:44               ` Stefano Stabellini
2018-11-15 19:06                 ` Julien Grall
2018-11-15 19:48                   ` Stefano Stabellini
2018-11-15 20:20                     ` Julien Grall
2018-11-16  9:05                       ` Andrii Anisov
2018-11-16  8:37               ` Andrii Anisov
2018-11-20 15:27               ` Andrii Anisov
2018-12-20 11:21               ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 5/8] xen/arm: Allow a privileged domain to map foreign page from DOMID_XEN Julien Grall
2018-11-15 13:45   ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 6/8] xen/arm: Initialize trace buffer Julien Grall
2018-11-15 13:49   ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 7/8] xenalyze: Build for Both ARM and x86 Platforms Julien Grall
2018-11-07 13:04   ` Wei Liu
2018-11-06 19:14 ` [PATCH 8/8] xen: Swich parameter in get_page_from_gfn to use typesafe gfn Julien Grall
2018-11-06 20:11   ` Andrew Cooper [this message]
2018-11-07  8:57     ` Paul Durrant
2018-11-07 13:08       ` Andrew Cooper
2018-11-07 13:08     ` Julien Grall
2018-11-07  9:24   ` Paul Durrant
2018-11-07 13:05     ` Julien Grall
2018-11-12 16:49   ` Andrii Anisov
2018-11-12 16:52     ` Julien Grall
2018-11-12 16:58       ` Andrii Anisov
2018-11-12 17:09         ` Julien Grall

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=479bb855-0bb7-dd30-a7a4-692b189cc7c5@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=brian.woods@amd.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julie.grall@arm.com \
    --cc=julien.grall@arm.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=paul.durrant@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --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 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).