Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1781174rwb; Mon, 7 Nov 2022 05:50:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM5AVRIKy58KC1xd1NeyaSfRwO+XPVMAJiVTHYll43e5BmkMR1H86twePK3ky/YC0r5hdoM9 X-Received: by 2002:a17:903:41c2:b0:187:3fb8:79bc with SMTP id u2-20020a17090341c200b001873fb879bcmr31649033ple.18.1667829031261; Mon, 07 Nov 2022 05:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667829031; cv=none; d=google.com; s=arc-20160816; b=E1Dld+x75NDzBP7T0zPK8u7bZ7r1vGpOtN9dKw2XPAxJSoMQOAEpuRfhuo8jQ2J84O McMOyG4RAlhkPskUFHibW3k1pE9ioG2vRVxuIzEsjCZlAuBTai3BXrPsLJFjm4YlqBqj bJVOm4goYpW3qnKTSHrw9NXJAYuMXCMCyl0p60VlMhceh7FjWtiHFV+x871edki5/rW1 Xd2jUpWo3e/9w1GQaZz3sJYGrbII5iGH4VjQCnZzMFyKJwvCOhi/gU0qAchJ/6FrBbYx 39LWQok8fbANFOL4rIYDM3RmXbQ0brBrHMkuu5Txmz+QgSYaST4n5MNLvAsTnq9ulBUF HsDQ== 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=EM7J7D1Zm6fNvtwG+ZxG6xLxxt3LquhQUFh8DKg9ovI=; b=XNOV9DtPVbCYzKJcNvS9UqsJeSY1GKmoCwkeh+pZ/4kBep72ZUzASi3oSbz0ttVXNB eo5Z0/vN8YYLll8S/yL3Hxj8PGkdtmsdBZKlIvm9Tjjhkuu9udY7Qr5jlF9As+4iuBgH 89uvkM8P0eQFPk4jyj5VQ8iqmE2HK9DIhldfVYivcwzUQbOtKAYdZgedCX34OBZLum+k 6PtdIst6Wv+qlv85Z0OgqToHgUoZPhtOUmjcT5onViyxLa2wbOBPswO3/DpKA0Q5QJhd F8ZJvTAVH6ENjd33OBHM+tD42H7JoK8lVy2h/q5lFdcm3o+0vbaiF5Mk/YJeYLEMRxru vEGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a17090a890100b001fe1c9436b1si9428642pjn.86.2022.11.07.05.50.17; Mon, 07 Nov 2022 05:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231980AbiKGNgr (ORCPT + 93 others); Mon, 7 Nov 2022 08:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbiKGNgp (ORCPT ); Mon, 7 Nov 2022 08:36:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E59041CB36 for ; Mon, 7 Nov 2022 05:36:44 -0800 (PST) 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 A6D441FB; Mon, 7 Nov 2022 05:36:50 -0800 (PST) Received: from [10.163.40.48] (unknown [10.163.40.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2798D3F73D; Mon, 7 Nov 2022 05:36:41 -0800 (PST) Message-ID: <375f4f58-e071-c102-43d7-7fdff3970f72@arm.com> Date: Mon, 7 Nov 2022 19:06:39 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH V2] arm64/mm: Simplify and document pte_to_phys() for 52 bit addresses Content-Language: en-US To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Mark Brown , Mark Rutland , linux-kernel@vger.kernel.org References: <20221107114850.2902150-1-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/22 17:32, Ard Biesheuvel wrote: > Hello Anshuman, > > On Mon, 7 Nov 2022 at 12:49, Anshuman Khandual > wrote: >> >> pte_to_phys() assembly definition does multiple bits field transformations >> to derive physical address, embedded inside a page table entry. Unlike its >> C counter part i.e __pte_to_phys(), pte_to_phys() is not very apparent. It >> simplifies these operations via a new macro PTE_ADDR_HIGH_SHIFT indicating >> how far the pte encoded higher address bits need to be left shifted. While >> here, this also updates __pte_to_phys() and __phys_to_pte_val(). >> >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: Mark Brown >> Cc: Mark Rutland >> Cc: Ard Biesheuvel >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-kernel@vger.kernel.org >> Suggested-by: Ard Biesheuvel >> Signed-off-by: Anshuman Khandual > > With the nit below fixed, this looks good to me > > Reviewed-by: Ard Biesheuvel > >> --- >> This applies on v6.1-rc4 >> >> Changes in V2: >> >> - Added PTE_ADDR_HIGH_SHIFT based method per Ard >> >> Changes in V1: >> >> https://lore.kernel.org/all/20221031082421.1957288-1-anshuman.khandual@arm.com/ >> >> arch/arm64/include/asm/assembler.h | 8 +++----- >> arch/arm64/include/asm/pgtable-hwdef.h | 1 + >> arch/arm64/include/asm/pgtable.h | 4 ++-- >> 3 files changed, 6 insertions(+), 7 deletions(-) >> >> diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h >> index e5957a53be39..6a39a3601cf7 100644 >> --- a/arch/arm64/include/asm/assembler.h >> +++ b/arch/arm64/include/asm/assembler.h >> @@ -660,12 +660,10 @@ alternative_endif >> .endm >> >> .macro pte_to_phys, phys, pte >> -#ifdef CONFIG_ARM64_PA_BITS_52 >> - ubfiz \phys, \pte, #(48 - 16 - 12), #16 >> - bfxil \phys, \pte, #16, #32 >> - lsl \phys, \phys, #16 >> -#else >> and \phys, \pte, #PTE_ADDR_MASK >> +#ifdef CONFIG_ARM64_PA_BITS_52 >> + orr \phys, \phys, \phys, lsl #PTE_ADDR_HIGH_SHIFT >> + and \phys, \phys, GENMASK_ULL(PHYS_MASK_SHIFT - 1, PAGE_SHIFT) > > Please use tabs between the mnemonics and the arguments. Sure, will do that.