Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2954245rdb; Tue, 12 Sep 2023 18:39:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsuSS/81n2+TioyMEoEOPW71VcfUKIJ1xQqG52uvw1/+uqNxQRTJgZPe4+2QtZRaQ4HW7M X-Received: by 2002:a17:902:ea01:b0:1bd:b8c8:98f8 with SMTP id s1-20020a170902ea0100b001bdb8c898f8mr1624405plg.4.1694569147221; Tue, 12 Sep 2023 18:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694569147; cv=none; d=google.com; s=arc-20160816; b=sQndq436vBWXpmAdMcMTwK/e4tabHMGKV1XmydFua8S3KGRaJWdV1phQQhizAtkfDz OnCSgK30xRJvDGrcCk3auNsrNP28UtQdSOnvgnbgs/0i9UHjd//m6IC8nfAzcLwCFe4A vWaNTL46VgLLrNc72KKRhFaweGqcMJdGkm2pZbIyTVcO4hN61HG+VJiD7FsQLrOuSKbB R2PTywoiTylT5Qufv6Vp51HFcstf5fKmVZOZst5YI42bT/tYlF/O78wyyBI+3KV7VUFz V4JJaadR00K5QKhN7d4Z31cwVXhet5a9n1rTaMU5Q5r+iM4EJNq+74QD7XhtEYzLVElr ho7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=063dqvWtVV0KIzgflDMtEgnv1vfUV9875KEhiQ6tE80=; fh=/Z3nYIAvYwDBnGBtBApzf0l+0ba+5hOrc07p4Zn/Um4=; b=KpQrcLx9b3VSKxlUfF9trjQJ9fftNjr2I0XJqVVR+h61rVTHusKB+fDY/8/V5XWZOZ +ce07/ube+VBgmMO4T4hJyPyzAxl+nKWyXJZtMwBfsvoBQeEOf0HXwjR/fCHixN+Ak1P OHbbwnAWEfzd3xdeXFL4ChNBz7pl4CIOn773Cl5nG6LGY1nBaqIAfX+6diuIHGi5TVxU +C/WN0IR/TFv4SPoKQ6EmUdgStNl4U1VPwbVnADRQEnitaxfBvWaCglbviWQbY//u/1/ 6tIFkQuSiu4PwhVKqfRBZnQ53HwloVhqoePdLQ5fKsYz2SiAj6NCeR4lelkUbYlkXiC3 ZzKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id jy5-20020a17090342c500b001b89b1bae72si8898450plb.528.2023.09.12.18.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 18:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5A6A1813CD9C; Tue, 12 Sep 2023 01:31:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232705AbjILIbw (ORCPT + 99 others); Tue, 12 Sep 2023 04:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjILIbv (ORCPT ); Tue, 12 Sep 2023 04:31:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0784AB9 for ; Tue, 12 Sep 2023 01:31:47 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C81FCC15; Tue, 12 Sep 2023 01:32:23 -0700 (PDT) Received: from [10.57.31.51] (unknown [10.57.31.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B83033F738; Tue, 12 Sep 2023 01:31:45 -0700 (PDT) Message-ID: <759c91b9-856e-a778-0e0a-e52240e5c8ce@arm.com> Date: Tue, 12 Sep 2023 09:31:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] arm64: cpufeature: Expose the real mpidr value to EL0 Content-Language: en-GB To: "guojinhui.liam" , catalin.marinas@arm.com, will@kernel.org Cc: lizefan.x@bytedance.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230912035209.1687-1-guojinhui.liam@bytedance.com> From: Robin Murphy In-Reply-To: <20230912035209.1687-1-guojinhui.liam@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 01:31:52 -0700 (PDT) On 2023-09-12 04:52, guojinhui.liam wrote: > In EL0, it can get the register midr's value to distinguish vendor. > But it won't return real value of the register mpidr by using mrs > in EL0. The register mpidr's value is useful to obtain the cpu > topology information. ...except there's no guarantee that the MPIDR value is anything other than a unique identifier. Proper topology information is already exposed to userspace[1], as described by ACPI PPTT or Devicetree[2]. Userspace should be using that. Not to mention that userspace fundamentally can't guarantee it won't be migrated at just the wrong point and read the MPIDR of a different CPU anyway. (This is why the MIDRs and REVIDRs are also reported via sysfs, such that userspace has a stable and reliable source of information in case it needs to consider potential errata.) Thanks, Robin. [1] https://www.kernel.org/doc/html/latest/admin-guide/cputopology.html [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/cpu/cpu-topology.txt > In some scenarios, the task scheduling in userspace can be > optimized with CPU Die information. > > Signed-off-by: guojinhui.liam > --- > arch/arm64/include/asm/sysreg.h | 3 --- > arch/arm64/kernel/cpufeature.c | 2 +- > 2 files changed, 1 insertion(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h > index 38296579a4fd..1885857c8a22 100644 > --- a/arch/arm64/include/asm/sysreg.h > +++ b/arch/arm64/include/asm/sysreg.h > @@ -901,9 +901,6 @@ > #define SYS_TFSR_EL1_TF0 (UL(1) << SYS_TFSR_EL1_TF0_SHIFT) > #define SYS_TFSR_EL1_TF1 (UL(1) << SYS_TFSR_EL1_TF1_SHIFT) > > -/* Safe value for MPIDR_EL1: Bit31:RES1, Bit30:U:0, Bit24:MT:0 */ > -#define SYS_MPIDR_SAFE_VAL (BIT(31)) > - > #define TRFCR_ELx_TS_SHIFT 5 > #define TRFCR_ELx_TS_MASK ((0x3UL) << TRFCR_ELx_TS_SHIFT) > #define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT) > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index b018ae12ff5f..6e18597fdcc3 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3450,7 +3450,7 @@ static inline int emulate_id_reg(u32 id, u64 *valp) > *valp = read_cpuid_id(); > break; > case SYS_MPIDR_EL1: > - *valp = SYS_MPIDR_SAFE_VAL; > + *valp = read_cpuid_mpidr(); > break; > case SYS_REVIDR_EL1: > /* IMPLEMENTATION DEFINED values are emulated with 0 */