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: 12285949 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 AA965C4707F for ; Fri, 28 May 2021 01:04:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 47F2D613C9 for ; Fri, 28 May 2021 01:04:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47F2D613C9 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 BADEB6B0070; Thu, 27 May 2021 21:04:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5D7A6B0071; Thu, 27 May 2021 21:04:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D8778D0001; Thu, 27 May 2021 21:04:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 6AC8B6B0070 for ; Thu, 27 May 2021 21:04:41 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 08448640E for ; Fri, 28 May 2021 01:04:41 +0000 (UTC) X-FDA: 78188844762.28.13D6B49 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf29.hostedemail.com (Postfix) with ESMTP id D703A3528 for ; Fri, 28 May 2021 01:04:29 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id n129-20020a2527870000b02904ed02e1aab5so2433158ybn.21 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=iSjUIc/06S0UKNoU8cNia6IaTc+pcohsAl3NYG1ATgai5lABJY8mPRjkjY71tryort 4YSjLW2RMmymvOO89xNs7+V+XePRdh/L40grKIf0gJa8nhVBISmKREu0thfQT+L2vO3V i6JRuo2mA/WtY7be2DpP/Aj8bG+p0ze8GLEnjxc6Vx1rkjKS9he6FqqRVaPkeKLVkdG8 obH81aC2LcR7oLG0quwISOLD2rL7lv9i7rkLpXhuvlnFMmgt8sFK+R15T9Z/olGxtnyE mUPXqF6J+IkYBdFUhqWJFFFbemqxFc0Jqu21HoL04ae7kaq59Y3PlYlBviF5LQRnPC7p b5VQ== X-Gm-Message-State: AOAM532jmGK+3wAJnK0C0YauEc2iwl7O/fs6OWH69TZnzlbTPB6zFceD 1bNbss1igvAXLibajmC3YlWioSc= 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 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=BKFgLfgb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of 3p0GwYAMKCPYnaaemmejc.amkjglsv-kkitYai.mpe@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3p0GwYAMKCPYnaaemmejc.amkjglsv-kkitYai.mpe@flex--pcc.bounces.google.com X-Stat-Signature: 8q6izr8gy8z7kngrcu131wqnqq4nokt1 X-Rspamd-Queue-Id: D703A3528 X-Rspamd-Server: rspam02 X-HE-Tag: 1622163869-684210 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 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(-)