From patchwork Thu Nov 19 20:16:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michael_B=C3=BCsch?= X-Patchwork-Id: 7661451 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 46C0A9F2EC for ; Thu, 19 Nov 2015 20:47:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B367520490 for ; Thu, 19 Nov 2015 20:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0204F2055C for ; Thu, 19 Nov 2015 20:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758646AbbKSUrI (ORCPT ); Thu, 19 Nov 2015 15:47:08 -0500 Received: from bues.ch ([80.190.117.144]:34684 "EHLO bues.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757137AbbKSUrI (ORCPT ); Thu, 19 Nov 2015 15:47:08 -0500 Received: by bues.ch with esmtpsa (Exim 4.80) (envelope-from ) id 1ZzVde-0001dT-MY; Thu, 19 Nov 2015 21:17:02 +0100 Date: Thu, 19 Nov 2015 21:16:36 +0100 From: Michael =?UTF-8?B?QsO8c2No?= To: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton Cc: Ilia Mirkin Subject: [PATCH] sh: Fix clearing of thread info fault code Message-ID: <20151119211636.048c4aa5@wiggum> X-Mailer: Claws Mail 3.13.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The expression (~0 >> x) will always yield all-ones, because the right shift is an arithmetic right shift that will always shift ones in. Hence the old fault code bits will not be cleared before being ORed with the new fault code. Fix this by forcing a logical right shift instead of an arithmetic right shift by using an unsigned long constant. Reported-by: Ilia Mirkin Signed-off-by: Michael Buesch --- The code also assumes sizeof(ti->flags) == 4. But that probably is ok for this arch. This patch is untested, because I do not have the hardware. Resend: Patch was originally sent on Wed, 18 Jun 2015. Index: linux/arch/sh/include/asm/thread_info.h =================================================================== --- linux.orig/arch/sh/include/asm/thread_info.h +++ linux/arch/sh/include/asm/thread_info.h @@ -172,7 +172,7 @@ static inline void set_restore_sigmask(v static inline void set_thread_fault_code(unsigned int val) { struct thread_info *ti = current_thread_info(); - ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) + ti->flags = (ti->flags & (~0UL >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) | (val << TI_FLAG_FAULT_CODE_SHIFT); }