Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3461960rwb; Fri, 30 Sep 2022 04:05:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5W6Yo6Kw4uEWC1+E/41XHHRCbsa6Yf5XIoKFAWOe6f7WmdUtGGLtrszpuKHpqXDKPkJcey X-Received: by 2002:a05:6402:c45:b0:442:c549:8e6b with SMTP id cs5-20020a0564020c4500b00442c5498e6bmr7418923edb.123.1664535923997; Fri, 30 Sep 2022 04:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664535923; cv=none; d=google.com; s=arc-20160816; b=wHJyx/Yhs70pkin60WadDk18GVUrBJMoeoJUWRZy8NDpqP4EGGG1zIl5Ma6IdP/ZRD pNe/zN8ZP5OxfZRtFY/75P/x3Trxurc1uEqgXlZlx0ztJdQ5H8y8kCnoDk7aJVHcl86v YfE/NhjwuR5/Q65oEUf6BMEfrMk8zMhC8GQlZ8NPK6iHgv77m8BjM9h3ngef3CoRbJdH tAgnDGl+6B36mVSJKe6Tj+634P+f33Wa0EiNv8UalYAPzRsOL0RH4PMXJOxDistmDbIp A41lYtKIk88RSgsuS9UprT5E2ofz0qAbhzx0ZTf4RQM7eQ8Tx+AUiw5QyJrc1u2amGoQ btzw== 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 :dkim-signature; bh=VfepGAL82iBGNZTgaOxhMV8LjtmZKSU1hZkU8U0DfCk=; b=ALsnNuKEDDt03FsTtYgRZGHixMpp/WtK1YDJVTPjtNttnD7SEYi1KersHcXbqubEOQ Ue/W7oCp0xYKvhg1ry+zIvAFQRyKeedKrevd3Cj/pZskIshYSnazUtWaNDpezpuFttOP Og16yTzq3BnpoLFUpS5/OrF+qG76Ct13x6GHEAgUj3dbDDDFfa9L1c7ebj7suJPfMkJ1 q3w0xV0PeaGYkvDLhJ6q4+fS/hsFgbCYIA8FLCajL8JLcQUN5aKZi24EPcS4BUw/NgNw DgsZxu1GKFL96V4qcm3fmjw3BUEvg+ba3z0WSnvwSyh4Gqn/Nujq7f+i4X0qX7cGkSAg /z+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N8KScZOF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a17090682c100b0078306c5c48asi1460931ejy.250.2022.09.30.04.04.56; Fri, 30 Sep 2022 04:05:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N8KScZOF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232378AbiI3K0A (ORCPT + 99 others); Fri, 30 Sep 2022 06:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231864AbiI3KUk (ORCPT ); Fri, 30 Sep 2022 06:20:40 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 702AC1F8C12; Fri, 30 Sep 2022 03:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664533154; x=1696069154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ST4szoZsbOwYTc04ubkpP+Tdapj3PLlz5Lv25v02VM4=; b=N8KScZOFuf2z0INRIfUFKYv1CHaUGSDWVkHPxTegpQUfqyEQiLpXHxVg HgK2YYcycX2c8JQqKdvcsfaJ7RL7uFxDjmJUI4Tuw7SqxfWgW9AdQ+fzX krGNx7vfPuFRiwHmxhliin2ys+2Sl4KtSX9ZhOWZujDXnfK6qpmF95mdY 49XlWERbD2BW4kdNhLlIugFPSfEuZocQos2eDQHRrwwvL2zEeggfmu9Ji ctSpcCpMGLECOhztqu4ybGxvuoF27rz4Gd5vH7EYcNI21yo7AAt0siZ7b QHL8pr7xBD0iNqOOldujY0FpdCyaSuDIBpbJCVarbHb79Hs2KQTGBji8V Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="328540160" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="328540160" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:19:06 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726807791" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="726807791" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:19:06 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [PATCH v9 088/105] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT Date: Fri, 30 Sep 2022 03:18:22 -0700 Message-Id: <56197179cc33dd80efea20058e09077b85a43ec3.1664530908.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 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 From: Isaku Yamahata Because guest TD state is protected, exceptions in guest TDs can't be intercepted. TDX VMM doesn't need to handle exceptions. tdx_handle_exit_irqoff() handles NMI and machine check. Ignore NMI and machine check and continue guest TD execution. For external interrupt, increment stats same to the VMX case. Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini --- arch/x86/kvm/vmx/tdx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index def8eb3df75f..7edf28a36d83 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -707,6 +707,25 @@ void tdx_handle_exit_irqoff(struct kvm_vcpu *vcpu) tdexit_intr_info(vcpu)); } +static int tdx_handle_exception(struct kvm_vcpu *vcpu) +{ + u32 intr_info = tdexit_intr_info(vcpu); + + if (is_nmi(intr_info) || is_machine_check(intr_info)) + return 1; + + kvm_pr_unimpl("unexpected exception 0x%x(exit_reason 0x%llx qual 0x%lx)\n", + intr_info, + to_tdx(vcpu)->exit_reason.full, tdexit_exit_qual(vcpu)); + return -EFAULT; +} + +static int tdx_handle_external_interrupt(struct kvm_vcpu *vcpu) +{ + ++vcpu->stat.irq_exits; + return 1; +} + static int tdx_handle_triple_fault(struct kvm_vcpu *vcpu) { vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; @@ -1079,6 +1098,10 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath) WARN_ON_ONCE(fastpath != EXIT_FASTPATH_NONE); switch (exit_reason.basic) { + case EXIT_REASON_EXCEPTION_NMI: + return tdx_handle_exception(vcpu); + case EXIT_REASON_EXTERNAL_INTERRUPT: + return tdx_handle_external_interrupt(vcpu); case EXIT_REASON_EPT_VIOLATION: return tdx_handle_ept_violation(vcpu); case EXIT_REASON_EPT_MISCONFIG: -- 2.25.1