From: "Jan Beulich" <JBeulich@suse.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
Yu Zhang <yu.c.zhang@linux.intel.com>,
zhiyuan.lv@intel.com, JunNakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v12 5/6] x86/ioreq server: Asynchronously reset outstanding p2m_ioreq_server entries.
Date: Fri, 07 Apr 2017 08:22:46 -0600 [thread overview]
Message-ID: <58E7BCD6020000780014EA21@prv-mh.provo.novell.com> (raw)
In-Reply-To: <99766d03-7d8f-f9ad-d530-a0db6fe6439f@citrix.com>
>>> On 07.04.17 at 15:56, <george.dunlap@citrix.com> wrote:
Most important thing first: The logic looks correct to me now.
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -533,6 +533,7 @@ static int resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn)
> {
> for ( gfn -= i, i = 0; i < EPT_PAGETABLE_ENTRIES; ++i )
> {
> + p2m_type_t nt;
> e = atomic_read_ept_entry(&epte[i]);
Blank line between these two please.
> @@ -542,10 +543,15 @@ static int resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn)
> _mfn(e.mfn), 0, &ipat,
> e.sa_p2mt == p2m_mmio_direct);
> e.ipat = ipat;
> - if ( e.recalc && p2m_is_changeable(e.sa_p2mt) )
> - {
> - e.sa_p2mt = p2m_is_logdirty_range(p2m, gfn + i, gfn + i)
> - ? p2m_ram_logdirty : p2m_ram_rw;
> + nt = p2m_recalc_type(e.recalc, e.sa_p2mt, p2m, gfn + i);
> + if ( nt != e.sa_p2mt ) {
Brace on its own line please.
> + if ( e.sa_p2mt == p2m_ioreq_server )
> + {
> + ASSERT(p2m->ioreq.entry_count > 0);
> + p2m->ioreq.entry_count--;
> + }
> +
> + e.sa_p2mt = nt;
> ept_p2m_type_to_flags(p2m, &e, e.sa_p2mt, e.access);
> }
This changes why ept_p2m_type_to_flags() is bypassed. I think
this is correct, but that wasn't immediately clear.
> @@ -562,23 +568,24 @@ static int resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn)
>
> if ( recalc && p2m_is_changeable(e.sa_p2mt) )
> {
> - unsigned long mask = ~0UL << (level * EPT_TABLE_ORDER);
> -
> - switch ( p2m_is_logdirty_range(p2m, gfn & mask,
> - gfn | ~mask) )
> - {
> - case 0:
> - e.sa_p2mt = p2m_ram_rw;
> - e.recalc = 0;
> - break;
> - case 1:
> - e.sa_p2mt = p2m_ram_logdirty;
> - e.recalc = 0;
> - break;
> - default: /* Force split. */
> - emt = -1;
> - break;
> - }
> + unsigned long mask = ~0UL << (level * EPT_TABLE_ORDER);
> +
> + ASSERT(e.sa_p2mt != p2m_ioreq_server);
> + switch ( p2m_is_logdirty_range(p2m, gfn & mask,
> + gfn | ~mask) )
> + {
> + case 0:
> + e.sa_p2mt = p2m_ram_rw;
> + e.recalc = 0;
> + break;
> + case 1:
> + e.sa_p2mt = p2m_ram_logdirty;
> + e.recalc = 0;
> + break;
> + default: /* Force split. */
> + emt = -1;
> + break;
> + }
> }
So if I'm getting it right the change here really is just the addition of
an ASSERT() and re-indentation? I think you will want to also adjust
indentation in the previous hunk then. (I'm afraid it was me who
broke it back when introducing that code...)
> @@ -606,6 +616,8 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
>
> if ( page_order == PAGE_ORDER_4K )
> {
> + p2m_type_t p2mt_old;
> +
> rc = p2m_next_level(p2m, &table, &gfn_remainder, gfn,
> L2_PAGETABLE_SHIFT - PAGE_SHIFT,
> L2_PAGETABLE_ENTRIES, PGT_l1_page_table, 1);
> @@ -629,6 +641,21 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
> if ( entry_content.l1 != 0 )
> p2m_add_iommu_flags(&entry_content, 0, iommu_pte_flags);
>
> + p2mt_old = p2m_flags_to_type(l1e_get_flags(*p2m_entry));
> +
> + /*
> + * p2m_ioreq_server is only used for 4K pages, so
> + * the count shall only be performed for level 1 entries.
> + */
> + if ( p2mt == p2m_ioreq_server )
> + p2m->ioreq.entry_count++;
> +
> + if ( p2mt_old == p2m_ioreq_server )
> + {
> + ASSERT(p2m->ioreq.entry_count > 0);
> + p2m->ioreq.entry_count--;
> + }
> +
> /* level 1 entry */
> p2m->write_p2m_entry(p2m, gfn, p2m_entry, entry_content, 1);
> /* NB: paging_write_p2m_entry() handles tlb flushes properly */
> @@ -726,15 +753,6 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
> return rc;
> }
I would have hoped for the two ASSERT()s to be added for the
2M and 1G cases, which we did talk about.
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -120,7 +120,10 @@ typedef unsigned int p2m_query_t;
>
> /* Types that can be subject to bulk transitions. */
> #define P2M_CHANGEABLE_TYPES (p2m_to_mask(p2m_ram_rw) \
> - | p2m_to_mask(p2m_ram_logdirty) )
> + | p2m_to_mask(p2m_ram_logdirty) \
> + | p2m_to_mask(p2m_ioreq_server) )
> +
> +#define P2M_IOREQ_TYPES (p2m_to_mask(p2m_ioreq_server))
>
> #define P2M_POD_TYPES (p2m_to_mask(p2m_populate_on_demand))
>
> @@ -157,6 +160,7 @@ typedef unsigned int p2m_query_t;
> #define p2m_is_readonly(_t) (p2m_to_mask(_t) & P2M_RO_TYPES)
> #define p2m_is_discard_write(_t) (p2m_to_mask(_t) & P2M_DISCARD_WRITE_TYPES)
> #define p2m_is_changeable(_t) (p2m_to_mask(_t) & P2M_CHANGEABLE_TYPES)
> +#define p2m_is_ioreq(_t) (p2m_to_mask(_t) & P2M_IOREQ_TYPES)
I don't think this and P2M_IOREQ_TYPES are needed anymore.
> @@ -744,6 +749,25 @@ static inline p2m_type_t p2m_flags_to_type(unsigned long flags)
> return (flags >> 12) & 0x7f;
> }
>
> +static inline p2m_type_t p2m_recalc_type_range(bool_t recalc, p2m_type_t t,
Just "bool" please (also below).
> + struct p2m_domain *p2m,
> + unsigned long gfn_start,
> + unsigned long gfn_end)
> +{
> + if ( !recalc || !p2m_is_changeable(t) )
> + return t;
> + if ( t == p2m_ioreq_server && p2m->ioreq.server != NULL )
> + return t;
> + return p2m_is_logdirty_range(p2m, gfn_start, gfn_end) ? p2m_ram_logdirty
> + : p2m_ram_rw;
Commonly we'd align the : with either the ? or the start of the
conditional expression.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-04-07 14:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 15:53 [PATCH v12 0/6] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Yu Zhang
2017-04-06 15:53 ` [PATCH v12 1/6] x86/ioreq server: Release the p2m lock after mmio is handled Yu Zhang
2017-04-06 15:53 ` [PATCH v12 2/6] x86/ioreq server: Add DMOP to map guest ram with p2m_ioreq_server to an ioreq server Yu Zhang
2017-04-07 7:33 ` Tian, Kevin
2017-04-06 15:53 ` [PATCH v12 3/6] x86/ioreq server: Add device model wrappers for new DMOP Yu Zhang
2017-04-06 15:53 ` [PATCH v12 4/6] x86/ioreq server: Handle read-modify-write cases for p2m_ioreq_server pages Yu Zhang
2017-04-06 15:53 ` [PATCH v12 5/6] x86/ioreq server: Asynchronously reset outstanding p2m_ioreq_server entries Yu Zhang
2017-04-06 16:45 ` George Dunlap
2017-04-07 7:34 ` Tian, Kevin
2017-04-07 9:40 ` Jan Beulich
2017-04-07 9:53 ` Yu Zhang
2017-04-07 10:22 ` George Dunlap
2017-04-07 10:22 ` Yu Zhang
2017-04-07 10:41 ` Jan Beulich
2017-04-07 10:26 ` Jan Beulich
2017-04-07 10:55 ` Yu Zhang
2017-04-07 11:31 ` Jan Beulich
2017-04-07 13:56 ` George Dunlap
2017-04-07 14:05 ` Yu Zhang
2017-04-07 14:22 ` George Dunlap
2017-04-07 14:22 ` Jan Beulich [this message]
2017-04-07 10:14 ` Yu Zhang
2017-04-07 10:28 ` Jan Beulich
2017-04-07 10:28 ` George Dunlap
2017-04-07 10:50 ` Yu Zhang
2017-04-07 11:28 ` Jan Beulich
2017-04-07 12:17 ` Yu Zhang
2017-04-07 12:36 ` Jan Beulich
2017-04-06 15:53 ` [PATCH v12 6/6] x86/ioreq server: Synchronously reset outstanding p2m_ioreq_server entries when an ioreq server unmaps Yu Zhang
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=58E7BCD6020000780014EA21@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=paul.durrant@citrix.com \
--cc=xen-devel@lists.xen.org \
--cc=yu.c.zhang@linux.intel.com \
--cc=zhiyuan.lv@intel.com \
/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.