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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97EC8C001E0 for ; Thu, 27 Jul 2023 11:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231590AbjG0LcG (ORCPT ); Thu, 27 Jul 2023 07:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231829AbjG0LcE (ORCPT ); Thu, 27 Jul 2023 07:32:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5D92D73; Thu, 27 Jul 2023 04:31:36 -0700 (PDT) Received: from [192.168.100.7] (unknown [59.103.218.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 95FF26607057; Thu, 27 Jul 2023 12:31:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690457490; bh=QwGbrEQGGJI024TRKlZTazP2ydOrrqpiaW+jd0PA/0w=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Kgu7lcFf3EpvlQmYW1IE3cyUf7qJnscHff1xjQoubuXKbU4ExNtRkW8Z8IHZDJqOs IXxru92rni9lSRWKvjObLgbWHUKMItwvi0xD5QSeHZPszFamTsoC4CNTYwU2mpx0B/ v28NqlvfD9ExtM+xDMnT0dbhwn29t/VQiujMYC2MI6BM6rifPilvU0HAiW2YKQJBUE 22SLiSUpW7dW0hwiw1a+niUbHy2W7Wlvx7k9HzaJY+q9S0ORwYH1U1AIxHV8KdCKiR BAxmXvTC/3WUHaYejcNER4w+b0xXgBo2BYfgOKoaqYubsKWC6kw4R49gcbkdHe7QYZ RI96tQJYcvr2w== Message-ID: Date: Thu, 27 Jul 2023 16:31:18 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Muhammad Usama Anjum , "Kirill A. Shutemov" , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrei Vagin , Danylo Mocherniuk , Alex Sierra , Alexander Viro , Andrew Morton , Axel Rasmussen , Christian Brauner , Cyrill Gorcunov , Dan Williams , David Hildenbrand , Greg KH , "Gustavo A . R . Silva" , "Liam R . Howlett" , Matthew Wilcox , Mike Rapoport , Nadav Amit , Pasha Tatashin , Paul Gofman , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , Yang Shi , Yun Zhou , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kernel@collabora.com Subject: Re: [v3] fs/proc/task_mmu: Implement IOCTL for efficient page table scanning Content-Language: en-US To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= References: <20230713101415.108875-6-usama.anjum@collabora.com> <7eedf953-7cf6-c342-8fa8-b7626d69ab63@collabora.com> <382f4435-2088-08ce-20e9-bc1a15050861@collabora.com> <44eddc7d-fd68-1595-7e4f-e196abe37311@collabora.com> <1afedab8-5929-61e5-b0da-9c70dc01c254@collabora.com> <89c09085-19ab-462b-e3be-b4e492a85899@collabora.com> From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On 7/27/23 4:26 PM, Michał Mirosław wrote: > On Thu, 27 Jul 2023 at 10:03, Muhammad Usama Anjum > wrote: >> On 7/27/23 2:10 AM, Michał Mirosław wrote: >>> On Wed, 26 Jul 2023 at 10:34, Muhammad Usama Anjum >>> wrote: >>>> On 7/25/23 11:05 PM, Michał Mirosław wrote: >>>>> On Tue, 25 Jul 2023 at 11:11, Muhammad Usama Anjum >>>>> wrote: > [...] >>>>> 2. For the address tagging part I'd prefer someone who knows how this >>>>> is used take a look. We're ignoring the tag (but clear it on return in >>>>> ->start) - so it doesn't matter for the ioctl() itself. >>>> I've added Kirill if he can give his thoughts about tagged memory. >>>> >>>> Right now we are removing the tags from all 3 pointers (start, end, vec) >>>> before using the pointers on kernel side. But we are overwriting and >>>> writing the walk ending address in start which user can read/use. >>>> >>>> I think we shouldn't over-write the start (and its tag) and instead return >>>> the ending walk address in new variable, walk_end. >>> >>> The overwrite of `start` is making the ioctl restart (continuation) >>> easier to handle. I prefer the current way, but it's not a strong >>> opinion. >> We shouldn't overwrite the start if we aren't gonna put the correct tag. So >> I've resorted to adding another variable `walk_end` to return the walk >> ending address. > > Yes. We have two options: > > 1. add new field and have the userspace check it and update start > itself to continue the scan, I've selected this option and sent v26 already: https://lore.kernel.org/all/20230727093637.1262110-1-usama.anjum@collabora.com > or: > 2. reconstruct the tag from either orignal `start` or `end` and have > the userspace re-set `start` if it wants to restart the scan instead > of continuing. In some case, compiler can put integrity checking metadata in the pointer's upper byte. So copying start or end's meta data would be wrong. > > (the second one, using `end`'s tag, might be the easiest for > userspace, as it can check `start` == `end` when deciding to continue > or restart). > > Best Regards > Michał Mirosław -- BR, Muhammad Usama Anjum