From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen/arm: fix rank/vgic locks inversion bug
Date: Thu, 15 Dec 2016 22:55:28 +0000 [thread overview]
Message-ID: <b272a7a0-2b8a-94df-56b7-baf9eb54889f@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1612141524350.9245@sstabellini-ThinkPad-X260>
Hi Stefano,
On 15/12/2016 01:04, Stefano Stabellini wrote:
> The locking order is: first rank lock, then vgic lock. The order is
> respected everywhere, except for gic_update_one_lr.
>
> gic_update_one_lr is called with the vgic lock held, but it calls
> vgic_get_target_vcpu, which tries to obtain the rank lock. This can
> cause deadlocks.
>
> We already have a version of vgic_get_target_vcpu that doesn't take the
> rank lock: __vgic_get_target_vcpu. Also the only routine that modify
> the target vcpu are vgic_store_itargetsr and vgic_store_irouter. They
> call vgic_migrate_irq, which already take the vgic lock.
>
> Solve the lock inversion problem, by not taking the rank lock in
> gic_update_one_lr (calling __vgic_get_target_vcpu instead of
> vgic_get_target_vcpu).
If I look at the callers of gic_update_one_lr, the function
gic_clear_lrs will not take the rank lock. So from my understanding
nobody will take the rank here.
However __vgic_get_target_vcpu has an ASSERT to check whether the rank
lock has been taken. So who is taking lock for gic_update_one_lr now?
We make this safe, by placing modifications to
> rank->vcpu within regions protected by the vgic lock.
This look unsafe to me. The vgic lock is per-vcpu, but rank->vcpu could
be written/read by any vCPU. So you will never protect rank->vcpu with
this lock. Did I miss anything?
>
> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
>
> ---
> There are supposed to be 2 Coverity IDs associated with this, but the
> system the currently down.
I think the 2 Coverity IDs are 1381855 and 1381853.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-12-15 22:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 1:04 [PATCH] xen/arm: fix rank/vgic locks inversion bug Stefano Stabellini
2016-12-15 22:55 ` Julien Grall [this message]
2016-12-16 0:08 ` Stefano Stabellini
2016-12-16 11:51 ` Julien Grall
2016-12-17 1:08 ` Stefano Stabellini
2016-12-17 1:13 ` Stefano Stabellini
2016-12-19 17:46 ` Julien Grall
2016-12-19 22:30 ` Stefano Stabellini
2016-12-19 22:56 ` Julien Grall
2016-12-19 23:22 ` Stefano Stabellini
2016-12-20 11:28 ` Julien Grall
2016-12-20 19:38 ` Stefano Stabellini
2016-12-22 2:12 ` Stefano Stabellini
2016-12-28 15:48 ` 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=b272a7a0-2b8a-94df-56b7-baf9eb54889f@arm.com \
--to=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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).