All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Kenny <darren.kenny@oracle.com>
To: Alexander Bulekov <alxndr@bu.edu>, qemu-devel@nongnu.org
Cc: mcascell@redhat.com, "Alexander Bulekov" <alxndr@bu.edu>,
	"Thomas Huth" <thuth@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH] memory: stricter checks prior to unsetting engaged_in_io
Date: Wed, 17 May 2023 15:21:04 +0100	[thread overview]
Message-ID: <m2v8grrqcv.fsf@oracle.com> (raw)
In-Reply-To: <20230516084002.3813836-1-alxndr@bu.edu>


On Tuesday, 2023-05-16 at 04:40:02 -04, Alexander Bulekov wrote:
> engaged_in_io could be unset by an MR with re-entrancy checks disabled.
> Ensure that only MRs that can set the engaged_in_io flag can unset it.
>
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/1563
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

> ---
>  softmmu/memory.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index b7b3386e9d..26424f1d78 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -534,6 +534,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
>      unsigned access_size;
>      unsigned i;
>      MemTxResult r = MEMTX_OK;
> +    bool reentrancy_guard_applied = false;
>  
>      if (!access_size_min) {
>          access_size_min = 1;
> @@ -552,6 +553,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
>              return MEMTX_ACCESS_ERROR;
>          }
>          mr->dev->mem_reentrancy_guard.engaged_in_io = true;
> +        reentrancy_guard_applied = true;
>      }
>  
>      /* FIXME: support unaligned access? */
> @@ -568,7 +570,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
>                          access_mask, attrs);
>          }
>      }
> -    if (mr->dev) {
> +    if (mr->dev && reentrancy_guard_applied) {
>          mr->dev->mem_reentrancy_guard.engaged_in_io = false;
>      }
>      return r;
> -- 
> 2.39.0


      reply	other threads:[~2023-05-17 14:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16  8:40 [PATCH] memory: stricter checks prior to unsetting engaged_in_io Alexander Bulekov
2023-05-17 14:21 ` Darren Kenny [this message]

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=m2v8grrqcv.fsf@oracle.com \
    --to=darren.kenny@oracle.com \
    --cc=alxndr@bu.edu \
    --cc=david@redhat.com \
    --cc=mcascell@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@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.