Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289019pxk; Mon, 21 Sep 2020 09:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzwqSMuxUeBT27+HpgaNzSTn2K6hQExj8Dev60vP7tKqJWU2vx3mnnB2cCIaomIjgMJ5ln X-Received: by 2002:a17:906:f11:: with SMTP id z17mr388772eji.88.1600706842053; Mon, 21 Sep 2020 09:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706842; cv=none; d=google.com; s=arc-20160816; b=n6y9XPkNhdfnv28AvFS6EKXz2ChgWoINtAGrJcj4XA2AqShANeedSqx8Hu955huz7m h9BE7C4EaHPObYujyHA+mVRyYgwuF7HBSSZ5DHPRZmzrw/2aWsXTv32H6qke1PInVVEP fNJFxUeGh8HbiLaA2MHNVgcJRCEpZfs5MaTIA+JpNTxcA73B7/ej6g6tY+FbxzvmttQx TvEF6rU68F0c4qxMSL9CJFIumFYNfAqCS5yn4XMUaqnvGd0uV1XKHFR4e0KbZ8gU+IaM zwXrlEaQyHP6uEoAWwN+DZOrDqMJYJ+zeHLvFZ8PodfzeEeMxB+u0xcI6H3aayrHWqrO lWAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=vJ/N7fbCmQZHQgE4s4FxlqqAIX97BY/inSKFwXFJToQ=; b=sYOhwVq18A3fYzNPxBjlUfdULVuhM8skbgNo8DZGrGjIfbKrK5tpYs4rZgSxLsY8sI tA82pvj0D3BPl+lZud4lC0vLOUp2JganUPjqNo97iFW0Xg150n3i4bqtM/ByzNsia7nU GT6LssmYCvp+NEcf2ZxDYe2spE+le40xDUpX8pEvaitRUpulE0nU4ZQCUBbmqF+CDGXI SBZcPteLz101DPr5xUybhBZuyqwNl0ML0XtayEcDbwXcqCECgUOkKYmO5DYPNNioZJXq w/pAkHmOgGhvpGm6UD/RJiv/ZYHB62N00WPx4B6hX3Qq9qKIc1VVoG2GzsKu/Dt3ztzH 90OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si9113651ejv.148.2020.09.21.09.46.58; Mon, 21 Sep 2020 09:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729625AbgIUQnl (ORCPT + 99 others); Mon, 21 Sep 2020 12:43:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727419AbgIUQne (ORCPT ); Mon, 21 Sep 2020 12:43:34 -0400 Received: from gaia (unknown [31.124.44.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91756238E6; Mon, 21 Sep 2020 16:43:32 +0000 (UTC) Date: Mon, 21 Sep 2020 17:43:30 +0100 From: Catalin Marinas To: Amit Daniel Kachhap Cc: Shuah Khan , linux-kernel@vger.kernel.org, Gabor Kertesz , linux-kselftest@vger.kernel.org, Vincenzo Frascino , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/6] kselftest/arm64: Add utilities and a test to validate mte memory Message-ID: <20200921164329.GD13882@gaia> References: <20200901092719.9918-1-amit.kachhap@arm.com> <20200901092719.9918-2-amit.kachhap@arm.com> <20200921141817.GC13882@gaia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200921141817.GC13882@gaia> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 21, 2020 at 03:18:19PM +0100, Catalin Marinas wrote: > On Tue, Sep 01, 2020 at 02:57:14PM +0530, Amit Daniel Kachhap wrote: > > diff --git a/tools/testing/selftests/arm64/mte/mte_helper.S b/tools/testing/selftests/arm64/mte/mte_helper.S > > new file mode 100644 > > index 000000000000..91af6d1293f8 > > --- /dev/null > > +++ b/tools/testing/selftests/arm64/mte/mte_helper.S > > @@ -0,0 +1,116 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* Copyright (C) 2020 ARM Limited */ > > + > > +#include "mte_def.h" > > + > > +#define ENTRY(name) \ > > + .globl name ;\ > > + .p2align 2;\ > > + .type name, @function ;\ > > +name: > > + > > +#define ENDPROC(name) \ > > + .size name, .-name ; > > + > > + .text > > +/* > > + * mte_insert_random_tag: Insert random tag and different from > > + * the orginal tag if source pointer has it. > > + * Input: > > + * x0 - source pointer with a tag/no-tag > > + * Return: > > + * x0 - pointer with random tag > > + */ > > +ENTRY(mte_insert_random_tag) > > + mov x1, #0x0 > > + gmi x1, x0, x1 > > + irg x0, x0, x1 > > + ret > > +ENDPROC(mte_insert_random_tag) > > What was the reason for gmi here? The test fails when you have an > include mask of 0x8000 (exclude mask 0x7fff) and x0 has tag 0xf. In this > case we exclude the only allowed tag here, so the CPU falls back to the > default tag 0. > > You can (a) stop the check_multiple_included_tags() earlier to have two > allowed tags here, (b) clear the pointer old tag so that you don't end > up in this scenario or (c) simply remove the gmi. My preference is the > latter, we don't test the hardware here, we only want to check whether > the kernel sets the GCR_EL1 correctly. > > BTW, you also remove mov x1, #0, just: > > irg x0, x0, xzr Ah, removing gmi breaks the check_user_mem test as it occasionally gets the same tag when it expects to be different. I'll leave this to you to fix, maybe use two different functions, one with gmi and another without. In addition, could you please add the PR_MTE_* definitions and PROT_MTE to a header file in the MTE kselftests (mte-def.h maybe)? They should be bracketed with #ifndef ... #endif. The reason is that we'd like to queue these patches on their own branch on top of vanilla 5.9-rc3 rather than on top of for-next/mte. Thanks. -- Catalin