Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2119104ioo; Mon, 23 May 2022 10:28:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypdm+C2/zLxfNpgHjxIF5tE45LLK2+AUddmoyiKld/W9Pc+t4rkxvu6vheHO0Hb7jE/d21 X-Received: by 2002:a63:1d65:0:b0:3fa:7e32:8024 with SMTP id d37-20020a631d65000000b003fa7e328024mr2867235pgm.162.1653326886878; Mon, 23 May 2022 10:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326886; cv=none; d=google.com; s=arc-20160816; b=g+xjTiDJ9oZbQfM2SytxF8jrFrkucmCd1fafiLJQMIgQ55MIyVeOs2WlmZqCvCSQpY OCYlZB3zH/sgHMDT74iXH9veKv9hP7DueDKRspoXrUQRUd/vjJmHl+Fi9S9er/lkiqf8 nL6l8YLTxFA0589ogfCFnrmpPnzJ8aQ8lZ/vSqg5EmsX8yIow+zM7tbqWNCwu4350Ojc C9oz0JkRbx7i5G56myZ23V+HY26tGQMsCeuoz4ytDMSAuGctgD5QINrCzaU8DzmWEy2u D1XdOBOZS9BatJyYiP7mgos8y8AjnKbXkVcdC9Xi8nOZo+7Ywm+3Jkfp4Vo7oasUDdde KIvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QLlviInb+wpbKN7o4gXSkbb+j/RJvT/e4RBaOec1zmk=; b=gJR/S7dtDs9la0hcKCK2hBDn8I5djk9SGwnr6sQ1Le5zS1nAJqG5jb/YlkQMQ7CFXm e85YOV14SDgEONrJEU6Dwg9vEKRwL+pR8X0akYRuMp+tWleZqiDal3FJ480FCa0CQgBh 3wg92L6uwfoQV+C9i6tzt4/dgfYt/+jah3q5kD7GAToQlgeCSom8jaO90+MYSeJtCvr5 KpjnFAse8n4KsXhpKNYzZuT+ysn6q3YN/guLygHh6m8YbF29Qv9FVwajyftheerfspVb 589usjbUgDYSfn9KbgCVqaKfQ4C4DL/5OCBF9JbaH1aRF2vd5rsPogNsSk/qhjYPz3yg PugA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mK8mRP/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m17-20020a170902bb9100b0015ea266647fsi10027306pls.394.2022.05.23.10.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mK8mRP/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4958D8FFB7; Mon, 23 May 2022 10:25:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240207AbiEWRUl (ORCPT + 99 others); Mon, 23 May 2022 13:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240969AbiEWRQw (ORCPT ); Mon, 23 May 2022 13:16:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50B86B665; Mon, 23 May 2022 10:16:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 99935B81205; Mon, 23 May 2022 17:13:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB92AC385A9; Mon, 23 May 2022 17:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325979; bh=XmBQV3f1U39XKjofWdJcehcZCPUMgpflEGSWZaI+XD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mK8mRP/92OrUtkg98ZJji2VdOdNTS5aqWNnB+PTdtyoSmLqho80UkrW/ubU8ORXrU ckcq6DTv0rKhcmaAdEg2U78palmkPPLnxJv9AL1dtl9Swhp+XUiYCkpctownGJIOcd ur7BWP+4EBE55P/2hiqVDxrXTogrsACeoBDjC/sM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miroslav Benes , Juergen Gross , Markus Boehme Subject: [PATCH 5.4 03/68] x86/xen: Make the secondary CPU idle tasks reliable Date: Mon, 23 May 2022 19:04:30 +0200 Message-Id: <20220523165803.141513758@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miroslav Benes commit c3881eb58d56116c79ac4ee4f40fd15ead124c4b upstream. The unwinder reports the secondary CPU idle tasks' stack on XEN PV as unreliable, which affects at least live patching. cpu_initialize_context() sets up the context of the CPU through VCPUOP_initialise hypercall. After it is woken up, the idle task starts in cpu_bringup_and_idle() function and its stack starts at the offset right below pt_regs. The unwinder correctly detects the end of stack there but it is confused by NULL return address in the last frame. Introduce a wrapper in assembly, which just calls cpu_bringup_and_idle(). The return address is thus pushed on the stack and the wrapper contains the annotation hint for the unwinder regarding the stack state. Signed-off-by: Miroslav Benes Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Signed-off-by: Markus Boehme Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/smp_pv.c | 3 ++- arch/x86/xen/xen-head.S | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -53,6 +53,7 @@ static DEFINE_PER_CPU(struct xen_common_ static DEFINE_PER_CPU(struct xen_common_irq, xen_pmu_irq) = { .irq = -1 }; static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id); +void asm_cpu_bringup_and_idle(void); static void cpu_bringup(void) { @@ -310,7 +311,7 @@ cpu_initialize_context(unsigned int cpu, * pointing just below where pt_regs would be if it were a normal * kernel entry. */ - ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle; + ctxt->user_regs.eip = (unsigned long)asm_cpu_bringup_and_idle; ctxt->flags = VGCF_IN_KERNEL; ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */ ctxt->user_regs.ds = __USER_DS; --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -58,6 +58,16 @@ ENTRY(startup_xen) call xen_start_kernel END(startup_xen) __FINIT + +#ifdef CONFIG_XEN_PV_SMP +.pushsection .text +SYM_CODE_START(asm_cpu_bringup_and_idle) + UNWIND_HINT_EMPTY + + call cpu_bringup_and_idle +SYM_CODE_END(asm_cpu_bringup_and_idle) +.popsection +#endif #endif .pushsection .text