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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6406BC6FD22 for ; Thu, 17 Aug 2023 23:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XkIHKAqnnLLDps4zQTEfu5rsTjvOUJ8j1AUrqvJKzlY=; b=F8k1Wz936Ud6tR VzIbk6JmcO0p2vxtvATehApP0DaoONSVDxwFtK91n9xShbrRE5INtXDLgOrYXu4JbTde7Krw8vbRf 4zNARM0Ay01zCcsSyolsk05panr4jUnB86rlqJZ+L1GoEigkCDghHqUGpSs7Zt7A5/VJT/gTdkJA/ tCiAcZxnBBoc22+qKCsoDzR7IgwAg3Na6+9DFSKYWLgmY31geRznm9oqVudCcagVyp+UOFsxeS8Rz 6mh4bO64FQinkl//gxtTYLOB3RL7ft8SWZYkyA7jpR762mElpUvxIdK5ZQsCjtXIiPWMP7c8O1/W+ eYTH8V3OiYqBr10I0oxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWmCO-007Iys-0K; Thu, 17 Aug 2023 23:14:40 +0000 Received: from mgamail.intel.com ([134.134.136.31]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWmCL-007IyL-1j for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2023 23:14:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692314077; x=1723850077; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=HPtftuttc3nnrGELFH+bHrdAFWcXr46RVKvnOFRQIDI=; b=dAQjJuEXT4ZIev0m/pIA0XF9v261UcJq/CG5H4UcAaHG/KLc6ONnmBzZ 7cvYULQ/xseaJ/1hL5SJXgJa6Ta1+Wmg1Dz0eT7tGaoGEAaR9YLiORw9l luDheJNgVH/6Ek8jDq/uEZiohRB5gsKk3lDlrpzAQOG1idvsa+3lM+1zG DdhKm3/wNlnuSLwSD+artcxzoVb4uLqnj0/tfVBrnPk8l5WCyW4VJ76Ft wGOvEfrAGDdTwVzw1NngM0JPLYV0PvF/76zoZFFzJsgkJknqpSVrWkeYJ 5+5y4CTnQTxg9BI18ndaAIHx7p1Cpd5cPXaslrRqPB29OIBj22enKgZ4q w==; X-IronPort-AV: E=McAfee;i="6600,9927,10805"; a="436872066" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="436872066" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2023 16:14:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10805"; a="824863019" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="824863019" Received: from lacoffin-mobl.amr.corp.intel.com (HELO [10.212.196.192]) ([10.212.196.192]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2023 16:14:31 -0700 Message-ID: <0d18816a-c46e-ac7e-b98f-ef3dba1c356e@intel.com> Date: Thu, 17 Aug 2023 16:14:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 02/15] mshyperv: Introduce hv_get_hypervisor_version function Content-Language: en-US To: Nuno Das Neves , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org Cc: patches@lists.linux.dev, mikelley@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, haiyangz@microsoft.com, decui@microsoft.com, apais@linux.microsoft.com, Tianyu.Lan@microsoft.com, ssengar@linux.microsoft.com, mukeshrathor@microsoft.com, stanislav.kinsburskiy@gmail.com, jinankjain@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, will@kernel.org, catalin.marinas@arm.com References: <1692309711-5573-1-git-send-email-nunodasneves@linux.microsoft.com> <1692309711-5573-3-git-send-email-nunodasneves@linux.microsoft.com> From: Dave Hansen In-Reply-To: <1692309711-5573-3-git-send-email-nunodasneves@linux.microsoft.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_161437_707682_1FCBFA41 X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 8/17/23 15:01, Nuno Das Neves wrote: > +int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) > +{ > + hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION, > + (struct hv_get_vp_registers_output *)info); > + > + return 0; > +} ... > +int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) > +{ > + unsigned int hv_max_functions; > + > + hv_max_functions = cpuid_eax(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS); > + if (hv_max_functions < HYPERV_CPUID_VERSION) { > + pr_err("%s: Could not detect Hyper-V version\n", > + __func__); > + return -ENODEV; > + } > + > + info->eax = cpuid_eax(HYPERV_CPUID_VERSION); > + info->ebx = cpuid_ebx(HYPERV_CPUID_VERSION); > + info->ecx = cpuid_ecx(HYPERV_CPUID_VERSION); > + info->edx = cpuid_edx(HYPERV_CPUID_VERSION); > + > + return 0; > +} I can't help but notice that the ARM version does *one* call to the hardware while the x86 version does CPUID four different times, once to get *EACH* register and throwing away the other three registers each time. Also recall that CPUID is a big, fat architecturally serializing instruction. This isn't a fast path, but CPUID is about as slow as you get. Is there any reason you can't just have an x86 version of hv_get_vpreg_128() that gets the 128 bits bytes of data that comes back in the 4 CPUID registers? That might even let you share some more code. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel