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 10D72C433F5 for ; Fri, 4 Feb 2022 15:58:27 +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=X5wW9Rk9pJwFh6xfmKr44UtPwMzEK4ET6Y4aY5yT9X8=; b=jbbOLdltKA0750dU8bmrXZQqjb 5Sxja9WgGY4AQUn6Xp2/3qjHtMQUnG2tBgFfGV+GGr2ttDUy0irFyCJvvoz15dN3A2SIdINy0DcN9 2GIUPcRvla5myCH7NhVmcj5srQ6yzxopt6WiS3cFIyMRnu0hyOxM1im5xpMxASAMZLzTwmNa8yedL 1vrGMwXxUmpZ1/4S2bXvf/LebC0sTJwsxCIgaFSD0u37idjDjIRv6ePDh0U6LK5x/xIRItlfHaFIe z8VQ0nOC1Ll+bTLjKpEkSWFfmqmq2JvTifEtTA9WRJHfIhs2DfeeNvzA+r7YcLHdctg5/76oDzUlx Nh7riRUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0xV-004qvM-79; Fri, 04 Feb 2022 15:57:13 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0xR-004qug-DD for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 15:57:10 +0000 Received: by mail-il1-x12e.google.com with SMTP id z18so5205058ilp.3 for ; Fri, 04 Feb 2022 07:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.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=CdgsZAgQdPG0ednneBLuVnElT7YMZJi95p9Lba3U438=; b=fLcGMOo9g/m7l/GSri2ubuy235hQPlqXg6ajT9JwHmV52fAqyyFbYGkICS+hK3CY/+ SH0ON3n4yUQVLYIZDmrjXHnpAThBm/+LhAOQxPH+xt+kDBveyOZTAQQKpEa83AfOlyeM bYA8h/Hlxywa1IwjS+yGJSIWqiDKYLr9h3J8I= 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=CdgsZAgQdPG0ednneBLuVnElT7YMZJi95p9Lba3U438=; b=kGBkqInqjYq3gYM58EajVXU1gQ245vdKHqfIzCRBczyd+8jpgsDdXKw9ikTUPVDXRP V1TY9w3oTh9gBSLUoz7jlOyPtX6SUc1/G26zw99C8xDII34Q7hzdIR8UZ99/rVbGYaZA rdEuVLZEg4egjLf+IDhv7xy+u9GY2w2wadrp4oLMRpTG43RU2CySzwMI/ZwlTKXD4c80 ac5nIDan0HylU/iXqz/abbxF2occiPK8DCnlcCfcrUNIyfwWa5BTKaeYptJ378Ae6ReE bDapG/48L8gRXoq/TB+6YWd/nTa3EakDX1rIO4fz2krjhQet1irPxXe6Te568YXcwioV 7wow== X-Gm-Message-State: AOAM5336I7MneA0UtM5w0tF5nw1PD6Ip2umcfcPAnaZ0vvf+NqLe4Yat J1Lzt5SimmTpCSIxvP28u4FDIw== X-Google-Smtp-Source: ABdhPJz2zi9gbLoBXgfipQwsg1WOQm6A8DNt4T8cF8yieRNcFaZbBePOz+wTbDHPQ5b/bESh3EWaCw== X-Received: by 2002:a05:6e02:188e:: with SMTP id o14mr1689437ilu.169.1643990228381; Fri, 04 Feb 2022 07:57:08 -0800 (PST) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id j3sm1120464ilq.13.2022.02.04.07.57.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Feb 2022 07:57:08 -0800 (PST) Subject: Re: [PATCH v2 3/6] kselftest/arm64: mte: user_mem: check different offsets and sizes To: Joey Gouly , linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, broonie@kernel.org, catalin.marinas@arm.com, shuah@kernel.org, will@kernel.org, Shuah Khan References: <20220203143620.30629-1-joey.gouly@arm.com> <20220203143620.30629-4-joey.gouly@arm.com> From: Shuah Khan Message-ID: Date: Fri, 4 Feb 2022 08:57:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220203143620.30629-4-joey.gouly@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220204_075709_488210_274FC220 X-CRM114-Status: GOOD ( 25.69 ) 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 2/3/22 7:36 AM, Joey Gouly wrote: > Iterate over different file offsets, pointer offsets and buffer sizes to exercise > and test different behaviour. Please add more information here. > > Signed-off-by: Joey Gouly > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Brown > Cc: Shuah Khan > --- > .../selftests/arm64/mte/check_user_mem.c | 49 +++++++++++-------- > 1 file changed, 29 insertions(+), 20 deletions(-) > > diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c > index e5bfeaeb64bb..35061ae23ed5 100644 > --- a/tools/testing/selftests/arm64/mte/check_user_mem.c > +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c > @@ -26,6 +26,8 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, > char val = 'A'; > size_t len, read_len; > void *ptr, *ptr_next; > + int fileoff, ptroff, size; > + int sizes[] = {1, 2, 3, 8, 16, 32, 4096, page_sz}; > > err = KSFT_PASS; > len = 2 * page_sz; > @@ -66,26 +68,33 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, > ptr_next = mte_insert_new_tag(ptr_next); > mte_set_tag_address_range(ptr_next, tag_len); > > - lseek(fd, 0, 0); > - /* Copy from file into buffer with invalid tag */ > - read_len = read(fd, ptr, len); > - mte_wait_after_trig(); > - /* > - * Accessing user memory in kernel with invalid tag should fail in sync > - * mode without fault but may not fail in async mode as per the > - * implemented MTE userspace support in Arm64 kernel. > - */ > - if (cur_mte_cxt.fault_valid) { > - err = KSFT_FAIL; > - goto usermem_acc_err; > - } > - if (mode == MTE_SYNC_ERR && read_len < len) { > - /* test passed */ > - } else if (mode == MTE_ASYNC_ERR && read_len == len) { > - /* test passed */ > - } else { > - err = KSFT_FAIL; Why not set err in usermem_acc_err - this way you can make the error paths common and simpler. > - goto usermem_acc_err; > + for (fileoff = 0; fileoff < 16; fileoff++) { > + for (ptroff = 0; ptroff < 16; ptroff++) { > + for (i = 0; i < ARRAY_SIZE(sizes); i++) { > + size = sizes[i]; > + lseek(fd, 0, 0); > + /* Copy from file into buffer with invalid tag */ > + read_len = read(fd, ptr + ptroff, size); > + mte_wait_after_trig(); > + /* > + * Accessing user memory in kernel with invalid tag should fail in sync > + * mode without fault but may not fail in async mode as per the > + * implemented MTE userspace support in Arm64 kernel. > + */ > + if (cur_mte_cxt.fault_valid) { > + err = KSFT_FAIL; The above assignment can go way if you add this to usermem_acc_err path > + goto usermem_acc_err; > + } > + if (mode == MTE_SYNC_ERR && read_len < len) { > + /* test passed */ > + } else if (mode == MTE_ASYNC_ERR && read_len == size) { > + /* test passed */ > + } else { > + err = KSFT_FAIL; Same here > + goto usermem_acc_err; > + } > + } > + } > } > usermem_acc_err: > mte_free_memory((void *)ptr, len, mem_type, true); > With the above requested changes - Reviewed-by: Shuah Khan thanks, -- Shuah _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel