From patchwork Tue Nov 27 16:55:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10701019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB59C14E2 for ; Tue, 27 Nov 2018 16:58:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D90B82C3C7 for ; Tue, 27 Nov 2018 16:58:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBFCF2C455; Tue, 27 Nov 2018 16:58:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 702342C3C7 for ; Tue, 27 Nov 2018 16:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731570AbeK1D4d (ORCPT ); Tue, 27 Nov 2018 22:56:33 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34494 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731645AbeK1Dyh (ORCPT ); Tue, 27 Nov 2018 22:54:37 -0500 Received: by mail-wr1-f66.google.com with SMTP id j2so23473400wrw.1 for ; Tue, 27 Nov 2018 08:56:06 -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=6e1l9Y/ECE5gJLR0cHfFtNGEhOKinaqvIQUjwSbnIxA=; b=c7RLbeCBSVZ4Kt6XmRk41o0eRiADDbVObnmQOr8RuKkIYie1CCJ4fYq8kfj9AfajBv OBvv316qqeqXWjU+4grgAXMDTb6uhS5R6mR7OXy5YlGkW6IH0gS0+aVi0WFb16P7E03z C9Mq+XCW4ZYUNS6UaPDcu9pBuiFLIKyA94mcuUhjZjhUXihex0N5TWIkfeVY82bcQLdr HnqZUKZa05tov8/OoSNckF7DsE/hTRTiN3nnqkdkfHNTjS9r2E1LQsQBFGxVT7sHi56N GABTW4X86jJYnMHRjmDPORCZC1aM5Kpaj34BLZGfRVchAXfgDVsAjf47zSHA1CHobvdE vn/Q== 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=6e1l9Y/ECE5gJLR0cHfFtNGEhOKinaqvIQUjwSbnIxA=; b=h+Jj9i3Xo65XomUArMOUfxLSs3Th8WiPqp0rzZPb/vISdFeN6OXohgg7/dtJKtLSqg QWoV2lbe/oSbyUhTfEsTu4TEweKX9Tk4EU21Z3J2Vupruk+72YP58RWM8t4ANu6SeDUa 31Rzjl0zoh5atWWIp1JVosI0gBPfB0cL0W5ErIhp5iqLRcGHeWWFdsX17dityHWGb0G6 Nq5DNjQZ5uwKwhhdY+4LTzC9lAn67DA5j1GO8xK72c+ZJioHDMsvoEfZvynjwozdFuhy /V35RFz8fOrzAsztosLkJNoDZ7BXuEqnGpuZDS9G15br8puOhIVox+jo1CUL5j3xWx1d T1gw== X-Gm-Message-State: AA+aEWYFeA/FSv3NsJwRw0g8IZyNzktjBYl+hO7FH4bVbn+m2fsrGGUN HeXuPnnEupO/X9KJmfDI0j65gg== X-Google-Smtp-Source: AFSGD/UuH/6DY8P2w9UpFgpPIClD7KG7B4718Xsjq1f+D3WUkqLpCJuTKqnCRQRqaKolqFu71jv+oA== X-Received: by 2002:adf:9d4c:: with SMTP id o12mr2491101wre.94.1543337765359; Tue, 27 Nov 2018 08:56:05 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id k73sm6383099wmd.36.2018.11.27.08.56.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 08:56:04 -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 v12 09/25] arm64: move untagged_addr macro from uaccess.h to memory.h Date: Tue, 27 Nov 2018 17:55:27 +0100 Message-Id: <432ef6686a25b49244f54c4dfd86bc4b20381d8a.1543337629.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: References: MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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