From patchwork Thu Nov 19 20:13:19 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: 7661441 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 275C6C05CA for ; Thu, 19 Nov 2015 20:47:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91B4320544 for ; Thu, 19 Nov 2015 20:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E485B2054D for ; Thu, 19 Nov 2015 20:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758546AbbKSUrH (ORCPT ); Thu, 19 Nov 2015 15:47:07 -0500 Received: from bues.ch ([80.190.117.144]:34683 "EHLO bues.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757137AbbKSUrG (ORCPT ); Thu, 19 Nov 2015 15:47:06 -0500 X-Greylist: delayed 2075 seconds by postgrey-1.27 at vger.kernel.org; Thu, 19 Nov 2015 15:47:06 EST Received: by bues.ch with esmtpsa (Exim 4.80) (envelope-from ) id 1ZzVaa-0001dD-69; Thu, 19 Nov 2015 21:13:52 +0100 Date: Thu, 19 Nov 2015 21:13:19 +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] m32r: Fix clearing of thread info fault code Message-ID: <20151119211319.784149af@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. (Sorry, hit the send button early, so here goes the actual patch.) Index: linux/arch/m32r/include/asm/thread_info.h =================================================================== --- linux.orig/arch/m32r/include/asm/thread_info.h +++ linux/arch/m32r/include/asm/thread_info.h @@ -77,7 +77,7 @@ static inline struct thread_info *curren 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); }