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: 12295841 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,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 D7C1CC4708F for ; Wed, 2 Jun 2021 23:59:20 +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 A452E613D6 for ; Wed, 2 Jun 2021 23:59:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A452E613D6 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=e5K lPWVLvfiPX0rucKm+1c87r+ezDVlsfL+/LHaBb6jt+eVJ7fFKq3Qe/r/P03NvG63/n73cArdaHxzj 4RoWQog0CD/5NoPCqUFBPoa4ohn/1/ct/Lw5jRrY+3mTgFMhvHRf3AuClqICvNR1+GRgYQPz/ZRGn VZ1NFCVTX1QIhoaECEY/QOaMt5A/hG1OOuc7fXx1z/llvWsLu8lhSUCjgdqxlRTD0DfoqLjrm6nHX exrZv0DIiH3QTMrLYeQdsJbxG4ZjWWl2+cpoG9tc5WvTFFw1gF7qjPOdz2MSjc66HR9rinCQyOdmh SWQYA/KvCw62jLpa7aX1IdvVPAH1a6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loaiC-006WCr-Rx; Wed, 02 Jun 2021 23:55:49 +0000 Received: from mail-qt1-f202.google.com ([209.85.160.202]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loaiA-006VxB-1S for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 23:55:47 +0000 Received: by mail-qt1-f202.google.com with SMTP id z7-20020a05622a0287b029023d95d4f05fso2384800qtw.3 for ; Wed, 02 Jun 2021 16:53:44 -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=Gk79EQOWRA4YqkRNJxp/FAaRn+u5LHC/h+B3vUfBHQlVAxha+GZ7R4mX3czxysd/Kp 1CkNzc7DEmglTz4r6E+CDBlwRTGI3m1W1nYld+WRtt8K/Tm1X/AvfcdeYScieWyHQLsj CkHt79wx1yU/OqBUJZC8sFFqBKLNIPrIZQp0iCD/R8bGD+vurw5r19svP6iGQSEhhmQe uRTXFDTryxnqIsa2psKDISgFAShl7DJnBRJXcNAtp3NGHNUeTX1ouxVBsGU+wkar/n2y UNyRRDvBrjAdALX40WR7n7brEVECc9QphgzaFmA4IjQLw9ZiQ+W2wBOX0g/rU9SurGYJ SQKg== X-Gm-Message-State: AOAM530u+wU1YtQZptQl3Q07EXxgKwZYOIcW9gUFUx+NwLQZ3E7ltFGO F97YgMGsJqObKQKAlbEcWosDp5E= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_165546_108837_867852BA X-CRM114-Status: GOOD ( 12.53 ) 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(-)