Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3532927pxb; Mon, 4 Apr 2022 20:12:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDHcjt5NoV9yG1+riYVNlvFYIgPBZqhiWvKdOI/9iEGbQTn7KOK3cJq1N0DMwPoj8w09R4 X-Received: by 2002:a17:902:f789:b0:14e:ebbc:264b with SMTP id q9-20020a170902f78900b0014eebbc264bmr1198663pln.169.1649128325098; Mon, 04 Apr 2022 20:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128325; cv=none; d=google.com; s=arc-20160816; b=tt/gyk8DlCIfz4iiiovDF942hWgzbDgySBNF9N835MF/JCA2SpN25sB1L6u3iHv6PA jeqBfZtpEeQxgMdIznPwtfMKK5P6YRbdGgBgxhShRA/T369PFLJ0d0WczHfiR1OODhgj Wq2C/BBtZyjdSXIsY4hu8bxYqmv5cEbWwCYtPHad7spBoMn9L0aeP2uIZ5VmuDOzKtHE auTb+Xv9ak26HnbDF3u2V9+ppgERn1/+FoXJsfUlBaNV7HckwLnOq8yYhW3SFeAXyP9w 4O0gGYUSnXInxfr9o16hQmRmcUlN0Xq3MFMbX1kAe4tKW04fHWW4dEOYFiUrRfCC6nvu H1tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=rzHOJTWuG4F8y35S9XsZI2ky5Bjudg359QwD8OTFa/4=; b=C10q+ZH1HKi8hfHyABfdxl0qQLIHEWZlwUygpDyTyQDendUdACibHhcElF+lhQD7MI HjyVOnB2dEI7u/hbprIX6trrDTFAQ4Sn/TmWB47vreM/1MJWH3XIAwfwRiMeIQGKuehv q9lGR7tNu3WeAXVnNv3I/wnQB1D2JqNFsBvpxTRprIWdapd1SgI3jRok9o8/jYkjPgOu mQ+CbHa00yK5bwZR1me4L4yPruOtB7y+Vmbrur3oLnjGcqAQb7XZraaRKIPR3BhRBZdx r2Awbtw6rFaywlOTxx/8TkgeOMzQxOQ88nZJjbx5m4NwDbBK6t3G0oohJQHTAPwJJv4K +T8w== 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 6-20020a630e46000000b003824f9f2affsi11171813pgo.451.2022.04.04.20.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:12:05 -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 48C24449609; Mon, 4 Apr 2022 18:12:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348282AbiDDWFD (ORCPT + 99 others); Mon, 4 Apr 2022 18:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380562AbiDDU3i (ORCPT ); Mon, 4 Apr 2022 16:29:38 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F9C2DAB8; Mon, 4 Apr 2022 13:27:41 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nbTIS-0003aH-H2; Mon, 04 Apr 2022 22:27:32 +0200 Message-ID: Date: Mon, 4 Apr 2022 22:27:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 6/8] KVM: SVM: Re-inject INTn instead of retrying the insn on "failure" Content-Language: en-US To: Sean Christopherson , Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220402010903.727604-1-seanjc@google.com> <20220402010903.727604-7-seanjc@google.com> From: "Maciej S. Szmigiero" In-Reply-To: <20220402010903.727604-7-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 2.04.2022 03:09, Sean Christopherson wrote: > Re-inject INTn software interrupts instead of retrying the instruction if > the CPU encountered an intercepted exception while vectoring the INTn, > e.g. if KVM intercepted a #PF when utilizing shadow paging. Retrying the > instruction is architecturally wrong e.g. will result in a spurious #DB > if there's a code breakpoint on the INT3/O, and lack of re-injection also > breaks nested virtualization, e.g. if L1 injects a software interrupt and > vectoring the injected interrupt encounters an exception that is > intercepted by L0 but not L1. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/svm/svm.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index ecc828d6921e..00b1399681d1 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -3425,14 +3425,24 @@ static void svm_inject_nmi(struct kvm_vcpu *vcpu) > static void svm_inject_irq(struct kvm_vcpu *vcpu) > { > struct vcpu_svm *svm = to_svm(vcpu); > + u32 type; > > WARN_ON(!gif_set(svm)); > > + if (vcpu->arch.interrupt.soft) { It should be possible to inject soft interrupts even with GIF masked, looked at the relevant code at patch 3 from my series [1]. Thanks, Maciej [1]: https://lore.kernel.org/kvm/a28577564a7583c32f0029f2307f63ca8869cf22.1646944472.git.maciej.szmigiero@oracle.com/