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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498CDC433F5 for ; Thu, 21 Oct 2021 09:21:48 +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 0CE80610CB for ; Thu, 21 Oct 2021 09:21:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0CE80610CB 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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=l3wCzvvWGOqRLUKWf+gC1Qw1zUvLsiMsl/7EjQgB2SQ=; b=tdekgzCjG2wB9a Osh85YXkdUhgibAsejaZa5yUK8LWkQ68F3rDrM0ZyBTsGN5yjKeAq0y2w14XuwctQVYobTsUzHwRL pLVe6LW8I2gXxlTQwl5u8FEb+drhJnN8etzjfc9peXHhD0IvAoQDxXMUOa/iWoxcU5t2iALYolxtk 2tT8qn0ATd18hp20Bv/W/S7BJfbf+UUFnwKRxmJrdR8Fo2qS3jVnaEXvNoLvLiN59Ym+z6bw2xxT9 iaBxjNmvvbOt+dzRGXYJ3ezY1WvwXEPIekZxGEqCKbC1OUytJlBK6ME7BcpXrk6DMK6mXZuAZ9wWy t4i+OQ5mdoSfb8c9eh4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdUFD-006zh7-JY; Thu, 21 Oct 2021 09:20:15 +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 1mdUF9-006zgk-Ix for linux-arm-kernel@lists.infradead.org; Thu, 21 Oct 2021 09:20:12 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E5BD61052; Thu, 21 Oct 2021 09:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634808011; bh=DsxZ3c+nz+gN8uiz8aKn1iq6c3nrCEqJ2g9Un+9wnGU=; h=From:To:Cc:Subject:Date:From; b=bk/zjoetHAM4akF87jaEnsf6Xk5t1jM4eGikmjwZmsRnKGDgM96V17m4MKhbr/TuT hryEWobppqG+ubUj0Q2WEPrIZkocXblhHvMmQ/3VbdM/iUvVn/P2s1pjZfpWYEkFlz lkkrTFiC+3fKelU30LkMSU3FFZBoTKCaKDE+H4UkyonL4URHeIch9kSnYnDdLe4DcI 1VV8rwLzwpiEj5NfUBC1v6iL3zQ/9Ft8N44riueAQIYixzaMJKR1RgJBZVZF/DcsGG 1DPdxIqcyEo5MHCRBHgHj0AqbltJsjTPhDqRb5TFSpP001pgbjxLoDKhLcKd1nijUu dZUTbxVXw0big== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linux@armlinux.org.uk, arnd@arndb.de, Ard Biesheuvel Subject: [PATCH] ARM: Fix PID_IN_CONTEXTIDR regression when THREAD_INFO_IN_TASK=y Date: Thu, 21 Oct 2021 11:19:59 +0200 Message-Id: <20211021091959.1411154-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2003; h=from:subject; bh=DsxZ3c+nz+gN8uiz8aKn1iq6c3nrCEqJ2g9Un+9wnGU=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhcTC+e8OQm/aSch3XOAXLLNNB3TDoNGR/Yl4ijI6f c96gyX6JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYXEwvgAKCRDDTyI5ktmPJPYQDA C+KOgkBph/9xQnp6XUE04EiuTfFJ6F8kNm6xRjbPrnIuK0e6etj3HPfkKTTUUlnuUPJ8ah5rSNMzvy 5D5OaFGgvnYhzDfy5mFOFlrCDjUN2kj2tF/ZF6aw6kR8e152lIVKHlcyZyqcm/a8s/OuFVx8K1Mkw4 EwCJaWYh5DgIDx0zYu4pe49PsKLgPOVB+NlGhnF9Dvf63gUss+KilUoYF7k+2KBboXNB45To0evlbz a1D8j7NfJIOAINyG7naZS6nxRer4uL/CaIj7bX0EiR8Oy6Dl3vnkmP4EaiGdm7hGjrpeZ0l6tAIzpM gmcZsk1oei7oAvWgwbfZlwtti/Ju/O0BYG4wT/QNzhT7y0W54VeuxZMfa4dWGkqKVm8xJRA1KtPimb RerTzFbT3B8jGnMEnisw8B3o0NdzWmQybGANeZcGhM45V09NmUosenB+TrkK5/JVZQzOc6hkouSSNc oocTZCjOV0rA1w4jh7u4j0sfqdVLc3KDsgRxiFUq0o3Eo= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211021_022011_691355_79AF884C X-CRM114-Status: GOOD ( 12.45 ) 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 The code that implements the rarely used PID_IN_CONTEXTIDR feature dereferences the 'task' field of struct thread_info directly, and this is no longer possible when THREAD_INFO_IN_TASK=y, as the 'task' field is omitted from the struct definition in that case. Instead, we should just cast the thread_info pointer to a task_struct pointer, given that the former is now the first member of the latter. So use a helper that abstracts this, and provide implementations for both cases. Fixes: 18ed1c01a7dd ("ARM: smp: Enable THREAD_INFO_IN_TASK") Reported by: Arnd Bergmann Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/thread_info.h | 11 +++++++++++ arch/arm/mm/context.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 787511396f3f..164e15f26485 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -79,9 +79,20 @@ struct thread_info { #ifdef CONFIG_THREAD_INFO_IN_TASK #define INIT_THREAD_INFO_TASK(tsk) + +static inline struct task_struct *thread_task(struct thread_info* ti) +{ + return (struct task_struct *)ti; +} + #else #define INIT_THREAD_INFO_TASK(tsk) .task = &(tsk), +static inline struct task_struct *thread_task(struct thread_info* ti) +{ + return ti->task; +} + /* * how to get the thread information struct from C */ diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c index b7525b433f3e..48091870db89 100644 --- a/arch/arm/mm/context.c +++ b/arch/arm/mm/context.c @@ -109,7 +109,7 @@ static int contextidr_notifier(struct notifier_block *unused, unsigned long cmd, if (cmd != THREAD_NOTIFY_SWITCH) return NOTIFY_DONE; - pid = task_pid_nr(thread->task) << ASID_BITS; + pid = task_pid_nr(thread_task(thread)) << ASID_BITS; asm volatile( " mrc p15, 0, %0, c13, c0, 1\n" " and %0, %0, %2\n" -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel