xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	min.he@intel.com, xen-devel@lists.xen.org, yi.z.zhang@intel.com
Subject: Re: [PATCH v2 2/2] x86/mm: fix a potential race condition in modify_xen_mappings().
Date: Fri, 10 Nov 2017 22:02:47 +0800	[thread overview]
Message-ID: <713e7e37-00ae-7bc5-c8de-6ed31abdfb99@linux.intel.com> (raw)
In-Reply-To: <5A058608020000780018DD9C@prv-mh.provo.novell.com>



On 11/10/2017 5:57 PM, Jan Beulich wrote:
>>>> On 10.11.17 at 08:18, <yu.c.zhang@linux.intel.com> wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -5097,6 +5097,17 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
>>                */
>>               if ( (nf & _PAGE_PRESENT) || ((v != e) && (l1_table_offset(v) != 0)) )
>>                   continue;
>> +            if ( locking )
>> +                spin_lock(&map_pgdir_lock);
>> +
>> +            /* L2E may be cleared on another CPU. */
>> +            if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
> I think you also need a PSE check here, or else the l2e_to_l1e() below
> may be illegal.

Hmm, interesting point, and thanks! :-)
I did not check the PSE, because modify_xen_mappings() will not do the 
re-consolidation, and
concurrent invokes of this routine will not change this flag. But now I 
believe this presumption
shall not be made, because the paging structures may be modified by 
other routines, like
map_pages_to_xen() on other CPUs.

So yes, I think a _PAGE_PSE check is necessary here. And I suggest we 
also check the _PAGE_PRESENT
flag as well, for the re-consolidation part in my first patch for 
map_pages_to_xen(). Do you agree?

>> @@ -5105,11 +5116,16 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
>>               {
>>                   /* Empty: zap the L2E and free the L1 page. */
>>                   l2e_write_atomic(pl2e, l2e_empty());
>> +                if ( locking )
>> +                    spin_unlock(&map_pgdir_lock);
>>                   flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */
>>                   free_xen_pagetable(pl1e);
>>               }
>> +            else if ( locking )
>> +                spin_unlock(&map_pgdir_lock);
>>           }
>>   
>> +check_l3:
> Labels indented by at least one space please.

Got it . Thanks.

Yu
>
> Jan
>
>


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

  reply	other threads:[~2017-11-10 14:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10  7:18 [PATCH v2 1/2] x86/mm: fix a potential race condition in map_pages_to_xen() Yu Zhang
2017-11-10  7:18 ` [PATCH v2 2/2] x86/mm: fix a potential race condition in modify_xen_mappings() Yu Zhang
2017-11-10  9:57   ` Jan Beulich
2017-11-10 14:02     ` Yu Zhang [this message]
2017-11-13  9:33       ` Jan Beulich
2017-11-10  9:49 ` [PATCH v2 1/2] x86/mm: fix a potential race condition in map_pages_to_xen() Jan Beulich
2017-11-10 14:05   ` Yu Zhang
2017-11-13  9:31     ` Jan Beulich
2017-11-13 10:34       ` Yu Zhang
2017-11-13 11:06         ` Jan Beulich
2017-11-13 11:22           ` 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=713e7e37-00ae-7bc5-c8de-6ed31abdfb99@linux.intel.com \
    --to=yu.c.zhang@linux.intel.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=min.he@intel.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yi.z.zhang@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).