lkml.org 
[lkml]   [2023]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/7] x86: Add a comment about the "magic" behind shadow sti before mwait
    Date
    Add a note to make sure we never miss and break the requirements behind
    it.

    Acked-by: Rafael J. Wysocki <rafael@kernel.org>
    Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
    ---
    arch/x86/include/asm/mwait.h | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
    index bae83810505b..920426d691ce 100644
    --- a/arch/x86/include/asm/mwait.h
    +++ b/arch/x86/include/asm/mwait.h
    @@ -87,6 +87,15 @@ static __always_inline void __mwaitx(unsigned long eax, unsigned long ebx,
    :: "a" (eax), "b" (ebx), "c" (ecx));
    }

    +/*
    + * Re-enable interrupts right upon calling mwait in such a way that
    + * no interrupt can fire _before_ the execution of mwait, ie: no
    + * instruction must be placed between "sti" and "mwait".
    + *
    + * This is necessary because if an interrupt queues a timer before
    + * executing mwait, it would otherwise go unnoticed and the next tick
    + * would not be reprogrammed accordingly before mwait ever wakes up.
    + */
    static __always_inline void __sti_mwait(unsigned long eax, unsigned long ecx)
    {
    mds_idle_clear_cpu_buffers();
    --
    2.42.1
    \
     
     \ /
      Last update: 2023-11-24 23:33    [W:2.387 / U:0.076 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site