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 71139C43334 for ; Sat, 23 Jul 2022 00:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236956AbiGWAxq (ORCPT ); Fri, 22 Jul 2022 20:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236805AbiGWAxN (ORCPT ); Fri, 22 Jul 2022 20:53:13 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60205C19BB for ; Fri, 22 Jul 2022 17:52:24 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31e60b8bb07so50759887b3.1 for ; Fri, 22 Jul 2022 17:52:24 -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=rUkhCIu3G6hVGxoVXeosOYZ1CHA90hebfQ0IThcWEiU=; b=dTZ9QzwbkjN8vSw1b4ZQ5CPuB06qdpj8gpR/RWuiDwzwolmGm5N2ePpnmceqHUUQJs 0nvprNHcU9JI67sqPhhJ9qYMnNEg4CfTCUK6ckj2Ym7QAmsGTMhbqy3/0S20Z9ptyE6h dnibPvvvHJTvRqyMuC/92cRS/ORmWU8z2WBFq0cuGvUvII05DIAE0nr8zIn6gwwE9lNh idyu6gTKtu66P6QDBbqi6NUYlABPgUfQlT05+0xU/VjFswiz8N3hoFx7amWMziwUaTpP u9j4Xt4a13fHwgW8fmnG2cyeia1vvNLOhKteYh3ZLw5di772IK5Aqkil4vV2VfoWVIjL OIRA== 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=rUkhCIu3G6hVGxoVXeosOYZ1CHA90hebfQ0IThcWEiU=; b=2NPhhy4L8GQN+YhXgUURE7+3BaT7/vFzX0xrP/APFDm6iwBiH7emUMILUnqTnWpt30 XwcJLeYuxD3DvRblXE1ig15hQfSj1uvjIsSPdPWDVuaKOLExA6o8Vi9wE3j0A7oTS5/v O8HY5uePOmLuqnkBBWSzQzSH0QvXpPhzs8/F07nTe/nb1buHxJ49wehFWwSNjfJO8J1m K3hIHoC2OC7QxP+29BGwiWFVUmd8J2x/mxc4ff5NLC2dVNBoNXzIvgUKLmV30y3xZSFK Gc+7zldjTsrlyq/utN0Rqjm56xXPL8IRjwY0DDd3UCkpr0cBwmjQv/rFipfBjNF8mkZg TeZA== X-Gm-Message-State: AJIora81x5U0vfV/ZCSoZPxCRiYO2/3F+ZHHZPJG3o/n3sjoS44BhrV4 KTreNzn2R2XBsp/8DiKnDFDH//MoISA= X-Google-Smtp-Source: AGRyM1tLKMklWgQ8FNSImnL/X0u9s1C+BqiyV2k5uUxPZxT/XciQjfwMQBolnnSWQj3XA+G8cMoIrTEuWQ4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:b98c:0:b0:670:9213:4f8a with SMTP id r12-20020a25b98c000000b0067092134f8amr2136101ybg.171.1658537533909; Fri, 22 Jul 2022 17:52:13 -0700 (PDT) Reply-To: Sean Christopherson Date: Sat, 23 Jul 2022 00:51:33 +0000 In-Reply-To: <20220723005137.1649592-1-seanjc@google.com> Message-Id: <20220723005137.1649592-21-seanjc@google.com> Mime-Version: 1.0 References: <20220723005137.1649592-1-seanjc@google.com> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH v4 20/24] KVM: x86: Treat pending TRIPLE_FAULT requests as pending exceptions 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 Treat pending TRIPLE_FAULTS as pending exceptions. A triple fault is an exception for all intents and purposes, it's just not tracked as such because there's no vector associated the exception. E.g. if userspace were to set vcpu->request_interrupt_window while running L2 and L2 hit a triple fault, a triple fault nested VM-Exit should be synthesized to L1 before exiting to userspace with KVM_EXIT_IRQ_WINDOW_OPEN. Link: https://lore.kernel.org/all/YoVHAIGcFgJit1qp@google.com Signed-off-by: Sean Christopherson Reviewed-by: Maxim Levitsky --- arch/x86/kvm/x86.c | 3 --- arch/x86/kvm/x86.h | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6c77411fc570..d714f335749c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12657,9 +12657,6 @@ static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) if (kvm_xen_has_pending_events(vcpu)) return true; - if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) - return true; - return false; } diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 256745d1a2c3..a784ff90740b 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -85,7 +85,8 @@ int kvm_check_nested_events(struct kvm_vcpu *vcpu); static inline bool kvm_is_exception_pending(struct kvm_vcpu *vcpu) { return vcpu->arch.exception.pending || - vcpu->arch.exception_vmexit.pending; + vcpu->arch.exception_vmexit.pending || + kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu); } static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu) -- 2.37.1.359.gd136c6c3e2-goog