lkml.org 
[lkml]   [2023]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v2 08/18] x86/reboot: Assert that IRQs are disabled when turning off virtualization
    From
    Assert that IRQs are disabled when turning off virtualization in an
    emergency. KVM enables hardware via on_each_cpu(), i.e. could re-enable
    hardware if a pending IPI were delivered after disabling virtualization.

    Remove a misleading comment from emergency_reboot_disable_virtualization()
    about "just" needing to guarantee the CPU is stable (see above).

    Signed-off-by: Sean Christopherson <seanjc@google.com>
    ---
    arch/x86/kernel/reboot.c | 8 +++++++-
    1 file changed, 7 insertions(+), 1 deletion(-)

    diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
    index dd7def3d4144..f0d405bc718e 100644
    --- a/arch/x86/kernel/reboot.c
    +++ b/arch/x86/kernel/reboot.c
    @@ -561,6 +561,13 @@ void cpu_emergency_disable_virtualization(void)
    {
    cpu_emergency_virt_cb *callback;

    + /*
    + * IRQs must be disabled as KVM enables virtualization in hardware via
    + * function call IPIs, i.e. IRQs need to be disabled to guarantee
    + * virtualization stays disabled.
    + */
    + lockdep_assert_irqs_disabled();
    +
    rcu_read_lock();
    callback = rcu_dereference(cpu_emergency_virt_callback);
    if (callback)
    @@ -570,7 +577,6 @@ void cpu_emergency_disable_virtualization(void)

    static void emergency_reboot_disable_virtualization(void)
    {
    - /* Just make sure we won't change CPUs while doing this */
    local_irq_disable();

    /*
    --
    2.40.0.rc1.284.g88254d51c5-goog
    \
     
     \ /
      Last update: 2023-03-27 00:54    [W:2.133 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site