From patchwork Mon Feb 1 19:06:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 12059765 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=-12.1 required=3.0 tests=BAYES_00,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_GIT 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 EF653C433DB for ; Mon, 1 Feb 2021 19:07:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 A4FBE64E8D for ; Mon, 1 Feb 2021 19:07:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4FBE64E8D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=z0a1B7a4BjG2PcYPyOjqmB/ohVPe3wwXdAnHd1hlaTk=; b=RS9q0kFtw6zjeX2LZp+N3q3P2X ks3V1pHd/4muO5kLEr7AeFGesKntGjoxpmk/vHzQAT6nvbQ6vTjJc5Z9ZKzQ6VJ2HdUbOu8dLq5wF VWqLiIikr8sgwH02S+y/FOjQK7JNeNgfUbLaX+755IfAUBONSYsqkHqrfJKieutg/bmaK50yo9mHF mObyIzffJ/dOc8fs/jqqygPnMBcuvJrCR5VOmmI/JI4K6C4e0kNzjQaxtTs77Czuo5xdRI7GjjXKg dvyxTL7Avd62vsK48H7kuZGzZz7MB05eB4EXDXRNVx1qz78yQsXmlr9FMOgLsEN9FlPOUvkNutCZ7 qMN05Mwg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6eX3-0005Pf-7m; Mon, 01 Feb 2021 19:06:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6eX0-0005Ol-PO for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 19:06:39 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2539764E8F; Mon, 1 Feb 2021 19:06:35 +0000 (UTC) From: Catalin Marinas To: Ard Biesheuvel , Linus Torvalds Subject: [PATCH 0/2] arm64: Further fixes to the linear address checking Date: Mon, 1 Feb 2021 19:06:32 +0000 Message-Id: <20210201190634.22942-1-catalin.marinas@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_140638_940681_B181376B X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. 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 , Vincenzo Frascino , Will Deacon , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There some history to virt_addr_valid() that goes back to 5.4. It seems to have been ok prior to this kernel, however, the VA reshuffling in commit 14c127c957c1 ("arm64: mm: Flip kernel VA space") broke it. The subsequent fix 68dd8ef32162 ("arm64: memory: Fix virt_addr_valid() using __is_lm_address()") partially addressed it but it left virt_addr_valid() returning true for user addresses (or NULL). The recent commit 519ea6f1c82f ("arm64: Fix kernel address detection of __is_lm_address()") fixed the NULL checking but broke the virt_addr_valid() macro for tagged addresses. The first patch attempts to fix virt_addr_valid() macro for tagged addresses. The second patch replaces the bitwise operations with a subtract. The resulting image is slightly smaller. Catalin Marinas (2): arm64: Do not pass tagged addresses to __is_lm_address() arm64: Use simpler arithmetics for the linear map macros arch/arm64/include/asm/memory.h | 6 +++--- arch/arm64/mm/physaddr.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)