linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-arch@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org,
	linux-mm@kvack.org, xen-devel@lists.xenproject.org,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE
Date: Fri, 16 Jan 2015 10:43:32 +0100	[thread overview]
Message-ID: <54B8DD44.1020402@de.ibm.com> (raw)
In-Reply-To: <1421363369.23332.8.camel@ellerman.id.au>

Am 16.01.2015 um 00:09 schrieb Michael Ellerman:
> On Thu, 2015-01-15 at 09:58 +0100, Christian Borntraeger wrote:
>> ACCESS_ONCE does not work reliably on non-scalar types. For
>> example gcc 4.6 and 4.7 might remove the volatile tag for such
>> accesses during the SRA (scalar replacement of aggregates) step
>> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145)
>>
>> Change the ppc/kvm code to replace ACCESS_ONCE with READ_ONCE.
>>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> ---
>>  arch/powerpc/kvm/book3s_hv_rm_xics.c |  8 ++++----
>>  arch/powerpc/kvm/book3s_xics.c       | 16 ++++++++--------
>>  2 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv_rm_xics.c b/arch/powerpc/kvm/book3s_hv_rm_xics.c
>> index 7b066f6..7c22997 100644
>> --- a/arch/powerpc/kvm/book3s_hv_rm_xics.c
>> +++ b/arch/powerpc/kvm/book3s_hv_rm_xics.c
>> @@ -152,7 +152,7 @@ static void icp_rm_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp,
>>  	 * in virtual mode.
>>  	 */
>>  	do {
>> -		old_state = new_state = ACCESS_ONCE(icp->state);
>> +		old_state = new_state = READ_ONCE(icp->state);
> 
> These are all icp->state.
> 
> Which is a union, but it's only the size of unsigned long. So in practice there
> shouldn't be a bug here right?

This bug was that gcc lost the volatile tag when propagating aggregates to scalar types.
So in theory a union could be affected. See the original problem
 ( http://marc.info/?i=54611D86.4040306%40de.ibm.com ) 
which happened on 

union ipte_control {
        unsigned long val;
        struct {
                unsigned long k  : 1;
                unsigned long kh : 31;
                unsigned long kg : 32;
        };
};

Christian

  reply	other threads:[~2015-01-16  9:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15  8:58 [PATCH 0/8] current ACCESS_ONCE patch queue Christian Borntraeger
2015-01-15  8:58 ` [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2015-01-15 23:09   ` Michael Ellerman
2015-01-16  9:43     ` Christian Borntraeger [this message]
2015-01-15  8:58 ` [PATCH 2/8] ppc/hugetlbfs: " Christian Borntraeger
2015-01-15  8:58 ` [PATCH 3/8] x86/xen/p2m: " Christian Borntraeger
2015-01-15  9:26   ` Jürgen Groß
2015-01-15 10:43   ` [Xen-devel] " David Vrabel
2015-01-15 11:07     ` Christian Borntraeger
2015-01-15  8:58 ` [PATCH 4/8] x86/spinlock: Leftover conversion ACCESS_ONCE->READ_ONCE Christian Borntraeger
2015-01-15 19:38   ` Oleg Nesterov
2015-01-15 19:51     ` Christian Borntraeger
2015-01-15 20:01       ` Oleg Nesterov
2015-01-15 21:00         ` Christian Borntraeger
2015-01-15  8:58 ` [PATCH 5/8] mm/gup: Replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2015-01-15  8:58 ` [PATCH 6/8] kernel: tighten rules for ACCESS ONCE Christian Borntraeger
2015-01-15  8:58 ` [PATCH 7/8] next: sh: Fix compile error Christian Borntraeger
2015-01-15  8:58 ` [PATCH 8/8] kernel: Fix sparse warning for ACCESS_ONCE Christian Borntraeger
2015-01-16 12:12 ` [PATCH 0/8] current ACCESS_ONCE patch queue Alexander Graf

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=54B8DD44.1020402@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=x86@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).