Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp638062ybf; Wed, 26 Feb 2020 20:08:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwAcl04rK6OZ0Prrb2YZeSzaQ1XdllAlYvn6KVwdR4aSshKSgOaKWt3t0h8+2sFCaF67o/e X-Received: by 2002:a9d:7342:: with SMTP id l2mr1828608otk.98.1582776510343; Wed, 26 Feb 2020 20:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582776510; cv=none; d=google.com; s=arc-20160816; b=yDQ3HEIePx1P07pHF6E0Xj8p5BT3yyEJkTyWC09jtUy5oGVrxxCyO9Wpqn/nzhtOFB pRJ1wtox/u1niBxW7t+ihQwPcdWFGn6DsxEkJOITL4YdH2fCQ586y7fvJ8LW1jxAMkoS +RsQIKwDwQA5R0BO20Zf/HAxlrXSmlzFkjK2PZG5OAkI1GEiFZ6a2R22HUB8yjMFa5+w I6xRjy7qX6ePcJoXODtvhOME+rFAjO6CZZRqInA84JILZbKmr1nJkdHVZX1gnaPb6eVj DAvL4nstrkniRl5CfvejWwBNKZRG3o9zskrvGTso/7Yhdeum92dGR2lvtEcWp1w6Gb5S Ifew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ywPsIkgrPJoYIUXoymwbgnam6fT3JNfW7hJSWCMkCyk=; b=zBZN0IqJ4Jl7ibHH0hNQjVI843wwY7JSvY4/GyhsXUcxspmOL1B3uB51Y91/gbCS7W vFPjoqJpx2lldhuLotlCIHEDXAfVj0zIEMDoNXtEtNX42paKmV0WNe94KgcVAWFitEkc gBCEDxZV5p8FrdGVswMj7SuoypavSmaVlFdWVGRM5iBN4U6WkbWuSsem6WBx8uETkf42 lTtVKzzcstXyPkV3Mcqfvq+D0QN9ZmH/d2T6INGD++9ZGJt9pIBjh9yTY9WQXYpEJ0fK hw8uaSYE/mosD/1/Qmt/XH+nl9SbQ5UUCjZYBzeAA76t6g/fPnZCSilS3RF5DrphRjsa pGJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si963930otg.128.2020.02.26.20.08.17; Wed, 26 Feb 2020 20:08:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728356AbgB0EHW (ORCPT + 99 others); Wed, 26 Feb 2020 23:07:22 -0500 Received: from foss.arm.com ([217.140.110.172]:45362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728221AbgB0EHW (ORCPT ); Wed, 26 Feb 2020 23:07:22 -0500 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 75D6F30E; Wed, 26 Feb 2020 20:07:21 -0800 (PST) Received: from [10.163.1.119] (unknown [10.163.1.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E40F83F73B; Wed, 26 Feb 2020 20:07:11 -0800 (PST) Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers To: Andrew Morton Cc: Christophe Leroy , Qian Cai , linux-mm@kvack.org, Mike Rapoport , Vineet Gupta , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "Kirill A . Shutemov" , Paul Walmsley , Palmer Dabbelt , linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, James Morse References: <1581909460-19148-1-git-send-email-anshuman.khandual@arm.com> <1582726182.7365.123.camel@lca.pw> <1582726340.7365.124.camel@lca.pw> <52db1e9b-83b3-c41f-ef03-0f43e2159a83@arm.com> <20200226200353.ea5c8ec2efacfb1192f3f3f4@linux-foundation.org> From: Anshuman Khandual Message-ID: <6a4518d5-9306-8f84-b676-26a40c594bd9@arm.com> Date: Thu, 27 Feb 2020 09:37:07 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200226200353.ea5c8ec2efacfb1192f3f3f4@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/27/2020 09:33 AM, Andrew Morton wrote: > On Thu, 27 Feb 2020 08:04:05 +0530 Anshuman Khandual wrote: > >>> Must be something wrong with the following in debug_vm_pgtable() >>> >>>     paddr = __pa(&start_kernel); >>> >>> Is there any explaination why start_kernel() is not in linear memory on ARM64 ? >> >> >> Cc: + James Morse >> >> This warning gets exposed with DEBUG_VIRTUAL due to __pa() on a kernel symbol >> i.e 'start_kernel' which might be outside the linear map. This happens due to >> kernel mapping position randomization with KASLR. Adding James here in case he >> might like to add more. >> >> __pa_symbol() should have been used instead, for accessing the physical address >> here. On arm64 __pa() does check for linear address with __is_lm_address() and >> switch accordingly if it is a kernel text symbol. Nevertheless, its much better >> to use __pa_symbol() here rather than __pa(). >> >> Rather than respining the patch once more, will just send a fix replacing this >> helper __pa() with __pa_symbol() for Andrew to pick up as this patch is already >> part of linux-next (next-20200226). But can definitely respin if that will be >> preferred. > > I didn't see this fix? I assume it's this? If so, are we sure it's OK to be > added to -next without testing?? My patch just missed your response here within a minute :) Please consider this. It has been tested on x86 and arm64. https://patchwork.kernel.org/patch/11407715/ > > > > From: Andrew Morton > Subject: mm-debug-add-tests-validating-architecture-page-table-helpers-fix > > A warning gets exposed with DEBUG_VIRTUAL due to __pa() on a kernel symbol > i.e 'start_kernel' which might be outside the linear map. This happens > due to kernel mapping position randomization with KASLR. > > __pa_symbol() should have been used instead, for accessing the physical > address here. On arm64 __pa() does check for linear address with > __is_lm_address() and switch accordingly if it is a kernel text symbol. > Nevertheless, its much better to use __pa_symbol() here rather than > __pa(). > > Reported-by: Qian Cai > Cc: Anshuman Khandual > Cc: James Morse > Cc: Christophe Leroy > Signed-off-by: Andrew Morton > --- > > mm/debug_vm_pgtable.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/mm/debug_vm_pgtable.c~mm-debug-add-tests-validating-architecture-page-table-helpers-fix > +++ a/mm/debug_vm_pgtable.c > @@ -331,7 +331,7 @@ void __init debug_vm_pgtable(void) > * helps avoid large memory block allocations to be used for mapping > * at higher page table levels. > */ > - paddr = __pa(&start_kernel); > + paddr = __pa_symbol(&start_kernel); > > pte_aligned = (paddr & PAGE_MASK) >> PAGE_SHIFT; > pmd_aligned = (paddr & PMD_MASK) >> PAGE_SHIFT; > _ > >