From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BC1AC43334 for ; Fri, 15 Jul 2022 20:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbiGOUnU (ORCPT ); Fri, 15 Jul 2022 16:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbiGOUnD (ORCPT ); Fri, 15 Jul 2022 16:43:03 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6901C87C3C for ; Fri, 15 Jul 2022 13:42:49 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id r6-20020a17090a2e8600b001f0768a1af1so5754799pjd.8 for ; Fri, 15 Jul 2022 13:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=liAaUig9e0Cr1DOkUSsRBP3sqraN0c1NE6Fb89OWpOk=; b=ZA3GLiG8vAIb5vtxA72D+lcqlm5AUpAo2aNjZhXjwP2fh4bAQHo/0h43sZmI3KFzAr 4xSYMwBO+O6+y65tQfQt/TfgMiIOfy0LZnuMsRhLYH33Ox/8hH0cv5qf3sRvhY19tvNS azyrethwyQOg8jD1Dea1lPlo4zQ07KeOP3LAwrFAJ5fbq/DsaAMwsVixX/jtWZ+9VsJX Za+lqOkppCejZwxD3sV50kG93XvEct5IW7GNUKZBDzgyY2uEF0afDXND7PbUwAh3sM/Z EQFyv/2wuP+fOtDKNaFWSrViMXNk+NUYq4G7NlxWZsx4Mkg/dRDv7dM48VejxCIiPDkz VYbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=liAaUig9e0Cr1DOkUSsRBP3sqraN0c1NE6Fb89OWpOk=; b=gnwNdWJ5LqEb7/0sfVSoGire1tjYUtrnR8oRh6Xc7hRCbJPrx/7xUJqVp6HdGfGUO0 rq4RVeu2ir+rclJBq8EMzHj/tGJqo5mLgPkTxI9W8/qXzL+0zrFAI57w0XuDJ5Qx3FcU LxHYaUf7oGTZNsK31CQwYHUvbzisWszSP2ujMHk40fjP9xqi03zBGyoA4ZRW1YGbfjat s3o5bh6V38dEAoJStwBRQQl3BRsO8kG/O5tWVee6YyrYdw7boQB7B1tX3f6ttOf/dKEB GGdH8cpZS3v3NEVKHVGXH729c9nFF3+d7frFoP1y7GYaahgd5jTQJPdkQapjUaqq7yw0 xcaQ== X-Gm-Message-State: AJIora9b03yyH37AaRO9Wpo2VT+7ljAmibL5wHYRN5M3pyt6P9Uq92vE 8stWpcPacoEew82avjP/IqIrdWnpAu4= X-Google-Smtp-Source: AGRyM1vFsr5VZGLYhoBiX3ZAXQYUYYRCOwRBRjGhs34dr796HCyIH34dh0X0i+a/wRdA36tGfPT3pNjjWsw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:249:b0:1e0:a8a3:3c6c with SMTP id t9-20020a17090a024900b001e0a8a33c6cmr911667pje.0.1657917767504; Fri, 15 Jul 2022 13:42:47 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 15 Jul 2022 20:42:10 +0000 In-Reply-To: <20220715204226.3655170-1-seanjc@google.com> Message-Id: <20220715204226.3655170-9-seanjc@google.com> Mime-Version: 1.0 References: <20220715204226.3655170-1-seanjc@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v2 08/24] KVM: nVMX: Ignore SIPI that arrives in L2 when vCPU is not in WFS From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , Maxim Levitsky , Oliver Upton , Peter Shier Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fall through to handling other pending exception/events for L2 if SIPI is pending while the CPU is not in Wait-for-SIPI. KVM correctly ignores the event, but incorrectly returns immediately, e.g. a SIPI coincident with another event could lead to KVM incorrectly routing the event to L1 instead of L2. Fixes: bf0cd88ce363 ("KVM: x86: emulate wait-for-SIPI and SIPI-VMExit") Signed-off-by: Sean Christopherson Reviewed-by: Maxim Levitsky --- arch/x86/kvm/vmx/nested.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index bc5759f82a3f..104f233ddd5d 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3925,10 +3925,12 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu) return -EBUSY; clear_bit(KVM_APIC_SIPI, &apic->pending_events); - if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) + if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) { nested_vmx_vmexit(vcpu, EXIT_REASON_SIPI_SIGNAL, 0, apic->sipi_vector & 0xFFUL); - return 0; + return 0; + } + /* Fallthrough, the SIPI is completely ignored. */ } /* -- 2.37.0.170.g444d1eabd0-goog