From patchwork Tue Jun 1 19:50:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12292131 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 1792EC4708F for ; Tue, 1 Jun 2021 19:51:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 819C7613C1 for ; Tue, 1 Jun 2021 19:51:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 819C7613C1 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 B371B6B006C; Tue, 1 Jun 2021 15:51:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE6516B006E; Tue, 1 Jun 2021 15:51:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 986C66B0070; Tue, 1 Jun 2021 15:51:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 693476B006C for ; Tue, 1 Jun 2021 15:51:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EE9C5824999B for ; Tue, 1 Jun 2021 19:50:59 +0000 (UTC) X-FDA: 78206198238.09.143FD56 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf16.hostedemail.com (Postfix) with ESMTP id 9F6A48019357 for ; Tue, 1 Jun 2021 19:50:47 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id s4-20020a3790040000b02902fa7aa987e8so12654603qkd.14 for ; Tue, 01 Jun 2021 12:50:59 -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=cOMbNtG2Nw9bKs+CKD1s4LM9f4ZyaUAJ2bE9oxoKNHeKnjgUazlZSihqJq86bqFk7T EC0ZzNs3nmYVMy8W+x+xeoGTjlO4gim5mCaTLfXL7kALDgMq5HzF6srmY4RpGvpnR6iw wQMw5Dx6iovSdBZ4YJc2heXCLFkvbDlL9KcDYduS/JgByVwcdtfpIQJx/FsTp5wqR13G DsNJfgeH07ThaUVql0IBnrUI2DMZ8vJR9N4vy9AE/Wu4hA/fIDd/w1EH42A6JIA7djK2 C9H+svQbjLp/lUfOUDGGjcgLkq6XQaC9NO4tzGekTJFpkMh+cJEAqLiigs5KBzqfGf5H 4OgA== 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=XJUMk9XJOUOHHzTJ+MhGMIQnxak+1eupnS2bUnxyAX2y8oN0KG2L3pPBE/skj2635h 6ANdxtD58cgGnF+mhS4h5ugFayf+T3zjDVrLRoxn9fRCSJMxeAwupvXEW0W+KkrWCvs0 yF2ve1/e4zREqF2jdBehoR88jGZuMHk7JsFM8eIbklVLYUsPOPfFvU9X8N6ho3mIzlIh u1dQ63pp45K7SCtu+RE5b4TDvy1lgZQMyG5zml2arj17y+3coXx6r6F3Kc8BFlB5+ZFC ccT28y78kbN82jFOZqOHJCZu4L3VfdaIc0GcIYkHIBdohoktQ5oZGUrJEa5+dd+k+nbY cCXA== X-Gm-Message-State: AOAM532igRimmwBZ58KoLEysgRP4cP4a2sthJGs9zxdcFjo5br6XDimu DIEcLCZUFS3oqVa/rkI1QF8DOBI= X-Google-Smtp-Source: ABdhPJw7T8PPSI2v5D3hlcTBq7FvLN1cZsViB5rROn4wZvEqJggfzKgerZL+sL8gVOaL4PupaqHj9Wk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:7faa:4fc5:a3b2:f7e5]) (user=pcc job=sendgmr) by 2002:a05:6214:212f:: with SMTP id r15mr24704717qvc.11.1622577058849; Tue, 01 Jun 2021 12:50:58 -0700 (PDT) Date: Tue, 1 Jun 2021 12:50:45 -0700 Message-Id: <20210601195049.2695657-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog Subject: [PATCH v5 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-Rspamd-Queue-Id: 9F6A48019357 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=cOMbNtG2; spf=pass (imf16.hostedemail.com: domain of 3oo-2YAMKCKcWJJNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--pcc.bounces.google.com designates 209.85.222.201 as permitted sender) smtp.mailfrom=3oo-2YAMKCKcWJJNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-Stat-Signature: 9jqtjyy1yeyk36yepp7jq6wqdks9zfys X-HE-Tag: 1622577047-223564 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(-)