On Wed, Jan 25, 2023 at 10:26:06PM +0100, Janis Schoetterl-Glausch wrote: > User space can use the MEM_OP ioctl to make storage key checked reads > and writes to the guest, however, it has no way of performing atomic, > key checked, accesses to the guest. > Extend the MEM_OP ioctl in order to allow for this, by adding a cmpxchg > op. For now, support this op for absolute accesses only. > > This op can be use, for example, to set the device-state-change > indicator and the adapter-local-summary indicator atomically. > > Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx> > --- > include/uapi/linux/kvm.h | 8 +++ > arch/s390/kvm/gaccess.h | 3 ++ > arch/s390/kvm/gaccess.c | 103 +++++++++++++++++++++++++++++++++++++++ > arch/s390/kvm/kvm-s390.c | 56 ++++++++++++++++++++- > 4 files changed, 169 insertions(+), 1 deletion(-) ... > + ret = cmpxchg_user_key((u8 *)hva, &old, *old_addr, new, access_key); FWIW, this and the three others need a __user annotation: ret = cmpxchg_user_key((u8 __user *)hva, &old, *old_addr, new, access_key); Otherwise you end up with sparse warnings (compile with C=1).