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: 12292143 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.1 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 90542C47080 for ; Tue, 1 Jun 2021 19:52:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 642B56023B for ; Tue, 1 Jun 2021 19:52:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 642B56023B 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=bombadil.20210309; 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=gVNaj+A60X9vEWgUUwijDMIV2Qkr7n4BI1pDJJmpcFw=; b=ccs I+hGq2t/ereSzsgvXzKT/Zj+RvzxcmWGRCnDI2tyAxmR6v/CE5ofk+J1Yf/FY6PI0hgVfmKGS+TE+ ousyec/y+hHZXXhePdYN56JSwgORrA0qgieg7JvIW8AIp6j5SaDk9ShM6iXS5UO2RLflARrUaM9jM 97hGrEAqtCd5SdxOfOVF0R4i9lN/iEDVxVtaEO2t4Ix9U5+u2AyXqNgwMfgczJeLleZkFcpFw9Z4B 4pLkRCv6mxk1WYicUm62ry2Bf1dw5MQfn5wjXdmJApLii/EVL4+742QQnPB/zxh8dZnstgRu6b1LW nsvC1NUWz1uz0fS1e6EchSLk42vh0Mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loAPo-000d1A-Jl; Tue, 01 Jun 2021 19:51:04 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loAPk-000d04-HA for linux-arm-kernel@lists.infradead.org; Tue, 01 Jun 2021 19:51:01 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id b24-20020a0cb3d80000b02901e78b82d74aso35950qvf.20 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=KYb2gBxpEMMpID8vBcyukqkfJ8Irt1YOglhmd/e0vJ/UwmQtf8FhFnpNx9lg9YGRSe nMGkQPqrVVRMvLESVUDpsKejgNFzuW9BoUqqQXJdedJtuKuSm18cuBoWrzllVcxXEx2H hIDqUYz6uBCBRmQygsD1cshXaCXVXQewnYDrBaI/2vw2YeqGdWmIcP4qb0mymROS6TpK tRTS9duttmQX6Hqaz+vHMGaIbdQo0pSftgbX0YcaBghVwu6YriOtPV9xjT/nWMh5l6ts I2d2J6mAWwEbQndNmOJcwN/+X7rMJoeTuwOndBvvcNEyQNOMUje/4kOUotF0Icm9FFyo 4DWw== X-Gm-Message-State: AOAM532mSUjICEWme+ov8qCStqyyOc505zI1WgfGmiwtCm79kVPhqf3M ZW0DQHUMGU6trhEwRp6LNnZkXK8= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_125100_610554_A8C6EC2C X-CRM114-Status: GOOD ( 12.79 ) 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 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(-)