From patchwork Tue Dec 3 22:32:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180768 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2172426ile; Tue, 3 Dec 2019 15:06:39 -0800 (PST) X-Google-Smtp-Source: APXvYqx2Xvu7PHcl/lnsjPumi9toySbsffqR3FRtgNg/uxToSqkKFoHl644OaZDk8N64fCxgjKOc X-Received: by 2002:a9d:6315:: with SMTP id q21mr259540otk.15.1575414399728; Tue, 03 Dec 2019 15:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575414399; cv=none; d=google.com; s=arc-20160816; b=YheAcc0rk7/s85GlTcbCzP7lcdNfRqw8dVJfHr4Y+ZnfYZgy3sqLqa/m6F4LlWiBAp nBiYvsTJd6pUyViGEuwtr1YiCS+K5v5hFAS6Kg9tBvb03XN+ZHGZxcdSWjx0C5+Q3E/f VPtPpxoKKBbnJh9XYElDnOiEa2K94WT1z2UME3AQK03oTmwTOwFCM1UlrQrcJm/cXtL/ IC+wtabGCm+eB7i4mRYZ4wtDPFcvAvvDhDTAlg+0RLzR9wou0JRgBY6plKfUz8q7+oq4 Lb+2I7IzNj/kMa6DW1dBQnVCh0efaAYNj3lY0iaSrf4u/gfnkO03tyTBd8rQ5GSrWnCM GwTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qBsoLE6H/hP5XTo8iytyyMCtc0xAwGFEngH6mdlWWzA=; b=JRuoY7ZZE6eRcTNOhTYzSF4KR1A2IRrmlaWgTGnv58c3TKJYG4f/Gj4toEm2n4Nl9c qwQV2/WDtPqMQBT/sbgSgkInNeLZHwMTJx00L3g4yFW0Lc8xt85gKYg7QM+6hUWPdmfE LpyMO17pnSx5YTfbhCLasd/ciJDMf8N6YnOUlPmiQSa+Axu3rf+2X/XhFUNDCV22t/Vy UvJIfinin+jqCa1k+uPrEQynaEZWdrFaQpQ7mucsdfEILR2dcekD0Gs/v27Vv2JRnEz6 N4IbV2cnT4apPeyDPFu+QEHsEF2f247IcjTQR0QLapJ0vYOYq+ecxMGE4hwc/9/ki8/O I7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xVnuhXVW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i185si1763533oia.187.2019.12.03.15.06.39; Tue, 03 Dec 2019 15:06:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xVnuhXVW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729449AbfLCWsb (ORCPT + 27 others); Tue, 3 Dec 2019 17:48:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729317AbfLCWs2 (ORCPT ); Tue, 3 Dec 2019 17:48:28 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3526820862; Tue, 3 Dec 2019 22:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413307; bh=MqOdMBcFN7cKpxoPq7s5s29VjuTXuCthvZFz0pCPqiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xVnuhXVWZfmQ7YneRNSsKvFjG9SGzV2N2VF9tCs6KbPohVzkh7eFeTVOdSfqy4DDB 16t7c0RPHGyVtOVkZf/bpNb0pgTqw7y6GtdnlLssfw6Kdocv8Sj1ZT4mQ1/2Pi/Qop umZ8XFE5rENHQR+JqLshkg0AYlC/eT7r8zJTVAfA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , "kernelci.org bot" , Kevin Hilman , Will Deacon , Sasha Levin Subject: [PATCH 4.19 077/321] arm64: preempt: Fix big-endian when checking preempt count in assembly Date: Tue, 3 Dec 2019 23:32:23 +0100 Message-Id: <20191203223431.166680020@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203223427.103571230@linuxfoundation.org> References: <20191203223427.103571230@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon [ Upstream commit 7faa313f05cad184e8b17750f0cbe5216ac6debb ] Commit 396244692232 ("arm64: preempt: Provide our own implementation of asm/preempt.h") extended the preempt count field in struct thread_info to 64 bits, so that it consists of a 32-bit count plus a 32-bit flag indicating whether or not the current task needs rescheduling. Whilst the asm-offsets definition of TSK_TI_PREEMPT was updated to point to this new field, the assembly usage was left untouched meaning that a 32-bit load from TSK_TI_PREEMPT on a big-endian machine actually returns the reschedule flag instead of the count. Whilst we could fix this by pointing TSK_TI_PREEMPT at the count field, we're actually better off reworking the two assembly users so that they operate on the whole 64-bit value in favour of inspecting the thread flags separately in order to determine whether a reschedule is needed. Acked-by: Ard Biesheuvel Reported-by: "kernelci.org bot" Tested-by: Kevin Hilman Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/assembler.h | 8 +++----- arch/arm64/kernel/entry.S | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 5a97ac8531682..0c100506a29aa 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -683,11 +683,9 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU .macro if_will_cond_yield_neon #ifdef CONFIG_PREEMPT get_thread_info x0 - ldr w1, [x0, #TSK_TI_PREEMPT] - ldr x0, [x0, #TSK_TI_FLAGS] - cmp w1, #PREEMPT_DISABLE_OFFSET - csel x0, x0, xzr, eq - tbnz x0, #TIF_NEED_RESCHED, .Lyield_\@ // needs rescheduling? + ldr x0, [x0, #TSK_TI_PREEMPT] + sub x0, x0, #PREEMPT_DISABLE_OFFSET + cbz x0, .Lyield_\@ /* fall through to endif_yield_neon */ .subsection 1 .Lyield_\@ : diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 5f800384cb9a8..bb68323530458 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -622,10 +622,8 @@ el1_irq: irq_handler #ifdef CONFIG_PREEMPT - ldr w24, [tsk, #TSK_TI_PREEMPT] // get preempt count - cbnz w24, 1f // preempt count != 0 - ldr x0, [tsk, #TSK_TI_FLAGS] // get flags - tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling? + ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count + cbnz x24, 1f // preempt count != 0 bl el1_preempt 1: #endif