From: Paolo Bonzini Subject: Re: [PATCH v2 06/27] x86/entry/64: Adapt assembly for PIE support Date: Thu, 15 Mar 2018 11:18:19 +0100 Message-ID: <6d14b321-debc-5bc8-8c1b-14150052f5b8@redhat.com> References: <20180313205945.245105-1-thgarnie@google.com> <20180313205945.245105-7-thgarnie@google.com> <20180314102951.GQ4043@hirez.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Kate Stewart , Nicolas Pitre , Michal Hocko , Sergey Senozhatsky , Petr Mladek , Len Brown , Boris Ostrovsky , Christopher Li , Dave Hansen , x86@kernel.org, Dominik Brodowski , linux-kernel@vger.kernel.org, Masahiro Yamada , Pavel Machek , "H . Peter Anvin" , kernel-hardening@lists.openwall.com, Jiri Slaby , Alok Kataria , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, Herbert Xu , Baoquan He , Jonathan Corbet , Joerg Roedel , =?UTF-8?B?UmF To: Christopher Lameter , Peter Zijlstra Return-path: In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: linux-crypto.vger.kernel.org On 14/03/2018 16:54, Christopher Lameter wrote: >>> + pushq %rax /* Support Position Independent Code */ >>> + leaq 1f(%rip), %rax /* RIP */ >>> + xchgq %rax, (%rsp) /* Restore RAX, put 1f */ >>> iretq /* continues at repeat_nmi below */ >>> UNWIND_HINT_IRET_REGS >>> 1: >> Urgh, xchg with a memop has an implicit LOCK prefix. > this_cpu_xchg uses no lock cmpxchg as a replacement to reduce latency. That requires using a second register, since %rax is used as the comparison source. At this point it's easier to just push %rax twice: pushq %rax pushq %rax leaq 1f(%ip), %rax movq %rax, 8(%rsp) popq %rax iretq Paolo