Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp197743pxb; Wed, 20 Jan 2021 05:01:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrsrY5wpDfzwXPNLhdyrrDQtSpmrkeVkVtLCVSSHR3Y7v2WEMukK0cCVEcoAFgoFSX6/6F X-Received: by 2002:a05:6402:50a:: with SMTP id m10mr7298165edv.324.1611147686253; Wed, 20 Jan 2021 05:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611147686; cv=none; d=google.com; s=arc-20160816; b=0i9fSGAqKqZABt96N+fKG7K0VCbVEcUXJTjWvIwMWHhnHyCE0sgc6agMKtw13cVs+K zVgnns3TVrMmrwH4L1FOkyc+nstnixba9lmjiynnNirU3UDGdcoMkD5hmJWIp+sBOGzk EPwtSS/tmFjU/CmUb2QNk+3m6llBl7n16sHMcXfOpR49S/Nsz02OrIRdqokc91uBusnT YN+uANLFfS9x3rJ452ZE24zduzren+5rLLkp/IQW4llzcJteY8MspL0+Rw69IU/QzFyM rFZqu+lrJfkH+maTdtQni9N0rXOGthxWnD1C0MvFt0wGObR/cHi32PX8FzfrBxllTreY rZOA== 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=exb1zlymwE/GFjFE6FNGEjOMLX4hdcEqfAyaRBEFLGXdos3Z9U33AQn5FoT3Z5GBsz 9LNT9zXVuTvSaEHraQErSqALytvdbJ4ZJUNq8y3fSJLyZhr0CCVXtom6xqzIa1XwWYZr vq4ilCNBXTwxRD2qF1E6Ic1kG1q0S58FGyb5KMpuIFgIXa0e0wgwvyW3/dwXrah2Bffi vfKvpMELGSVNyXmKsEjLXJ4xxClJMLuc4HaMY9c5OTsABK43FZPYnC9fp0KJJV1B4MOA 1dpiFKzSuWjftQL0fQ39jBHtKEFwCGP3E47VWQ8rq+AT5cNVZNlAHVVUuXVKC8m1YRe7 Cpvg== 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 k22si655082ejs.273.2021.01.20.05.01.01; Wed, 20 Jan 2021 05:01: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 S2388272AbhATM7c (ORCPT + 99 others); Wed, 20 Jan 2021 07:59:32 -0500 Received: from mail-wm1-f43.google.com ([209.85.128.43]:33075 "EHLO mail-wm1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389205AbhATMKp (ORCPT ); Wed, 20 Jan 2021 07:10:45 -0500 Received: by mail-wm1-f43.google.com with SMTP id s24so3179060wmj.0; Wed, 20 Jan 2021 04:10:28 -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=Of/09TrXX32d1adULmFOcooVT1eOAVcZ5uYiQ7m+O6CuNVHmNq9/QZ1a0SIYXDcDaH 5VvmFpSLsIoJWtJ1MWuEz5fnl/Za2dtaf3H07X3zS+r9psqXxzxlbHM6T5OUo+JjsIZA 2ZaOm/+phqLPkJD/45EWDeELn5kkg34wjwVHBr5hGtCglUe2F/04TjZqdXc8+8OPd39X b2nweUfg75px9MdzZCTFlRToxcruftbi03P1XUWpMlc801he4yVOrj+aP0c8XquqqivB il0JBQHpT0aoSkyPHvmj6emuWtonshaUBeZWgvWJFAEf9mAjX8FkQYyG2A1vQ3UeuGo9 PDhg== X-Gm-Message-State: AOAM531PcX7SzrKjQwqwYlby1pwOdqMfRU9i1+QZOF0iuWvx4Yki8RDj N+AMCc0cESaqyfdADaRF8USNKHTo+Mo= X-Received: by 2002:a1c:7e4e:: with SMTP id z75mr3999033wmc.40.1611144073152; Wed, 20 Jan 2021 04:01:13 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id x17sm3747671wro.40.2021.01.20.04.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 04:01:12 -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 v5 10/16] x86/hyperv: implement and use hv_smp_prepare_cpus Date: Wed, 20 Jan 2021 12:00:52 +0000 Message-Id: <20210120120058.29138-11-wei.liu@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210120120058.29138-1-wei.liu@kernel.org> References: <20210120120058.29138-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