From patchwork Sat Feb 3 09:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 196233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp947820dyc; Sat, 3 Feb 2024 02:25:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF09MjpJGDX8Y59ccTKIjGF6g6BFQU50y5jk39KPsFsqa1MClS4wUNe+fIndI3jrvCSE6Xt X-Received: by 2002:ac8:61ca:0:b0:429:9e63:57f4 with SMTP id kr10-20020ac861ca000000b004299e6357f4mr924144qtb.56.1706955909587; Sat, 03 Feb 2024 02:25:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706955909; cv=pass; d=google.com; s=arc-20160816; b=kQA++evO4aYWb1VSPsLvFLXkw9AovJsIP3mVGB9gJ8G9FkTHK254TQzfeAwLDRhZ4v 7IFTqv+odLQKpAUlLUNCA4TPgk07j6JhUbpHSrAe+gJ7RYoVbd+C0ylxBJSXrIacevJQ sDgiEwDcnoCZR98Z7lCHGKQAOP84LXpkvCb8NWfxb8Ctekcet5Z0GnT0RJhhT9HR/g8P J1Oe7GIXXfZXgc3thRQbNTBaj8yTMbTufU2QdHw51vOdufrUNJVkMKpKQvB0o2tS6XbG YBT7zpqpRAwGN+TbB6J7/mgkaw0EqBqvns3oKsmLYscQOCMaP5OZ/yT1MICBbA9Xuejq GliA== 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=r6dzgGut0keklvVJHwarwVCtSBngywzP8My2o5tknPA=; fh=7R8VIopY0RgowsQp9xJeqEN5xvAct3j2DelU0wnduXg=; b=gUoFmrBWaXAhpV0/QMGn6Qa3Sj8WwXTSH0o6V4mnUw7ZXF7g7s+G8UwsHk0LXVkPpg i9t0yXFYvg8X9ORgjaM16kWtwHMpz0r+mrKKmp4M7as7UjJKHBkTiaidusyx6qKi6lA8 SMmcKPgLXkug95byJBjTI+aj5/O668NzBOOmWZWkkfe+nRqWjEc8etY+tpkLr/e+9gI6 ii/mY/fgGT3CvQNLr9KU2AYxp5uYsve1S9sHYMFa3ZFyTMD/4Pi/D/gX1cDetuw36Kfl sPeP/PZpOve8EDqZK9TYkyQdYznwsDhEpLvEHr4iGKLnMXKE4lWdU+WauMtOhzNbKTwl Dciw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ho84Tknx; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50994-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50994-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUsDcFKwFjrW3VxGBhyNj1N9l1JePP6plY18O4PepJAsyUKxpR1CUoyDe15+wQqC+KKKEqF5ZKHQlPVgQ36riaFFHbpMw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s16-20020a05622a179000b0042beec2b951si4000918qtk.77.2024.02.03.02.25.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 02:25:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50994-ouuuleilei=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=ho84Tknx; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50994-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50994-ouuuleilei=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 9570A1C28864 for ; Sat, 3 Feb 2024 09:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11EAB60DD1; Sat, 3 Feb 2024 09:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ho84Tknx" 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 DBF8C6086E; Sat, 3 Feb 2024 09:01:17 +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=1706950879; cv=none; b=UaGQTJqd38Ux+1UH/zMbkyTZJ7wyhVeUEwnaGNANCeGAv0uqJUdUM5mudZpYYvtGLXXl7DddxskIzsua+umUPtDLbWo8tGgshtgbNzyHRT00OvZ23SPBwms2Xwiz1Klg1sSB4xZbNaHfCWJCpJGUeis/qSqNcVqe8MCIAKwHuRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706950879; c=relaxed/simple; bh=o9Ea4he1GyJdoS3fqNSGXkZQw07L9///FXUYj80JU5U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oLhRptss+HYgza5tvMN2hw4SKyBx71bmpStT+7/c27Y325Rdwgw/GseVobg/FuTcqMv7+pJxkzeAmBrItsWUwHEHfTQ/sjyJsqlKQhwhTYZfejVc0AoyLvvl+UwTIKJxLTm0XK6lzx+Eg9JixGZagWnTvwwVhI4wR41QrdiTbK4= 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=ho84Tknx; 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=1706950878; x=1738486878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o9Ea4he1GyJdoS3fqNSGXkZQw07L9///FXUYj80JU5U=; b=ho84TknxSFDncqBiIGAInwPEc9R1sZIU2l7u5x6rySaMBs8YvndVtUro fVFoF+XKepcIRIVwcLuEKq9GlIWFkjCRBD9+PrLhA/6YBOWhk0FbSz6Df x2++Q+OzoyrxVCPDKwWq4ezXLGNY6vd+nrqjXn86RvB2wlGM42xsQmwUp 1czQ//dGkTV2DoYrMLovGsCbVdudttw8V2nLZ9uJunDS3ZH5VpDNQ6Y46 SxBsw3eXNOa91AFOVzZDMC6iD0ILANm5zJ+acuD1lHLA1SSbhU1QECmeo +5GWtX3O36LE6ZOtZyx81/35TnAZ9eQBwrd4DKuDoRww0gnfsazBe6oF9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="4132054" X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="4132054" 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:01:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="291457" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa009.fm.intel.com with ESMTP; 03 Feb 2024 01:01:11 -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 16/26] KVM: VMX: Update HFI table when vCPU migrates Date: Sat, 3 Feb 2024 17:12:04 +0800 Message-Id: <20240203091214.411862-17-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789872999870133292 X-GMAIL-MSGID: 1789872999870133292 From: Zhuocheng Ding When the vCPU migrates to a different pCPU, the virtual hfi data corresponding to the vCPU's hfi index should be updated to the new pCPU's data. We don't need to re-register HFI notifier because currently ITD/HFI virtualization is only supported for client platforms (with only one HFI instance). In this case, make the request to update the virtual hfi table. Tested-by: Yanting Jiang Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- arch/x86/kvm/vmx/vmx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 0ad5e3473a28..44c09c995120 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1735,6 +1735,17 @@ static void vmx_dynamic_update_hfi_table(struct kvm_vcpu *vcpu) mutex_unlock(&kvm_vmx->pkg_therm.pkg_therm_lock); } +static void vmx_vcpu_hfi_load(struct kvm_vcpu *vcpu, int cpu) +{ + if (!intel_hfi_enabled()) + return; + + if (!vmx_hfi_initialized(to_kvm_vmx(vcpu->kvm))) + return; + + kvm_make_request(KVM_REQ_HFI_UPDATE, vcpu); +} + /* * Switches to specified vcpu, until a matching vcpu_put(), but assumes * vcpu mutex is already taken. @@ -1748,6 +1759,9 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) vmx_vcpu_pi_load(vcpu, cpu); vmx->host_debugctlmsr = get_debugctlmsr(); + + if (unlikely(vcpu->cpu != cpu)) + vmx_vcpu_hfi_load(vcpu, cpu); } static void vmx_vcpu_put(struct kvm_vcpu *vcpu)