From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B3D0C55178 for ; Thu, 5 Nov 2020 16:59:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32DFB2073A for ; Thu, 5 Nov 2020 16:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604595556; bh=y1TVWvgNrIk8iK3RwZswJ6HvZRM/kwhmdLe2lih++xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZKg3di8mf4zev0VpulLq6/VAe64TQLokadSqI3JY9TW3zNkTaSnoujZ5TFsrUHh3b CyFTPmnoU6QJgMk0z02gF6L+cmLCJ5qRstMd+n5sV+eG/Pn0TihN+SNl0ggrpS6z9D VZIU8Tg7D9gQsujKKAWNWgrtcvjhS8AX1MNJTAa0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731974AbgKEQ7P (ORCPT ); Thu, 5 Nov 2020 11:59:15 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34568 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731755AbgKEQ6a (ORCPT ); Thu, 5 Nov 2020 11:58:30 -0500 Received: by mail-wr1-f67.google.com with SMTP id e6so2604318wro.1; Thu, 05 Nov 2020 08:58:29 -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=E7gGWE1KUMsd9+39KuELqcUtVQ22QVdu595tFsS9SHU=; b=cAVSQA+dN1YEiEenMp26R4+7bVkLyMuWEgpS/sXNq7oTDiM9YEg4D2K9HJY9lxVwyZ mlpBH5puKP2tsZmtarOPgBPl/ZT+OUFQuZ6+4xIciCme5U8gvJ4bvowNChsByqbpcTrf f/1XInPNAEPZyNbRNzpYYUxy54KN3AYy9PdvyMazC9cKUz5vC98VYemJoyY1Y1ejUhnF 27Txp1gJ6ZRwnGT0ADYoV7Llbd97/WUzLOX2UFuVbu31ooV1zc1tqh1jjgeZ/Xfrb4d2 hhW9BIIH0oqWzMv/ctu3OJa1ZPZuzt7YIGZqSY2kVuJYSLGk+60TgkgxzDoRPNdenkFj fQ/g== X-Gm-Message-State: AOAM532n7hGLwXVAGtv7G0FGSYuhdHQspH4x+QI9oxnde5K2toylWZBE hhZW21DNObq4GvrexdQEvgqZhebO6V8= X-Google-Smtp-Source: ABdhPJwpDhvQrHK3WwjrjTFn71gUwZVgYIQo08rac/znVi21vuGDo5TBoSBrp2OT0Qz88kzACQ9qQg== X-Received: by 2002:adf:9b95:: with SMTP id d21mr3903627wrc.335.1604595508956; Thu, 05 Nov 2020 08:58:28 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id z5sm3350729wrw.87.2020.11.05.08.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 08:58:28 -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 , 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 v2 10/17] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Thu, 5 Nov 2020 16:58:07 +0000 Message-Id: <20201105165814.29233-11-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201105165814.29233-1-wei.liu@kernel.org> References: <20201105165814.29233-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 --- 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 f7633e1e4c82..4795e54550e6 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -31,6 +31,7 @@ #include #include #include +#include struct ms_hyperv_info ms_hyperv; EXPORT_SYMBOL_GPL(ms_hyperv); @@ -208,6 +209,30 @@ 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 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, i, i); + BUG_ON(ret); + } +#endif +} #endif static void __init ms_hyperv_init_platform(void) @@ -364,6 +389,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