Re: [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE

2015-01-16 Thread Christian Borntraeger
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 
>> ---
>>  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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE

2015-01-16 Thread Christian Borntraeger
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 borntrae...@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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE

2015-01-15 Thread 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 
> ---
>  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?

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/8] ppc/kvm: Replace ACCESS_ONCE with READ_ONCE

2015-01-15 Thread 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 borntrae...@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?

cheers


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/