[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8211a3d2-66e0-4563-b804-8aa4bd0f0de9@intel.com>
Date: Wed, 13 Nov 2024 09:49:00 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: "Xin Li (Intel)" <xin@...or.com>, linux-kernel@...r.kernel.org
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
peterz@...radead.org, andrew.cooper3@...rix.com
Subject: Re: [PATCH v3 1/1] x86/fred: Clear WFE in missing-ENDBRANCH #CPs
On 11/13/24 01:13, Xin Li (Intel) wrote:
> An indirect branch instruction sets the CPU indirect branch tracker
> (IBT) into WAIT_FOR_ENDBRANCH (WFE) state, and WFE stays asserted
> across the instruction boundary. When decoder finds an instruction
> and WFE is set, and the instruction is not the appropriate ENDBR, it
> raises a #CP fault.
>
> For the kernel IBT no ENDBR selftest where #CPs are deliberately
> triggerred, the WFE state of the interrupted context needs to be
> cleared to let execution continue. Otherwise when the CPU resumes
> from the instruction that just caused the previous #CP, another
> missing-ENDBRANCH #CP is raised and the CPU enters a dead loop.
>
> This is not a problem with IDT because it doesn't preserve WFE and
> IRET doesn't set WFE. But FRED provides space on the entry stack
> (in an expanded CS area) to save and restore the WFE state, thus the
> WFE state is no longer clobbered, so software must clear it.
>
> Clear WFE to avoid dead looping in ibt_clear_fred_wfe() and the
> !ibt_fatal code path when execution is allowed to continue.
>
> Clobbering WFE in any other circumstance is a security-relevant bug.
With the minor fixes Ingo mentioned:
Acked-by: Dave Hansen <dave.hansen@...ux.intel.com>
Powered by blists - more mailing lists