From patchwork Fri Oct 8 20:48:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 12546431 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 EE2E5C433FE for ; Fri, 8 Oct 2021 20:48:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D53D460EFF for ; Fri, 8 Oct 2021 20:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242932AbhJHUuh (ORCPT ); Fri, 8 Oct 2021 16:50:37 -0400 Received: from smtp.duncanthrax.net ([178.63.180.169]:43320 "EHLO smtp.duncanthrax.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243266AbhJHUuf (ORCPT ); Fri, 8 Oct 2021 16:50:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QbiWZaIEFL/r5D4YIsa9tNdWo0DCFE/2tu4bKS0BZe8=; b=ZdYgPXn7EfclBuLnocDtmIPB/J Ayodd1j1e+0XowmaHzPNwesPR78i8sH3SCWkdFmDdzuNY9KI5aedB6/5u1RYCQCmnXR7hAfI/d2qF uZ2OzJwEmqWuS8c82dPi4y8LZD7UOsBpSMYyeCxs59EOQPlMXysHJNBAV8pH2nNBgBxA=; Received: from hsi-kbw-109-193-149-228.hsi7.kabel-badenwuerttemberg.de ([109.193.149.228] helo=x1.stackframe.org) by smtp.duncanthrax.net with esmtpa (Exim 4.93) (envelope-from ) id 1mYwnG-0006vO-Cj; Fri, 08 Oct 2021 22:48:38 +0200 From: Sven Schnelle To: deller@gmx.de Cc: linux-parisc@vger.kernel.org Subject: [PATCH 1/4] parisc: disable preemption during local tlb flush Date: Fri, 8 Oct 2021 22:48:23 +0200 Message-Id: <20211008204825.6229-2-svens@stackframe.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008204825.6229-1-svens@stackframe.org> References: <20211008204825.6229-1-svens@stackframe.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org flush_cache_mm() fetches %sr3 via mtsp(3). If it matches mm->context, it flushes caches and the TLB. However, the TLB is cpu-local, so if the code gets preempted shortly after the mtsp(), and later resumed on another CPU, the wrong TLB is flushed. Signed-off-by: Sven Schnelle --- arch/parisc/kernel/cache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index 39e02227e231..90656c49bc07 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -558,6 +558,7 @@ void flush_cache_mm(struct mm_struct *mm) return; } + preempt_disable(); if (mm->context == mfsp(3)) { for (vma = mm->mmap; vma; vma = vma->vm_next) { flush_user_dcache_range_asm(vma->vm_start, vma->vm_end); @@ -565,8 +566,10 @@ void flush_cache_mm(struct mm_struct *mm) flush_user_icache_range_asm(vma->vm_start, vma->vm_end); flush_tlb_range(vma, vma->vm_start, vma->vm_end); } + preempt_enable(); return; } + preempt_enable(); pgd = mm->pgd; for (vma = mm->mmap; vma; vma = vma->vm_next) { From patchwork Fri Oct 8 20:48:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 12546437 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 223ABC433F5 for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 117EF60EFF for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242708AbhJHUui (ORCPT ); Fri, 8 Oct 2021 16:50:38 -0400 Received: from smtp.duncanthrax.net ([178.63.180.169]:43324 "EHLO smtp.duncanthrax.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243275AbhJHUuh (ORCPT ); Fri, 8 Oct 2021 16:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+BjgNCV0/lu3CDm1NJ8AzlrRox5HQiErnYXfhWVfoBc=; b=CQ8nmc5/zTO8SaPAF9h+eN08nH he0lR3rSNxQeAEhKGsraaPX80d7dFCzL414svXxorewZ7CvxRNWm2mPzulSldLnhGq8xysP9HDw8C r4Po3ATAifiwucPgeI7WU9TOOfwm+YJPb8KLOaJ5GgA2Vn+9yzsTBAs33gYbBXyAOr7E=; Received: from hsi-kbw-109-193-149-228.hsi7.kabel-badenwuerttemberg.de ([109.193.149.228] helo=x1.stackframe.org) by smtp.duncanthrax.net with esmtpa (Exim 4.93) (envelope-from ) id 1mYwnH-0006vO-0J; Fri, 08 Oct 2021 22:48:39 +0200 From: Sven Schnelle To: deller@gmx.de Cc: linux-parisc@vger.kernel.org Subject: [PATCH 2/4] parisc: fix preempt_count() check in entry.S Date: Fri, 8 Oct 2021 22:48:24 +0200 Message-Id: <20211008204825.6229-3-svens@stackframe.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008204825.6229-1-svens@stackframe.org> References: <20211008204825.6229-1-svens@stackframe.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org preempt_count in struct thread_info is unsigned int, but the entry.S code used LDREG, which generates a 64 bit load when compiled for 64 bit. Fix this to use an ldw and also change the condition in the compare one line below to only compares 32 bits, although ldw zero extends, and that should work with a 64 bit compare. Signed-off-by: Sven Schnelle --- arch/parisc/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S index 9f939afe6b88..e9e598c18cb0 100644 --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -974,8 +974,8 @@ intr_do_preempt: /* current_thread_info()->preempt_count */ mfctl %cr30, %r1 - LDREG TI_PRE_COUNT(%r1), %r19 - cmpib,COND(<>) 0, %r19, intr_restore /* if preempt_count > 0 */ + ldw TI_PRE_COUNT(%r1), %r19 + cmpib,<> 0, %r19, intr_restore /* if preempt_count > 0 */ nop /* prev insn branched backwards */ /* check if we interrupted a critical path */ From patchwork Fri Oct 8 20:48:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 12546435 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 E78ADC43217 for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD4CC60EFF for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243042AbhJHUuj (ORCPT ); Fri, 8 Oct 2021 16:50:39 -0400 Received: from smtp.duncanthrax.net ([178.63.180.169]:43328 "EHLO smtp.duncanthrax.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243069AbhJHUui (ORCPT ); Fri, 8 Oct 2021 16:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NRZLbVYtbqTzMEvUTRV/83DJyzg6trhIBb8yH3RTIx4=; b=F0dsMDrnOxxNzBwpWsDI6juEXg vPQi0uHvk4NCwKpUawmX/GTq0JmhzVxACdGdxAvD5OqKqFa6+V1jH8zJ9/M4Eb6clVsqld2IOvU3i RfACxiNw+i1wk21dsEV4e0SeEJT3NQORtaTRL9L85kwHHjiPLKstR0/2Tu5IZm8EMvdU=; Received: from hsi-kbw-109-193-149-228.hsi7.kabel-badenwuerttemberg.de ([109.193.149.228] helo=x1.stackframe.org) by smtp.duncanthrax.net with esmtpa (Exim 4.93) (envelope-from ) id 1mYwnH-0006vO-KP; Fri, 08 Oct 2021 22:48:39 +0200 From: Sven Schnelle To: deller@gmx.de Cc: linux-parisc@vger.kernel.org Subject: [PATCH 3/4] parisc: disable preemption in send_IPI_allbutself() Date: Fri, 8 Oct 2021 22:48:25 +0200 Message-Id: <20211008204825.6229-4-svens@stackframe.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008204825.6229-1-svens@stackframe.org> References: <20211008204825.6229-1-svens@stackframe.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org Otherwise we might not stop all other CPUs. Signed-off-by: Sven Schnelle --- arch/parisc/kernel/smp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 1405b603b91b..3413e6949c87 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -219,11 +219,13 @@ static inline void send_IPI_allbutself(enum ipi_message_type op) { int i; - + + preempt_disable(); for_each_online_cpu(i) { if (i != smp_processor_id()) send_IPI_single(i, op); } + preempt_enable(); } From patchwork Fri Oct 8 20:48:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 12546439 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 AA2DFC4332F for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90E8B60EFF for ; Fri, 8 Oct 2021 20:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243266AbhJHUuj (ORCPT ); Fri, 8 Oct 2021 16:50:39 -0400 Received: from smtp.duncanthrax.net ([178.63.180.169]:43332 "EHLO smtp.duncanthrax.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243287AbhJHUui (ORCPT ); Fri, 8 Oct 2021 16:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OxTKNI8XCny7h9we6L6NOBdFK3V44SBGlYijzCauxE0=; b=RimPCVnm/IC38xdpLwwDGBQS6k LAHOV3sULSfXg1AX3GCTZAzN3gLrx0NkiWPtqob/Zw3v+XGQw+L7fXLoSHjx0AcyhNnF5CrJA0wds 1XUgvk9PVvfMhPOlP+YJUNujFaqgBrt73alvgGL1yRmNawvsha06svCpflVc4jTQghtc=; Received: from hsi-kbw-109-193-149-228.hsi7.kabel-badenwuerttemberg.de ([109.193.149.228] helo=x1.stackframe.org) by smtp.duncanthrax.net with esmtpa (Exim 4.93) (envelope-from ) id 1mYwnI-0006vO-4B; Fri, 08 Oct 2021 22:48:40 +0200 From: Sven Schnelle To: deller@gmx.de Cc: linux-parisc@vger.kernel.org Subject: [PATCH 4/4] parisc: fix warning in flush_tlb_all Date: Fri, 8 Oct 2021 22:48:26 +0200 Message-Id: <20211008204825.6229-5-svens@stackframe.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008204825.6229-1-svens@stackframe.org> References: <20211008204825.6229-1-svens@stackframe.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org I've got the following splat after enabling preemption: [ 3.724721] BUG: using __this_cpu_add() in preemptible [00000000] code: swapper/0/1 [ 3.734630] caller is __this_cpu_preempt_check+0x38/0x50 [ 3.740635] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.15.0-rc4-64bit+ #324 [ 3.744605] Hardware name: 9000/785/C8000 [ 3.744605] Backtrace: [ 3.744605] [<00000000401d9d58>] show_stack+0x74/0xb0 [ 3.744605] [<0000000040c27bd4>] dump_stack_lvl+0x10c/0x188 [ 3.744605] [<0000000040c27c84>] dump_stack+0x34/0x48 [ 3.744605] [<0000000040c33438>] check_preemption_disabled+0x178/0x1b0 [ 3.744605] [<0000000040c334f8>] __this_cpu_preempt_check+0x38/0x50 [ 3.744605] [<00000000401d632c>] flush_tlb_all+0x58/0x2e0 [ 3.744605] [<00000000401075c0>] 0x401075c0 [ 3.744605] [<000000004010b8fc>] 0x4010b8fc [ 3.744605] [<00000000401080fc>] 0x401080fc [ 3.744605] [<00000000401d5224>] do_one_initcall+0x128/0x378 [ 3.744605] [<0000000040102de8>] 0x40102de8 [ 3.744605] [<0000000040c33864>] kernel_init+0x60/0x3a8 [ 3.744605] [<00000000401d1020>] ret_from_kernel_thread+0x20/0x28 [ 3.744605] Fix this by moving the __inc_irq_stat() into the locked section. Signed-off-by: Sven Schnelle --- arch/parisc/mm/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 3f7d6d5b56ac..65f50f072a87 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -842,9 +842,9 @@ void flush_tlb_all(void) { int do_recycle; - __inc_irq_stat(irq_tlb_count); do_recycle = 0; spin_lock(&sid_lock); + __inc_irq_stat(irq_tlb_count); if (dirty_space_ids > RECYCLE_THRESHOLD) { BUG_ON(recycle_inuse); /* FIXME: Use a semaphore/wait queue here */ get_dirty_sids(&recycle_ndirty,recycle_dirty_array); @@ -863,8 +863,8 @@ void flush_tlb_all(void) #else void flush_tlb_all(void) { - __inc_irq_stat(irq_tlb_count); spin_lock(&sid_lock); + __inc_irq_stat(irq_tlb_count); flush_tlb_all_local(NULL); recycle_sids(); spin_unlock(&sid_lock);