Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4107940rwb; Sun, 7 Aug 2022 15:14:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR562zNsJ3IfVW2vL4YpwkJsK8wr0S9/jnUhpE8BgRCy4EOj24DibNp4BvRcszBNsHuHXUp0 X-Received: by 2002:a63:2254:0:b0:41c:4b26:863d with SMTP id t20-20020a632254000000b0041c4b26863dmr13299230pgm.4.1659910475509; Sun, 07 Aug 2022 15:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659910475; cv=none; d=google.com; s=arc-20160816; b=dwmRqrNNEveKQZPZgj+j7K/PtkWTFIiwzenx2FCIML7yOXIlO6q+PLz5X9zzaWOYyZ yZPk8JIFc3f3d24tnDXEmhge8QY4gZDZIwiqqjBV7OR3QoQRZKUrhzl+ukS0YhAj8MUP NEdzQeWP51Gd+XQ0wXiCyOxjyE80wUD/LJ4lbJDg77+Ck1HE1eaFaE0i58gvB8PhJgH8 nDtNMkbfnkB/7zl2EH/jcfKrWPexxNiuI3rarHKz0vKP30Vmfq6kWu+7mdae/Dq7HS+R drw7mKQWnzRX92oxOvNPnMELjS4b09jCQ20tc7EnIf46rkMz47M5mlTMet0LQZug8yOh NpQw== 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=6iPdAntCdD+G1xj87Gbkb7WXhEFEhY/FTlSZaxRvaUo=; b=Pf55EyuJKKHTuqc7eyJ6wYjGGwcaRrKAd6rKcinEMfp/B77E9CDTSUlDJLBqxdAXwn cFLEO10/EyKsWk+kwqfEEYz5pkKyIMf7w8jGJ/7x5CGPRha/vWSEwjAOvQ5tS+4WS+E4 puD02WIe0JF709G23PvDGWuB6XI49obJFSU+E/xNvkrEvqaWQhB1FTHK7VP4IgwlKJnP f0b0ff6S6Q+Td37E+CkLvdvNnzgorRIKlC2bYI8zzNdKGqHIqUqZCuXYlV1vQ29FPBwq LWzhHlhhh1zWwVzFvsZTy1jaMxNPR3iYAiJ3c8bc1/d/SVvy0HC/Bmk3ThvceEqh1wvX AGHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="K/SqWjbt"; 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 k35-20020a63ff23000000b0041a4c29e7a3si5252959pgi.272.2022.08.07.15.14.19; Sun, 07 Aug 2022 15:14:35 -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="K/SqWjbt"; 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 S242289AbiHGWKw (ORCPT + 99 others); Sun, 7 Aug 2022 18:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237003AbiHGWHK (ORCPT ); Sun, 7 Aug 2022 18:07:10 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89B7BC05; Sun, 7 Aug 2022 15:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909795; x=1691445795; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oFXIR5guBM3IH/WRfBvZZDq02VrN8ETcFKxC55g5V10=; b=K/SqWjbtV0ehqfT7W3n3xc1dOaGPItuaTWB4GQ4vnSvUE1IZjpfVY6o/ JnsVsrnaKZAsFmVZ7sbdHzJH+R3+esz8d7Ob3dcRPx4y0I4+hDLnHKWZB L+U8oGYZPOVm5wURQmZPi+Ex2jLNDgeA03/8nRA5aBrGRY6HTTYKvnCWV VSpLjKFtNy+0wAKo2M8fi6NbZEBS8g6HGz+UVevXYTFkw4khdDn2+7jqG H1zqr6iylCUX0rIATmg3Y8nyRxsTCU35Of2YQsyf2pescoBFB5jOCxc5N RJg3M8qA333XylWBGEqm4hcmR409+99hIOrNeENqd0PBeHAGjpOju09x0 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="270240396" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="270240396" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682731" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:42 -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 v8 087/103] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT Date: Sun, 7 Aug 2022 15:02:12 -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=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 de618935fe01..7524bd8374be 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -839,6 +839,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; @@ -1248,6 +1267,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