Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10635851imu; Thu, 6 Dec 2018 04:29:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/VydYwcyFRKAYKEPKh/gYJ5hnMWs5NpdlAe0O9ZoXQVMP119MKawXZuMu9Ca2djzhtR80R8 X-Received: by 2002:a17:902:b112:: with SMTP id q18mr28067183plr.255.1544099361091; Thu, 06 Dec 2018 04:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544099361; cv=none; d=google.com; s=arc-20160816; b=XL5LjjPIyZDrgF409u276Hf0uHEn4NEDkmNLKIhPDTTDevmPSbmt1EL0lwTty4OAhq 4RPqtkzmvFySoS5Wnf6bEtKpeuTQ4NKrINZFkjEeaKQ4wNqB/JRE/DDTI9jHgYTYJScL GTyt+g5X4au7X99akon5s05Y4t5jRyHE4dgVOvBui/bBjibtLW7iyQ6ZURk0s3J+utYb 9A4Wg3I5vvFLblzREt4T81PbbvO50oTE+6cVM09e0hvkF2g4HOPmG0ibJOPtlCuIGpuj u1ecbYz4JM0gKtg7kcEFqzf3nGqwtcMjXpCS3dpxHU12bdJhbs7WY2cTcYb3y/pIAUbs 6Ldw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F/Rs74E1jKAK3ACh/wE42WMWNbPFeAMFJIPcMbt9WD4=; b=hdJbB2rqTSEz0+xMa/xN7bzzLUYAs8yovtl1iOUG0X8EpX1hbKMEeLNFuAJWIYBsGN QQ26gEbxFf6F25p2PG5G0i80RopGjQxznfz2SjETPex7RzOYhJtgh1jOoLgJ/M0/i9PK kuGx/t49/B3SVcXZJs9+d38Q/M+QTLf3eAI+MAk7UQHQyuFXvijrMkhPSQw8voCfQibF OSzd+pCBxrrVV0DgaizWkMK284WGqTyi9Xrg+2rKAcLP17k03pmFnsADvhj/hJrU/A6G 9B+/fOgv/UeCK79khUTomR+dK6QnwbC6PHidO5t3mNsnsqxt6wUhSqjDV1VNZaWujNJe uzIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VAlGzqot; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si183878pls.146.2018.12.06.04.29.04; Thu, 06 Dec 2018 04:29:21 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=VAlGzqot; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729912AbeLFM1G (ORCPT + 99 others); Thu, 6 Dec 2018 07:27:06 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44746 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729571AbeLFMZE (ORCPT ); Thu, 6 Dec 2018 07:25:04 -0500 Received: by mail-wr1-f65.google.com with SMTP id z5so259841wrt.11 for ; Thu, 06 Dec 2018 04:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F/Rs74E1jKAK3ACh/wE42WMWNbPFeAMFJIPcMbt9WD4=; b=VAlGzqot4KggH/2lBiRkMM4lITHs5IpRZ4p+F4SbO+qt098Hg0g4wlLA22lQa2+sgu 1ZO/pc5wB2nDiSRi5FFQsNwlSmKERZzC6+C1bm7VRPFwLoKQrSId434VtYvpzCsk7c3i /vH7cIfPKbr+V1Dilr9fKTxodHnjd41ZTfyz597HV372In0cpd9mvAmlNFP+HJxA+AQ+ mzStQ2w6DGPYRDzykQjqYtFlASCb4Bva887fDY6JzKFwMetT4nD71IbFlWztZ4E/AIat lVr7320saaRT4uROOn2botn655EPyWEYbn4KMSnBzLpXEAJMIWiYQJli7yQdCgLhi50x ffvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F/Rs74E1jKAK3ACh/wE42WMWNbPFeAMFJIPcMbt9WD4=; b=EpVzrT96tIIhCwtQ39l57nMuL2wnsNPS2EqaM9Bmghi/jiZF5HmIjE0YesXe2HRmsw bzUgYhl4//ZxnkCxXJMV1rl3sXQM4uTMxoOTGG+1TtkVzlRTjDmjYt3cz0FbD8yHhrNE Mzu8wL3DTgn+0CEIHzsPS19TsWJ8FS0IHZ0reXqGMtTZEukzTGxecAxEkszmecjKzgTx eDE7MXyQeLpm5ao/JkUmxI1c+eqkyR+u7KLsMMw1jpEmrNQurB62uSdiVX/9V2rKjqf5 fQ8skYialVKt7y6HdP37Tru3ngH8W7IzUHFiZaI9GoR4L17nFsRmIgWXVcipYwxAprK8 FbpA== X-Gm-Message-State: AA+aEWZAeC5IR8KqmzAJ9K8XwUCUSvDHHjSX97Q4/u8u50D/nGbM9Vlw szJ28+r0a40rLM/Q6FdpBvwI1A== X-Received: by 2002:adf:b783:: with SMTP id s3mr26257157wre.274.1544099102810; Thu, 06 Dec 2018 04:25:02 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id j8sm339988wrt.40.2018.12.06.04.25.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 04:25:01 -0800 (PST) From: Andrey Konovalov To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan , Andrey Konovalov Subject: [PATCH v13 09/25] arm64: move untagged_addr macro from uaccess.h to memory.h Date: Thu, 6 Dec 2018 13:24:27 +0100 Message-Id: <2e9ef8d2ed594106eca514b268365b5419113f6a.1544099024.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the untagged_addr() macro from arch/arm64/include/asm/uaccess.h to arch/arm64/include/asm/memory.h to be later reused by KASAN. Also make the untagged_addr() macro accept all kinds of address types (void *, unsigned long, etc.). This allows not to specify type casts in each place where the macro is used. This is done by using __typeof__. Acked-by: Mark Rutland Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/memory.h | 8 ++++++++ arch/arm64/include/asm/uaccess.h | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 05fbc7ffcd31..e2c9857157f2 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -211,6 +211,14 @@ static inline unsigned long kaslr_offset(void) */ #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) +/* + * When dealing with data aborts, watchpoints, or instruction traps we may end + * up with a tagged userland pointer. Clear the tag to get a sane pointer to + * pass on to access_ok(), for instance. + */ +#define untagged_addr(addr) \ + ((__typeof__(addr))sign_extend64((u64)(addr), 55)) + /* * Physical vs virtual RAM address space conversion. These are * private definitions which should NOT be used outside memory.h diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 07c34087bd5e..281a1e47263d 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -96,13 +96,6 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si return ret; } -/* - * When dealing with data aborts, watchpoints, or instruction traps we may end - * up with a tagged userland pointer. Clear the tag to get a sane pointer to - * pass on to access_ok(), for instance. - */ -#define untagged_addr(addr) sign_extend64(addr, 55) - #define access_ok(type, addr, size) __range_ok(addr, size) #define user_addr_max get_fs -- 2.20.0.rc1.387.gf8505762e3-goog