Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2989914ybh; Mon, 16 Mar 2020 13:37:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvdZaTWL/sN/vFF1kuS8rX1ACWAP7//HnH0XhVVh4vB3WEI/gNDHhzsFFkNQoC7RBTgDPtD X-Received: by 2002:a05:6808:495:: with SMTP id z21mr1009917oid.149.1584391047253; Mon, 16 Mar 2020 13:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584391047; cv=none; d=google.com; s=arc-20160816; b=Qd+TT2729+qSpYdndwWv8xllrXjuZQCZfFK362oYYnBZRYcHTh8uCINhvDW0TMarli YjV2vaEu58E76QlV+bK5l6qkmTlq50yGwS7iIXEBlNVwCjZP/UhwnNElF2yZttfliQRR aMGioPc+IwCfWzEp2wsSjl846RLvlYydrg7LufPnRUvCnfyKCiQUyB2C39BaaoVQOMWb R8QPrjrWR+ioKv4HwEtUMiP0g9VAdx5WXsMzEP+FWFwJJRQ+6kxTQUA6mAbGCkAsrEjB WW18NFLi91IHjc1nqdhJyy3AptHdmzYBl6lNA2vxw1N5wE5vqSfKea663a7ej14zv0kr 9Nag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rNP0mmhYO3ZkBwa0TVYh9YRT8v7S/Igc0A+3yqdKcRw=; b=XLTYYBsiUDMj6rg6YTbd5IhQAksQYQPyVgLckZ41R67mzJCXO2MvNFJ58PDJdi2l4L kG6sf4FzDYr6AFOLZ/TpeTthky70HCqmXqzY0eXAa+GPcxDvkTDm9Z92W26dXZ/yrYPz vl6sUG0ZHoVwGUvifU9xGhn8JbPvGM2M9lrj2d43OAS2jR2d4PYOJtDmKheywIRxCFwM jEbgmb50YGQbD3haObEG9E5T6LI3FZUZRgVOeCi9OlkpTZhu6RJ1JSB/AkrBDmyoQS2P RCLZ9PrYwkxxxwOjN6ZGg/enICBg+GM6ct1pIRsI2C0ro36V8MWwwkA/hJ4TAmnlIBee N2qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TDsn/0Mv"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si511588otb.169.2020.03.16.13.37.13; Mon, 16 Mar 2020 13:37:27 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TDsn/0Mv"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732587AbgCPUf0 (ORCPT + 99 others); Mon, 16 Mar 2020 16:35:26 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:25462 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732580AbgCPUf0 (ORCPT ); Mon, 16 Mar 2020 16:35:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584390925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rNP0mmhYO3ZkBwa0TVYh9YRT8v7S/Igc0A+3yqdKcRw=; b=TDsn/0MvQKYnUkqIoaEDGFZUN+u5cqn8G3PYqWyOf3c9QVPVWoKwtEy6d1HYXLZjYlWLn6 1qCam8sKstCg8WgnPWueBs8doiSw37t5AV5B68CBatXIdJ1UkLfDo5j2BgFymqZXFSCgn8 xBDfk5HIR+pwwshhL269G/cqG93Wfs4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-yXlxTpiMOSaQPrYogFg8ag-1; Mon, 16 Mar 2020 16:35:21 -0400 X-MC-Unique: yXlxTpiMOSaQPrYogFg8ag-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39A0918AB2C0; Mon, 16 Mar 2020 20:35:19 +0000 (UTC) Received: from treble (ovpn-121-192.rdu2.redhat.com [10.10.121.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 852049CA3; Mon, 16 Mar 2020 20:35:16 +0000 (UTC) Date: Mon, 16 Mar 2020 15:35:14 -0500 From: Josh Poimboeuf To: Miroslav Benes Cc: =?utf-8?B?SsO8cmdlbiBHcm/Dnw==?= , boris.ostrovsky@oracle.com, sstabellini@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, jslaby@suse.cz, Peter Zijlstra Subject: Re: [RFC PATCH 2/2] x86/xen: Make the secondary CPU idle tasks reliable Message-ID: <20200316203514.qm7so7b55jbmskgg@treble> References: <20200312142007.11488-1-mbenes@suse.cz> <20200312142007.11488-3-mbenes@suse.cz> <75224ad1-f160-802a-9d72-b092ba864fb7@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 16, 2020 at 04:51:12PM +0100, Miroslav Benes wrote: > > diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c > > index 6b88cdcbef8f..39afd88309cb 100644 > > --- a/arch/x86/xen/smp_pv.c > > +++ b/arch/x86/xen/smp_pv.c > > @@ -92,6 +92,7 @@ asmlinkage __visible void cpu_bringup_and_idle(void) > > { > > cpu_bringup(); > > boot_init_stack_canary(); > > + asm volatile (UNWIND_HINT(ORC_REG_UNDEFINED, 0, ORC_TYPE_CALL, 1)); > > cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); > > } > > > > and that seems to work. I need to properly verify and test, but the > > explanation is that as opposed to the above, cpu_startup_entry() is on the > > idle task's stack and the hint is then taken into account. The unwound > > stack seems to be complete, so it could indeed be the fix. > > Not the correct one though. Objtool rightfully complains with > > arch/x86/xen/smp_pv.o: warning: objtool: cpu_bringup_and_idle()+0x6a: undefined stack state > > and all the other hacks I tried ended up in the same dead alley. It seems > to me the correct fix is that all orc entries for cpu_bringup_and_idle() > should have "end" property set to 1, since it is the first function on the > stack. I don't know how to achieve that without the assembly hack in the > patch I sent. If I am not missing something, of course. > > Josh, any idea? Yeah, I think mucking with the unwind hints in C code is going to be precarious. You could maybe have something like asm(" UNWIND_HINT_EMPTY\n mov $CPUHP_AP_ONLINE_IDLE, %rdi\n call cpu_startup_entry\n )" unreachable(); but that's pretty ugly (and it might not work anyway). I suppose we could add a new facility to mark an entire C function as an "end" point. But I think it would be cleanest to just do something like your patch and have the entry code be asm which then calls cpu_bringup_and_idle(). That would make it consistent with all other entry code, which all lives in asm. -- Josh