From nobody Sun May 5 11:19:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1588156924; cv=none; d=zohomail.com; s=zohoarc; b=Ubh/ouIVc1xGnNReg5FW2V+nBxmpDMcXORCz7cWZZyHhvfFb28g96vvlVJpxUxafw+6nZRdGIHf9oGV9DbHvzffsmhY5jSq8t2WfgzpaPJ5BsgQObfu589WYI/VWaxuU181wNiS21MlKCJ55ltU7SnL62pezBzmGClESgRZ27RY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588156924; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DftQOi/0ZZ65kQGBjKhjDE6NVGdkGHPGvh7+6NEfCIE=; b=U+SZ6A3VtrD1BkgZzagV2f8/gptVNLOwL5C7ag5YhCqz22X1n8a8JAkmxjc7Yh5HEDYTKgu0RTKAHOh+vex3c698p9NbCeDHPfG7yZpyf7OpqrWTKgRmmUonXQho1MUAnwWftYsDbg7a3aoSl/47whelJB7H75H8bwVzd6aILug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1588156924934774.1330973011247; Wed, 29 Apr 2020 03:42:04 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTkA1-000849-Oa; Wed, 29 Apr 2020 10:41:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTkA0-000844-O5 for xen-devel@lists.xenproject.org; Wed, 29 Apr 2020 10:41:48 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 06b917fc-8a06-11ea-ae69-bc764e2007e4; Wed, 29 Apr 2020 10:41:48 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id y24so1462622wma.4 for ; Wed, 29 Apr 2020 03:41:47 -0700 (PDT) Received: from localhost.localdomain (44.142.6.51.dyn.plus.net. [51.6.142.44]) by smtp.gmail.com with ESMTPSA id n2sm30270332wrq.74.2020.04.29.03.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 03:41:46 -0700 (PDT) X-Inumbo-ID: 06b917fc-8a06-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DftQOi/0ZZ65kQGBjKhjDE6NVGdkGHPGvh7+6NEfCIE=; b=JB0u8o+ofud/6GLH1aBjwGbjh2F72l2MzXQLgSGL/S7l3W9R9rAy1fGRThc2w6R2r5 PJ9CQfqM50uRhUY3iOAqZN+1nvaTJU8Hm0UFWQltCAZzQLpLKR2UeoSVDsJnf3dlSBh/ zJNCbwM41L4S6L3OB4gcJyq01oDVJGQnaNsDec5TgR16Zj+5mfjih5FzpVSH9tYS1OqH oJixayzSK/reIVDYgKM7lCPcJb2pMml/DZvkqGfG67iTXuC/gkbRz76v2tk1ofTLGeP7 TkWtTXRsnQsDEyFkJw1TRW0u3okUmeNYOw48YaB6BZUH0/M0WCwBTaX1qyn3F68UxsDv ZjnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=DftQOi/0ZZ65kQGBjKhjDE6NVGdkGHPGvh7+6NEfCIE=; b=cFq5lAgDyvCY/GWt1wdUncvSoHg/IYN65XmwFSiUNXyfgFjUIuR+LFpu26QZeNVthh VVgT9NAG1B5XFkE8xMayAeBCeZE/Fu9xmuRk4mIu3CWcfUBta34Z+Q4zq17Hqn3Ui7Jv 90vRIqQgEXAcZPVpwNcZqvhV+orPQF58nQa+YlwUygiK+YoETH6ehZ14WmJDWBqZliDb 7hFI6zMGj3GzPXKlI8lWhGBBELxliSR2EFKctmcAvpeEM8EyDCTt6SoE2Va/Y6gC4T7K Nm+z4UpklUIO8ZMzUNdQpC0xEMJ8Kw9h8F90Z/p488q+6aK+o0zSAgTOB2HCkxJq4mgB m9pA== X-Gm-Message-State: AGi0PubUNICGv81LTheFsdD97JyRD/YJz/lTlwnzQvxuotEjv8EO6SE9 e/+d+HbJViHFOnCgl8xi6AEoSxOtv8s= X-Google-Smtp-Source: APiQypIJ5yNPYFk1U3Xqscn/+94PcbzPa7A42oLwYxfRYauXgdOAK26PwiTzw/sDX9Y1yTxs1j+mCg== X-Received: by 2002:a1c:4304:: with SMTP id q4mr2738653wma.152.1588156907008; Wed, 29 Apr 2020 03:41:47 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Subject: [PATCH] x86/hyperv: stash and use the configured max VP index Date: Wed, 29 Apr 2020 11:41:44 +0100 Message-Id: <20200429104144.17816-1-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Paul Durrant , Andrew Cooper , Michael Kelley , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The value returned from CPUID is the maximum number for virtual processors supported by Hyper-V. It could be larger than the maximum number of virtual processors configured. Stash the configured number into a variable and use it in calculations. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/guest/hyperv/hyperv.c | 4 ++++ xen/arch/x86/guest/hyperv/private.h | 1 + xen/arch/x86/guest/hyperv/tlb.c | 2 +- xen/arch/x86/guest/hyperv/util.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 91a6782cd986..84221b751453 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -33,6 +33,7 @@ DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page); DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist); DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); =20 +unsigned int __read_mostly hv_max_vp_index; static bool __read_mostly hcall_page_ready; =20 static uint64_t generate_guest_id(void) @@ -143,6 +144,9 @@ static int setup_hypercall_pcpu_arg(void) rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr); this_cpu(hv_vp_index) =3D vp_index_msr; =20 + if ( vp_index_msr > hv_max_vp_index ) + hv_max_vp_index =3D vp_index_msr; + return 0; } =20 diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyper= v/private.h index 354fc7f685a7..fea3e291e944 100644 --- a/xen/arch/x86/guest/hyperv/private.h +++ b/xen/arch/x86/guest/hyperv/private.h @@ -28,6 +28,7 @@ DECLARE_PER_CPU(void *, hv_input_page); DECLARE_PER_CPU(void *, hv_vp_assist); DECLARE_PER_CPU(unsigned int, hv_vp_index); +extern unsigned int hv_max_vp_index; =20 static inline unsigned int hv_vp_index(unsigned int cpu) { diff --git a/xen/arch/x86/guest/hyperv/tlb.c b/xen/arch/x86/guest/hyperv/tl= b.c index 1d723d6ee679..0a44071481bd 100644 --- a/xen/arch/x86/guest/hyperv/tlb.c +++ b/xen/arch/x86/guest/hyperv/tlb.c @@ -166,7 +166,7 @@ int hyperv_flush_tlb(const cpumask_t *mask, const void = *va, { unsigned int vpid =3D hv_vp_index(cpu); =20 - if ( vpid >=3D ms_hyperv.max_vp_index ) + if ( vpid >=3D hv_max_vp_index ) { local_irq_restore(irq_flags); return -ENXIO; diff --git a/xen/arch/x86/guest/hyperv/util.c b/xen/arch/x86/guest/hyperv/u= til.c index bec61c2afd87..2c5f421b7bd9 100644 --- a/xen/arch/x86/guest/hyperv/util.c +++ b/xen/arch/x86/guest/hyperv/util.c @@ -33,7 +33,7 @@ int cpumask_to_vpset(struct hv_vpset *vpset, { int nr =3D 1; unsigned int cpu, vcpu_bank, vcpu_offset; - unsigned int max_banks =3D ms_hyperv.max_vp_index / 64; + unsigned int max_banks =3D hv_max_vp_index / 64; =20 /* Up to 64 banks can be represented by valid_bank_mask */ if ( max_banks > 64 ) --=20 2.20.1