Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1800862pxu; Tue, 24 Nov 2020 09:12:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF5W1u8vr/3YOMKDhElDzwGJZJTJXv4Uh0bvsugxmP0Gk72IVDC+KRoDJVfHh4McsR6+RS X-Received: by 2002:aa7:c5c7:: with SMTP id h7mr4759256eds.143.1606237941888; Tue, 24 Nov 2020 09:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606237941; cv=none; d=google.com; s=arc-20160816; b=YmjmdluvlquAkZomJyhcIydn8GBSD2OZZaoWPjUEPnTQ+eilGR4T7e1voqORM51cJB fSfrtz7O4sT5+qMScoJ5Moy1RUKI7Te5H5CeS/HhbdTJ8HwyGEnOtBA91HFhPLxMh5sF o6dEBtFAMX01K00cn4FHODlmdX21UMqIR0HEeiSlrEyFOh8E/wMkWbi9iUEMiJdFeGSr dk/5VRh4JU7/2HxvMNLeUSuPfc/JX8BwdC/vPnR7i+adDY9TuDoOQyAC9JFSbT/AGSxh 8820FJWGGbB/+7zspNk+sdArJTjWR3yr1ixa4fLksDA3VB4OQwWp96msYyAtR6d+DqGa o6Sg== 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=g3RfEJx7EqAAW54lT43C3SETi7IT2PM+rjr+/VWw9IA=; b=BPNWNHZw+63GAbw6xHYLihuSXU5lUPgNTjKqXtkZqu005O9lHOKVtCva+6hTR1gFrf xudKL2VCxn+txZhmUIDllloS5WntyD4Z9slkexNxC2QCQsl0XcA4ecNJPyZTv6FLHspu v5HDWeHUuADUkJruHgapnGvQ9yTrkBttpyZ9gU2iiyUiZDfsIL6Q5OnVHc/7Bcr0K32O g8ODaRLI0RTU5bsbv1CNCfir1hBTpyf6HySha7Fcl7fbrmPH31/aEowJY9er6NEUoirM 1NINUNTwjDcA4UaiAwhzIxVo8vhbut2xqSmByagAgz0aNY/Ddq1X27DgI9UBcVQfpG4h XAsg== 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 s15si9180936edj.165.2020.11.24.09.11.57; Tue, 24 Nov 2020 09:12:21 -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 S2403876AbgKXRI2 (ORCPT + 99 others); Tue, 24 Nov 2020 12:08:28 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38116 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390718AbgKXRIC (ORCPT ); Tue, 24 Nov 2020 12:08:02 -0500 Received: by mail-wm1-f66.google.com with SMTP id 1so3625445wme.3; Tue, 24 Nov 2020 09:08:00 -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=g3RfEJx7EqAAW54lT43C3SETi7IT2PM+rjr+/VWw9IA=; b=qUBdNXMNpfmw9Om3kA4sCHtxNritkey2T7aawsS9ig7lnAFwzJbD8aGGw5ayuHXCsk EpMkhCKsBJCbTUYLF3th+nNR+1WhsyY6Pxm5oIZ+JC8OVTvXEskmDPXTIs2+9DWFXq80 waaHdvNVRlKbrupxcpGcuWNgXA+frBjZVAzjwXsCzOjzM5RWW/zHvzllHqX+5nrRQfD1 RpAnBKA8VHNTjUOVH96vQgPvMtZIx9jhuRURcQf6IWIsYUjzjeZD5Wm4BenYSmkF7bBV D8KpctTA3NMkr0a2ocLIUK28K3fpRHRwU9fCtACz2h6YBeQTd4PzAjgSdQyH80cil4xU 5N/w== X-Gm-Message-State: AOAM531W7fAjZmUmHengQEVprRReNDJA41y0kk//RhQmcE3mphsDdD+M gZyKTMVP2OeKbi6N7GCdhMsuTP5SMuc= X-Received: by 2002:a05:600c:2119:: with SMTP id u25mr5530653wml.53.1606237679731; Tue, 24 Nov 2020 09:07:59 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id v20sm6419874wmh.44.2020.11.24.09.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 09:07:59 -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 v3 10/17] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Tue, 24 Nov 2020 17:07:37 +0000 Message-Id: <20201124170744.112180-11-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201124170744.112180-1-wei.liu@kernel.org> References: <20201124170744.112180-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. 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 f0b8c702c858..956007d2bf0d 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