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 X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF694C433EF for ; Tue, 7 Sep 2021 16:06:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D07EE610E8 for ; Tue, 7 Sep 2021 16:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244516AbhIGQHU (ORCPT ); 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-Google-Smtp-Source: ABdhPJzCHK/gFgjxE677WaXrrlZNPfq5Xf3OssXYH00UAECgEt6c16PeLBnUnBaGFDeDwFDWHl8W3OIfmHf2xWev+Hg= 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. 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 X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27D04C433EF for ; Tue, 7 Sep 2021 16:07:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EAD75610E9 for ; Tue, 7 Sep 2021 16:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EAD75610E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CCJow8hm0SNa1lsmamK51InGPMwFDxgTAyHovDx7RS4=; b=CNockKRXsnfk5d +gUdrPmNg2rv1+z+isIeO9/DR+lvTTHICH8F2z6VgEgVuBGMjNHQ5AfTlXivQsRQFv7V1qR4S/Hjg aWmKtXthmoI5crYJ9ZkaPEfTJcQJ1ku0emqSiONRCi6+A9W1vNXil/usy6p7GpCsftGB+dU/0g9C5 SJOU2y4nmdYmSiayy9UfNYkewXYttcwI2O7zQYJpoGNq8WMcx0hyzTPpuGkdkPVFP5o6zBeaICeAF 2Aq6xlz+v8Gde5wnLoPqo2tEmGdOxmI5Yd8wwR/LBR/pWNQN33VbjFkO1n21XISgLQXnhu4Kppfin czudEsSi8IMTp2xQ3FAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNdby-0049XA-5w; Tue, 07 Sep 2021 16:06:14 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNdbu-0049Wk-EO for linux-arm-kernel@lists.infradead.org; Tue, 07 Sep 2021 16:06:12 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAEA561159 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-f54.google.com with SMTP id k20-20020a4ad114000000b0029133123994so3064789oor.4 for ; Tue, 07 Sep 2021 09:06:09 -0700 (PDT) X-Gm-Message-State: AOAM531OHajwFSZH8p+/VXq+f3aG2n24L+0WrbIMjzMIKKyqg/XDhS5o fmYZEowiOjpdSwWqXDHPW8WFea1bXf5Yp3YXRhQ= X-Google-Smtp-Source: ABdhPJzCHK/gFgjxE677WaXrrlZNPfq5Xf3OssXYH00UAECgEt6c16PeLBnUnBaGFDeDwFDWHl8W3OIfmHf2xWev+Hg= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210907_090610_561648_449F922F X-CRM114-Status: GOOD ( 33.89 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel