Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp480625lqt; Fri, 19 Apr 2024 01:21:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX32lg1hSy/RgAl7esEtxKVg46BWsz4N6R/WOohHVDoiObQuwGescYQM1tjoZfjVI6Kxlu/uC2Se90JRKHhfvRxZSgILetbRY96+YdN2Q== X-Google-Smtp-Source: AGHT+IEB/w1Qvwug56lG7M2rmGparV2XBrB2AwyKOmt0rThZNCxzfSZkwTIS0gPptaOctkXCNNjf X-Received: by 2002:ac2:5499:0:b0:51a:cfba:839b with SMTP id t25-20020ac25499000000b0051acfba839bmr41100lfk.35.1713514901739; Fri, 19 Apr 2024 01:21:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713514901; cv=pass; d=google.com; s=arc-20160816; b=JESnUhFYC431P7Lve7JgFPT3ZRZwsv0uh+fAK/Txw+BB54+A1ReMHWgX5lPrWmG1ht 5rxPsHqNNK9lPWvHw3CxJs2Kjm9UFVDbu9oqCzj7J+rZElM5OIr7Lbpc1dq3qwESTNT8 FyEqp6gH8gV9viwbx0INoHl4x+5dGWF6Nj1eft+/U/3dv0rrVeQ6gmuNSouJba7vm5C3 9XDIilzTVUWZRVhN5NvJLjU0rwl0m9me78p10joEYsximT8PCtD8JYSgzQ2qZJHMuIPe k9Ad9xfFcsCOy86NXoGxnhtLfZ9F3M3hADlX2Hn0n7VGPe1Cp0IM7TyONt0APdAIfGw1 vyyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=eYjGpCPyeWK2sj3jV0vx5x7iuv60LnJG0TwbVQ2lmiI=; fh=8scsGQn+hJ1HvbMI23kGOdGh/wtWpH4wdCi8Q1zCFc4=; b=UZZHwUj/VgAkwT40dbJxKDf5Jo0dnTJEeEeLnbSIYcA2XLc+BolUkjNJw4Gny1ZZCL F3tp8V+8fTVxxqoPzCZ7vtiRC5Ut2J52+b2kLJ7U0nXpWatwAaTMWw0177emfm+cPHQ7 ilSNCyRRcBLx8moEgfuQrDO008NtzKR9weGbHNsIv8sNJEKE52l96rsmUpIwB5xca9DX ecoadSVyyREAz2UldGc3NSI0i7TYtA4SUsTg8wlLiPcQCBXASJlHk1SXInRWPFiiDcG8 HPpoomFKhuFgFUL4/WtdYnH6gEeCvw1LynrMlWkzTeqEgDvevXwb0/yl+tTtzfspJWWR 7OGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AOc+NMFp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-151083-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151083-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 i12-20020a170906698c00b00a51cb37909bsi1781324ejr.107.2024.04.19.01.21.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 01:21:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151083-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=AOc+NMFp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-151083-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151083-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 8A7D01F22245 for ; Fri, 19 Apr 2024 07:05:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1634D3E494; Fri, 19 Apr 2024 07:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AOc+NMFp" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 8A928171AF; Fri, 19 Apr 2024 07:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713510303; cv=none; b=Huoja2ZJUGevBH++c44ZgaG+blVN+vlpjn7PG/ktedy8jmesNBobGBNO38G2rbhMCJMqwprbdJHk023I6xtlp8AzGObagVPluoWakANA8byN1w0U8Rs44teVEr9Q3cr6VHsH1CPgxopF67iOAApY/LkyA8D6YFY8ejTsObaUGJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713510303; c=relaxed/simple; bh=pMSBPEkWDp/jsic95GP6gMJqfatPqHB7pZ/fZMqhS0k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pPNMao+L1i1cLJmamR9FjdLnmMfRouLz/DS4ZGxqlR6yPyWumCQHVq0rxSPKglpuV1PJ7Bxr5ONsE19cpadqjX5LpMvOce8gFvF7WpPu73nLyto6DzbGa0XoB9mZf+3LftiVrSUkfEBNvU/7dY2qOz7gO0KrhOYVOJlQ+6y6nEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AOc+NMFp; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713510302; x=1745046302; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=pMSBPEkWDp/jsic95GP6gMJqfatPqHB7pZ/fZMqhS0k=; b=AOc+NMFpxnUz8DYj0YN0SnNxRiAfso7sWy8WsMivP9vyrYZnYXK3oxaP pTxwfa5wS9fdyoPkQsffkBwSbYlvBDTy2wqrbuQ3ccmgHhQGcysfr7gt8 FNMuRrFs9ICF4ddSvym9Jw2MDnE4Us5gWvxEgOYXrnrPksJYcKO7MIyY1 HhpC+0slzbM6bW8YiwHfeGXuXkZ0MvjpNehkKfPbq+u264245YCAS7pvm 2f/6/HpGgzjzvY9jw1DQuOrsHy1z4P9wZ4ufU+buXWgrRRl2pXKJQuX1b quv4+vWvnMmYzpPgHkXrmPTCSzXbLzIeMKXje2LRebTbAmKIw3XYUIli5 Q==; X-CSE-ConnectionGUID: onbVQJBdR96mQ8dLkIre+Q== X-CSE-MsgGUID: W6Hf6dsVQFe7lidSJkFEQw== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8958406" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="8958406" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2024 00:05:01 -0700 X-CSE-ConnectionGUID: TYAZJSYfS3eHb68wJrlaXw== X-CSE-MsgGUID: mRy+ATAURBith12OO/wGXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28027345" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.225.183]) ([10.124.225.183]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2024 00:04:57 -0700 Message-ID: <384458a2-c7be-4443-bfe3-5408a749a476@linux.intel.com> Date: Fri, 19 Apr 2024 15:04:54 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 116/130] KVM: TDX: Silently discard SMI request To: isaku.yamahata@intel.com Cc: 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 References: <9c4547ea234a2ba09ebe05219f180f08ac6fc2e3.1708933498.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <9c4547ea234a2ba09ebe05219f180f08ac6fc2e3.1708933498.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/26/2024 4:26 PM, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > TDX doesn't support system-management mode (SMM) and system-management > interrupt (SMI) in guest TDs. Because guest state (vcpu state, memory > state) is protected, it must go through the TDX module APIs to change guest > state, injecting SMI and changing vcpu mode into SMM. The TDX module > doesn't provide a way for VMM to inject SMI into guest TD and a way for VMM                                                             ^                                                             or > to switch guest vcpu mode into SMM. > > We have two options in KVM when handling SMM or SMI in the guest TD or the > device model (e.g. QEMU): 1) silently ignore the request or 2) return a > meaningful error. > > For simplicity, we implemented the option 1). > > Signed-off-by: Isaku Yamahata > --- [...] > + > +static void vt_enable_smi_window(struct kvm_vcpu *vcpu) > +{ > + if (is_td_vcpu(vcpu)) { > + tdx_enable_smi_window(vcpu); > + return; Can "return tdx_enable_smi_window(vcpu);" directly. > + } > + > + /* RSM will cause a vmexit anyway. */ > + vmx_enable_smi_window(vcpu); > +} > +#endif > + [...] > > +#if defined(CONFIG_INTEL_TDX_HOST) && defined(CONFIG_KVM_SMM) > +int tdx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection); > +int tdx_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram); > +int tdx_leave_smm(struct kvm_vcpu *vcpu, const union kvm_smram *smram); > +void tdx_enable_smi_window(struct kvm_vcpu *vcpu); > +#else #elif defined(CONFIG_KVM_SMM) These functions are only needed when CONFIG_KVM_SMM is defined. > +static inline int tdx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection) { return false; } > +static inline int tdx_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram) { return 0; } > +static inline int tdx_leave_smm(struct kvm_vcpu *vcpu, const union kvm_smram *smram) { return 0; } > +static inline void tdx_enable_smi_window(struct kvm_vcpu *vcpu) {} > +#endif > + > #endif /* __KVM_X86_VMX_X86_OPS_H */