Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1112056pxu; Wed, 6 Jan 2021 12:37:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3WqFZOsvnDRy8UHA9JdgbkXQQhjaRHWfxHiBk7TG2mumaW1tQ0dxM39UaV9GdwbAYjVnF X-Received: by 2002:a17:906:40d3:: with SMTP id a19mr3959456ejk.98.1609965433525; Wed, 06 Jan 2021 12:37:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609965433; cv=none; d=google.com; s=arc-20160816; b=kIQov6TtlWtQe4vtWxNZW0kYvdQSPKLtQX78YSa0efdaB38ZeUW3kgSh8G4VdTgH6i DK6yYEdOYe1TgVmSCEV1EZOcFaNWh9e5NsJXMIxfGU42fQAtG+y7eI1i3JWG2r0rVQa2 dCScfbZbL2YYQI2QIifQFe8S3eY0pSBDUlaDi9HymyhOQQ586XeRqUtU5c0kqXXKyJMs AhgIhiR1RatjpK3KCDYfZ5ugs/am3+RCSavFgOU8pJWYh/Trgt3PMoDhpa9hZZoCiGJr C/0LqxFd1xGft3DQi1h0COR9PWon07lPuapQD3cL1luLhwp9sINou3HThfm+8Qz63NwU 723g== 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=rN/0fuFHwVfj55c/MsJ39TIimzupnKoIy4FjFz+d0q8=; b=CqW6cCMsPJWJM3TtcR8WCleoqrUZsXobFNY2wiMY9g0IG9ed20ncM9mdJge2tFrb9v UkdY7A7X9QRdCj3WQle3VAR+p1BxA/zKN8NcqJu5g/AOKRrwNxe1XK7c4ug4+ELgWsvK x+EizEE4DA2VHhfAusZXstKr6rYQeCXFlN1GFRGOXb2/AvKMVHE9qZmMu6mEljWTz7FE eD0Um7k87QyAzsoSBwaknu7HdBpQlbgz/JIEGwDJgYjfY72Ro8lFDVNb3AmpUfmVFjGf N9iYKU5hjRNFKQ0/OB1Uzel2qBkVCuvo0foaW3UZHMECrHqbeJhqYARRjO0HBvZz4RX3 vG9Q== 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 i19si1291270edr.468.2021.01.06.12.36.45; Wed, 06 Jan 2021 12:37:13 -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 S1727529AbhAFUes (ORCPT + 99 others); Wed, 6 Jan 2021 15:34:48 -0500 Received: from mail-wm1-f54.google.com ([209.85.128.54]:51212 "EHLO mail-wm1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727497AbhAFUeq (ORCPT ); Wed, 6 Jan 2021 15:34:46 -0500 Received: by mail-wm1-f54.google.com with SMTP id v14so3451202wml.1; Wed, 06 Jan 2021 12:34:30 -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=rN/0fuFHwVfj55c/MsJ39TIimzupnKoIy4FjFz+d0q8=; b=ss0j/JncKwSkW85blDKA0KdsCTyMZNhTG6n/ij3HIuvtLlx6n0+CqLxfuVMzr/zG/e nPdWKmL1xOMzGAec6ea5WGvvb+JtKMQv7XDPUnSyzGXOVt5UN9cjtM8J2KyW7MAMFFAY 6n4eLD83vV6XE+4CSHKplk0Z5RaOvp3aJV/IzUqWprvMVzzENvDDk54kGrO/h1TS5sSU mNJYOofLgReZyrd/bZRdCFSZeuU762ydbXIuNnDWThw2Urp7WmEqcRNza24KY7l0SrdP yrNsTi+H/wAU0VP8n9x9zCCjGeVHiJHp0yTVzHLQIBNU2CyC91sHP0heZrw7Lu+PLcd5 zPRA== X-Gm-Message-State: AOAM532tNbtF5twXP09Z+XJlNqTeakkWpCJESAvQRzxxBFbPS2RSIz9Y A00JP7rvnvXu4djRd4FyRtqvkXl/XUM= X-Received: by 2002:a1c:5402:: with SMTP id i2mr5384686wmb.12.1609965244266; Wed, 06 Jan 2021 12:34:04 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id u9sm4499456wmb.32.2021.01.06.12.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 12:34:03 -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 v4 10/17] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Wed, 6 Jan 2021 20:33:43 +0000 Message-Id: <20210106203350.14568-11-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210106203350.14568-1-wei.liu@kernel.org> References: <20210106203350.14568-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 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