From patchwork Wed May 12 20:09:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12254609 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=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 78A70C433B4 for ; Wed, 12 May 2021 20:09:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 073E361408 for ; Wed, 12 May 2021 20:09:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 073E361408 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 618836B0072; Wed, 12 May 2021 16:09:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EF146B0073; Wed, 12 May 2021 16:09:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 491406B0074; Wed, 12 May 2021 16:09:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id 172426B0072 for ; Wed, 12 May 2021 16:09:44 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A7A401812C286 for ; Wed, 12 May 2021 20:09:43 +0000 (UTC) X-FDA: 78133669446.09.6005D28 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf30.hostedemail.com (Postfix) with ESMTP id 64685E000111 for ; Wed, 12 May 2021 20:09:13 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id l8-20020a25b3080000b02904f8bd69022dso15621122ybj.9 for ; Wed, 12 May 2021 13:09:43 -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=+0yao2TT5p+GhWI1k25YcAL0rNNU5KO4OXR8rnQwh+s=; b=Lv22/LjmwMimEtlv7dgarWOQmOloUg2zsCDl0rehf9BM/oY85KfP51miSbM6u6IEwu wG64sT/V3MUhbrmAleEVhUXKqnh2R0mKokU2b4f7t3dgWKjcUZi6XbZMDV1opoK6htik nEqFn9/cdtko2wO9tf1TUnrCjTIENtLg/F1qVH0St/DVovTXHjNqZ/IxyfRWceF3EDne SlT/5/fw/4SCTjfXx4bG+9ZiencU2ATl2xngegCMfuxfTjyK0RkypWcwBUnuCMA3w8YP m2w8BiJNdTf8qiUZyKwtI7mVRO0GVjc1hBD5OhqJWrdAyfdZ+nnHtt7eYE9GwgjIfBNl rPSw== 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=+0yao2TT5p+GhWI1k25YcAL0rNNU5KO4OXR8rnQwh+s=; b=eYa9FDwkodQBQ3RMWAmdIDbmNr5XmuEvUvbMqGfGYLQ6QPoKTgCXM+veZeoZS3nQ0T jjmOkeJubnkhA5Z1zc4Wh3mpaJpPnnnA6wIXFzwCPg36Jj84kkquAItBDgMs0ius4Gpw topKFV0K/dCsBkHz+RBBnU0xsQKud1qwOTKwc8jH3fnrFwKAgqxTj5kIykri3c0OVBCv ovnzTIya4JP8a3IzF52nTKSXPSW/XPuogfbWXMNsrLkP8FJUXAiZOZQPA4BH/aew1pqD wx0Z9A3hOjIOaCFvN8D2WCAPPF3zPNsg1FvB9xlD5WujWq2Z0aAuJFC3WM/OhyNs0oEL l48w== X-Gm-Message-State: AOAM530EgzMl5UbyphFT7M8YZzRcD6drvGXmET92ZIfYEG5SKUbTR0Z0 uQxM/Fd1GZn/yueIQDSZWFc+UkQ= X-Google-Smtp-Source: ABdhPJzf1yEJQZQc6i5JDpgjPF+O5I4ljfly/agrb55QOA4U2Dkpef3nqmlN0DVzgJT5k1pBWsg1slk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:d8b:fba6:20f0:cbe3]) (user=pcc job=sendgmr) by 2002:a25:30d5:: with SMTP id w204mr50240961ybw.416.1620850182425; Wed, 12 May 2021 13:09:42 -0700 (PDT) Date: Wed, 12 May 2021 13:09:30 -0700 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH v3 0/3] arm64: improve efficiency of setting tags for user pages From: Peter Collingbourne To: Andrey Konovalov , Alexander Potapenko , Catalin Marinas , Vincenzo Frascino , Andrew Morton Cc: Peter Collingbourne , Evgenii Stepanov , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b="Lv22/Ljm"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3BjacYAMKCO0eRRVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3BjacYAMKCO0eRRVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--pcc.bounces.google.com X-Stat-Signature: 7n5u755g1ckyb5ij9kcphbce4pnbjpk8 X-Rspamd-Queue-Id: 64685E000111 X-Rspamd-Server: rspam02 Received-SPF: none (flex--pcc.bounces.google.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from="<3BjacYAMKCO0eRRVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--pcc.bounces.google.com>"; helo=mail-yb1-f201.google.com; client-ip=209.85.219.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620850153-196586 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 providing the option to avoid poisoning user pages on free. Peter Collingbourne (3): kasan: use separate (un)poison implementation for integrated init arm64: mte: handle tags zeroing at page allocation time kasan: allow freed user page poisoning to be disabled with HW tags arch/arm64/include/asm/mte.h | 4 ++ arch/arm64/include/asm/page.h | 9 ++++- arch/arm64/lib/mte.S | 20 ++++++++++ arch/arm64/mm/fault.c | 25 +++++++++++++ arch/arm64/mm/proc.S | 10 +++-- include/linux/gfp.h | 18 +++++++-- include/linux/highmem.h | 8 ++++ include/linux/kasan.h | 66 ++++++++++++++++++++------------- include/linux/page-flags.h | 9 +++++ include/trace/events/mmflags.h | 9 ++++- mm/kasan/common.c | 4 +- mm/kasan/hw_tags.c | 31 ++++++++++++++++ mm/mempool.c | 6 ++- mm/page_alloc.c | 67 ++++++++++++++++++++-------------- 14 files changed, 221 insertions(+), 65 deletions(-)