diff mbox

[1/3] powerpc: implement barrier primitives

Message ID 1434534230-17249-2-git-send-email-andre.przywara@arm.com
State Not Applicable, archived
Headers show

Commit Message

Andre Przywara June 17, 2015, 9:43 a.m. UTC
Instead of referring to the Linux header including the barrier
macros, copy over the rather simple implementation for the PowerPC
barrier instructions kvmtool uses. This fixes build for powerpc.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

I just took what kvmtool seems to have used before, I actually have
no idea if "sync" is the right instruction or "lwsync" would do.
Would be nice if some people with PowerPC knowledge could comment.

Cheers,
Andre.

 powerpc/include/kvm/barrier.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Will Deacon June 17, 2015, 10:15 a.m. UTC | #1
On Wed, Jun 17, 2015 at 10:43:48AM +0100, Andre Przywara wrote:
> Instead of referring to the Linux header including the barrier
> macros, copy over the rather simple implementation for the PowerPC
> barrier instructions kvmtool uses. This fixes build for powerpc.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> Hi,
> 
> I just took what kvmtool seems to have used before, I actually have
> no idea if "sync" is the right instruction or "lwsync" would do.
> Would be nice if some people with PowerPC knowledge could comment.

I *think* we can use lwsync for rmb and wmb, but would want confirmation
from a ppc guy before making that change!

Will
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf June 17, 2015, 10:46 a.m. UTC | #2
On 17.06.15 12:15, Will Deacon wrote:
> On Wed, Jun 17, 2015 at 10:43:48AM +0100, Andre Przywara wrote:
>> Instead of referring to the Linux header including the barrier
>> macros, copy over the rather simple implementation for the PowerPC
>> barrier instructions kvmtool uses. This fixes build for powerpc.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>> Hi,
>>
>> I just took what kvmtool seems to have used before, I actually have
>> no idea if "sync" is the right instruction or "lwsync" would do.
>> Would be nice if some people with PowerPC knowledge could comment.
> 
> I *think* we can use lwsync for rmb and wmb, but would want confirmation
> from a ppc guy before making that change!

Also I'd prefer to play safe for now :)


Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michael Ellerman June 18, 2015, 9:11 a.m. UTC | #3
On Wed, 2015-06-17 at 11:15 +0100, Will Deacon wrote:
> On Wed, Jun 17, 2015 at 10:43:48AM +0100, Andre Przywara wrote:
> > Instead of referring to the Linux header including the barrier
> > macros, copy over the rather simple implementation for the PowerPC
> > barrier instructions kvmtool uses. This fixes build for powerpc.
> > 
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> > Hi,
> > 
> > I just took what kvmtool seems to have used before, I actually have
> > no idea if "sync" is the right instruction or "lwsync" would do.
> > Would be nice if some people with PowerPC knowledge could comment.
> 
> I *think* we can use lwsync for rmb and wmb, but would want confirmation
> from a ppc guy before making that change!

Ugh, memory barriers :)

You probably can use lwsync, assuming you're only ordering cacheable vs
cacheable.

But, lwsync has given us pain in the past[1], so I'd be happier if you just used
sync.

cheers

[1]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=51d7d5205d3389a32859f9939f1093f267409929


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Will Deacon June 18, 2015, 9:38 a.m. UTC | #4
On Thu, Jun 18, 2015 at 10:11:58AM +0100, Michael Ellerman wrote:
> On Wed, 2015-06-17 at 11:15 +0100, Will Deacon wrote:
> > On Wed, Jun 17, 2015 at 10:43:48AM +0100, Andre Przywara wrote:
> > > Instead of referring to the Linux header including the barrier
> > > macros, copy over the rather simple implementation for the PowerPC
> > > barrier instructions kvmtool uses. This fixes build for powerpc.
> > > 
> > > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > > ---
> > > Hi,
> > > 
> > > I just took what kvmtool seems to have used before, I actually have
> > > no idea if "sync" is the right instruction or "lwsync" would do.
> > > Would be nice if some people with PowerPC knowledge could comment.
> > 
> > I *think* we can use lwsync for rmb and wmb, but would want confirmation
> > from a ppc guy before making that change!
> 
> Ugh, memory barriers :)

I prefer to call them "Job Security" :)

> You probably can use lwsync, assuming you're only ordering cacheable vs
> cacheable.
> 
> But, lwsync has given us pain in the past[1], so I'd be happier if you just used
> sync.

No probs. I pushed Andre's original patch.

Will
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/powerpc/include/kvm/barrier.h b/powerpc/include/kvm/barrier.h
index dd5115a..4b708ae 100644
--- a/powerpc/include/kvm/barrier.h
+++ b/powerpc/include/kvm/barrier.h
@@ -1,6 +1,8 @@ 
 #ifndef _KVM_BARRIER_H_
 #define _KVM_BARRIER_H_
 
-#include <asm/barrier.h>
+#define mb()   asm volatile ("sync" : : : "memory")
+#define rmb()  asm volatile ("sync" : : : "memory")
+#define wmb()  asm volatile ("sync" : : : "memory")
 
 #endif /* _KVM_BARRIER_H_ */