xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jaeyong Yoo <jaeyong.yoo@samsung.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Tim Deegan <tim@xen.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] ARM: cache coherence problem in guestcopy.c
Date: Tue, 18 Jun 2013 11:22:54 +0000 (GMT)	[thread overview]
Message-ID: <5815755.345161371554573758.JavaMail.weblogic@epv6ml06> (raw)

> 
> So I think we probably actually need the dcache flush in domain_map_page
> at the "/* Commandeer this 2MB slot */" point. In that context I don't
> think we can avoid flushing anything other than the complete 2MB
> mapping. Does this work for you too?

I am not sure that this would work. If we map_domain_page and unmap_domain_page
with the same mfn over and over again while the ref count is not zero (say 5), 
then flush is not called. And, I think we should call flush according to the reason below:

> 
> The laziness of the remappings makes me wonder though. Do you know if
> the slot is reused between step #2 and #3?  Otherwise I'd expect us to
> reuse the existing mapping with the cache intact. The caches are PIPT so
> I wouldn't expect the address aliasing to be an issue. Unless the
> mapping is reused for something else I'm not too sure where the cache
> pollution is coming from.

Let me try explain in more detail. 
We can consider the DomU as a producer (writing values to mfn) and
hypervisor as a consumer (reading values from mfn). While DomU is 
invoking multiple hypercalls, it reuses the same mfn and the same 
mapping at xen page table.

       (consumer)             (producer)
           xen                   DomU
             \                    /   (writing path)
            (cache)              /
                 \              /
(reading path)    \           /
_______________________________________
                    |   mfn   |        (physical memory)
---------------------------------------

If we see the above figure, xen "may" keep reading the cached value while 
DomU is writing different values to mfn. Here goes my observation where
cache pollution happen:

The pollution actually happens in second line of cache.
DomU side hypercall param local address is 0xc785fe38 (cache line size = 0x40B),
and the size of hypercall param is 24B. So the hypercall param lays out in two
cache lines. When hypervisor is reading the hypercall param, it reads the first 
8 bytes correctly (means the first cache line is flushed) and the other 16 bytes
are polluted (means the second cache line is not flushed).
Honestly, I'm not sure why the first cache line is flushed and the second is not.
I think we can also cache_line_align the hypercall param struct, but that is only
when  the sizes of all hypercall params are smaller than cache line size.

I hope the alignment of the figure is not broken :)

Best,
Jaeyong

             reply	other threads:[~2013-06-18 11:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 11:22 Jaeyong Yoo [this message]
2013-06-18 11:45 ` [PATCH] ARM: cache coherence problem in guestcopy.c Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20  8:34 Jaeyong Yoo
2013-06-25  9:22 ` Ian Campbell
2013-07-02  9:38 ` Ian Campbell
2013-07-02 12:14   ` Sengul Thomas
2013-07-02 12:24     ` Sengul Thomas
2013-07-02 12:33     ` Ian Campbell
2013-07-02 12:39       ` Sengul Thomas
2013-06-18 12:05 Jaeyong Yoo
2013-06-18 12:18 ` Ian Campbell
2013-06-19 15:12   ` Ian Campbell
2013-06-20 11:55   ` Stefano Stabellini
2013-06-20 12:19     ` Tim Deegan
2013-06-25  9:43       ` Ian Campbell
2013-06-18  5:03 Jaeyong Yoo
2013-06-18  9:20 ` Ian Campbell

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=5815755.345161371554573758.JavaMail.weblogic@epv6ml06 \
    --to=jaeyong.yoo@samsung.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=tim@xen.org \
    --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 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).