lkml.org 
[lkml]   [2021]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC][PATCH 2/3] x86/uaccess: Implement unsafe_try_cmpxchg_user()
On Mon, Dec 20, 2021 at 05:30:05PM +0000, Sean Christopherson wrote:
> On Tue, Dec 14, 2021, Peter Zijlstra wrote:
> > Do try_cmpxchg() loops on userspace addresses.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > @@ -501,6 +543,21 @@ do { \
> > } while (0)
> > #endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
> >
> > +extern void __try_cmpxchg_user_wrong_size(void);
> > +
> > +#define unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label) ({ \
> > + __typeof__(*(_ptr)) __ret; \
> > + switch (sizeof(__ret)) { \
> > + case 4: __ret = __try_cmpxchg_user_asm("l", (_ptr), (_oldp), \
> > + (_nval), _label); \
> > + break; \
> > + case 8: __ret = __try_cmpxchg_user_asm("q", (_ptr), (_oldp), \
> > + (_nval), _label); \
> > + break; \
>
> Can we add support for 1-byte and 2-byte cmpxchg, and for using cmpxchg8b to handle
> 8-byte operations in 32-bit mode? Support for all the flavors (except 16-byte)
> would allow KVM to use this in an emulator path that currently kmaps the target.
> I'd be more than happy to help test the result.

Sure, no problem. I currently still need to audit parts of mm/ and
do the smp-wake-idle bits before I repost -- that and take a xmas break
ofcourse :-) So it'll be a while before I repost this.

\
 
 \ /
  Last update: 2021-12-21 12:18    [W:0.123 / U:1.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site