Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2066743ybe; Tue, 3 Sep 2019 07:32:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqze06xO6wPlAVscU4YowaUlA/34l+XLF+XWbCguaovaDV6K+HmqpOk7sQBbN2ySLYIyNana X-Received: by 2002:a65:6256:: with SMTP id q22mr30681163pgv.408.1567521137316; Tue, 03 Sep 2019 07:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567521137; cv=none; d=google.com; s=arc-20160816; b=mERuY7gkRcTFtdUzrDatH89Q7LSmR9S7nXKIWcavm8NX5SK7UMGKFIGOhxQ4Hn4MwF 5uGfSzJ9eRmMIu5nUb6hj3iLMicfRXDMnUOhtmT4jYm1LRM8xI7LqdePlosH7/X6ugQf pMkeT1SqAgZKin3nvahoDAtjUqleZrl3XAx9cBR1UTMXRXIucOa0R4CHGzuMS69DPtjm Qeps1jh4TfwwK10aoKI9P0VVTTRHPK6wt7/TODIitMq7m0OpYLrVAkGEsOvEKI8KS2EN nzKSdql78DnwJPYGoHS4OGpPW6lcKjOftSm4jVu9ct9xLJizSfQPrNGJ921U3hcGqD9Q wf0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Y3tldZVleS6/uO69vfM735Y3BEnG4rxL1Yj6ScUvmq0=; b=DAWoMlGi/l/WYjvrJhT3jLdhPmaXYYl2jKxCvi6x77Js4q5LktB9apA+C4X20w1fAc hgIoLj8jRCjmm9TYt9OneXnebE6NBExH7zR6dMNyyrktwISXtFyhyjtpPlSpdbuPRKZ8 lXfCkcwzAfFjAwwQ+aowWfdeHHt2hb0+JdGxaZTsnAj4dbKtaSZuVzf/m52O/mcFs5sl HXBgkZqtQUOMn5R8AVqYnTPbfSwJTOjCAVgbV8hwkCJ6TKROF9Re1dJW9EVIztvrer3P iEx29Yxw5WcaNiQJtA0J3D+wcxYpnNAdPwF01E+UWdHHgW0UaGYvrRo6ImaiUcqz0Nsg 5+6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=macv1Uxw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si14694204pgp.475.2019.09.03.07.32.01; Tue, 03 Sep 2019 07:32:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=macv1Uxw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729813AbfICOaW (ORCPT + 99 others); Tue, 3 Sep 2019 10:30:22 -0400 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:62499 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbfICOaW (ORCPT ); Tue, 3 Sep 2019 10:30:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1567521020; x=1599057020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Y3tldZVleS6/uO69vfM735Y3BEnG4rxL1Yj6ScUvmq0=; b=macv1UxwCGEVyvQfJR/io6n5m1vjtuHFrPWhHECa/ZdGpUPIS0QA2ctk T85FmjZn+0dGo4Qo4RwCIJbDz3LeyR8IA/rvBzrgMLQz3Z42kyNvEzEwr c5yv93W1wqcm4XmphBm6g2A7wt5j/Js+N54EGBRYMRXfPBgw/DiViqCOo 0=; X-IronPort-AV: E=Sophos;i="5.64,463,1559520000"; d="scan'208";a="783035776" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-859fe132.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 03 Sep 2019 14:30:18 +0000 Received: from EX13MTAUWC001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-859fe132.us-west-2.amazon.com (Postfix) with ESMTPS id 25247221C0E; Tue, 3 Sep 2019 14:30:17 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 3 Sep 2019 14:30:08 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.162.242) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 3 Sep 2019 14:30:05 +0000 From: Alexander Graf To: CC: , , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Joerg Roedel , Jim Mattson , Wanpeng Li , Vitaly Kuznetsov , "Sean Christopherson" , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini Subject: [PATCH 1/2] KVM: VMX: Disable posted interrupts for odd IRQs Date: Tue, 3 Sep 2019 16:29:53 +0200 Message-ID: <20190903142954.3429-2-graf@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142954.3429-1-graf@amazon.com> References: <20190903142954.3429-1-graf@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.242] X-ClientProxiedBy: EX13D27UWA002.ant.amazon.com (10.43.160.30) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can easily route hardware interrupts directly into VM context when they target the "Fixed" or "LowPriority" delivery modes. However, on modes such as "SMI" or "Init", we need to go via KVM code to actually put the vCPU into a different mode of operation, so we can not post the interrupt Add code in the VMX PI logic to explicitly refuse to establish posted mappings for advanced IRQ deliver modes. This fixes a bug I have with code which configures real hardware to inject virtual SMIs into my guest. Signed-off-by: Alexander Graf --- arch/x86/kvm/vmx/vmx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 570a233e272b..d16c4ae8f685 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7401,6 +7401,28 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq, continue; } + switch (irq.delivery_mode) { + case dest_Fixed: + case dest_LowestPrio: + break; + default: + /* + * For non-trivial interrupt events, we need to go + * through the full KVM IRQ code, so refuse to take + * any direct PI assignments here. + */ + + ret = irq_set_vcpu_affinity(host_irq, NULL); + if (ret < 0) { + printk(KERN_INFO + "failed to back to remapped mode, irq: %u\n", + host_irq); + goto out; + } + + continue; + } + vcpu_info.pi_desc_addr = __pa(vcpu_to_pi_desc(vcpu)); vcpu_info.vector = irq.vector; -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879