[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5519806A.1060807@sr71.net>
Date: Mon, 30 Mar 2015 09:57:14 -0700
From: Dave Hansen <dave@...1.net>
To: Borislav Petkov <bp@...en8.de>
CC: linux-kernel@...r.kernel.org, x86@...nel.org, tglx@...utronix.de,
dave.hansen@...ux.intel.com
Subject: Re: [PATCH 15/17] x86, mpx: do 32-bit-only cmpxchg for 32-bit apps
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists