On Wed, Jan 17, 2024 at 12:30:00PM +0000, Mark Rutland wrote: > On Tue, Jan 16, 2024 at 02:51:21PM -0400, Jason Gunthorpe wrote: > > Hey Catalin, > > > > I'm just revising this and I'm wondering if you know why ARM64 has this: > > > > #define __raw_writeq __raw_writeq > > static __always_inline void __raw_writeq(u64 val, volatile void __iomem *addr) > > { > > asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr)); > > } > > > > Instead of > > > > #define __raw_writeq __raw_writeq > > static __always_inline void __raw_writeq(u64 val, volatile void __iomem *addr) > > { > > asm volatile("str %x0, %1" : : "rZ" (val), "m" (*(volatile u64 *)addr)); > > } > > > > ?? Like x86 has. > > I believe this is for the same reason as doing so in all of our other IO > accessors. > > We've deliberately ensured that our IO accessors use a single base register > with no offset as this is the only form that HW can represent in ESR_ELx.ISS.SRT > when reporting a stage-2 abort, which a hypervisor may use for emulating IO. FWIW, IIUC the immediate-offset forms *without* writeback can still be reported usefully in ESR_ELx, so I believe that we could use the "o" constraint for the __raw_write*() functions, e.g. static __always_inline void __raw_writeq(u64 val, volatile void __iomem *addr) { asm volatile("str %x0, %1" : : "rZ" (val), "o" (*(volatile u64 *)addr)); } However, the __raw_read*() functions would still need to use "r" due to ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE. Mark.