Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp474315lqp; Wed, 12 Jun 2024 07:15:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVjtO/RNEGDgt5RwJJgdVlFc5Wet+T5FK58ZNgL0y2KoH927ahaCWglhGgAx8XFuS8KRodM/Y5ytDK7OS9h+FeMFfhLpOt2TreemsveQ== X-Google-Smtp-Source: AGHT+IFNVzcVhw4ouXiJTh/9P70XTJrJY6jOcR26NWoTl+2GHEmXV/hmCuOeYHV51H5PBV7ukYgn X-Received: by 2002:a05:6a21:788a:b0:1b6:d8bd:c428 with SMTP id adf61e73a8af0-1b8a9bd082cmr2349905637.26.1718201739594; Wed, 12 Jun 2024 07:15:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718201739; cv=pass; d=google.com; s=arc-20160816; b=kdWUKDciuvbUX4z9rLJFcXKoYidwFNOzCIcHrvxuj/rIHzaCDRJ+hLCXvtYreIRTT0 xYFeB21Lb6sZ4XLc49fZndhGchj267kGQQOcaoGYIDrJnlkPbW7on+qOIplH2nLwB1Hz 0cRSH49/S5l2CvOvsrnE/yAT0l2+nVCQRLwQFRWNq5YJh6vEgUkZ6j/jqh+XlpURuvB9 1zs/ipXaiYqXOkY3ME9xa/y7UL0RVzEz3RyZDht61Nd8MCz39kGviuglGZHIsvE0/904 8crH+qMyaOCmWO/4mTkBeCJ46FJF4ZZSnzwOsHQy0Iml9QTsLD+sJ8r9AoiR0xz5gjL3 UeKA== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=9f+pNTj/JYVr1NFCr6lio+IDNrmZKKPO+/OIOzTgEPk=; fh=bfU6EAp4Q8ZYcAmOHgm/RHs1d7b8IpxKrPXRi3hS85Q=; b=SW60YXFhdsJ++861ClQNfTbF/tYF1sgt9RrXV5+p5O7ISn7VBWcnTKRFvenTjFa7mN RbZu/q5TIvxm4e19yfHCcvHDQpcuQEr/lTz0W4xLZqxKLx7EPbJUyC5mGsRkIHQtDfFn BAhFSiOeAFISHzmOCKAWyXZPd/3Lrfu2E0Ww1wxvJB+ZNfhfvsCFtDzgjKgEyFgrGXQi b3WgrpXbmxzBel+jcwaybQZ5amOtq2dlZJhPoHSBfqVv6G3vNC/95x27vu/wQO+BG3k0 wX6kInm84cCZoPP3Q5m+3Ej71p7j0Kf/jgeJ9LwqIDU+/6MX7FLgQEugaU+LnyjpdtNf Q3Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Usxm4G/p"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-211533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e8ae5dca27si7705479a12.750.2024.06.12.07.15.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 07:15:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Usxm4G/p"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-211533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211533-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C09B4B21DD0 for ; Wed, 12 Jun 2024 13:07:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A73B17A92D; Wed, 12 Jun 2024 13:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Usxm4G/p" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 7BAED1D54B; Wed, 12 Jun 2024 13:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718197608; cv=none; b=KjTAMHZdM4c7h3r1+/h6JoLwoyw8FfqzOjAukvdcXUDV7nlF45NyppBIGpwTG1dOvV6KGGJEV65Xb7vws+ls/R+D6mUWKK+ZrSj63Dx41qJiqbzsoeg3kCNYVmmXZf5FhRZEEzwGsNYngxDZny8PZD8/7CjO//leELlF4a3AOkM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718197608; c=relaxed/simple; bh=aIayRRsQaPA/oqt1m3vRxSNmBQNMixeu/uWFnr2hb9o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=p+ZRnnfAQve6nadc/dAu9PX0fNjzqNUN/eHogFBuvBpcIUxOspg0qU9/+yPJCeaItQKyWdJ6+/FlcYEzJ9AVS8enb377EapYVtWCh4Rn+cnwVkmTgJXmJ6lkfABB+fKbChUIHYgonuu5O6TGpKrIhxieXJAZB3F8Re81ecW7v1o= 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=Usxm4G/p; arc=none smtp.client-ip=192.198.163.14 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=1718197606; x=1749733606; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=aIayRRsQaPA/oqt1m3vRxSNmBQNMixeu/uWFnr2hb9o=; b=Usxm4G/phZQxxYegJaLchXxnbXYDMObQs0hfED0849AvKGuhsVFoUdLP Zi/kVhVRb9ACDtrL6ATo/deGudJoRDSdjcrLjYWtyw1gS+UMgbQzBwv8k JYj0gnWprHMKDsm1FvLHQOGtVMInRsbPI1SG/yDNzo6XM9rrmJZ6OEeGg wmjQ4pUm9qv9NfyF+NMTiyYv13kHpU8jT1HRt1Da0WDiFQcVQx8Jnc3Tg xMA6BHerRbKw5h5YCgTyx/52MoAemLTbzwqb+fUp1IBvZFQZNn2GE1+Ge Se6jLU/+iqxAXvtxzzBbC9OBry1wHdrADlI8htABX7Jtav+87S8ZSZ06M g==; X-CSE-ConnectionGUID: NBiRkOZoTgKUPKO9lscGaA== X-CSE-MsgGUID: t/OBqNjyTXexmVwU3uC1Pw== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="15190825" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="15190825" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 06:06:45 -0700 X-CSE-ConnectionGUID: +VOr4MHiRouuDc5MeUp1LQ== X-CSE-MsgGUID: 1J7nmcFhTHSAKfh7h9oYhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="44722784" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.224.116]) ([10.124.224.116]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 06:06:43 -0700 Message-ID: Date: Wed, 12 Jun 2024 21:06:40 +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: Paolo Bonzini Cc: Sean Christopherson , isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, erdemaktas@google.com, Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com References: <9c4547ea234a2ba09ebe05219f180f08ac6fc2e3.1708933498.git.isaku.yamahata@intel.com> Content-Language: en-US From: Binbin Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/11/2024 10:11 PM, Paolo Bonzini wrote: > On Tue, Jun 11, 2024 at 3:18 PM Binbin Wu wrote: >>>> } >>>> >>>> diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c >>>> index ed46e7e57c18..4f3b872cd401 100644 >>>> --- a/arch/x86/kvm/vmx/main.c >>>> +++ b/arch/x86/kvm/vmx/main.c >>>> @@ -283,6 +283,43 @@ static void vt_msr_filter_changed(struct kvm_vcpu *vcpu) >>>> vmx_msr_filter_changed(vcpu); >>>> } >>>> >>>> +#ifdef CONFIG_KVM_SMM >>>> +static int vt_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection) >>>> +{ >>>> + if (is_td_vcpu(vcpu)) >>>> + return tdx_smi_allowed(vcpu, for_injection); >>> Adding stubs for something that TDX will never support is silly. Bug the VM and >>> return an error. >>> >>> if (KVM_BUG_ON(is_td_vcpu(vcpu))) >>> return -EIO; >> is_td_vcpu() is defined in tdx.h. >> Do you mind using open code to check whether the VM is TD in vmx.c? >> "vcpu->kvm->arch.vm_type == KVM_X86_TDX_VM" > I'd move it to some place that main.c can see. is_td_vcpu() can be seen in main.c > Or vmx.c as Sean says > below, but I am not sure I like the idea too much. Which you may not like? Remove the vt_* wrapper or use KVM_BUG_ON()? > > Paolo > >>> And I wouldn't even bother with vt_* wrappers, just put that right in vmx_*(). >>> Same thing for everything below. > If it's a KVM_BUG_ON() >