Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1982656lqt; Sun, 21 Apr 2024 18:56:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTNj/6sg9uhao8n2JICTSWUKvJmxrIvM0lGE08nvWrR3DjPfJIvehvh9w1wrk75d8zt5VpxtgeCdki44iFKVvpcJC/K2SdyUMz9YiWMw== X-Google-Smtp-Source: AGHT+IE/A0yXekvgPr8PLMXlbpnRKAbJxw9bsv/NLIRdTh+9wk/uW8z1D4aiotNRhKbkIGzAwSHg X-Received: by 2002:a17:902:8541:b0:1e2:6bcd:e64e with SMTP id d1-20020a170902854100b001e26bcde64emr7507076plo.16.1713750982222; Sun, 21 Apr 2024 18:56:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713750982; cv=pass; d=google.com; s=arc-20160816; b=D9a7Cs07441hwlN+c8QxsPwnqSLtHyxsZamzCdFsXcoEb0eAjpu4HMtwJaFpx7JVvI k0JS3NIESacWzOissfFkg5Ql1feQMcR+6gKCC/3rIF+MENofeJ6wegYmOwzfoR0f+FUf RB8oPfSi3ws4jpxeQ7GWunPI51Tg7Vp5GKc4d07qWN0Tnz/IZ35/FWAVoBczubDB3K/O Wimy/adbyX25Vny68FuG4v+uFb84ONtYU2gaDznW0e0tplLCFvOGYlfQ1F7VI4ULXZU0 7q8conLW2NJmlUqu1Pskfn16e0swl+2HOJkPzlyJJ5Hb3y9s0k+ZK3SoY7VL1Oszzuhc 5iLA== 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=MfrEQbg22rSfA+50Q3VgxfhIBH51nbuIJ/AdJVZo9d4=; fh=8scsGQn+hJ1HvbMI23kGOdGh/wtWpH4wdCi8Q1zCFc4=; b=bV8F+tjWHOpZTBfXIe25Ywr9TKi5zVh4fsyyooKf3/yDimKz5LG1QN7pCbkg18G9aY KR0ChjLIWJhviwUvYEwI3lS3Jbn02F2JEROdbqa8nzsJzNiugUcCusWN+J+dmyheZZ9S EryS+7vDXDqpDnH/zj/vb2UoRXTKlA4m7QkXIslDlQ6ag+8ej6iXnwauctxk62CmJ5Tb o16ra2Sw8Z7WU15h9+ZnPrqdQe8LkA3TbLafy+uz+V1VM02nnXVfIYH0yedeW+r4VNwy Iqy5B2lWpegvdVjPbB1McOgwPLyaD4htRN7ka0B8/0XOCNVdeLonP3nyxq9Lx1l5t5dM rZRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e8Vrgf8w; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i6-20020a170902eb4600b001e43e674a2dsi6951343pli.379.2024.04.21.18.56.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 18:56:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e8Vrgf8w; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152674-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D447B280E65 for ; Mon, 22 Apr 2024 01:56:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7FAA4C66; Mon, 22 Apr 2024 01:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="e8Vrgf8w" 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 64D032595; Mon, 22 Apr 2024 01:56:12 +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=1713750974; cv=none; b=kA5uwtXtMbECYmwWxMY1Pmpnaq5KoWrpfuLUXC4dgUTjuSXqLsnEtZ1DZ1Mg6G7PZZ9ONCcU/FMSLojIPYztpsleaWycjciaGzW4S2wJrQX4zWPTaQd5HowEntXt3c6cLlFlbFt7D9DGZaZoTp0TJcpXhAhuCNcnD/q2hqobUX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713750974; c=relaxed/simple; bh=pc0+DFhUnhDyqWAXr1SyPZIimJcwgm1tRpRj/vXiOPI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=s1upm3H7wEU06oP3GNGIzjZotHNlqlXJL03Gxt+rHRd9rVFDDON/BXvXcXcb3Bb+gf1drJxuujMDilD9eOIiRFCXrgyzVuleKym4DVuuaUUZn7p5x78YkAAMTxtNMPislQmcn5zryivQmyRqiX+gH+6lw/Y+nBCDTXSG9bTEhGI= 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=e8Vrgf8w; 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=1713750973; x=1745286973; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=pc0+DFhUnhDyqWAXr1SyPZIimJcwgm1tRpRj/vXiOPI=; b=e8Vrgf8wkggUkIm8gXRVpuvg7yTPD2/cA//yq+LXC/y9Se3xPqp7g/7e Jjpki3Tge+m3DuplQuWyHXeWndLoWH14wS1fHSiox1qUIR40p/GaF3QE5 79aiDkurvzXlvQNnCTjKNT87Dg1VM89s6giTYmFIfpfODYNoWPnMrpzR6 ElaTDncXG4s50/T1cyWdXLmSE/XqOyxqKTYeGi31ZTZ8mKExM7qnUoRQ1 Y6dXiPTVvvSL4hhAdT/dUo+c4HwylVtGjeySN7q+TaSM1/CHcZPuC4A8C qvs+D5Kv6KDqwmukahYnWgbbP2bBXsSxJbS79NfWLVKAnu8Zb/Wsqfa1F Q==; X-CSE-ConnectionGUID: jYx0fKqITTuvJSW1O9Z7Yw== X-CSE-MsgGUID: rhEFXTPKQ6WBC1RzFPvNDw== X-IronPort-AV: E=McAfee;i="6600,9927,11051"; a="9131984" X-IronPort-AV: E=Sophos;i="6.07,219,1708416000"; d="scan'208";a="9131984" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2024 18:56:12 -0700 X-CSE-ConnectionGUID: wi5hlz+XRde6C1OlC/+K2w== X-CSE-MsgGUID: 834t/sWqSJqftSHZnQR6OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,219,1708416000"; d="scan'208";a="61310180" Received: from unknown (HELO [10.238.8.201]) ([10.238.8.201]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2024 18:56:08 -0700 Message-ID: <1a3f4283-0dfd-4b7d-ae1b-f22c13a8c4e1@linux.intel.com> Date: Mon, 22 Apr 2024 09:56:05 +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 125/130] KVM: TDX: Add methods to ignore virtual apic related operation 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: <52300c655b1e7d6cc0a13727d977f1f02729a4bb.1708933498.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <52300c655b1e7d6cc0a13727d977f1f02729a4bb.1708933498.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/26/2024 4:27 PM, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > TDX protects TDX guest APIC state from VMM. Implement access methods of > TDX guest vAPIC state to ignore them or return zero. > > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/vmx/main.c | 61 ++++++++++++++++++++++++++++++++++---- > arch/x86/kvm/vmx/tdx.c | 6 ++++ > arch/x86/kvm/vmx/x86_ops.h | 3 ++ > 3 files changed, 64 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c > index fae5a3668361..c46c860be0f2 100644 > --- a/arch/x86/kvm/vmx/main.c > +++ b/arch/x86/kvm/vmx/main.c > @@ -352,6 +352,14 @@ static bool vt_apic_init_signal_blocked(struct kvm_vcpu *vcpu) > return vmx_apic_init_signal_blocked(vcpu); > } > > +static void vt_set_virtual_apic_mode(struct kvm_vcpu *vcpu) > +{ > + if (is_td_vcpu(vcpu)) > + return tdx_set_virtual_apic_mode(vcpu); Can open code this function... > + > + return vmx_set_virtual_apic_mode(vcpu); > +} > + [...] > > +void tdx_set_virtual_apic_mode(struct kvm_vcpu *vcpu) > +{ > + /* Only x2APIC mode is supported for TD. */ > + WARN_ON_ONCE(kvm_get_apic_mode(vcpu) != LAPIC_MODE_X2APIC); > +} > +