From patchwork Tue May 11 23:54:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12252397 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 973EEC433ED for ; Tue, 11 May 2021 23:54:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 08FA061287 for ; Tue, 11 May 2021 23:54:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08FA061287 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 24A316B0036; Tue, 11 May 2021 19:54:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FA1C6B006E; Tue, 11 May 2021 19:54:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09C2E6B0070; Tue, 11 May 2021 19:54:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id E17446B0036 for ; Tue, 11 May 2021 19:54:37 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 95955B9EE for ; Tue, 11 May 2021 23:54:37 +0000 (UTC) X-FDA: 78130607394.07.2532AF2 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf08.hostedemail.com (Postfix) with ESMTP id EDC5980192C6 for ; Tue, 11 May 2021 23:54:09 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id g1-20020a25b1010000b02904f93e3a9c89so2773635ybj.23 for ; Tue, 11 May 2021 16:54:37 -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=axoMvw7OpAa3NsMr2vhm+9NnfT/T3RatT2RDkzWUXdawH8Um9LXsecLUmlropXgBpl kUObkm6V9AaG9lDFArB5lS7N/P3gWx1KhbJq1MU2dbFnkAZKT9LDGOfzYGqUl95PQxhe 3HaakG3Dp/Sj05wgAvrnDKuUS4fdwEldxXS8MZ5KZ1D8e5RpBGfyKSkS04fZCEAS5PNN mIoMix4gkX4Y+i8lCh1pX5c0ISV14Jqlyg2rXkkLv/JucALdvNDYFtT0TlwpZ6fDUjzY ThSXg2oS/Hz9M2gt1a8GPMaYMlRoSGDmQcB3UBlm0x/iRhjGQz79V9StJfpGV574tyDP 0R3A== 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=FWH4mYxfK2vdik0ap+if9MVbh7TA4jOb3UmcKgego2QDoA0z7GatzQtqAF+cEei0Vk 2mgVgVE3LvGpF6TO7XdUrs7d4OQWzuKId4DvKUAqD8PW4np9GquRuBNWz/jfhgKioWfc 2NUtw9SOwUffJA+5TWlj33l++Hyc+AnbuOWLRRwqlSF2Fjdv+J10S8lMQZHaZXN7m20v AY1vDs4suZvSFfTuebS7974wdPxmSsvW3dzaCppRT1AUi8jpjjLlhsCOp2ZN75YECPSx ctqh0pLcq5ortVknJ1LhGt3ICcwV9hhMNtuis/3227ew8REno8KlaPAW4teJl1/nPyuK R/WQ== X-Gm-Message-State: AOAM533kLAYwebJdWIX8JTXRzQ6os8yX7Vr/aZ1taZItEHtSbjHTaRC9 LMLIbd9jJ0cgQUN4yEp980Xt6UA= X-Google-Smtp-Source: ABdhPJxnX8g9Z2hExJysiykfU3/GikoRKYlGYCEjclH9hMmLd0zXKhKEP65lovVPLxZweWNlwLmrH0s= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:1c93:1da8:808a:36cd]) (user=pcc job=sendgmr) by 2002:a25:8190:: with SMTP id p16mr42804158ybk.156.1620777276352; Tue, 11 May 2021 16:54:36 -0700 (PDT) Date: Tue, 11 May 2021 16:54:23 -0700 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH v2 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 X-Rspamd-Queue-Id: EDC5980192C6 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=axoMvw7O; spf=pass (imf08.hostedemail.com: domain of 3PBmbYAMKCOUWJJNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PBmbYAMKCOUWJJNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-Stat-Signature: t7kkmwwizcddux8ybjreinubh13eft7k Received-SPF: none (flex--pcc.bounces.google.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from="<3PBmbYAMKCOUWJJNVVNSL.JVTSPUbe-TTRcHJR.VYN@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: 1620777249-649425 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(-)