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: 12252387 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=-12.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 0DE3BC433ED for ; Tue, 11 May 2021 23:56:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6101861205 for ; Tue, 11 May 2021 23:56:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6101861205 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=0BRDNtCUPQE9xKx21ImQhz264CddgGlpvpqjzcySAZg=; b=aElmhuUm1m9UOQ5Z0Uzhji76Wm ndVLnoONawjP9LVn2N1aLxOfBxA+S6PskgsPiyaDQ4CEiP0+pqofXqoyTiWDMMLIXyBK+GAG10oai ZGlqWY/HgIoCLe1bWCxTqGVU3YxxSKjj2ShDYNwh/C4Hg8KhZGjGLVwZg9kuinzWBWEC7jjaMwpsw VhxUh7UIGiJLMGNDYlEDUo73LLyXJw24MlaPrCE6V90b5cRXI5XKR6KNSPxM/8FG1SeD6Oa1gPgUw FMLV5IhWMfYxUa4L1ZjjLm6fqFsNzd7PiFhuG0HaZTEzJaypMB3xvb1KwPElaryBU856l26YG65cP VSyVBrFQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgcD5-001Z0t-3G; Tue, 11 May 2021 23:54:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgcD3-001Z0e-CB for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 23:54:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:From:Subject: Mime-Version:Message-Id:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=+0yao2TT5p+GhWI1k25YcAL0rNNU5KO4OXR8rnQwh+s=; b=P2sRSoJdJyLDwWEyxmUgH+FoaZ vxcCZvdmUfJd2WwpDHeia2PmQccQJlsZy5b41JB+QVB9zwdG/veP3ZVNwCx8v/xqilL25akz0jb99 2ipSqmcQ76DX5Wmh16OPC76RWj6BHAkonY2t2UGrcN5qwk4ibi/wTUPaHGRGbw7bmK4pY2HSF0joY cAk6o4OGcWgVqumVeSieQEKxV70PRCiY2iNJC8hdB0FmQwv0SPEXTaLRuF6VTO0BcSI2CgJJuBhJa wWU4z9+00ves0qZ/ximG9o587BvsMTv2qknv7eHGbmUZxUsrdGNtISFepIQO08tIjkH2nV7j6m+/V 3RFVji1g==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgcD0-00A02O-Ju for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 23:54:40 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id s8-20020a5b04480000b029049fb35700b9so25962627ybp.5 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=hd1DQ1eb/J43ndsxaSf37/PCWGcsPZYUiUIbk7T2evUA7NRzoDsU4w8/mdSe1IPF6a L2hWcXNG6vOrx7SOJTqGaM40gTxTlcG9tGyq1kvw2jdY7/grP2GQUEgoLo8LEtv4jUBJ GIhUe9S/Ly9kNadV7sYJAmjxVtFYnndidwfB3psXP3Qvq0K/QoKYnHWsss9vddKnBQor kuyMLsdEdtlzvX6uB3ah+1jFGa4JlbmvpK96/ORNfWTehK4sgjkoQ2C+gvFZ4H++MspU pO9r5oVhVXrHUkQ+fsGMDLKbJJZAEs/y1KYkZtT5Jaavm3QbeKm/1nml1qlqn8taZCjZ gpgA== X-Gm-Message-State: AOAM530FT63nn3EbYc6fOXpskI1uHveddx0Q5zLZoHiU2jwpNwwk+0Yr 8tZgQKun+lgolsOeQgsllXMa6V4= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_165438_697330_D9495848 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-)