RE: [PATCH] selftests: KVM: Handle compiler optimizations in ucall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: oliver.upton@xxxxxxxxx
> Sent: 16 June 2022 19:45

> 
> June 16, 2022 11:48 AM, "David Laight" <David.Laight@xxxxxxxxxx> wrote:
> > No wonder I was confused.
> > It's not surprising the compiler optimises it all away.
> >
> > It doesn't seem right to be 'abusing' WRITE_ONCE() here.
> > Just adding barrier() should be enough and much more descriptive.
> 
> I had the same thought, although I do not believe barrier() is sufficient
> on its own. barrier_data() with a pointer to uc passed through
> is required to keep clang from eliminating the dead store.

A barrier() (full memory clobber) ought to be stronger than
the partial one than barrier_data() generates.

I can't quite decide whether you need a barrier() both sides
of the 'magic write'.
Plausibly the compiler could discard the on-stack data
after the barrier() and before the 'magic write'.

Certainly putting the 'magic write' inside a asm block
that has a memory clobber is a more correct solution.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux