Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp83804rdb; Thu, 25 Jan 2024 08:54:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQLik57J4osI4ZUUV6bWbbkfhhQYEJY7gghKh8kcDI4lXSrmC/UqLjl5fglXZSUscdr2gh X-Received: by 2002:ac8:590b:0:b0:429:e705:1b0b with SMTP id 11-20020ac8590b000000b00429e7051b0bmr1557250qty.66.1706201646269; Thu, 25 Jan 2024 08:54:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706201646; cv=pass; d=google.com; s=arc-20160816; b=eYjNdTJ8DzZsFb01fmYScAcA3bBYYaF/75lIC/MUINyJ/Sy3xBf2TspMcQ6z6z2NFI CP6v0AdXBPagNhQ6JhAya6IZc7Bq4ExTKJqliueLYev3ajwDjhuOwtQI4m9+PLbTon7J VdkVDVKtQRzXXMfH3ol07dGsHTAHzyugtsHeTeyYtc0LHVlFTSskYD6pp8BhpNWqEIUD W1qtZhqHxykERfAyyoFrAz/9whCtiCZr9sbhEQ8aq5v2DR75FKB03zEBiXSLRYzUDDKC O1aGZA0cteIkg2NFI9HVTe6asxFoQA2EgqmZA2ibzfqiVsXP7FxlDwMoDBQPQvZ/FkHD xd+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6SFhHxHCIfL6RZYw6/4SEfw42kw/Q+SBxFbIBdpiS3E=; fh=ON0oQ90Z4xnjbNCGsyMgiRbLR29nyOKvbeaw6TmRihk=; b=V8EhzJidqo0lVM3bewQpiDjxCsmozzMexBbP58o6OqGF5pmmn+m0NOJT1bRrB41YpX xhdCkDnBZu2E6TgZscOHkvLNT4GivyT5tg84DaX/FMiyH/EobG1UI8pqRzPLnv78TphI DChMAVAyn7KEw1Yiyqj3LS5qvIuQI6b414mshnoWoeRt7g3c5PQAHlz/NlYLx4LsqHel vFhdh9zRmV7igt+YAJV/k8rjhww5kwS4SBl+y+gN27UdJsWzoLn85F2i0r8JzSQkPW4u UIihiqlwMOCIitRWapiawv8qf/6bDNbngFgO9iPursEsFvuwGDNTRt9l7b5R9k4x9fyH hcIQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g1-20020ac87d01000000b0042a2b1651d4si13087060qtb.171.2024.01.25.08.54.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:54:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A7881C228E3 for ; Thu, 25 Jan 2024 16:54:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22B40141998; Thu, 25 Jan 2024 16:45:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B829135A55; Thu, 25 Jan 2024 16:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201113; cv=none; b=scGs38KOmFkcmDYM72GIYIqcqq+gWQlLIXIpoF//2kKNkLeWNGoJo/CCainZBIfVr0r3p7w8EASlHTrlsEfFAjQXA2xBI+ejfA2+xPbSBiiI7IjUqWJhh7JSEpW7KjJmMXvcYeso8pY5mBT26KAJ1r7MfC34Rx/eh9Lmac3wpXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201113; c=relaxed/simple; bh=7GSpvoz7AckF0nurdaP1+AUs5Wt1UqGcytFWfgfXtws=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d3g+29fziuSkccth75Nd1XFlUJVFwSBJe/e4qmW6ZY+PFq6FJLGVuoGlUWAfenUZFqhQKPjRklnAXrlDwSfrAu3BM7irzXwQIPFbSkT7notLZaveqK4GxNdSxc1AEHpObSKn0fon6bHe9f/gEFiWjS5aRUrOADjRLhtLhNvJRP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08EF7169C; Thu, 25 Jan 2024 08:45:56 -0800 (PST) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C34E3F5A1; Thu, 25 Jan 2024 08:45:05 -0800 (PST) From: Alexandru Elisei To: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com Cc: pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH RFC v3 25/35] arm64: mte: Reserve tag block for the zero page Date: Thu, 25 Jan 2024 16:42:46 +0000 Message-Id: <20240125164256.4147-26-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125164256.4147-1-alexandru.elisei@arm.com> References: <20240125164256.4147-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On arm64, when a page is mapped as tagged, its tags are zeroed for two reasons: * To prevent leakage of tags to userspace. * To allow userspace to access the contents of the page with having to set the tags explicitely (bits 59:56 of an userspace pointer are zero, which correspond to tag 0b0000). The zero page receives special treatment, as the tags for the zero page are zeroed when the MTE feature is being enabled. This is done for performance reasons - the tags are zeroed once, instead of every time the page is mapped. When the tags for the zero page are zeroed, tag storage is not yet enabled. Reserve tag storage for the page immediately after tag storage management becomes enabled. Note that zeroing tags before tag storage management is enabled is safe to do because the tag storage pages are reserved at that point. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Expanded commit message (David Hildenbrand) arch/arm64/kernel/mte_tag_storage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/mte_tag_storage.c b/arch/arm64/kernel/mte_tag_storage.c index 8c347f4855e4..1c8469781870 100644 --- a/arch/arm64/kernel/mte_tag_storage.c +++ b/arch/arm64/kernel/mte_tag_storage.c @@ -363,6 +363,8 @@ static int __init mte_enable_tag_storage(void) goto out_disabled; } + reserve_tag_storage(ZERO_PAGE(0), 0, GFP_HIGHUSER); + static_branch_enable(&tag_storage_enabled_key); pr_info("MTE tag storage region management enabled"); -- 2.43.0