From patchwork Wed May 12 20:09:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12254619 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,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 3D871C433B4 for ; Wed, 12 May 2021 20:15:15 +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 8DF5A61408 for ; Wed, 12 May 2021 20:15:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DF5A61408 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=UnP4go5cHkDpfWgVVeqEJM3yex FJkfsXIXY3QSOSsBU0oTpuLH4zBK4xeOzwIQ2yLGMDp1QLA/iCa7KZ4NMbbSSDpvG6LNZ9w/kUsf1 UK1zhZV25c4oQCRWdmYtA4do6pX+KK9NA+3YfnIUSqjGOBaqFfOggZ5+KNCdiAG5UC7q6mn3M0Jgp SzKDYPCSt9T5NM/L4k9k6Dt1JafdLnMotDLH/9Ck/VBvDqBkPepEKfEbmzzqyUa8ydZiGDwDhuisN oLFs/3lS1iIcKpnbju1SgUXwId8LxNQHD7SgkEdazvtr1jYv4eRB8AdJ3+Toa4LRqfAa1yJMGhAAl +3SpG/hw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgvE3-003sin-Cz; Wed, 12 May 2021 20:12:59 +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 1lgvAx-003rqx-OZ for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 20:09:47 +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=RUY0jqGFjlBn1KfR8O+pjX9MFc 0YvS8zSyYV6QLq68Ar2Og+ava2PnPEpDaoKisBKUCUA/SKqBZdBOEmUaEROP5uXVLJwl5m7svDh2q jthN5mHv5EDrWTjtnWrPsxOlPhYC54O+5scisqL1QGECt9Lxk/GMQnCwJh7htJ/Jeo1+WG5BCkg6a XBZs/Qq6m/kArSBwn1IvrSt6queIT6ICeynARJvH5ENktkUGntUh42F4/HVtOmrJnMFspXGlwpLZS HdGoo45ZgjRNscZRNdi79z+tTP+YDff/QXwWbKetJeg5wzlkjVU6pkqh/eqYWvV5537qpIszgmZvD tWX9vgMg==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgvAu-00Amwg-T5 for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 20:09:46 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 78-20020a250b510000b02904f953c1fb64so4303653ybl.1 for ; Wed, 12 May 2021 13:09: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=+0yao2TT5p+GhWI1k25YcAL0rNNU5KO4OXR8rnQwh+s=; b=Lv22/LjmwMimEtlv7dgarWOQmOloUg2zsCDl0rehf9BM/oY85KfP51miSbM6u6IEwu wG64sT/V3MUhbrmAleEVhUXKqnh2R0mKokU2b4f7t3dgWKjcUZi6XbZMDV1opoK6htik nEqFn9/cdtko2wO9tf1TUnrCjTIENtLg/F1qVH0St/DVovTXHjNqZ/IxyfRWceF3EDne SlT/5/fw/4SCTjfXx4bG+9ZiencU2ATl2xngegCMfuxfTjyK0RkypWcwBUnuCMA3w8YP m2w8BiJNdTf8qiUZyKwtI7mVRO0GVjc1hBD5OhqJWrdAyfdZ+nnHtt7eYE9GwgjIfBNl rPSw== 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=c1z5x7BEzDIYissozUH0vk4urY4q2TVLxwCqLEei2FG/nz8hsM2gPK6LxY14EmQYsC XZXBZ7NARSUjTzxitLRhSCXbW3t7FTJZIcKjcaPVuv/DGIMP1gCHbRVKSS0kfhCMZzBV WBTmRZvFmg/4J5o3KNnvmEaIz8NTgU4GYhgeB9bjEwq3W/iRZHD+ugpIa2JmMGcY6g5+ ifb3j97iWXRxL+Xkd68Q6QKIaEbAWkR+IbFaRIIdHq/Q69corT1/5sMJo5ukw918KZ+4 +YxIXTBzwdb84d0Huqgn9MwIa5sVYgafqGZMI7g4R4WulWgIPqiEF4BdyhLZ4q9H+DMr T6Mw== X-Gm-Message-State: AOAM530pM8P2M0OAS1Gbzrpa0ymhYDyLTXXjdXS5bGDR2r1gqmxTW1dM 5TO7Gg2RtxFxiDabP3XkqAAiGxI= X-Google-Smtp-Source: ABdhPJzf1yEJQZQc6i5JDpgjPF+O5I4ljfly/agrb55QOA4U2Dkpef3nqmlN0DVzgJT5k1pBWsg1slk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:d8b:fba6:20f0:cbe3]) (user=pcc job=sendgmr) by 2002:a25:30d5:: with SMTP id w204mr50240961ybw.416.1620850182425; Wed, 12 May 2021 13:09:42 -0700 (PDT) Date: Wed, 12 May 2021 13:09:30 -0700 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH v3 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-20210512_130944_982334_E7AF8D38 X-CRM114-Status: GOOD ( 12.61 ) 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(-)