Re: [PATCH] efi/x86: use naked RET on mixed mode call wrapper

From: Peter Zijlstra
Date: Mon Jul 18 2022 - 12:39:43 EST


On Mon, Jul 18, 2022 at 06:28:27PM +0200, Borislav Petkov wrote:
> On Mon, Jul 18, 2022 at 01:41:37PM +0200, Peter Zijlstra wrote:
> > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
> > index 10a3bfc1eb23..f934dcdb7c0d 100644
> > --- a/arch/x86/include/asm/nospec-branch.h
> > +++ b/arch/x86/include/asm/nospec-branch.h
> > @@ -297,6 +297,8 @@ do { \
> > alternative_msr_write(MSR_IA32_SPEC_CTRL, \
> > spec_ctrl_current() | SPEC_CTRL_IBRS, \
> > X86_FEATURE_USE_IBRS_FW); \
> > + altnerative_msr_write(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, \
> > + X86_FEATURE_USE_IBPB_FW); \
> > } while (0)
>
> So I'm being told we need to untrain on return from EFI to protect the
> kernel from it. Ontop of yours.

I don't think there's any credible way we can protect against EFI taking
over the system if it wants to. It runs at CPL0 and has access to the
direct map. If EFI wants it can take over the system without trying.