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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31205C433FF for ; Wed, 14 Aug 2019 09:19:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 009E820843 for ; Wed, 14 Aug 2019 09:19:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qqepgfCD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 009E820843 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vXBRJXNNqj8bnHJBEZAl4JC5h1/JMMNhjaJgqmoDPXk=; b=qqepgfCDbf7G5m EGoi/m48buQnue7jm6ieDe8Fm60CmAnrgsYh5URHWueTwX7eFs1xl5hY7epA8Bs6Cl++ZJEWJTNZv Z3S5pE7iq37O9vGqWyCvxlgF4RvpaXmYksil56vMX1k0Fgz4j7IYNSLAErfhJg4C7qjSOfNr7OCVW dJhewUcfDey8oL7pFT8HGR9fAyGhsYmcvHxHWzqM9rnIQei/p8C1geFpjM8Yiz4+0hhye0Jd0LlxB qLsSH8YrM3Qp8TpkUCDwU2krKFg6g2SxJKrWlQgtGNTtJ+hsnejOUCIL3/i6uqYmxIblnQo1mRqjY KkESXcET9eksnpSEmc3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hxpRf-0007Gs-ET; Wed, 14 Aug 2019 09:19:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hxpRc-0007GF-Im for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2019 09:19:49 +0000 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 D1EE1344; Wed, 14 Aug 2019 02:19:45 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D00F43F694; Wed, 14 Aug 2019 02:19:44 -0700 (PDT) Date: Wed, 14 Aug 2019 10:19:42 +0100 From: Catalin Marinas To: Will Deacon Subject: Re: [PATCH 1/8] arm64: memory: Fix virt_addr_valid() using __is_lm_address() Message-ID: <20190814091942.GA50688@arrakis.emea.arm.com> References: <20190813170149.26037-1-will@kernel.org> <20190813170149.26037-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190813170149.26037-2-will@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190814_021948_665350_85ABCFAC X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Steve Capper , Andrey Konovalov , Geert Uytterhoeven , Qian Cai , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Aug 13, 2019 at 06:01:42PM +0100, Will Deacon wrote: > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index afaf512c0e1b..442ab861cab8 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -244,9 +244,9 @@ static inline const void *__tag_set(const void *addr, u8 tag) > /* > * The linear kernel range starts in the middle of the virtual adddress > * space. Testing the top bit for the start of the region is a > - * sufficient check. > + * sufficient check and avoids having to worry about the tag. > */ > -#define __is_lm_address(addr) (!((addr) & BIT(vabits_actual - 1))) > +#define __is_lm_address(addr) (!(((u64)addr) & BIT(vabits_actual - 1))) > > #define __lm_to_phys(addr) (((addr) + physvirt_offset)) > #define __kimg_to_phys(addr) ((addr) - kimage_voffset) > @@ -326,13 +326,13 @@ static inline void *phys_to_virt(phys_addr_t x) > > #define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) + VMEMMAP_START)) > #endif > -#endif > > -#define _virt_addr_is_linear(kaddr) \ > - (__tag_reset((u64)(kaddr)) >= PAGE_OFFSET) > +#define virt_addr_valid(addr) ({ \ > + __typeof__(addr) __addr = addr; \ > + __is_lm_address(__addr) && pfn_valid(virt_to_pfn(__addr)); \ > +}) There is a slight change of semantics here but I don't think it's an issue currently. __is_lm_address() is true even for a user address, so at least the first part of virt_addr_valid() now accepts such addresses. The pfn would be wrong eventually because of the virt-to-phys offsetting and pfn_valid() false but we rely on this rather than checking it's a kernel address. Slight concern as this macro is called from drivers. Should we keep the PAGE_OFFSET check as well? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel