Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp376039lqp; Tue, 11 Jun 2024 07:11:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWiO1ohhBFyBHeVnUUt61VfJPrz2+4euWpVp6hC74ARFt+allUxYNQXU86B2n8dlq8VojeqLaOhxP39yiFUP09R19qtthaDIkBoTlKWQA== X-Google-Smtp-Source: AGHT+IG9AAu+tsHOhkJ1vzLRqK1+JwHyBQTIu2+gWAn7Jn34iNeL40/0Nim2Q1pDj24cgkIbWFWf X-Received: by 2002:a05:6214:4509:b0:6b0:9280:7700 with SMTP id 6a1803df08f44-6b0928077c5mr2593816d6.61.1718115110706; Tue, 11 Jun 2024 07:11:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718115110; cv=pass; d=google.com; s=arc-20160816; b=G2rx80bNZUZRnZFAOC7IoYnjg6z8weq8t/T1j2XY9L3JSBCJZl7x1ooUUk7bUcOFXc cvde9kFJ+NnRy5cuKBQZeANNipaL4MPf40U2Wsm9PCAYW7NIz5zSaAmj5hq/hxaYA2DU L2Xkk6V3SssT1NtNiL5hD+u7HjPZ4zup6RJgjnLzNZj6yoQJ/Ni/1LoMkRr6uv2t2qoi Ggfx1FiSUJ7ph15V3kS9bKVQYtcWyhsBCb93yVJgg0QNXN8/cLPItrU8bJjVqX56SPVL 5nT2tO4Xs9Zuf2XxeB1XNdf7uUKBVSuyP63PJcJne+ZHx6sBQgtOs9WMu5wz3ZwJdvym TM6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=RpDAWqVGKOY605xFCvj/GBOlGGRTneCE6rG1ivSak+k=; fh=woE52pvpHao8A6mMcVdyHZ99bDzTLE3beDzeq1zMMCU=; b=jw93Xl263hNYC4oIT87/bnho5PoZc83CRBZo++OMCCDn+iVMDJz3n9s4YG1i7LmWH6 EAug87i3W6PuQCOvN/rWLqlS512brXvaBIi8/PHHxGlfLNK+QQHN4IW7kEtq5JemIL1e L1o1DRpxku5X3oFTgDhXja+QuUJyIj6Dfo5HIBozMEaFz1p9E40ZLxPteBa9ZOliGSQa 1XjHrfEEumQGtpL0q74djsHPqS4w6T7PqPr3di7afERf7HHqmQQjvQcFeUxX42nbIBNV WqHgpw2hdcfidXp1xHFex7rYH2JSj+Ou1L6cuSy2LUivInEbEhOU8PKMHFMiUQyN8kTI b6OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CGmDUaKy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-210040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b08ff9b6c0si10000366d6.404.2024.06.11.07.11.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 07:11:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CGmDUaKy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-210040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6742F1C22BAA for ; Tue, 11 Jun 2024 14:11:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 998A117D890; Tue, 11 Jun 2024 14:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CGmDUaKy" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 646AC1DDF4 for ; Tue, 11 Jun 2024 14:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718115101; cv=none; b=MBG5yhfYkftJu/mtucKELRBiaZmVoYbJZ3CrvnmAwYz5SBk5Cexju/P1knQMRcY62jFHneKivDxQm/4/mjzrt7OadG4xTbTzVttBrmIkRgYWrVO0+K6x2Xld4KuDR/hvTWLrLaWeSdlgoWafFs1Crx20ZL9pHo5ZTvsE0umlAA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718115101; c=relaxed/simple; bh=pIcYc7qj+KGZTsXvqC+Dyfy5a8D1ol5MLnz6Q2+/6T0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=i5YUBjHWgyKuQF2YfWYCvbIulg4TV4nSMSQCm4C8oqhr8rdyj2/HDtaK7Xfi9RHYeo+zAbNT/Q0cqSZIN4X8PLe7p7DYdh8ciRmyIIwd1U9xgPlNBKQd5MGWSrjxu5cMWC25nFNEvHKYsXBr8Y/pdSSTQA4nzsClmHhfOm/IxYA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CGmDUaKy; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718115099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RpDAWqVGKOY605xFCvj/GBOlGGRTneCE6rG1ivSak+k=; b=CGmDUaKyDS+MXAIOAB2TebwVwrUtllmxzvMDMzE7Fa004x0ITqiEo2+vN/zCthFPqhC1g7 MMPG0cQs1ED+z3Jjyi4jhA/Kv53i4Q+zkiBj2Dv8E9WqZK2LGkzspoj0x6pj9PNx9xzq1z GpxOHZnqKVlyPHCn4ZXrG47p3/XKQqg= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-ui_OQuWEMWWAyXh20vg2Aw-1; Tue, 11 Jun 2024 10:11:37 -0400 X-MC-Unique: ui_OQuWEMWWAyXh20vg2Aw-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ebdc5ccb17so20649211fa.1 for ; Tue, 11 Jun 2024 07:11:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718115095; x=1718719895; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RpDAWqVGKOY605xFCvj/GBOlGGRTneCE6rG1ivSak+k=; b=iv/esMmNkJtifLtGiW8dXrBLxbf6O2GjyheHBSS0b2gE+i1WO6h8dnpfaeUzKBI0m5 QsK1bO3LXjAUgUsHgJzF538+254uXzfr/qGFUI56EbBf7SnK6QFvmbXPPIw1KHyE4oiT xJW+rId6Nvem+KbSEiA2c7Rbf+Xt+ZcLoRJUHc5PWSTKNbTh+wUGYT5mnhfGtfM32du2 jVDfy4912EJNhONeQXahjr3bZESaWgyoHddyjG4vwtks+mfyRXv4jZxYB6SPucxQ6+Rf /paaHe9HEgQvvhKdL6MKBB7c4Wbz2Xc2KFbF7xDKLQdSINwV+CFM83eufvc1PI4EjXta GXug== X-Forwarded-Encrypted: i=1; AJvYcCU4FyQf+6CRCjs9mBIOsfeHoUo3Fn6PGAhK40gUrHWU9vdhE+KhQotbYRKmoUnqO+/bJd7bnZRMgu6ydJKGPdVF7XAf6ZNDOPuk+ZAR X-Gm-Message-State: AOJu0YzwAXC99sGb3vA7hKcwy+LMRibOI8IjNl0a1uYs8zV+muAzpwN6 u9mVhr+xSecVifFIosgnjeDWxAY65lVgKAivDi9kjy81iFjpLnZs22QG+uI3ehZ4vqiYEwjjylY T4VlFmy97fc1o4guF43A56sZs+9k/5FMBuGDhWHUWl7/zw9mCKdEXXlzz6XWxMNMCymmtgsC4Gd 1dQPPmjehJSrSpUNUJALWNK61ZJDDNMFLiIfUi X-Received: by 2002:a2e:9b95:0:b0:2eb:dc60:6ca9 with SMTP id 38308e7fff4ca-2ebdc6071f1mr44281981fa.21.1718115095636; Tue, 11 Jun 2024 07:11:35 -0700 (PDT) X-Received: by 2002:a2e:9b95:0:b0:2eb:dc60:6ca9 with SMTP id 38308e7fff4ca-2ebdc6071f1mr44281841fa.21.1718115095310; Tue, 11 Jun 2024 07:11:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <9c4547ea234a2ba09ebe05219f180f08ac6fc2e3.1708933498.git.isaku.yamahata@intel.com> In-Reply-To: From: Paolo Bonzini Date: Tue, 11 Jun 2024 16:11:23 +0200 Message-ID: Subject: Re: [PATCH v19 116/130] KVM: TDX: Silently discard SMI request To: Binbin Wu 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 11, 2024 at 3:18=E2=80=AFPM 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 t= he 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 =3D=3D KVM_X86_TDX_VM" I'd move it to some place that main.c can see. Or vmx.c as Sean says below, but I am not sure I like the idea too much. Paolo > > And I wouldn't even bother with vt_* wrappers, just put that right in v= mx_*(). > > Same thing for everything below. If it's a KVM_BUG_ON()