Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1314068rdb; Sat, 3 Feb 2024 01:04:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpEB3L52PJxzneHo04YgGJQqCTGEzy4YtOKYez7QPoBZ9oDhd6ZiTnN6J+p5FjvfUKHzbT X-Received: by 2002:a05:6808:130b:b0:3bd:dd9d:a3ab with SMTP id y11-20020a056808130b00b003bddd9da3abmr12738414oiv.42.1706951059461; Sat, 03 Feb 2024 01:04:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706951059; cv=pass; d=google.com; s=arc-20160816; b=UquBhN81Kx0r4+L3n4saGQE+OHVVlKMpBpefPHlEBR4y4++P7k0nbaYB1J6os+wRKt /fsmVRO76Xj19NmaUca4aAiplcZSmdYmzKgXwRUeSsTIyqY6DmJXm9nn9jUx+9lwXQY1 TZ+hR9gpeyTb4MtcMc9DEW/+aQrhjhS130lzldf17SVAlOMV2HYBslVLUA5f5DpgJbvY HZrzq3PCG8JVu2Dn532FtJcv52giVQ0NPOCWA9SpdZRWz23Pfzip1iA0Hzqxoj3IuP9/ 5wW1wCB2zUfB9XdBnb7ZwPN31NikEagGcLd/myFIQ8/DJbgjQJAuqktNQXiQvQJMuVrY sA5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VSRuA4EwT51rWJMzMk0M15pYWUVVnhINNZhjeG+LSDQ=; fh=wTN10LCh0IIer8oGpuPNLklvvqccQrrikFEp9/iR57k=; b=v1sDpADMuKHGyQttpbEdNSUD34dbvF3tkNwGTMboaVWnIIYhWx8ozHZS0PdVjgSpGA XRtz60RavzlUmUSQRdV4eAMOvjDOxetON3F82LAmJ8Du9iX5fVEIFtis0xzkd2CimNQl NuBwZVG3vEJWGVBF3jzp6zh/QCTT7bS9YnQb6TMy2TRYbc112hN6/RJxZW4pNXoP2zVk H0TW5p9Sk+EXGAD+EpA4XUql2bpih4ETn76Jtnri/c9kf/wfMYmh16W5suVHnWITqpzp 1W05rIB4+iphhhrtqNoYkl1MQsPjtER+XUr5RI3WA0TUfIEGUIqd8liaeD3oxJgVcLQp FjDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=B+ztlGDJ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50990-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50990-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUvLoyqm4ysugj7xAtV/ZeaD60IRQmj+mDrg9Uhxw6xvnuP0yyzFm1slDnhUsB6cIlpgwNJjPVO8CfA7x5rc1RwYfdwwigU+zv/wEN+cQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s27-20020a05620a081b00b0078543d8bd4dsi3853137qks.571.2024.02.03.01.04.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 01:04:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50990-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=@intel.com header.s=Intel header.b=B+ztlGDJ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50990-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50990-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 08A011C27E76 for ; Sat, 3 Feb 2024 09:04:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C4CD5FDA4; Sat, 3 Feb 2024 09:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B+ztlGDJ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 357335FB83; Sat, 3 Feb 2024 09:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706950856; cv=none; b=E5qUu5ni4G3RBNbBQNLusJLzWgdv1SI8vhkC+uT129HzTqROm0zJ1k4mA32SF/rz2orD4X9NSooPUYogMTdaa8FoZBOChKFSljHFq3s7eRDKYmtcivm5Ei6ZaeGPekeImV5RGgs50DvFfKaRs1MFjqX7ZRCpq0Vs9Em8wEEPhAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706950856; c=relaxed/simple; bh=xuhB6ti18yKxtjfmmEA4k56Sy3StXgqJYsS1nszVK90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bv7JYMiajwWvSaIpgaQpW8L05Ki6ac1Ee8q7LtitG6ElffeCjBvFvpmjGfNrc3vMXiGjiVkEBqHYHVlFoXPOK1Mr7/uZ58szU29Nu1/SqfzPbNAvm9UaN/ntdLl7QNNzyxH6lZ5bG16XCvj2NNQY7JXOpE/UGH9QLd3X0QDmMSc= 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=B+ztlGDJ; arc=none smtp.client-ip=198.175.65.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=1706950855; x=1738486855; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xuhB6ti18yKxtjfmmEA4k56Sy3StXgqJYsS1nszVK90=; b=B+ztlGDJ3I4kpBbMIE3LTOQlXmNBXXW+uM9Q/mrh0x8LOSPgJMA1L8WI H4mdRYiQmV3QOqg+IuNz2Ox/QCwXXm9uNagv72T1qWK43stAKQftg+w7l +/VItCHcPr52eJ8uS6LOQx5xgzkbmqQDRncfJThMIuyb8RW438+HpZj1d qNW4+TrTpSvBwUFaXxLd4Ph9/nc70cdUqz4GoMGvzzRpTPZvb1EXgJRkL XUKeaPgZcKdwTtgK6NLYyjRcRVOH02ohXHUWVXEuBeFI8vkaV1x9ahOIW 5Nwm2HRbk5NTN8ufq+eyLcb6c/bMQgcgCirVsV6UeXc6Q2DILjVuy+q55 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="4132013" X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="4132013" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2024 01:00:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="291369" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa009.fm.intel.com with ESMTP; 03 Feb 2024 01:00:49 -0800 From: Zhao Liu To: Paolo Bonzini , Sean Christopherson , "Rafael J . Wysocki" , Daniel Lezcano , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: Ricardo Neri , Len Brown , Zhang Rui , Zhenyu Wang , Zhuocheng Ding , Dapeng Mi , Yanting Jiang , Yongwei Ma , Vineeth Pillai , Suleiman Souhlal , Masami Hiramatsu , David Dai , Saravana Kannan , Zhao Liu Subject: [RFC 12/26] KVM: VMX: Introduce HFI table index for vCPU Date: Sat, 3 Feb 2024 17:12:00 +0800 Message-Id: <20240203091214.411862-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240203091214.411862-1-zhao1.liu@linux.intel.com> References: <20240203091214.411862-1-zhao1.liu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhao Liu The HFI table contains a table header and many table entries. Each table entry is identified by an HFI table index, and each CPU corresponds to one of the HFI table indexes [1]. Add hfi_table_idx in vcpu_vmx, and this will be used to build virtual HFI table. This HFI index is initialized to 0, but in the following patch the VMM can be allowed to configure this index with a custom value (CPUID.0x06. edx[bits 16-31]). [1]: SDM, vol. 3B, section 15.6.1 Hardware Feedback Interface Table Structure Tested-by: Yanting Jiang Signed-off-by: Zhao Liu --- arch/x86/kvm/vmx/vmx.c | 6 ++++++ arch/x86/kvm/vmx/vmx.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 48f304683d6f..96f0f768939d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7648,6 +7648,12 @@ static int vmx_vcpu_create(struct kvm_vcpu *vcpu) tsx_ctrl->mask = ~(u64)TSX_CTRL_CPUID_CLEAR; } + /* + * hfi_table_idx is initialized to 0, but later it may be changed according + * to the value in the Guest's CPUID.0x06.edx[bits 16-31]. + */ + vmx->hfi_table_idx = 0; + err = alloc_loaded_vmcs(&vmx->vmcs01); if (err < 0) goto free_pml; diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 4bf4ca6ac1c0..63874aad7ae3 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -362,6 +362,9 @@ struct vcpu_vmx { struct pt_desc pt_desc; struct lbr_desc lbr_desc; + /* Should be extracted from Guest's CPUID.0x06.edx[bits 16-31]. */ + int hfi_table_idx; + /* Save desired MSR intercept (read: pass-through) state */ #define MAX_POSSIBLE_PASSTHROUGH_MSRS 16 struct { -- 2.34.1