From: Andrew Cooper Subject: [PATCH v2] x86/setup: Correct register clobbers for the asm statement when resyncing the stack Date: Tue, 21 Oct 2014 17:27:16 +0100 Message-ID: <1413908836-31111-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Daniel Kiper , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org When resyncing the stack, the asm statement does not identify %rsi, %rdi and %rcx as clobbered by the 'rep movsq'. Luckily, there are no functional problems in the generated code. GCC decides not to save any of them before calling boostrap_map(), which clobbers them. Correct the clobbers, by listing them as earlyclobber discarded outputs. Reported-by: Daniel Kiper Signed-off-by: Andrew Cooper Reviewed-by: Daniel Kiper Tested-by: Daniel Kiper CC: Keir Fraser CC: Jan Beulich --- I have done an audit of the other uses of `rep $STRINGOP` and this is the only asm statement with incorrect clobbers. v2: * Drop stack variable and reuse 'i' * Use named parameter for pagetabes * Fix style --- xen/arch/x86/setup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8c8b91f..98c0427 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -902,11 +902,13 @@ void __init noreturn __start_xen(unsigned long mbi_p) "movq %%cr4,%%rsi ; " "andb $0x7f,%%sil ; " "movq %%rsi,%%cr4 ; " /* CR4.PGE == 0 */ - "movq %0,%%cr3 ; " /* CR3 == new pagetables */ + "movq %[pg],%%cr3 ; " /* CR3 == new pagetables */ "orb $0x80,%%sil ; " "movq %%rsi,%%cr4 " /* CR4.PGE == 1 */ - : : "r" (__pa(idle_pg_table)), "S" (cpu0_stack), - "D" (__va(__pa(cpu0_stack))), "c" (STACK_SIZE / 8) : "memory" ); + : "=&S" (i), "=&D" (i), "=&c" (i) /* All outputs discarded. */ + : [pg] "r" (__pa(idle_pg_table)), "0" (cpu0_stack), + "1" (__va(__pa(cpu0_stack))), "2" (STACK_SIZE / 8) + : "memory" ); bootstrap_map(NULL); } -- 1.7.10.4