Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1884829pxv; Fri, 2 Jul 2021 15:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTBuWn7QwW7GyDfyCGwROkHc9mTQ3yynZ/pRRfalXdjb6SKmXWQjzN5tamwp+tAkCBJ0N2 X-Received: by 2002:aa7:df19:: with SMTP id c25mr1991980edy.80.1625263681657; Fri, 02 Jul 2021 15:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263681; cv=none; d=google.com; s=arc-20160816; b=hAUTAqAiEMPZdN83frSkMGsIZt61Xp/4lAmUYpCADDfhthzA6HpcbrQUi6Jv9cYPKI pEQx+KgsNBII+lmP6qiNc9kcTuM3g7Mi6WWXhvRs9Aj77svo6Xn+K9BmP4RmqwezrPex z3BNMJ/hIUdamXA5HpfxuvU/IuaUarH5bMp7OPU9cgysB0JBFKNNJrZPJByqt1/cWrcY +Ck0uh7dgAuE1/pVcTUSw7t/OJY+GL3+VKEUahgjGyBipg5CopFKvj8RMYWWfeTtBdCL wPdc8rGqxCQkwjvc911XhloM0rjZt3Wpu9/cIB7Vx/oHpS1tEuw8ptgTI5dmVikuWiph 2XTQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HHw0rI+eVdo53elCKKaBxNMveZgQoZVS9rMLX/uqEZY=; b=TAy1j/S7idcpw9hKavcLy9NE477OU7pTq2+FBu7jm8zrzef+w9K/HKt7TWuSzdngO0 OXINoqgONAoOydJTtNJ+6gP5VoxIxN6xiHg0l0m/Q2gqh9rfKVMMkkmXa2vY8t+XdlXK uQvA6IvgKouV7bKRtMJfn7jHVd12S9g3E3+Unk3oSj0kFasUEBmcN9x1ee1/CqEZLTmB dpWfmZty9Wg64pG/qiswIetMa2KovDzt0/8fxZ0wBkV4ch9Rbi8l36NjVfDTwD+CJxi5 wuHhTdXX7ufmogD8CqrZJUyHlec2PHEa6R2t7eL7ZiyUwWL9isPdhP0QcK3jnmIoqSnO dnqw== 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 p11si4341447edh.404.2021.07.02.15.07.38; Fri, 02 Jul 2021 15:08:01 -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 S233705AbhGBWIc (ORCPT + 99 others); Fri, 2 Jul 2021 18:08:32 -0400 Received: from mga12.intel.com ([192.55.52.136]:50197 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233119AbhGBWH5 (ORCPT ); Fri, 2 Jul 2021 18:07:57 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="188472731" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="188472731" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:23 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814753" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:23 -0700 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 , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , 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 v2 25/69] KVM: x86: Add per-VM flag to disable direct IRQ injection Date: Fri, 2 Jul 2021 15:04:31 -0700 Message-Id: <15c51e04bc3c5c2b6131c649291a3ee1b006abf0.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Add a flag to disable IRQ injection, which is not supported by TDX. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- 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 301b10172cbf..be329f0a7054 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1063,6 +1063,7 @@ struct kvm_arch { bool exception_payload_enabled; bool bus_lock_detection_enabled; + bool irq_injection_disallowed; /* Deflect RDMSR and WRMSR to user space when they trigger a #GP */ u32 user_space_msr_mask; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b89845dfb679..4070786f17d1 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4264,7 +4264,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)) { @@ -8562,6 +8563,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)); } -- 2.25.1