Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3870975pxb; Tue, 7 Sep 2021 09:17:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTGWcRp6TJPNxyFvo3+SJQ2H+SvKsqvlABVeP0cN4q7C6GMcc6wtgodBkSP8QRpZB7b76R X-Received: by 2002:aa7:ca0e:: with SMTP id y14mr226684eds.249.1631031463768; Tue, 07 Sep 2021 09:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631031463; cv=none; d=google.com; s=arc-20160816; b=NZW11TjtWHdupaaCaYYObKkvDel0Nej7KvAW0JUU3Yl/HiuzMMEqGncMDoW+Rdo67G PWYF1kwNbu8eeglfmIrXNK9vekNPbxgWdxB7cm61X39Gcq5my4610xLMi/8v9sXqHpCe HHL3gampEexsnhIqvdMpAicvRAQLjRbQrvbV552UdP2VIDYY+yt5Wi0fmEyrXNaXZmbF Wt5LG3czIeji/eoBU2vf3McvOelQqFwvjcbGv5l3gd3F4FW7oSJwchszWlNZHryn7L6Q /4+F4LFsfpZNkUbgejIx0L96dWmHoGuWK9BGSKAXICqf8zHYKn6njPwsAkXwZlYZzpQk wMMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1L/ng3m4NIBOnr8uJkim7/Whttmr/PGC9aOgg/t9Axg=; b=LyxeN2MCBtzoV6cvCMD9GKhcESsS9KJqZahuWMJIKpo6e1/mtXe1ABGQcCrOAnZeQc WRDSlt7ShOHLnezmeQLgU0z7eamoo9eA556ntgx74szc3Koa7W95eucFPZL1iTP8G7zH kpW8HrcXoh6bZdpXylEFr4zJ4kS6zxCmMGudffpFw1QLeBMEHlfQaf9nUqbSqnsqFBhi DCTEi2kYa3gWqIdd0T5q715QAKt0OiHG4G6J89Q2ZZMGrzf+6rC+wMl14kUE/xS3G1zR Roj+ioUL2/HxGaveM3+2aZXj43aYZQ77qOzl61dBtuLVDbsDpHOCO7OXtto1bOr4ZSR8 Z0WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MSYCdzfG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si10892011edq.331.2021.09.07.09.17.18; Tue, 07 Sep 2021 09:17:43 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MSYCdzfG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233891AbhIGQHU (ORCPT + 99 others); Tue, 7 Sep 2021 12:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243976AbhIGQHP (ORCPT ); Tue, 7 Sep 2021 12:07:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8529A61106 for ; Tue, 7 Sep 2021 16:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631030769; bh=1L/ng3m4NIBOnr8uJkim7/Whttmr/PGC9aOgg/t9Axg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MSYCdzfG4ct3IH+Drqzg4YYE0HMENTgnPq2jUOnU71YIf7AAn2NM6J6yOVqwu7M5a Yss0GwkvIYPpEYuRsUpkW+CdNuehP9jHZbjR21v3cdiLOXBywJHHNDaSw7Fq9UPXZz 1ffY4V6cC9A+P079htCwPbMUYslcwzu+dcTUePXMCt3KViNdzxTZa0UE0Mt/daNic5 dQ7PClxqvQbAvHTkJIMiY29eNJ8NslH+g1IaKg5ah5QJX2DxRyx96zUP2GWE7D79lM fP2qAhRdnOEY8I+mgP1k0EPz2sTYCpLZAJ7WnxXUC8+FJZsva3h+ZToigTJbD8hbhN Z2CSikksmQjGA== Received: by mail-oo1-f50.google.com with SMTP id y16-20020a4ad6500000b0290258a7ff4058so3055627oos.10 for ; Tue, 07 Sep 2021 09:06:09 -0700 (PDT) X-Gm-Message-State: AOAM530YeAz4/zYCsLMcSZNp7xDgyvUp/YJJVzQI+qxntQdYuCNDAgW1 yt7q7LvugxZKSG/pPopz+JRK0DDhG+lTxaPbWWc= X-Received: by 2002:a4a:c904:: with SMTP id v4mr537358ooq.26.1631030768782; Tue, 07 Sep 2021 09:06:08 -0700 (PDT) MIME-Version: 1.0 References: <20210902155429.3987201-1-keithp@keithp.com> <20210904060908.1310204-1-keithp@keithp.com> <20210904060908.1310204-3-keithp@keithp.com> <8735qifcy6.fsf@keithp.com> <874kawcssr.fsf@keithp.com> In-Reply-To: <874kawcssr.fsf@keithp.com> From: Ard Biesheuvel Date: Tue, 7 Sep 2021 18:05:47 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] ARM: Move thread_info into task_struct (v7 only) To: Keith Packard Cc: Linux Kernel Mailing List , Abbott Liu , Alexander Sverdlin , Andrew Morton , Anshuman Khandual , Arnd Bergmann , Bjorn Andersson , Florian Fainelli , Geert Uytterhoeven , Hartley Sweeten , Jens Axboe , Jian Cai , Joe Perches , Kees Cook , Krzysztof Kozlowski , Linus Walleij , Linux ARM , Manivannan Sadhasivam , Marc Zyngier , Masahiro Yamada , Miguel Ojeda , Mike Rapoport , Nathan Chancellor , Nick Desaulniers , Nicolas Pitre , Rob Herring , Russell King , Thomas Gleixner , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Valentin Schneider , Viresh Kumar , "Wolfram Sang (Renesas)" , YiFei Zhu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Sept 2021 at 17:24, Keith Packard wrote: > > Ard Biesheuvel writes: > > > Sure, so it is precisely for that reason that it is better to isolate > > changes that can be isolated. > > I'll go ahead and split this apart then; that is how I did development, > after all. > > > All the time. 'current' essentially never changes value from the POV > > of code running in task context, so there is usually no reason to care > > about preemption/migration when referring to it. Using per-CPU > > variables is what creates the problem here. > > Thanks for helping me -- I just got the wrong model stuck in my head > over the weekend somehow. > > If I do have this figured out, we should be able to stick the > per_cpu_offset value in thread_info and use TPIDRPRW to hold 'current' > as code using per_cpu_offset should already be disabling > preemption. That should be an easier change than putting a kernel > pointer in a user-visible register. > That is still a bit tricky, given that you now have to swap out the per-CPU offset when you migrate a task, and the generic code is not really set up for that. > > Given that we are already relying on the MP extensions for this > > anyway, I personally think that using another thread ID register to > > carry 'current' is a reasonable approach as well, since it would also > > allow us to get per-task stack protector support into the compiler. > > But I would like to hear from some other folks on cc as well. > > That would be awesome; I assume that doesn't require leaving > per_cpu_offset in a thread ID register? > > In any case, I'll give my plan a try, and then see about trying your > plan as well so I can compare the complexity of the two solutions. > I had a stab at this myself today (long boring day with no Internet connection). https://android-kvm.googlesource.com/linux/+log/refs/heads/ardb/arm32-ti-in-task It resembles your code in some places - I suppose we went on the same journey in a sense :-) We'll fix up the credits before this gets resubmitted. Fixing the per-task stack protector plugin on top of these changes should be trivial but I need a coffee first.