From patchwork Wed Jun 2 23:52:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12295827 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 EBD2AC47083 for ; Wed, 2 Jun 2021 23:52:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D7C860FF3 for ; Wed, 2 Jun 2021 23:52:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D7C860FF3 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 1FCC36B006C; Wed, 2 Jun 2021 19:52:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AD856B006E; Wed, 2 Jun 2021 19:52:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04DD76B0070; Wed, 2 Jun 2021 19:52:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id C97D96B006C for ; Wed, 2 Jun 2021 19:52:44 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 66D6C181AC9CB for ; Wed, 2 Jun 2021 23:52:44 +0000 (UTC) X-FDA: 78210436248.05.6F8D982 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) by imf07.hostedemail.com (Postfix) with ESMTP id 1855CA000257 for ; Wed, 2 Jun 2021 23:52:29 +0000 (UTC) Received: by mail-qt1-f202.google.com with SMTP id j19-20020ac85f930000b029021f033edf60so2366576qta.10 for ; Wed, 02 Jun 2021 16:52: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=I4ckXxb7BYUcQj3GMVTquKYIZgsVFQFrr67ubRsypgw=; b=eGIpygq+jQeJ3+Y/wLZuXCHzzJbZ/SNyxbsbHKUO7ERQRVmZRciSXJBUoF+Zh0OABk BfGUS1f1mkIGW6evq+4+11rUh5Xt+hVNTTazRdAaDMBsBwvIsV1WmMFhRUn+GCtyihix gNRbjTTsz9WfU+QRPur3CC5vP9Ue6Iy43tg4Hn9SFBMo+lI5bkZH5cunYFBN4TljrtNB 0rCAUK4ObfYvVUWQ5Ag8TsY00S+31Qm36CmkjRtuMvaZj8DPwycAJHv3Tb7y+dHPdCHd Pbp8mtOhFqTPDQIMDYMwAvPlApgf7ttv23lIVfMW7v05yXxw869+CDiM8GXh0F7HhC4I f5ZA== 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=I4ckXxb7BYUcQj3GMVTquKYIZgsVFQFrr67ubRsypgw=; b=iGF1VSHiw898BkMm7cGqzDxnzTLOCxWBEg7N3M5XG/U/XH4QslUdZL5IhLdJ9nHRtH quC1iK1lXIwSznFuT9m0ZwdBZzFxx6Y9tI2ywsxjl8pjs3qKD7l0n+a2r7NKaOFpA4Gj dnCWtVawVHV0gz/GE+CBmJmwPW/FGZP1TsLs88i/3w9gAxh4XLWemFbWfnVTBDp8R700 OOFABd4Oc0nnfleAXV0O9qTHquxXMML1N48y+PZLhJD5oVqlTxdQUVsXbmCTLm2X/1Ka EGVn+0eROcDVuKcYhR72rVMHkpfCVMP8UwAgOe4PvkyTsayLv3kiNLx65vYAoUJ5q0F1 dbXw== X-Gm-Message-State: AOAM532WTkWStbRmjvgspyCOSCUXII1JrqgkFgymUjz5wwyvGsesohI9 wx/6szt1aZDlqb4rvOmpY/ZGL/U= X-Google-Smtp-Source: ABdhPJyVc4OKFiURwjhClLXjtijHweElHlBEFIlOgb2I/Ik8tkKqWieSjpJSaCEPBqJi4hERFEZcf9U= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:1ca2:69fb:b6e1:cf21]) (user=pcc job=sendgmr) by 2002:a0c:b28c:: with SMTP id r12mr31708135qve.32.1622677963366; Wed, 02 Jun 2021 16:52:43 -0700 (PDT) Date: Wed, 2 Jun 2021 16:52:26 -0700 Message-Id: <20210602235230.3928842-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog Subject: [PATCH v6 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: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=eGIpygq+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of 3yxm4YAMKCOobOOSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--pcc.bounces.google.com designates 209.85.160.202 as permitted sender) smtp.mailfrom=3yxm4YAMKCOobOOSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--pcc.bounces.google.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1855CA000257 X-Stat-Signature: dxjdo9p3epsen6j91x3y9dh9575o5u8c X-HE-Tag: 1622677949-189474 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(-)