lkml.org 
[lkml]   [2022]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 14/29] x86/ibt: Add IBT feature, MSR and #CP handling
On Fri, Feb 18, 2022 at 05:21:55PM -0800, Josh Poimboeuf wrote:
> On Fri, Feb 18, 2022 at 05:49:16PM +0100, Peter Zijlstra wrote:
> > +DEFINE_IDTENTRY_ERRORCODE(exc_control_protection)
> > +{
> > + if (!cpu_feature_enabled(X86_FEATURE_IBT)) {
> > + pr_err("Whaaa?!?!\n");
> > + return;
> > + }
>
> Might want to upgrade that to a proper warning :-)

"Unexpected #CP\n" ?

> > +bool ibt_selftest(void)
> > +{
> > + ibt_selftest_ok = false;
> > +
> > + asm (ANNOTATE_NOENDBR
> > + "1: lea 2f(%%rip), %%rax\n\t"
> > + ANNOTATE_RETPOLINE_SAFE
> > + " jmp *%%rax\n\t"
> > + "2: nop\n\t"
> > +
> > + /* unsigned ibt_selftest_ip = 2b */
> > + ".pushsection .data,\"aw\"\n\t"
> > + ".align 8\n\t"
> > + ".type ibt_selftest_ip, @object\n\t"
> > + ".size ibt_selftest_ip, 8\n\t"
> > + "ibt_selftest_ip:\n\t"
> > + ".quad 2b\n\t"
> > + ".popsection\n\t"
> > +
> > + : : : "rax", "memory");
>
> Can 'ibt_selftest_ip' just be defined in C (with __ro_after_init) and
> passed as an output to the asm doing 'mov $2b, %[ibt_selftest_ip]'?

This seemed simpler... note that it's ran on cpu bringup, so if you do
cpu hotplug it'll end up trying to write to ro memory if you do what you
suggest.

\
 
 \ /
  Last update: 2022-02-19 10:26    [W:0.210 / U:1.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site