Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4666476ybz; Tue, 28 Apr 2020 16:02:20 -0700 (PDT) X-Google-Smtp-Source: APiQypIl6NHZ8TzQvrunor14OlF7sI6Lwu5Hilq4AD6rcyYhKdPuYyPIwlcjdCSr6857ccRVyHIO X-Received: by 2002:a50:de02:: with SMTP id z2mr70026edk.292.1588114940787; Tue, 28 Apr 2020 16:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588114940; cv=none; d=google.com; s=arc-20160816; b=FVzaD2bJw8iGs9mxBwqzBwRdqTBRW7gMwqPpa7AHTxrAVXHPQvW+AvXBDJtbB6MV16 WbLzT7afkbbu5N29qQkhJxz4N8RjJhHVFFjGRrQmwRO0oFyp4qrmCyNaUTyUm3nUI8qo XiymgmUJjH+LTgqbuvOiJM28tGKwp7STHLK94YS4d2W/jXDBI+f8YpTFlZIeAOEP9/t6 N8aenYaD6hF084VMRv4viNzPBujxmb0m8oZq3wyKcg15X+8DtvAQNjLHGXxqaVKD3FFf Qq8FiUQc/G6i16y/YqM/T2TQHm9HEPWd4E41BPkSbSK3dPmXX05lchba/g1NrmwFg5VW wfpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=0gD8ESW1LNMNPhFjAjfZQZL+ox/eM0UagcoQto/ILa0=; b=kDnVNmpOaioJVhPeUgZE3wmBvGVvB2py8UfDzwfy0D0bKi0hsdftzKmwbXEcilHCcO Zd5PoulWd3WDHl8DcBmTzF1Yeke9MVX9BPBUIArZDtBkPRioE5q/q+MMEjqAMAO4y438 H/VCAyvhvoawQ8jo0mqv9amtFCYoQ4z0kX11OFm0/WhXnSpTMilRpjypsn5++Nch5YCF 55xJfEyFIqiu93DeqUcTnW18mukU6yUVLh9FoRJvDd/3yw03mNbVdZT9b3qG9Qn2HuLw wNc9t5NpLQ2TemMuyitcX9m7FAZqRJOLOArpMMXiaOYBgEIbBOdL+PfS7ZyIg6bKJ/yb zxyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si2344033edq.390.2020.04.28.16.01.56; Tue, 28 Apr 2020 16:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbgD1W7u (ORCPT + 99 others); Tue, 28 Apr 2020 18:59:50 -0400 Received: from mga06.intel.com ([134.134.136.31]:34722 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgD1W7t (ORCPT ); Tue, 28 Apr 2020 18:59:49 -0400 IronPort-SDR: 17JYpusfx3wqeAcXgrT20D8bbng2g8fPPxAmysmfymBQjzl8HAaFuEuDfGJGqJG6sDgsKjn7iz i2EixqJ7V3OA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 15:59:49 -0700 IronPort-SDR: FvwbRXz7kliL1mLjNirEPURHs2TcLkEdMsEFv0ZhSYG0aC/xjPkrz/fN1UKWCYn78sFrTzxOnA Lv9+xwG2tQMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,328,1583222400"; d="scan'208";a="246656016" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga007.jf.intel.com with ESMTP; 28 Apr 2020 15:59:49 -0700 Date: Tue, 28 Apr 2020 15:59:49 -0700 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Oliver Upton , Peter Shier Subject: Re: [PATCH 09/13] KVM: nVMX: Prioritize SMI over nested IRQ/NMI Message-ID: <20200428225949.GP12735@linux.intel.com> References: <20200423022550.15113-1-sean.j.christopherson@intel.com> <20200423022550.15113-10-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 03:04:02PM -0700, Jim Mattson wrote: > On Wed, Apr 22, 2020 at 7:26 PM Sean Christopherson > wrote: > > > > Check for an unblocked SMI in vmx_check_nested_events() so that pending > > SMIs are correctly prioritized over IRQs and NMIs when the latter events > > will trigger VM-Exit. This also fixes an issue where an SMI that was > > marked pending while processing a nested VM-Enter wouldn't trigger an > > immediate exit, i.e. would be incorrectly delayed until L2 happened to > > take a VM-Exit. > > > > Fixes: 64d6067057d96 ("KVM: x86: stubs for SMM support") > > Signed-off-by: Sean Christopherson > > --- > > arch/x86/kvm/vmx/nested.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > > index 1fdaca5fd93d..8c16b190816b 100644 > > --- a/arch/x86/kvm/vmx/nested.c > > +++ b/arch/x86/kvm/vmx/nested.c > > @@ -3750,6 +3750,12 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu) > > return 0; > > } > > > > + if (vcpu->arch.smi_pending && !is_smm(vcpu)) { > > + if (block_nested_events) > > + return -EBUSY; > > + goto no_vmexit; > > + } > > + > > From the SDM, volume 3: > > • System-management interrupts (SMIs), INIT signals, and higher > priority events take priority over MTF VM exits. > > I think this block needs to be moved up. Hrm. It definitely needs to be moved above the preemption timer, though I can't find any public documentation about the preemption timer's priority. Preemption timer is lower priority than MTF, ergo it's not in the same class as SMI. Regarding SMI vs. MTF and #DB trap, to actually prioritize SMIs above MTF and #DBs, we'd need to save/restore MTF and pending #DBs via SMRAM. I think it makes sense to take the easy road and keep SMI after the traps, with a comment to say it's technically wrong but not worth fixing.