Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1353308rdb; Sat, 3 Feb 2024 03:05:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9HSxtD/xWKd6ukzIgLUG0l8G4pWX1oTWmJszIQu8cgCVyiW9D9Csf1fzJOHQSRWdsyMN8 X-Received: by 2002:a05:6808:148c:b0:3be:8d4b:bf76 with SMTP id e12-20020a056808148c00b003be8d4bbf76mr12773075oiw.45.1706958348433; Sat, 03 Feb 2024 03:05:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706958348; cv=pass; d=google.com; s=arc-20160816; b=tErBZaQVowIVhEwDaUhu8cn7BhS8bBb/3eI1bq0fQnZe8J51N+6u2BzvAqQkQ6/5JP RMsqVqqSp1jRDDtrDhnkwPzLhwQGCj1LFI+AOti+cs2ozZaVEHP9Vt0n2bDsdHvMRCU5 N+KbYAq/7WvsAdqzSXurK3XfCguXuh0QzrYBPQLNd78Bo3rBeyq8oLLIYdGhJwkOmDEp 694aREcjiWTJAfvAHF6+aNR7B76Ms5B8TNCC9xy3F/Rign6bWrigPQ+SdxHcRMYCUXOI s89aE3Ta1wflzYljka8T3zeQklcDsnwINWy2ZFGxGz0/E6YyDiF31/T8B0KwIsllDcOG NRIQ== 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=0NKzDy97q77fi3j2C0i2Y38ughfA32KcRNOWkpe68Rk=; b=YSviEzh+KQkNBrblE93rqFGir+ucf1ei/Csj4+fk52PhUAkOkIiRaITpl0wDdMy9qY J7DzHmXnS4SzS65QxW1DguRig8q+lcFWIhrxRBVlpO7dEBn0mLOn4u+/VxH2QMlpjhl6 RL+31GleUBCVsMxVrVJVXxzUtzR3kWd9ANd9uqRkkqnAXsv8tACUb/gnXCNGseRcaUBO EhqwbWvjQQCj4jh26Y3oxSROyYi6/u7NwNGjYSI7nw0xAjEPa8pdNzvDsSbQSLPgEqXR s27zyCTmyqUjAsQo6YTbxmn1GbMMzoTu094QIzRXE78OeekoNttKvPhu4KxRecw/sE9x jpKQ==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50994-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; AJvYcCUNEYhu3GVKPLN2wU67wKsgOro27z20X9zbkXYu13PMPkJmJBlo4NlFFMXHSEelUZlz1qA+Ggz7Q8InyKUCO+xoQZazG7AXRInEglDIeg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cj17-20020a056a00299100b006e02980b0bcsi769946pfb.135.2024.02.03.03.05.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 03:05:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50994-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 C5028B2A2AA for ; Sat, 3 Feb 2024 09:05:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17A566087B; Sat, 3 Feb 2024 09:01:20 +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 Content-Transfer-Encoding: 8bit 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) -- 2.34.1