From patchwork Mon Nov 16 18:26:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 11910427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29FBAC6379F for ; Mon, 16 Nov 2020 18:33:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1BC82080A for ; Mon, 16 Nov 2020 18:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388054AbgKPS2C (ORCPT ); Mon, 16 Nov 2020 13:28:02 -0500 Received: from mga06.intel.com ([134.134.136.31]:20628 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387771AbgKPS2B (ORCPT ); Mon, 16 Nov 2020 13:28:01 -0500 IronPort-SDR: WoVba1Axp/k8FrY97SANrXZ96KizjveiwvyTcmPfkcdjqgeaW34QXXkY+6UTQM8YaTOLQDtY9G Tn7yaLoRDXnw== X-IronPort-AV: E=McAfee;i="6000,8403,9807"; a="232410017" X-IronPort-AV: E=Sophos;i="5.77,483,1596524400"; d="scan'208";a="232410017" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 10:28:00 -0800 IronPort-SDR: 0JTcbWU0K0RTbpdP8qYFfT7xWmV1wAD3/6l5xaRUGXdlr+rV4VBpoLMgZWynVipuWDrWMDyAUF bMdOrZHl6M0w== X-IronPort-AV: E=Sophos;i="5.77,483,1596524400"; d="scan'208";a="400527917" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 10:28:00 -0800 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH 18/67] KVM: x86: Add per-VM flag to disable direct IRQ injection Date: Mon, 16 Nov 2020 10:26:03 -0800 Message-Id: <9b3fb23c848a5937b47b6b784aca71427bf2e001.1605232743.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Add a flag to disable IRQ injection, which is not supported by TDX. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index e687a8bd46ad..e8180a1fe610 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -995,6 +995,7 @@ struct kvm_arch { } msr_filter; bool guest_state_protected; + bool irq_injection_disallowed; struct kvm_pmu_event_filter *pmu_event_filter; struct task_struct *nx_lpage_recovery_thread; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6154abecd546..ec66d5d53a1a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4041,7 +4041,8 @@ static int kvm_vcpu_ready_for_interrupt_injection(struct kvm_vcpu *vcpu) static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) { - if (irq->irq >= KVM_NR_INTERRUPTS) + if (irq->irq >= KVM_NR_INTERRUPTS || + vcpu->kvm->arch.irq_injection_disallowed) return -EINVAL; if (!irqchip_in_kernel(vcpu->kvm)) { @@ -8170,6 +8171,7 @@ static int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt) static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu) { return vcpu->run->request_interrupt_window && + !vcpu->kvm->arch.irq_injection_disallowed && likely(!pic_in_kernel(vcpu->kvm)); }