From: Ingo Molnar Subject: Re: x86: PIE support and option to extend KASLR randomization Date: Sat, 23 Sep 2017 11:49:59 +0200 Message-ID: <20170923094959.hfzx7fzrdyj47vdn@gmail.com> References: <20170817080920.5ljlkktngw2cisfg@gmail.com> <20170825080443.tvvr6wzs362cjcuu@gmail.com> <20170921155919.skpyt7dutod5ul4t@gmail.com> <20170922163225.bfrd5myl6d7deiim@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Thomas Garnier , Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph La To: "H. Peter Anvin" Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Sender: Ingo Molnar Content-Disposition: inline In-Reply-To: List-Id: linux-crypto.vger.kernel.org * H. Peter Anvin wrote: > On 09/22/17 09:32, Ingo Molnar wrote: > > > > BTW., I think things improved with ORC because with ORC we have RBP as an extra > > register and with PIE we lose RBX - so register pressure in code generation is > > lower. > > > > We lose EBX on 32 bits, but we don't lose RBX on 64 bits - since x86-64 > has RIP-relative addressing there is no need for a dedicated PIC register. Indeed, but we'd use a new register _a lot_ for constructs, transforming: mov r9,QWORD PTR [r11*8-0x7e3da060] (8 bytes) into: lea rbx,[rip+] (7 bytes) mov r9,QWORD PTR [rbx+r11*8] (6 bytes) ... which I suppose is quite close to (but not the same as) 'losing' RBX. Of course the compiler can pick other registers as well, not that it matters much to register pressure in larger functions in the end. Plus if the compiler has to pick a callee-saved register there's the additional saving/restoring overhead of that as well. Right? > I'm somewhat confused how we can have as much as almost 1% overhead. I suspect > that we end up making a GOT and maybe even a PLT for no good reason. So the above transformation alone would explain a good chunk of the overhead I think. Thanks, Ingo