lkml.org 
[lkml]   [2022]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v3 25/37] x86/shstk: Add user-mode shadow stack support
Date
On Tue, 2022-11-15 at 13:32 +0100, Peter Zijlstra wrote:
> > + struct thread_shstk *shstk = &current->thread.shstk;
> > + unsigned long addr, size;
> > +
> > + /* Already enabled */
> > + if (features_enabled(CET_SHSTK))
> > + return 0;
> > +
> > + /* Also not supported for 32 bit and x32 */
> > + if (!cpu_feature_enabled(X86_FEATURE_USER_SHSTK) ||
> > in_32bit_syscall())
> > + return -EOPNOTSUPP;
> > +
> > + size = adjust_shstk_size(0);
> > + addr = alloc_shstk(size);
> > + if (IS_ERR_VALUE(addr))
> > + return PTR_ERR((void *)addr);
> > +
> > + fpregs_lock_and_load();
> > + wrmsrl(MSR_IA32_PL3_SSP, addr + size);
> > + wrmsrl(MSR_IA32_U_CET, CET_SHSTK_EN);
>
> This..
>
> > + fpregs_unlock();
> > +
> > + shstk->base = addr;
> > + shstk->size = size;
> > + features_set(CET_SHSTK);
> > +
> > + return 0;
> > +}
> > +static int shstk_disable(void)
> > +{
> > + if (!cpu_feature_enabled(X86_FEATURE_USER_SHSTK))
> > + return -EOPNOTSUPP;
> > +
> > + /* Already disabled? */
> > + if (!features_enabled(CET_SHSTK))
> > + return 0;
> > +
> > + fpregs_lock_and_load();
> > + /* Disable WRSS too when disabling shadow stack */

Oops, this comment is in wrong patch.

> > + set_clr_bits_msrl(MSR_IA32_U_CET, 0, CET_SHSTK_EN);
>
> And this... aren't very consistent in approach. Given there is no
> U_IBT
> yet, why complicate matters like this?

Sure, I can change it.
\
 
 \ /
  Last update: 2022-11-15 22:46    [W:0.172 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site