Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp457408ybg; Thu, 19 Mar 2020 02:57:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vshV7VDzd4Pt6wgB5z9eEnaidU5q/ceZv9gpoUpcG9mNDbIHBbGVo2mSxomYTsuvzYx0oeh X-Received: by 2002:a54:478c:: with SMTP id o12mr1598599oic.106.1584611829327; Thu, 19 Mar 2020 02:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584611829; cv=none; d=google.com; s=arc-20160816; b=dC3owQ6kKlnYkmdu4pw+oz4NXtkaLsDX2fBNlpWTuQhwjyQCb1dryNFtYglVk/C/FN xvcjH7fU5ruBzh7sQgB3t18A7hd9n8hnes8bgAT2D3Q2XuHzcVJXUDRAceolYvYqNg4+ EWLjOIUq+4WEZi1z71Ams0eQCdIKOK8JgYNCzFSSjyzIQSYM9qt5GjZFUVPvdG4JdMfB lJGrIFYmue+LL9ujPRnEoXmgEQGu1J2TpsZWNlDHa1MJHYeiDyCW+g92NzzuwcUQVglV tN/Cw1F2GsuCOpCZ2SU7dLhXxxtNsUGCeIa59DI0YXNxwWWB67rkTKEnX2q+jUbnxp7R toSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8i7xwmNYQWj7dz2a3GmpSXGFM6woZbRjVwVByavaS5c=; b=ix6k3lauqoXYYb/eFh7si8OKorF6GdgQt2wLCLXdpBFraGCrXVuuggZ8zw3OnAjMVR 0gB1rLhn1S4+V31AuqbIa7L3yYgFNRd4zIUQGb3JW2MCT4avWp3/gM+evnweGSd8ArVz AZiQWCuV4BYDEXPhCc/McwaxlczMuHF3IYtgHeaxSjcq9aWIwPI/LqUY7pnhqIt/tS8W 76HmLvWyGjNcBYfTFrl6+S/cPpmMgbAPKuqm5gPmTk4rAGP6haByyzR+qRAP2npfMPfO iGVMg1l0aqEEPJaAmoOQidxiQ1BBz1xKNI//Mx2iGyrrbwLYS5NZpJXUH6Jq7ySeXn2Y 9zoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193si841304oie.51.2020.03.19.02.56.57; Thu, 19 Mar 2020 02:57:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbgCSJ4N (ORCPT + 99 others); Thu, 19 Mar 2020 05:56:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:35468 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726936AbgCSJ4M (ORCPT ); Thu, 19 Mar 2020 05:56:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C6909AE59; Thu, 19 Mar 2020 09:56:10 +0000 (UTC) From: Miroslav Benes To: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, jpoimboe@redhat.com Cc: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, jslaby@suse.cz, andrew.cooper3@citrix.com, Miroslav Benes Subject: [PATCH v2 1/2] x86/xen: Make the boot CPU idle task reliable Date: Thu, 19 Mar 2020 10:56:05 +0100 Message-Id: <20200319095606.23627-2-mbenes@suse.cz> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200319095606.23627-1-mbenes@suse.cz> References: <20200319095606.23627-1-mbenes@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The unwinder reports the boot CPU idle task's stack on XEN PV as unreliable, which affects at least live patching. There are two reasons for this. First, the task does not follow the x86 convention that its stack starts at the offset right below saved pt_regs. It allows the unwinder to easily detect the end of the stack and verify it. Second, startup_xen() function does not store the return address before jumping to xen_start_kernel() which confuses the unwinder. Amend both issues by moving the starting point of initial stack in startup_xen() and storing the return address before the jump, which is exactly what call instruction does. Signed-off-by: Miroslav Benes --- arch/x86/xen/xen-head.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 1d0cee3163e4..edc776af0e0a 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -35,7 +35,11 @@ SYM_CODE_START(startup_xen) rep __ASM_SIZE(stos) mov %_ASM_SI, xen_start_info - mov $init_thread_union+THREAD_SIZE, %_ASM_SP +#ifdef CONFIG_X86_64 + mov initial_stack(%rip), %_ASM_SP +#else + mov pa(initial_stack), %_ASM_SP +#endif #ifdef CONFIG_X86_64 /* Set up %gs. @@ -51,7 +55,7 @@ SYM_CODE_START(startup_xen) wrmsr #endif - jmp xen_start_kernel + call xen_start_kernel SYM_CODE_END(startup_xen) __FINIT #endif -- 2.25.1