Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2620510rdg; Mon, 16 Oct 2023 09:35:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL0aKIrD0ODxkM/FKsrl/KiCYAQWxQmgWofE60Wqsw9h/PuuYKi3nheFx/3cB2z9HgOnz2 X-Received: by 2002:a17:902:d504:b0:1c9:aac5:df30 with SMTP id b4-20020a170902d50400b001c9aac5df30mr24669139plg.66.1697474138400; Mon, 16 Oct 2023 09:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474138; cv=none; d=google.com; s=arc-20160816; b=wPWPTt7wVnMjF5V9wiEo2JKqgrW+Ph7mOsUPghB9DwmlvNxT8sDKsdRiajmyAAnEmG fKSkOo30dl8y7L7MQW4BX2HWDpS0SfUjYL5EkLwRfHRL4EhIqU0tSdzzJcCyJdQcZiV1 Q+eAgc3HiNV6AigbhyQS9DgNuseYLcAw1Qidfj93cH99ISsL+alT9yMAQonp0vm093rQ iWjkqwJnW76amnHs7KLRaAha/uuDeF7D8npz2Pvwuxi7R9nYlqQJ0b6uHrvYcDid7CMY g1Arl+XpgEjWGS57eWuC0lNjbaX8xyc1hx/TsuCfbsR3Mn5ODTrThLaIBD/EGOpkY2ve PfYQ== 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=k5evOdE37+5OmB8p1NG05NAPMo3354kszcLQHHnu6M0=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=TM2H9AlTgvgbAcepau5bznvSmmfUbIEQecwukfCGeecUVup2Qn3DJHzLbf3cIrYXfo N0CXUW6Je88nO3VKi1gakSh4j5k6Omef55fLsRVvSqqLaO4O4k6kYiq8Lhwvb5PkkCfQ DHiI1Rvc5DT8prK3MyCUbyVbW+AB0vFC1x/tDNde6XAUs0AXTpOFDDYjA7u7A560HgMr R2Zx5LmDzuTGqGIxtQw+8tn6I0oK7srhzmUHu+8BfrKA9fYs4KNY54fbgF4ZjMKL+kgW ZKetx8mSr1qz4e4DRucGHF0yPIF06xgK84pCl3ygr1yVR9YYtsRAEvL838FnXqpAR1Xg jtxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OPXa8Dzo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d12-20020a170902c18c00b001c09d893c94si10523916pld.612.2023.10.16.09.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OPXa8Dzo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AF2648022003; Mon, 16 Oct 2023 09:35:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234099AbjJPQfX (ORCPT + 99 others); Mon, 16 Oct 2023 12:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234123AbjJPQeU (ORCPT ); Mon, 16 Oct 2023 12:34:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F323469D; Mon, 16 Oct 2023 09:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473209; x=1729009209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MsBktsb3DAZzlx1/Ek1C6F/9rTLE6JI+J9Y+xXj79Bo=; b=OPXa8Dzosc9Jf1o1F5uVb+Clncb39WiEQS6MbEYPbbm9YrbZqX/GsqAC +4KCqGciHD1hXLB9pSFXJVMHkLB2bMBIhNd9ylGJRcHZe/daZvx4cEqd5 cV+xPVZD3c/39ROJ1uMXLHxhk+wkUszJnDA6hNXS+5NaWZv4YksXygN0f 1bw+KO1WVNZJljcjy6mpMdjnCRlEjKLkEh5kLaiSy+B/HVA0FwL+V1N97 WsHWxBDhhTsEoGQSGmKv/oy9MjCEmIHwbOX44vhXoGgoFe9Iyf4NzLg86 ho1TnPYEtHokvx36nCPOdHHfwVMDwhkcq4wIcFCyq/Wq3Lf6DZ+TBCWTQ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364922012" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364922012" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448273" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448273" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:02 -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 , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v16 086/116] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT Date: Mon, 16 Oct 2023 09:14:38 -0700 Message-Id: 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:35:35 -0700 (PDT) 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 f98b27cb9003..6bed75c4069c 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -892,6 +892,25 @@ void tdx_handle_exit_irqoff(struct kvm_vcpu *vcpu) vmx_handle_exception_irqoff(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; @@ -1381,6 +1400,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