All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [RFC PATCH] hw/virtio/vhost: re-factor vhost-section and allow DIRTY_MEMORY_CODE
Date: Thu, 04 Jun 2020 14:50:14 +0100	[thread overview]
Message-ID: <87a71j54a1.fsf@linaro.org> (raw)
In-Reply-To: <0cce5904-fe53-d7ff-93b7-095cded2caf3@redhat.com>


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 6/4/20 1:49 PM, Alex Bennée wrote:
>> 
>> Michael S. Tsirkin <mst@redhat.com> writes:
>> 
>>> On Thu, Jun 04, 2020 at 12:13:23PM +0100, Alex Bennée wrote:
>>>> The purpose of vhost_section is to identify RAM regions that need to
>>>> be made available to a vhost client. However when running under TCG
>>>> all RAM sections have DIRTY_MEMORY_CODE set which leads to problems
>>>> down the line. The original comment implies VGA regions are a problem
>>>> but doesn't explain why vhost has a problem with it.
>>>>
>>>> Re-factor the code so:
>>>>
>>>>   - steps are clearer to follow
>>>>   - reason for rejection is recorded in the trace point
>>>>   - we allow DIRTY_MEMORY_CODE when TCG is enabled
>>>>
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>>> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
>>>> Cc: Stefan Hajnoczi <stefanha@redhat.com>
>>>> ---
>>>>  hw/virtio/vhost.c | 46 ++++++++++++++++++++++++++++++++--------------
>>>>  1 file changed, 32 insertions(+), 14 deletions(-)
> [...]
>>>> +
>>>> +    if (memory_region_is_ram(section->mr) && !memory_region_is_rom(section->mr)) {
>>>> +        uint8_t dirty_mask = memory_region_get_dirty_log_mask(section->mr);
>>>> +        uint8_t handled_dirty;
>>>>  
>>>> -    if (result && dev->vhost_ops->vhost_backend_mem_section_filter) {
>>>> -        result &=
>>>> -            dev->vhost_ops->vhost_backend_mem_section_filter(dev, section);
>>>> +        /*
>>>> +         * Vhost doesn't handle any block which is doing dirty-tracking other
>>>> +         * than migration; this typically fires on VGA areas. However
>>>> +         * for TCG we also do dirty code page tracking which shouldn't
>>>> +         * get in the way.
>>>> +         */
>>>> +        handled_dirty = (1 << DIRTY_MEMORY_MIGRATION);
>>>> +        if (tcg_enabled()) {
>>>> +            handled_dirty |= (1 << DIRTY_MEMORY_CODE);
>>>> +        }
>>>
>>> So DIRTY_MEMORY_CODE is only set by TCG right? Thus I'm guessing
>>> we can just allow this unconditionally.
>> 
>> Which actually makes the test:
>> 
>>   if (dirty_mask & DIRTY_MEMORY_VGA) {
>
> Eh? Shouldn't this be "if (dirty_mask & (1 << DIRTY_MEMORY_VGA))"?

Yeah - that's what I meant... I've left it as the other form in v2
though.

>
>>      .. fail ..
>>   }
>> 
>> which is more in line with the comment although wouldn't fail if we
>> added additional DIRTY_MEMORY flags. This leads to the question what
>> exactly is it about DIRTY tracking that vhost doesn't like. Is it really
>> only avoiding having virtqueue in video RAM? Does this ever actually
>> happen?
>> 
>> I assume boards with unified memory models where video ram is shared
>> with system ram just end up partitioning the memory regions?
>> 


-- 
Alex Bennée


  reply	other threads:[~2020-06-04 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 11:13 [RFC PATCH] hw/virtio/vhost: re-factor vhost-section and allow DIRTY_MEMORY_CODE Alex Bennée
2020-06-04 11:24 ` Michael S. Tsirkin
2020-06-04 11:49   ` Alex Bennée
2020-06-04 11:55     ` Michael S. Tsirkin
2020-06-04 12:39       ` Alex Bennée
2020-06-04 13:07         ` Dr. David Alan Gilbert
2020-06-04 12:58     ` Philippe Mathieu-Daudé
2020-06-04 13:50       ` Alex Bennée [this message]
2020-06-04 13:26 ` Dr. David Alan Gilbert
2020-06-04 14:02   ` Alex Bennée
2020-06-04 14:29     ` Dr. David Alan Gilbert

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=87a71j54a1.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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.