Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp244395iob; Mon, 2 May 2022 18:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzskd3gOpjJa1pppApl+RZ2yZg3Un4O2MoQTVOEw7J8Oe6dIrnS8sQIDJo1P3sZ1kpbv28q X-Received: by 2002:a17:902:ef50:b0:156:486f:b593 with SMTP id e16-20020a170902ef5000b00156486fb593mr14240316plx.104.1651540821412; Mon, 02 May 2022 18:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651540821; cv=none; d=google.com; s=arc-20160816; b=MkDHFWu6lNkDiaJ7kb04TlSRf6S+3XOKwcP+YjAsW7vDanS03r4J4R4hOx1d8l0AGX pcDLhrvHzd8jpjVJDhWW9cjCq92PKVUjA2pXLELDLZC50Kk/IOj5xJDg/MHwibRKy1/i 2p1rbScV2QIyMNfwOwjzQo1GS9C/LLagnzFZXoWNOA40hP5x9xXwVYzwq3+ZWL9qdT0/ z7bLTg21RNzV/oxwhW0xNZ2mM2l7/pX8ufy8H6mObQoX0XNWZFVZtzTYKFtPxUSUhToM TvwdSbTuXLXXIKkESgOmBsRmMgYozaQBIIqZwezsylTqcaDrTloB9MGII03aO4ZnbVTn q5UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+IBtO+cMnrAmypfXWBQzEGXxDVRPm5nRpyq/e26Hhsc=; b=exCkSjpJZ0KVBzb2v5vwCwMBdvC5zmNB8uP+0IVdneCY1n939T8mKm/4LQURf669mc 3buAogOIto0eLaWVHbMt30qegGS3FEix1zZSLSb4kyeDx3LuZ201eJVrqGGpTv2tOvyU 7SXVKB2SjYU+0/xIAwgTVpkjzjSW44aLMoQ+hEu6aVBg//QR0CmaidrGd7bnmTosFMUU Qa0izRuwL+8GKnjnLNs81pm/B6PvYwfdlmHtAMK8Gl7aMvGM4Tzpth8l0ka9NMz79xXv ptMFooVVPruVAu3hk0Go0YbYP0LAeNvGLJUt91LRKlnv+w+EfS08ZM+Bd9A/zdf/TyzA HciA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a3-20020a170902ecc300b001569eedd2dasi6196974plh.408.2022.05.02.18.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D236664BD9; Mon, 2 May 2022 17:59:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355567AbiEAWLY (ORCPT + 99 others); Sun, 1 May 2022 18:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233403AbiEAWLW (ORCPT ); Sun, 1 May 2022 18:11:22 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76AC1C93F; Sun, 1 May 2022 15:07:54 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nlHjB-0008MV-VJ; Mon, 02 May 2022 00:07:42 +0200 From: "Maciej S. Szmigiero" To: Paolo Bonzini , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Maxim Levitsky , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 00/12] KVM: SVM: Fix soft int/ex re-injection Date: Mon, 2 May 2022 00:07:24 +0200 Message-Id: X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Maciej S. Szmigiero" This series is an updated version of Sean's SVM soft interrupt/exception re-injection fixes patch set, which in turn extended and generalized my nSVM L1 -> L2 event injection fixes series. Detailed list of changes in this version: * "Downgraded" the commit affecting !nrips CPUs to just drop nested SVM support for such parts instead of SVM support in general, * Removed the BUG_ON() from svm_inject_irq() completely, instead of replacing it with WARN() - Maxim has pointed out it can still be triggered by userspace via KVM_SET_VCPU_EVENTS, * Updated the new KVM self-test to switch to an alternate IDT before attempting a second L1 -> L2 injection to cause intervening NPF again, * Added a fix for L1/L2 NMI state confusion during L1 -> L2 NMI re-injection, * Updated the new KVM self-test to also check for the NMI injection scenario being fixed (that was found causing issues with a real guest), * Changed "kvm_inj_virq" trace event "reinjected" field type to bool, * Integrated the fix from patch 5 for nested_vmcb02_prepare_control() call argument in svm_set_nested_state() to patch 1, * Collected Maxim's "Reviewed-by:" for tracepoint patches. Previous versions: Sean's v2: https://lore.kernel.org/kvm/20220423021411.784383-1-seanjc@google.com Sean's v1: https://lore.kernel.org/kvm/20220402010903.727604-1-seanjc@google.com My original series: https://lore.kernel.org/kvm/cover.1646944472.git.maciej.szmigiero@oracle.com Maciej S. Szmigiero (4): KVM: nSVM: Sync next_rip field from vmcb12 to vmcb02 KVM: SVM: Don't BUG if userspace injects an interrupt with GIF=0 KVM: nSVM: Transparently handle L1 -> L2 NMI re-injection KVM: selftests: nSVM: Add svm_nested_soft_inject_test Sean Christopherson (8): KVM: SVM: Unwind "speculative" RIP advancement if INTn injection "fails" KVM: SVM: Stuff next_rip on emulated INT3 injection if NRIPS is supported KVM: SVM: Re-inject INT3/INTO instead of retrying the instruction KVM: SVM: Re-inject INTn instead of retrying the insn on "failure" KVM: x86: Trace re-injected exceptions KVM: x86: Print error code in exception injection tracepoint iff valid KVM: x86: Differentiate Soft vs. Hard IRQs vs. reinjected in tracepoint KVM: nSVM: Drop support for CPUs without NRIPS (NextRIP Save) support arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/svm/nested.c | 55 ++++- arch/x86/kvm/svm/svm.c | 179 +++++++++++---- arch/x86/kvm/svm/svm.h | 8 +- arch/x86/kvm/trace.h | 31 ++- arch/x86/kvm/vmx/vmx.c | 4 +- arch/x86/kvm/x86.c | 20 +- tools/testing/selftests/kvm/.gitignore | 3 +- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/processor.h | 17 ++ .../selftests/kvm/include/x86_64/svm_util.h | 12 + .../kvm/x86_64/svm_nested_soft_inject_test.c | 217 ++++++++++++++++++ 12 files changed, 478 insertions(+), 71 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c