Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2903355lqz; Wed, 3 Apr 2024 11:51:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPsdLj6U5DKunUGRJapmm98HgBn4fsC1wV/TnkyPoabUUKoxUe1+R1d5/C/IxLtxS/iKUf6miuh42AfAgnsl3Fee3HC05qCNGdMVgCxQ== X-Google-Smtp-Source: AGHT+IHqDKJFKPf3Aq/SWqAJfHpMtzJFJTjtX7wBfNmdK/+wvThoMAfd76KR3Sma0KSSEMWdDk38 X-Received: by 2002:a50:cd5e:0:b0:56e:c29:abef with SMTP id d30-20020a50cd5e000000b0056e0c29abefmr139543edj.34.1712170280207; Wed, 03 Apr 2024 11:51:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712170280; cv=pass; d=google.com; s=arc-20160816; b=EnDY3jTcMeEI44d69zvvTrWuV6BfcI4d3yUnv1/gBxnc8+19OQm1CSVdkPNDV5bCZK e0VzC1a39QWZvp/OhkDTcuE8GzTq0On1JoOneWZPTabFxKELM4o1OwPiRy1ETfCwpo0s gF4zSFpwesESzyCkE8XamxEhKo+DD93+C9RAFwzVtGxjR4xN78rg2DnGjNhZ/3fYLJo1 nD8PIxuwHTYc5i6lyQmcko6Mva1suD6C8F3mPty+XKEF+TSwSvyX2nCuuFdN+QwvHd8q P8fvEQXjm7zqhkTayclTmOTbMOnrp4pR9OG6SIjKLA65zbbl+oO5Gr0SM7nybQ6PDe0Q cYhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VEWBLbo5dyqiOocdbHXxfxTUb0T07F1z56Vxjt7qFGk=; fh=tt0CEY5xhom/IlvDKU6vi+rzDvhB3cKAIKF4sAkibAI=; b=iVn5IePedGoVitDBKSAmeXgYDmUOXotgWEnGZU8i8x1NgFg29lzReOjxENFltzgWAM BoZu0dG1BhFswn6OiDgB+YN8C9l/xUN+HbJzYTEjCFcqsRxWSU+06TxbwvPuctF1QlEh VzuHAP0BZ46t46PFYYByqen2lDbKwFVpu0bTYQ6zltXyFYglc5xFVmoi9zvKjhFbjCv6 UX+mSHRAp1ojpDrXYunZZgOpu4wIgUJECtvZoK3w+p7DyBgH3PuaQJ15436jxMslZ2mT x1NJAPKYe9yY9RBXTbA5TlR21ZevsK15/fGdu75awjvlbIwP0bYkP0ROtcf6fzk3s9RS zTrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Kg/Pc4Yq"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-130475-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130475-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fd5-20020a056402388500b005656776bf67si6812937edb.655.2024.04.03.11.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 11:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130475-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Kg/Pc4Yq"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-130475-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130475-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EAD5D1F23307 for ; Wed, 3 Apr 2024 18:51:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA57815445B; Wed, 3 Apr 2024 18:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Kg/Pc4Yq" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1C3F839E1; Wed, 3 Apr 2024 18:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712170266; cv=none; b=jlrD9jd3pSGw7rzFa5EGnnRL1uQYXv5p5Q8Cs3F+3ZwcNIRh4g7HtGY5mZ+l/F2dv1OO85DkJzF/PLH2mWfmEoIBI+rnywTWTP5cMLjkD+iqqAQeKFSHwrFKOl4HuB+RCCjodfdesnxKPWxK61bRKEGxOuL4JJ2mV1JrdlM1JVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712170266; c=relaxed/simple; bh=lSO5a/LR2abT5IbXVMvLNuvxnTKyJrqDXsHF2+SQ84c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DOPnOApc+tSSq5vwFpn383JYsfLlnUtqaiAoUsf2KMDzfddZ+daaXUgrxa2m9O8hfv3LD28GzOx6kp8A3GpIYyVnWIgT6mb58ZO92AW+/wiegCN4TBlwlB8Hf1Dp1atMHLBOkAwJcbtUrMMzWvVkveHqM05w/ELuGpd6yBfbxec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Kg/Pc4Yq; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712170265; x=1743706265; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=lSO5a/LR2abT5IbXVMvLNuvxnTKyJrqDXsHF2+SQ84c=; b=Kg/Pc4YqmTqkPvPpBJ9HmgPGeTjOSRvshMnFRLBo7+L1AohuBpo5673f PXoC+dA4I2+8+1tOYg74oAMEW2SPuDBZg91dttMLH785wTAAy8/qkxmOx ln11dX8QWoLtKbGhuUr+XvO9WELc9kS7q2XjAOMtLAbZCIo7TU2Ytbb4B bD9h1iUoWV5GEUm72wmozgxetYsdOHul5laGv49e6HX4zGChNkKWnQk+3 dJ+26TvENI2U/KWSLFiYv4eAqWFkKohWVT6boH946eOlONPV1BjPSBlMH D0eS5CAqK83Qv4sqDl7frg1vtDtCtL39+okzBc35a57FfOskk6x/a47ox g==; X-CSE-ConnectionGUID: UZAiFbdXTfqZqQtOtLm9Ug== X-CSE-MsgGUID: ncrA96eMREOKF+CJZod54w== X-IronPort-AV: E=McAfee;i="6600,9927,11033"; a="7538817" X-IronPort-AV: E=Sophos;i="6.07,177,1708416000"; d="scan'208";a="7538817" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2024 11:51:04 -0700 X-CSE-ConnectionGUID: anH6KJ8vRluvEQv7Pt4gmA== X-CSE-MsgGUID: 1UMUQKVqQGGMzXn/qWPyXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,177,1708416000"; d="scan'208";a="23290440" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2024 11:51:04 -0700 Date: Wed, 3 Apr 2024 11:51:03 -0700 From: Isaku Yamahata To: Chao Gao Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 102/130] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT Message-ID: <20240403185103.GK2444378@ls.amr.corp.intel.com> References: <3ac413f1d4adbac7db88a2cade97ded3b076c540.1708933498.git.isaku.yamahata@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Mon, Apr 01, 2024 at 04:22:00PM +0800, Chao Gao wrote: > On Mon, Feb 26, 2024 at 12:26:44AM -0800, isaku.yamahata@intel.com wrote: > >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 > > tdx_handle_exit_irqoff() doesn't handle NMIs. Will it to tdx_handle_exception(). > >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 0db80fa020d2..bdd74682b474 100644 > >--- a/arch/x86/kvm/vmx/tdx.c > >+++ b/arch/x86/kvm/vmx/tdx.c > >@@ -918,6 +918,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; > > Add a comment in code as well. Sure. > >+ > >+ 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; > > -EFAULT looks incorrect. As this is unexpected exception, we should exit to to the user-space with KVM_EXIT_EXCEPTION. Then QEMU will abort with message. -- Isaku Yamahata