Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp362345pxb; Wed, 3 Feb 2021 07:18:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKTAFcEhGEfvGfp/N8Rt7WrLgeSB2IQPYFVF3N4sv+ClBcV8WGWs8rNFk+3XE+8FRVJLye X-Received: by 2002:aa7:d401:: with SMTP id z1mr3474248edq.213.1612365506109; Wed, 03 Feb 2021 07:18:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612365506; cv=none; d=google.com; s=arc-20160816; b=n+rqVDkfU/cutS3B2vTZbX7G9wI78N2dJkEkdqs3r7uqTRev8Wg5v1ZYJ2d3XZWJVO eCa/K/Xvu8hkHaxO3uFSfmMHS3rytlCoX8J1XhLAWBoON+709iJqF/YqesQorMHzsxge mVBuAVS9uBY96yGwVvhopaejq0npl8TT/ReNcxMfHYXAm9Kh1+hAH3VsM8z7OwUdeXhq QvQQkSyYf6IFYG7WCf0kX69NdyPL5cUhX6HFUHCTPK4Yb7VawAxugtAOd/FrvY7gvDkD pNe4X63BHqZoBYv9isXH0eC+npTONq3Fl/y5gswtu/AFR8wVFOJMyfo4L1I6zmp29rAE vskw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZDT1aR/ZIaB/uEZttZ80oWLaviiBKbPfEaTtbPxJzow=; b=sMHprjnJ5omiLaeTQv7EN56rslOjJjdAs2++T1ddOTqXdt3enHrMkjF+tiHn1A0TTH N4RI9y2iT0gaomrkXMv9UwnNb5TKBMduuckYi3jHNAoqbJPIhh/6kqNQVglF9xphx1El BZYazzKcy9OtdqMeblRYz6IcA74Yr2tboeJitdzlaiu+4Am809N+Ub873qvaxaQfoYE6 YQM6UBvpBO/2UlMrQB/K+9uubEvq+NGfAJuGZeWSxWE+YJXzOGGh/2tpJ4nHmXFiubxL yTAAcsPfi2UsLRU+KGznM1deO54CjCNhml86zqIsdpavYY0Ph1UbqYCu0u3XT7e9nZ5X m3qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si1477703ejr.748.2021.02.03.07.17.52; Wed, 03 Feb 2021 07:18:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233735AbhBCPOu (ORCPT + 99 others); Wed, 3 Feb 2021 10:14:50 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:45735 "EHLO mail-wr1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233980AbhBCPFe (ORCPT ); Wed, 3 Feb 2021 10:05:34 -0500 Received: by mail-wr1-f45.google.com with SMTP id m13so24736230wro.12; Wed, 03 Feb 2021 07:05:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZDT1aR/ZIaB/uEZttZ80oWLaviiBKbPfEaTtbPxJzow=; b=tpaOJecSGK+z6EhLq7qVNhRAo4q+cy9UdnLYVFKTJH/kRH20PyYFbejUhdsG2XOo+1 K8XkmPYcXKEgR70A/xAUbHv3W9U8ejGjzO5w1IMhHLH0FPF2cRDJtZWIaL7YLP5+N5XP gjODc/blpVtQElM8ta+9fDXe8F7WAoJUS2sTp9XVx/bd8UhE+uYp4UsnUA0pQw5FfVNL ei1qtpAeeMIARwz0lOxH40/BlZB4Y0h7qZIq0NYfNAL47pkm9vfqpj430Z48nnN0dFpc wa8594OjzdVmnTrG8wKi1gvNa185iw55Njik4NcN15Y3ov8VWi4ZsYJukCDeJgwjAA8Q uI1Q== X-Gm-Message-State: AOAM532VnESZthAgRiC5NBhidFxyUMOkLgmOfbZb0BJYjXfl4vhO1rCr Wdapar2CFI4U2A+YFqtUK21JSpgFjqY= X-Received: by 2002:a5d:5253:: with SMTP id k19mr4035750wrc.224.1612364689654; Wed, 03 Feb 2021 07:04:49 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id r17sm4051704wro.46.2021.02.03.07.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:04:49 -0800 (PST) From: Wei Liu To: Linux on Hyper-V List Cc: virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , pasha.tatashin@soleen.com, Wei Liu , Lillian Grassin-Drake , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" Subject: [PATCH v6 10/16] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Wed, 3 Feb 2021 15:04:29 +0000 Message-Id: <20210203150435.27941-11-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203150435.27941-1-wei.liu@kernel.org> References: <20210203150435.27941-1-wei.liu@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Microsoft Hypervisor requires the root partition to make a few hypercalls to setup application processors before they can be used. Signed-off-by: Lillian Grassin-Drake Signed-off-by: Sunil Muthuswamy Co-Developed-by: Lillian Grassin-Drake Co-Developed-by: Sunil Muthuswamy Signed-off-by: Wei Liu Reviewed-by: Michael Kelley --- CPU hotplug and unplug is not yet supported in this setup, so those paths remain untouched. v3: Always call native SMP preparation function. --- arch/x86/kernel/cpu/mshyperv.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index c376d191a260..13d3b6dd21a3 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -31,6 +31,7 @@ #include #include #include +#include /* Is Linux running as the root partition? */ bool hv_root_partition; @@ -212,6 +213,32 @@ static void __init hv_smp_prepare_boot_cpu(void) hv_init_spinlocks(); #endif } + +static void __init hv_smp_prepare_cpus(unsigned int max_cpus) +{ +#ifdef CONFIG_X86_64 + int i; + int ret; +#endif + + native_smp_prepare_cpus(max_cpus); + +#ifdef CONFIG_X86_64 + for_each_present_cpu(i) { + if (i == 0) + continue; + ret = hv_call_add_logical_proc(numa_cpu_node(i), i, cpu_physical_id(i)); + BUG_ON(ret); + } + + for_each_present_cpu(i) { + if (i == 0) + continue; + ret = hv_call_create_vp(numa_cpu_node(i), hv_current_partition_id, i, i); + BUG_ON(ret); + } +#endif +} #endif static void __init ms_hyperv_init_platform(void) @@ -368,6 +395,8 @@ static void __init ms_hyperv_init_platform(void) # ifdef CONFIG_SMP smp_ops.smp_prepare_boot_cpu = hv_smp_prepare_boot_cpu; + if (hv_root_partition) + smp_ops.smp_prepare_cpus = hv_smp_prepare_cpus; # endif /* -- 2.20.1