qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Emilio G. Cota" <cota@braap.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Fam Zheng" <famz@redhat.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] translate-all: fix locking of TBs whose two pages share the same physical page
Date: Wed, 27 Jun 2018 12:47:57 -0400	[thread overview]
Message-ID: <20180627164757.GA17117@flamenco> (raw)
In-Reply-To: <168807dc-6c5b-fc1f-6a70-72e0a518b178@linaro.org>

On Tue, Jun 26, 2018 at 19:28:19 -0700, Richard Henderson wrote:
> On 06/25/2018 09:31 AM, Emilio G. Cota wrote:
> > +    } else if (page1 == page2) {
> > +        page_lock(p1);
> > +        if (ret_p2) {
> > +            *ret_p2 = p1;
> 
> I think you should set NULL here...
> 
> > @@ -1623,7 +1641,7 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
> >          tb = existing_tb;
> >      }
> >  
> > -    if (p2) {
> > +    if (p2 && p2 != p) {
> >          page_unlock(p2);
> 
> ... so that you need no change here.
> Otherwise it looks good.

I did that initially. However, note that if we do that then
the second page is not added to the list of pages for this
TB (via tb_page_add), which breaks the provided test case.

    page_lock_pair(&p, phys_pc, &p2, phys_page2, 1);
    tb_page_add(p, tb, 0, phys_pc & TARGET_PAGE_MASK);
    if (p2) {
        tb_page_add(p2, tb, 1, phys_page2);
    } else {
        tb->page_addr[1] = -1;
    }

Regardless of whether p1 and p2 point to the same physical page,
the fact that the TB goes across two virtual pages should be
preserved, and in this case tb_page_add must be called twice.

Thanks,

		Emilio

  reply	other threads:[~2018-06-27 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 16:31 [Qemu-devel] [PATCH] translate-all: fix locking of TBs whose two pages share the same physical page Emilio G. Cota
2018-06-25 16:46 ` Max Filippov
2018-06-25 17:11 ` Philippe Mathieu-Daudé
2018-06-27  2:28 ` Richard Henderson
2018-06-27 16:47   ` Emilio G. Cota [this message]
2018-06-28 23:06     ` Richard Henderson

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=20180627164757.GA17117@flamenco \
    --to=cota@braap.org \
    --cc=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=famz@redhat.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).