Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp457075pxb; Thu, 12 Nov 2020 07:55:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQjaIR5loIEbTANLzMloqPOTyXB8anMxvumMriH+ZAnpM3kSCxrw2fAHsSC0NK9UniAyO6 X-Received: by 2002:a17:906:12cf:: with SMTP id l15mr32701901ejb.540.1605196518732; Thu, 12 Nov 2020 07:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605196518; cv=none; d=google.com; s=arc-20160816; b=I4uI3f+0RzxjkeRhMIkXDUzt0OuizF3zMSoHHWjQmEGhxPyhEw0kqMZzWZKumgS3Y/ j1j7chjFfMCaWypBh5dkwQ5p6peay1Ohj11gKzitnEsYj7C3miq10WHw9/Mil8fzNutJ uygXNkUlJeXvv1gkJIpsBnsMT6m+4emUNAhjMhj/OxkgVV7OhTcLxNyyf01p2r2bkBrn lPu90WbBwyQJZUDyCK+YtXrkv7XrdFmJ5+DA7I7k0IAMVy10tfE6xd6d6rIkQ9tiUzOo hVAyFxMTphZLSVhgQYI2MGNqJBcV0LAcX/14P1KTxFIzwORlXCBE/rL3wqJMQDUDTCDt kD7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZgjLmQmxgEDr2mbUWpkwRYMxwIwNvNfHIb6zZGhdyzM=; b=N3tWtVt7jhkiZEOllNYkb+HkZyCH7Tg/IMBfKtahXVMnlLJp3w03z1PBS+l/ogHy0o UVgEd3Bft5HfXONy29UfBouqSG2dsEW5/mRPAFZp9RocM3vTOUajPxcwYGvGEYXuh+7f fdQ3pRTDuwjxlQfku+QO7GQykbSNd5PGlXySKCHC5eo4mS4lub7whRGyr4CTqPPtYp0F 2h0xQsRnc1AEGW4SlTHmgSemTRRyZmHrR4SfujF5YY+GIYr8H4y+YJZ203VCp1JqYprA dNjGbW1ToeO/WDkRQxcpSo4bztDqRYm4AH7ynyHrjkhPrShpp8ERJFNwSTPmmJhLKGdD DUOQ== 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 a15si5233242edr.134.2020.11.12.07.54.55; Thu, 12 Nov 2020 07:55:18 -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 S1728593AbgKLPvc (ORCPT + 99 others); Thu, 12 Nov 2020 10:51:32 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38203 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728519AbgKLPva (ORCPT ); Thu, 12 Nov 2020 10:51:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id p8so6512486wrx.5; Thu, 12 Nov 2020 07:51:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZgjLmQmxgEDr2mbUWpkwRYMxwIwNvNfHIb6zZGhdyzM=; b=Bi0j/SUFlEZ8wem/BmtSdWvlHMZafg4omoQNpgPfdO9mk1bjJYkAu40GPcDO0gN+gG HI6yIkRaYm9670pbad4GtyZs5TMwD3vCGCgCUgkHpqUrRNpl6NcOTNfd0Ah/mr4c9oHK VKSQkeIc+KwcmQIqGNC5O6KNCpWG8H8Jx11WHT1xC5NnFQZjhokTA0aNhaIJw9Ckq5Ar 6lLxRHKJUNww1zXRcVeJD4D+ot/IcyPfBQmZ6Y0fR2A7Mx4JrS7LeaBPXQ3w7nAbA0sa L5H8dnYpvnraSVMGHXS72PQHfk8PuNfzsIKFenbEEQ+vs8TMU7ylMgi/4wHRMtL4DD1I f2kg== X-Gm-Message-State: AOAM531tXkYrlpbp8peusAeFDSAfEd0p9cCKwfvK9qtIspFd96p9NdOJ 2u6qubBUYVd9+GTyaDMJvwObZYhB4Wg= X-Received: by 2002:a5d:5146:: with SMTP id u6mr254027wrt.66.1605196286237; Thu, 12 Nov 2020 07:51:26 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id g186sm14984945wma.1.2020.11.12.07.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 07:51:25 -0800 (PST) Date: Thu, 12 Nov 2020 15:51:24 +0000 From: Wei Liu To: Vitaly Kuznetsov Cc: Wei Liu , Linux on Hyper-V List , virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" Subject: Re: [PATCH v2 02/17] x86/hyperv: detect if Linux is the root partition Message-ID: <20201112155124.x35q2rg2k53mc7to@liuwe-devbox-debian-v2> References: <20201105165814.29233-1-wei.liu@kernel.org> <20201105165814.29233-3-wei.liu@kernel.org> <87lff6y59t.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lff6y59t.fsf@vitty.brq.redhat.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 04:16:30PM +0100, Vitaly Kuznetsov wrote: [...] > > /* > > * Virtual processor will never share a physical core with another virtual > > * processor, except for virtual processors that are reported as sibling SMT > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > > index ffc289992d1b..ac2b0d110f03 100644 > > --- a/arch/x86/include/asm/mshyperv.h > > +++ b/arch/x86/include/asm/mshyperv.h > > @@ -237,6 +237,8 @@ int hyperv_fill_flush_guest_mapping_list( > > struct hv_guest_mapping_flush_list *flush, > > u64 start_gfn, u64 end_gfn); > > > > +extern bool hv_root_partition; > > Eventually this is not going to be an x86 only thing I believe? I hope so. :-) > > > + > > #ifdef CONFIG_X86_64 > > void hv_apic_init(void); > > void __init hv_init_spinlocks(void); > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > > index 05ef1f4550cb..f7633e1e4c82 100644 > > --- a/arch/x86/kernel/cpu/mshyperv.c > > +++ b/arch/x86/kernel/cpu/mshyperv.c > > @@ -237,6 +237,22 @@ static void __init ms_hyperv_init_platform(void) > > pr_debug("Hyper-V: max %u virtual processors, %u logical processors\n", > > ms_hyperv.max_vp_index, ms_hyperv.max_lp_index); > > > > + /* > > + * Check CPU management privilege. > > + * > > + * To mirror what Windows does we should extract CPU management > > + * features and use the ReservedIdentityBit to detect if Linux is the > > + * root partition. But that requires negotiating CPU management > > + * interface (a process to be finalized). > > + * > > + * For now, use the privilege flag as the indicator for running as > > + * root. > > + */ > > + if (cpuid_ebx(HYPERV_CPUID_FEATURES) & HV_CPU_MANAGEMENT) { > > We may want to cache cpuid_ebx(HYPERV_CPUID_FEATURES) somewhere but we > already had a discussion regading naming for these caches and decided to > wait until TLFS for ARM is out so we don't need to rename again. Exactly. Wei.