Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp617436pxb; Tue, 14 Sep 2021 05:15:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhplpizdDlF42hSu6twCj+P1WfGIQdmkafWSCZJgYSsCb+kl32jdYEvjpHg7MHajMfEPk7 X-Received: by 2002:a17:906:3f95:: with SMTP id b21mr17917390ejj.368.1631621701733; Tue, 14 Sep 2021 05:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631621701; cv=none; d=google.com; s=arc-20160816; b=Ga+rRYQo33AUGGVzO3WQWp8dbAUSAkFkZp3mktyL0f8eMyAwd+f3e/nKjbAbroyIB4 Tz1RUB24YFg5ZOe7cdMIta7r48sOl535pYdKd6T/6hrhHok+pv7mcOPA3sRvuHR5sbTb IR4ZA2q4fpA1XELEk9YgZaWtdWAtGZyX3Yi1FLaPilyzed6npFcADQAO5eeQCel0MQst AIiPbgOYDBDvu5gUbsNqEdWPAQGqszTTuKSqVzMDdqMQE6E0SfBQInbG9jdgwXDp0C16 onavhk6YGu30GxqAPxk4dSMDdH0OraxH5tLThATV0W77m2ugBEb1ZuuxX0VNABXfEa4R CDnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CGyW2wgkoknHF4JJz7ROaPhlPYZOif9Q9EzGJ3lLXcI=; b=sJ4kFHxF3dlZ74N3oCUhmUOgnpztVdeQD20I52R4UJSRc4MwlTg6qD21fRHtpIDCEK gDhV9KsmZP3mawHt1uqu9rODgo73fu+EriR8gIY96szM1J44E7gBEs1RwUu1mIqx2Qgo P1GhLTjP69RserDe/5Zoi7X9TBHzCALn5zYMr4SQ6trSkUghCSsS6AMgBjki9x6JSoiB +Oeh6Xwq42x9RJIRt8Bc9N+eROSnIUAPVM3diU+7nwPwhiFieaDAOEbuWJUrjBBLAMkI mFKH5h6bu4WDr4HfeCNn04ehDkL/pArPZrscUWnCvnKTt/LVX6YMvhUK8NFI6G2wqM3+ Nkzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sq4xNJYS; 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 r24si13051381ejy.194.2021.09.14.05.14.37; Tue, 14 Sep 2021 05:15:01 -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=sq4xNJYS; 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 S232623AbhINMMs (ORCPT + 99 others); Tue, 14 Sep 2021 08:12:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbhINMMj (ORCPT ); Tue, 14 Sep 2021 08:12:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1B9061130; Tue, 14 Sep 2021 12:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631621482; bh=gTE6Maj6qRThpm0j9WlP+9jacEHHOVPzS1LeC09xFzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sq4xNJYSujytX0giN9tZTKEaOzYD99AoPZb5diJ6v8ZAjwO5L9EID0jPVwA1owf1M TUkNBA2g8rKZnUhOWZqFpX4YIsAShnVKKwNDiVXjBuR/tzUEJxrxofKcFpvIX+0irJ +JrqZCjv8Mn0uOgKR/MhH1uWWih3JrcuHdrVCFAJU5Sln4k9/Qqo0VgLXkwbpSs4U4 imre3233wp3Ze4O59wpDEi+UlzgF2CR5ZwoHG0NdUSH8s4hlC16/ymCV3ijg3efUrD ri2dJ8UalQ4h3SdQLeA+gTmhy9W6yusoyBSnHFId2k8x9mekBA7KST/0d7RiSOBFcM 7x18E6ko3mTPQ== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Keith Packard , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Christophe Leroy , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Kees Cook , Andy Lutomirski , Linus Torvalds , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org Subject: [RFC PATCH 6/8] powerpc: smp: remove hack to obtain offset of task_struct::cpu Date: Tue, 14 Sep 2021 14:10:34 +0200 Message-Id: <20210914121036.3975026-7-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210914121036.3975026-1-ardb@kernel.org> References: <20210914121036.3975026-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of relying on awful hacks to obtain the offset of the cpu field in struct task_struct, move it back into struct thread_info, which does not create the same level of circular dependency hell when trying to include the header file that defines it. Signed-off-by: Ard Biesheuvel --- arch/powerpc/Makefile | 11 ----------- arch/powerpc/include/asm/smp.h | 17 +---------------- arch/powerpc/kernel/asm-offsets.c | 2 -- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index aa6808e70647..54cad1faa5d0 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -446,17 +446,6 @@ else endif endif -ifdef CONFIG_SMP -ifdef CONFIG_PPC32 -prepare: task_cpu_prepare - -PHONY += task_cpu_prepare -task_cpu_prepare: prepare0 - $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h)) - -endif # CONFIG_PPC32 -endif # CONFIG_SMP - PHONY += checkbin # Check toolchain versions: # - gcc-4.6 is the minimum kernel-wide version so nothing required. diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index 7ef1cd8168a0..007332a4a732 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -87,22 +87,7 @@ int is_cpu_dead(unsigned int cpu); /* 32-bit */ extern int smp_hw_index[]; -/* - * This is particularly ugly: it appears we can't actually get the definition - * of task_struct here, but we need access to the CPU this task is running on. - * Instead of using task_struct we're using _TASK_CPU which is extracted from - * asm-offsets.h by kbuild to get the current processor ID. - * - * This also needs to be safeguarded when building asm-offsets.s because at - * that time _TASK_CPU is not defined yet. It could have been guarded by - * _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing - * when building something else than asm-offsets.s - */ -#ifdef GENERATING_ASM_OFFSETS -#define raw_smp_processor_id() (0) -#else -#define raw_smp_processor_id() (*(unsigned int *)((void *)current + _TASK_CPU)) -#endif +#define raw_smp_processor_id() (current_thread_info()->cpu) #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()]) static inline int get_hard_smp_processor_id(int cpu) diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index e37e4546034e..cc05522f50bf 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -9,8 +9,6 @@ * #defines from the assembly-language output. */ -#define GENERATING_ASM_OFFSETS /* asm/smp.h */ - #include #include #include -- 2.30.2