From patchwork Fri May 28 01:04:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12285959 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_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 C6206C47089 for ; Fri, 28 May 2021 01:07:16 +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 80AC5613B8 for ; Fri, 28 May 2021 01:07:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80AC5613B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date: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=CV7JbmgKbunAO96Dh89HeafQFHnF4Vo7/evj2qaQWI4=; b=Y+0 I5TwZBG3obJiyauHThRohkR9lbz25b23o+3xgXsAqz4Sry3NKq/7I1c8KkjAT6uQSstdTuZgiVfpo tE3yxnPNN3quF+SS3st9UXdcGnqql8IceVjsTYyHnX6wsuzRYAvXo1ADd9Xx0a6YO8JFTvo4WUkQV CvH9lPg6BacinDQs4AhTC2YMdB8IJ6gO5Lp8SQd44iHyFpUnVxhIKuJiqvxotSjnPpxnvoK1bEs6U OIpj1/u65pyKxBx4tiasIhDIS51qr8LCpDYZ7gSGrPjW48ziJ7KpPdA5IRDKNrcFkE6XhkmObg6wR aGZhGV2ja9Q+NV/Yu2J9JVyjeu6tFow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmQvt-00AntN-VJ; Fri, 28 May 2021 01:05:03 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmQvZ-00Ankv-QD for linux-arm-kernel@lists.infradead.org; Fri, 28 May 2021 01:04:43 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id d20-20020a25add40000b02904f8960b23e8so2502564ybe.6 for ; Thu, 27 May 2021 18:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=yGQNPDZVZEKXhNRsAsdzkYtxvbYhsxMqkIDbMyScfIk=; b=BKFgLfgb9mU0prypCg4ahbt3T4miMBIX7jvBJc3NeEtM4kitE531un1cnIDsjjwrp1 WFRSc1HrkDfyjsIbXKXghZrKHqT8HJIkM/vzq5l/I5pPN2ntDLfSO5BIlo9auT/eALGK T08mmzyqCbY7kNOxuxe6UVtJVAW6lx8xmZqQ4dmY+CE/xZuz1Al8nH9XRCExLMD5OuCP iUwy5TfJ59zOC6INg6062K7qsA4MWtp8XcLZRaaPCMJYzAAB5bN5TfHeoBF2LSTbRUEs snHPfMPGViNystEhnRIj+n2cGbPJ//4m6+dbyEZmVpKqsSEX9Y4feDXfhFiI2/18rrKB BfsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=yGQNPDZVZEKXhNRsAsdzkYtxvbYhsxMqkIDbMyScfIk=; b=XxmqUxKRWHkx3gO+8cYLgLcSrAugIUxtporHMnBqXXRDNB5QecA5bAM8StK9foML6U CobKr7NKzsFiPZeWBow5ZclxykyHb50yF+Ch0epKDmCu+WeSRWBwcyR41VJPwoGJDQxv 7CdZNB6gXf4gI++TJqehRjHuyWNi/r12aPf55xKxFLSttqaxicE9T8tlrcnp5M/8Olwi xY+mCtEBEVTFqhbC/LMfQHu5ubvYxtnZHVXO53xcMgPqoMXDvVscl/eF/qgQT8QX3hrW d0yNky2IfO4CsLFC7vwK1ari7H140S1ZG9UEZFug33cbxAgFmlriuBC/83w/p6rbkh7D NAzA== X-Gm-Message-State: AOAM531FnRpH6oG10EpSjhjI3PbtwzPh/DHxOG/8hJTI+h+blUtLHIYy AYBERBOj1oJgu4etmPxfQQTCEIM= X-Google-Smtp-Source: ABdhPJyicO4FUY2khispE+PoXbec2o1vIqIP9VYltd7e9qQP0Ag/7lInkA5qjcnQ0Wm2mvhDQZWAZv4= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:81d5:efb9:ec22:d557]) (user=pcc job=sendgmr) by 2002:a5b:cc3:: with SMTP id e3mr8793789ybr.297.1622163879947; Thu, 27 May 2021 18:04:39 -0700 (PDT) Date: Thu, 27 May 2021 18:04:11 -0700 Message-Id: <20210528010415.1852012-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog Subject: [PATCH v4 0/4] arm64: improve efficiency of setting tags for user pages From: Peter Collingbourne To: Andrey Konovalov , Alexander Potapenko , Catalin Marinas , Vincenzo Frascino , Andrew Morton , Jann Horn Cc: Peter Collingbourne , Evgenii Stepanov , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_180441_908455_8D711B86 X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently we can end up touching PROT_MTE user pages twice on fault and once on unmap. On fault, with KASAN disabled we first clear data and then set tags to 0, and with KASAN enabled we simultaneously clear data and set tags to the KASAN random tag, and then set tags again to 0. On unmap, we poison the page by setting tags, but this is less likely to find a bug than poisoning kernel pages. This patch series fixes these inefficiencies by only touching the pages once on fault using the DC GZVA instruction to clear both data and tags, and avoiding poisoning user pages on free. Peter Collingbourne (4): mm: arch: remove indirection level in alloc_zeroed_user_highpage_movable() kasan: use separate (un)poison implementation for integrated init arm64: mte: handle tags zeroing at page allocation time kasan: disable freed user page poisoning with HW tags arch/alpha/include/asm/page.h | 6 +-- arch/arm64/include/asm/mte.h | 4 ++ arch/arm64/include/asm/page.h | 10 +++-- arch/arm64/lib/mte.S | 20 ++++++++++ arch/arm64/mm/fault.c | 26 +++++++++++++ arch/arm64/mm/proc.S | 10 +++-- arch/ia64/include/asm/page.h | 6 +-- arch/m68k/include/asm/page_no.h | 6 +-- arch/s390/include/asm/page.h | 6 +-- arch/x86/include/asm/page.h | 6 +-- include/linux/gfp.h | 18 +++++++-- include/linux/highmem.h | 43 ++++++++------------- include/linux/kasan.h | 64 +++++++++++++++++++------------- include/linux/page-flags.h | 9 +++++ include/trace/events/mmflags.h | 9 ++++- mm/kasan/common.c | 4 +- mm/kasan/hw_tags.c | 32 ++++++++++++++++ mm/mempool.c | 6 ++- mm/page_alloc.c | 66 +++++++++++++++++++-------------- 19 files changed, 242 insertions(+), 109 deletions(-)