From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753134AbbC3Q5Q (ORCPT ); Mon, 30 Mar 2015 12:57:16 -0400 Received: from www.sr71.net ([198.145.64.142]:55262 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753074AbbC3Q5P (ORCPT ); Mon, 30 Mar 2015 12:57:15 -0400 Message-ID: <5519806A.1060807@sr71.net> Date: Mon, 30 Mar 2015 09:57:14 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Borislav Petkov CC: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com Subject: Re: [PATCH 15/17] x86, mpx: do 32-bit-only cmpxchg for 32-bit apps References: <20150326183327.64807530@viggo.jf.intel.com> <20150326183353.A2A5B371@viggo.jf.intel.com> <20150327172914.GE5517@pd.tnic> <55159E89.5090007@sr71.net> <20150328083928.GA17284@pd.tnic> In-Reply-To: <20150328083928.GA17284@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/28/2015 01:39 AM, Borislav Petkov wrote: > - if (is_64bit_mm(mm)) { > - ret = user_atomic_cmpxchg_inatomic(actual_old_val_ptr, > - bd_entry_addr, expected_old_val, new_bd_entry); > - } else { > - u32 uninitialized_var(actual_old_val_32); > - u32 expected_old_val_32 = expected_old_val; > - u32 new_bd_entry_32 = new_bd_entry; > - u32 __user *bd_entry_32 = (u32 __user *)bd_entry_addr; > - ret = user_atomic_cmpxchg_inatomic(&actual_old_val_32, > - bd_entry_32, expected_old_val_32, > - new_bd_entry_32); > - if (!ret) > - *actual_old_val_ptr = actual_old_val_32; > - } > - return ret; > + if (is_64bit_mm(mm)) > + return user_atomic_cmpxchg_inatomic(actual_old_val_ptr, > + bd_entry_addr, > + expected_old_val, > + new_bd_entry); > + else > + return futex_atomic_cmpxchg_inatomic((u32 *)actual_old_val_ptr, > + (u32 __user *)bd_entry_addr, > + expected_old_val, > + new_bd_entry); > } That does look tempting, and I appreciate the analysis. But, I'd really rather not hide this behind another layer of abstraction in order to save a few variable declarations. It's definitely _smaller_ code, but it's a little less obvious what is going on.