Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2122712pxk; Mon, 14 Sep 2020 05:29:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6aS30EzcswpJICI4tbf23kCnOAOC106w72Wo6mC3yR+nHxp7sThmGOBx4WXI+7Tlff8vp X-Received: by 2002:a05:6402:18d:: with SMTP id r13mr16308745edv.267.1600086580127; Mon, 14 Sep 2020 05:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600086580; cv=none; d=google.com; s=arc-20160816; b=AV2aqTKJLp4aW+XJSOpMJhVgk7nbuQamesPEcW7dS48oAusHzjGEbV1z2Cllg0SlHl fQ0ULIUwFCj6XYotSPdX8+xjYCNKrOyuYDG8ar+15gLFPZb34HJlZeQdaspXdgEp1b8n GHb4bS4LgYhIDVCulk53IJKLfIhYprtOIJ4RIse6QJTlxiU3Vaoby0YBJKHdFHeqM9x2 lPJtxhiUjnmW1PH9qy++/ABVpSIP97gsMsPWQnSiZFYs0ziGa7vmNK4YiglPtX2CMB/M QssUrS7LXrhogonZnrGqdi3h1ofSLOEUIJVYyPw5BEeberw3LY+5eKXT3qk3o7iwJfLR zm4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q2b8Hx6LFneW6965HjzLe+3orBdeADynSXFLtZaWjCw=; b=us0qhu1CI/H6THOsoXhVZGikIMQb/nnmwO5vbEAHIMeUubAiAC2yCIvmFMdfKigf16 nyo6xKyVD7mo0dKP50NLDpXlBe0oibVsbVJIkZCHsf8Rjowx/OnF37/OTVNB7jYssNcV PeidyPUvTY/TdcP0xolxr2E1LrY0Z+rtFrbVrfns1bqYyESokwqqBgBPu9cChCP0n8+V 8d/dNeHdcBXGRRTfAKaLp8GsI5ISwv9VTgHEtPl3m/0Bmi7uyAFVsaph6mGr3PYoKeZi mBQqnW6LtcUliknW4XXU454Si0QzbPun9Q5Q2GjX7hBm4HYL4NnXNsfSj1oohtBj0NIO IuGA== 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 n12si6953400edv.103.2020.09.14.05.29.16; Mon, 14 Sep 2020 05:29:40 -0700 (PDT) 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 S1726050AbgINM2P (ORCPT + 99 others); Mon, 14 Sep 2020 08:28:15 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39206 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbgINMZz (ORCPT ); Mon, 14 Sep 2020 08:25:55 -0400 Received: by mail-ed1-f65.google.com with SMTP id e22so6843934edq.6; Mon, 14 Sep 2020 05:25:53 -0700 (PDT) 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=Q2b8Hx6LFneW6965HjzLe+3orBdeADynSXFLtZaWjCw=; b=Zja261ehjQBrl2aok+5n10901pgFU8K+eHwsp7PtsDS+Un8qweDGS/Ju1I/SENsDwQ GgdXZfYaBnJ4XJtR1sdisAUfRu+Q2hwOx6ZTdaA78MWkgf/2iMZ4JSlyqdX8R3Cyk7Bm VCkDmh4f1/IVzJfA/5Vp02UBz5uVxGmJuHfynzl1WiHFH9COCxWxoFlQB7Jgfso8aHSj 58R8gzPQCsPROM1jhz436Gp9lr770BDB86lY93S2YenlanW6+e1PAYX/Bb4uhK/Kn/FL wBNY+ZP3udD0JD9HMyywB9AecwW3MuTqqOnY+qVK3MLuS934IMQ37cHxG5RdVPKlog/6 F9fQ== X-Gm-Message-State: AOAM533ztR2NWMT0SanMBdsFbh9I2X/MaHdvQvPeBaROiqPcbRS3ekI+ 3nZ4KNEaqdLvdRQmz/IkQVTeJD27z8E= X-Received: by 2002:adf:a1d6:: with SMTP id v22mr16016915wrv.185.1600084777041; Mon, 14 Sep 2020 04:59:37 -0700 (PDT) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id c205sm18764809wmd.33.2020.09.14.04.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 04:59:36 -0700 (PDT) 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 , 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 RFC v1 10/18] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Mon, 14 Sep 2020 11:59:19 +0000 Message-Id: <20200914115928.83184-2-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200914112802.80611-1-wei.liu@kernel.org> References: <20200914112802.80611-1-wei.liu@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 --- CPU hotplug and unplug is not yet supported in this setup, so those paths remain untouched. --- arch/x86/kernel/cpu/mshyperv.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 1bf57d310f78..7522cae02759 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -203,6 +203,31 @@ static void __init hv_smp_prepare_boot_cpu(void) hv_init_spinlocks(); #endif } + +static void __init hv_smp_prepare_cpus(unsigned int max_cpus) +{ +#if defined(CONFIG_X86_64) + int i; + int vp_index = 1; + int ret; + + native_smp_prepare_cpus(max_cpus); + + 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, vp_index++, i); + BUG_ON(ret); + } +#endif +} #endif static void __init ms_hyperv_init_platform(void) @@ -359,6 +384,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