From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6CC84C4332F for ; Mon, 3 Jan 2022 17:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nCP/UrGXADXpIKTSbmREutIxhJZZK5D5Z/dUHHpFnqw=; b=VOBcBoz7WKrZPUAWr3ReWK7fwp EvPGGFzmQriDbqMDbxqqTN9UIAQXnkwxhI/Kr0SNQAIGOHoL7ue7EIWcV1ggCrUH3zkKRWLhGeWBk zUXipOn/y+uC7NbjRgnG9iauqBwc4/4qR6Ca3uckKw/liu5YWEaIqc/1RFh2+XwJ2m8IHD8S3C2il U2WHjqoYMlpP1MZPwNmu5QDsZQrRzDrP38GOQx6etrWB9Fzn/xv3JLyRnW++D4I5O1fTNRC5xQwyY EI91tzg2DAFLX4AzjY3cmcFWO6O8jTcpFjpy7WN4v9l3MaVasCu/g/6xIfQOy7w0WNlCef6NcVH4N Z8vPgzTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4R8E-009fUE-HJ; Mon, 03 Jan 2022 17:28:26 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4R7s-009fOw-DW for linux-arm-kernel@lists.infradead.org; Mon, 03 Jan 2022 17:28:05 +0000 Received: by mail-qk1-x72c.google.com with SMTP id w27so25825167qkj.7 for ; Mon, 03 Jan 2022 09:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1kSIR6DoJ+H3crxURp5a7BYp726kZXolUvR8WT3aOMI=; b=HhM5SHuzHngOuJ7iShquyq0iiZCdaRWJI/s2N8KE/qferk+mjfvofGUD3jsb/Iv95J EM7Gkz5GRavxOOKz36O/6OslMlBWsstusngApM8G8wqCIEYIIC3r1psso8mDDCPW8oQv b13rto7blee5FqsKiw4G9cjAN8ewX1TG3xw+kUOistP1UfBEt09IjbtyMZmKXJAa0kUc BxUPMYK8GSXhY4g8eNChHiNSLbkE3yr/6z/3gqDqWmLnzdC3N59+HW2mZyx9YbEyxSzo 170/G5nT2baxEQJwtBeJwi6IckDTvECLGA5IG+MpEfyWOjFNuqATnBkr3P0P2CjjQbmE /pkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1kSIR6DoJ+H3crxURp5a7BYp726kZXolUvR8WT3aOMI=; b=ppPg99T17/0hBLdHx+tG/sMmtJ3lHTUG61W+FHut97g8SKjVlSO4QhqBaW0c39/OIV vjIHHkAgh5kPMntHcjAW/c3rh3MAN4xzJCUXLoFqqitzr6sXLBwAdAVAGp7QeSMBJQuO BGZxQdAGqsY8f2k7QcGgJJGhH7+l06si+YVhvBLbTm2dR8fEQLiyzUGWnD8OMnWdTVHp iNHzCMPiTQbuQ5To28ynPsLuTtlCMXvyD7zIvYyOWs0d/a1dyQEiIuJkx7vUxcy8fdLN TyaQaKvp6jo1NROcb184IfjrzxAK0DNopkZs9EHCVq0PuXf6/Et7uaOfjWs9+vttQsTx Na6Q== X-Gm-Message-State: AOAM5331FBKYrLPDXdtP9SQM1U0+zoF3QBN4+CgYKyx5+c9vhslgSdoP tH7+plBVVUDjwG4S5z8DYDwbwg== X-Google-Smtp-Source: ABdhPJyu3QBrXcN26wi/JNUraH2Kj3R6Tpszf+VOBjKHjMjAVwCKyZImHHeGdTn2AxIiXSXYlOS0Uw== X-Received: by 2002:a05:620a:1a95:: with SMTP id bl21mr33158278qkb.200.1641230882303; Mon, 03 Jan 2022 09:28:02 -0800 (PST) Received: from ?IPv6:2804:7f0:4841:563b:5da1:e213:4480:4ee4? ([2804:7f0:4841:563b:5da1:e213:4480:4ee4]) by smtp.gmail.com with ESMTPSA id b2sm27814906qtq.95.2022.01.03.09.27.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jan 2022 09:28:02 -0800 (PST) Subject: Re: [PATCH 3/5] arm64: mte: Define the number of bytes for storing the tags in a page To: Catalin Marinas , linux-arm-kernel@lists.infradead.org Cc: Will Deacon , John Baldwin , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Szabolcs Nagy , Andrew Morton References: <20211208121941.494956-1-catalin.marinas@arm.com> <20211208121941.494956-4-catalin.marinas@arm.com> From: Luis Machado Message-ID: Date: Mon, 3 Jan 2022 14:27:58 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211208121941.494956-4-catalin.marinas@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_092804_517217_D0496C70 X-CRM114-Status: GOOD ( 21.99 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/8/21 9:19 AM, Catalin Marinas wrote: > Rather than explicitly calculating the number of bytes for a compact tag > storage format corresponding to a page, just add a MTE_PAGE_TAG_STORAGE > macro. With the current MTE implementation of 4 bits per tag, we store > 2 tags in a byte. > > Signed-off-by: Catalin Marinas > --- > arch/arm64/include/asm/mte-def.h | 1 + > arch/arm64/lib/mte.S | 4 ++-- > arch/arm64/mm/mteswap.c | 2 +- > 3 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/mte-def.h b/arch/arm64/include/asm/mte-def.h > index 626d359b396e..14ee86b019c2 100644 > --- a/arch/arm64/include/asm/mte-def.h > +++ b/arch/arm64/include/asm/mte-def.h > @@ -11,6 +11,7 @@ > #define MTE_TAG_SHIFT 56 > #define MTE_TAG_SIZE 4 > #define MTE_TAG_MASK GENMASK((MTE_TAG_SHIFT + (MTE_TAG_SIZE - 1)), MTE_TAG_SHIFT) > +#define MTE_PAGE_TAG_STORAGE (MTE_GRANULES_PER_PAGE * MTE_TAG_SIZE / 8) > > #define __MTE_PREAMBLE ARM64_ASM_PREAMBLE ".arch_extension memtag\n" > > diff --git a/arch/arm64/lib/mte.S b/arch/arm64/lib/mte.S > index e83643b3995f..62a1025aa118 100644 > --- a/arch/arm64/lib/mte.S > +++ b/arch/arm64/lib/mte.S > @@ -128,7 +128,7 @@ SYM_FUNC_END(mte_copy_tags_to_user) > /* > * Save the tags in a page > * x0 - page address > - * x1 - tag storage > + * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes > */ > SYM_FUNC_START(mte_save_page_tags) > multitag_transfer_size x7, x5 > @@ -152,7 +152,7 @@ SYM_FUNC_END(mte_save_page_tags) > /* > * Restore the tags in a page > * x0 - page address > - * x1 - tag storage > + * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes > */ > SYM_FUNC_START(mte_restore_page_tags) > multitag_transfer_size x7, x5 > diff --git a/arch/arm64/mm/mteswap.c b/arch/arm64/mm/mteswap.c > index 7c4ef56265ee..a9e50e930484 100644 > --- a/arch/arm64/mm/mteswap.c > +++ b/arch/arm64/mm/mteswap.c > @@ -12,7 +12,7 @@ static DEFINE_XARRAY(mte_pages); > void *mte_allocate_tag_storage(void) > { > /* tags granule is 16 bytes, 2 tags stored per byte */ > - return kmalloc(PAGE_SIZE / 16 / 2, GFP_KERNEL); > + return kmalloc(MTE_PAGE_TAG_STORAGE, GFP_KERNEL); > } > > void mte_free_tag_storage(char *storage) > Acked-by: Luis Machado _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel