From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753508AbcADVCw (ORCPT ); Mon, 4 Jan 2016 16:02:52 -0500 Received: from mail.skyhub.de ([78.46.96.112]:34315 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753031AbcADVCu (ORCPT ); Mon, 4 Jan 2016 16:02:50 -0500 Date: Mon, 4 Jan 2016 22:02:28 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: Tony Luck , Ingo Molnar , Andrew Morton , Andy Lutomirski , Dan Williams , Robert , Linux Kernel Mailing List , "linux-mm@kvack.org" , linux-nvdimm , X86-ML Subject: Re: [PATCH v6 1/4] x86: Clean up extable entry format (and free up a bit) Message-ID: <20160104210228.GR22941@pd.tnic> References: <968b4c079271431292fddfa49ceacff576be6849.1451869360.git.tony.luck@intel.com> <20160104120751.GG22941@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 04, 2016 at 10:08:43AM -0800, Andy Lutomirski wrote: > All of that's correct, including the part where it's confusing. The > comments aren't the best. > > How about adding a comment like: > > ----- begin comment ----- > > The offset to the fixup is signed, and we're trying to use the high > bits for a different purpose. In C, we could just do: > > u32 class_and_offset = ((target - here) & 0x3fffffff) | class; > > Then, to decode it, we'd mask off the class and sign-extend to recover > the offset. > > In asm, we can't do that, because this all gets laundered through the > linker, and there's no relocation type that supports this chicanery. > Instead we cheat a bit. We first add a large number to the offset > (0x20000000). The result is still nominally signed, but now it's > always positive, and the two high bits are always clear. We can then > set high bits by ordinary addition or subtraction instead of using > bitwise operations. As far as the linker is concerned, all we're > doing is adding a large constant to the difference between here (".") > and the target, and that's a valid relocation type. > > In the C code, we just mask off the class bits and subtract 0x20000000 > to get the offset. > > ----- end comment ----- Yeah, that makes more sense, thanks. That nasty "." current position thing stays in the way to do it cleanly. :-) Anyway, ok, I see it now. It still feels a bit hacky to me. I probably would've added the third int to the exception table instead. It would've been much more straightforward and clean this way and I'd gladly pay the additional 6K growth. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.