From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
zhiyuan.lv@intel.com, Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v12 5/6] x86/ioreq server: Asynchronously reset outstanding p2m_ioreq_server entries.
Date: Fri, 7 Apr 2017 20:17:44 +0800 [thread overview]
Message-ID: <58E78368.9020904@linux.intel.com> (raw)
In-Reply-To: <58E79413020000780014E7FA@prv-mh.provo.novell.com>
On 4/7/2017 7:28 PM, Jan Beulich wrote:
>>>> On 07.04.17 at 12:50, <yu.c.zhang@linux.intel.com> wrote:
>> On 4/7/2017 6:28 PM, George Dunlap wrote:
>>> On 07/04/17 11:14, Yu Zhang wrote:
>>>> On 4/7/2017 5:40 PM, Jan Beulich wrote:
>>>>>>>> On 06.04.17 at 17:53, <yu.c.zhang@linux.intel.com> wrote:
>>>>>> --- a/xen/arch/x86/mm/p2m-ept.c
>>>>>> +++ b/xen/arch/x86/mm/p2m-ept.c
>>>>>> @@ -544,6 +544,12 @@ static int resolve_misconfig(struct p2m_domain
>>>>>> *p2m, unsigned long gfn)
>>>>>> e.ipat = ipat;
>>>>>> if ( e.recalc && p2m_is_changeable(e.sa_p2mt) )
>>>>>> {
>>>>>> + if ( e.sa_p2mt == p2m_ioreq_server )
>>>>>> + {
>>>>>> + ASSERT(p2m->ioreq.entry_count > 0);
>>>>>> + p2m->ioreq.entry_count--;
>>>>>> + }
>>>>>> +
>>>>>> e.sa_p2mt = p2m_is_logdirty_range(p2m, gfn
>>>>>> + i, gfn + i)
>>>>>> ? p2m_ram_logdirty : p2m_ram_rw;
>>>>> I don't think this can be right: Why would it be valid to change the
>>>>> type from p2m_ioreq_server to p2m_ram_rw (or p2m_ram_logdirty)
>>>>> here, without taking into account further information? This code
>>>>> can run at any time, not just when you want to reset things. So at
>>>>> the very least there is a check missing whether a suitable ioreq
>>>>> server still exists (and only if it doesn't you want to do the type
>>>>> reset).
>>>> Also I do not think we need to check if a suitable ioreq server still
>>>> exists. We have guaranteed
>>>> in our patch that no new ioreq server will be mapped as long as the p2m
>>>> table is not clean. :)
>>> Jan is saying that you should only change ioreq_server -> ram if there
>>> is *not* an ioreq server; and that if this is called with an ioreq
>>> server still active, then it must be some other change you're looking at.
>>>
>>> The problem, though, is that misconfiguration happens in many
>>> circumstances. Grep for "memory_type_changed()" -- each of those
>>> results in a recalculation of the entire p2m, which will (in the current
>>> code) wipe out any ioreq_server entries.
>> Well, I'm not aware that other actions besides the logdirty will cause the reset.
>> But if that would happen, will below change solve this?
>>
>> @@ -546,12 +546,16 @@ static int resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn)
>> {
>> if ( e.sa_p2mt == p2m_ioreq_server )
>> {
>> - ASSERT(p2m->ioreq.entry_count > 0);
>> - p2m->ioreq.entry_count--;
>> + if ( p2m->ioreq.server == NULL )
>> + {
>> + ASSERT(p2m->ioreq.entry_count > 0);
>> + p2m->ioreq.entry_count--;
>> + e.sa_p2mt = p2m_ram_rw;
>> + }
>> }
>> -
>> - e.sa_p2mt = p2m_is_logdirty_range(p2m, gfn + i, gfn + i)
>> - ? p2m_ram_logdirty : p2m_ram_rw;
>> + else
>> + e.sa_p2mt = p2m_is_logdirty_range(p2m, gfn + i, gfn + i)
>> + ? p2m_ram_logdirty : p2m_ram_rw;
> Now you _never_ change away from ioreq-server, you only adjust
> the counter.
Oh right.
Then sth. like:
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index ecd5ceb..b960a1d 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -542,7 +542,10 @@ 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) )
+ if ( e.recalc &&
+ (p2m_check_changeable(e.sa_p2mt) ||
+ (e.sa_p2mt == p2m_ioreq_server &&
+ p2m->ioreq.server == NULL)) )
{
if ( e.sa_p2mt == p2m_ioreq_server )
{
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index 4b2ff9e..1c600b1 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -442,7 +442,8 @@ static int do_recalc(struct p2m_domain *p2m,
unsigned long gfn)
P2M_DEBUG("bogus recalc leaf at d%d:%lx:%u\n",
p2m->domain->domain_id, gfn, level);
p2mt_old = p2m_flags_to_type(l1e_get_flags(e));
- if ( p2m_is_changeable(p2mt_old) )
+ if ( p2m_check_changeable(p2mt_old) ||
+ (p2mt_old == p2m_ioreq_server && p2m->ioreq.server == NULL) )
{
unsigned long mask = ~0UL << (level * PAGETABLE_ORDER);
p2m_type_t p2mt = p2m_is_logdirty_range(p2m, gfn & mask,
gfn | ~mask)
But as you can see. I used p2m_check_changeable() here.
Yu
> Jan
>
>
> _______________________________________________
> 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
next prev parent reply other threads:[~2017-04-07 12:17 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
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 [this message]
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=58E78368.9020904@linux.intel.com \
--to=yu.c.zhang@linux.intel.com \
--cc=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=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 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).