Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp646237pxb; Tue, 2 Feb 2021 14:14:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVLD6pykEvEMvk++oZRNyVKSyV8FszkhpOD2n7EzZZAYjbd4we+qEjzMwuY9d/oruSTNdi X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr147008ejc.254.1612304078514; Tue, 02 Feb 2021 14:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304078; cv=none; d=google.com; s=arc-20160816; b=xRVTDa7TuG+w+Z7B1CmZCqSTHFDs6N2bqHl5PniKbXQx+Ic9/WQ4jTutSfWmbDebhL I6jz7hJlSE3JnLPABElle3LhpjyrNR6MfEuLByiCk+YeIgcf0We77jZnniVkuEyAMqUM U3zkq+r1Qs6f1Cekc4VJZpN0svQYbf0dXXZykoe9C1oMV0uNnxzf9E0t5W/z6fe03x2h 8Ga+fbcUR1lHykoAjhAiYw08uox+4ccwQg7NSd7j515UxnmBy6YBmCZJCniYo6UlpAw6 Nlea44m70pJMLyF3Q3pftGPTYQ5ZrbO+1VlRqddWtE2vZx9DSgYE1sHlNI797Syjzp9X GxKQ== 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=H7o+/kmLEfuZanw8xqyvLrNXGJID6yrIXorXRuLgS+U=; b=tNjI2xStMwFSsM4rUFSRhT3rFwrz915V1SF9JXzrWzZZgd2BsabNKOV+79wctVAB1T E1T68tr/aAKVA+UDbmdy0bO35xMsOdYq8Qdf0B/bbJFrqGGpzogCLig6ThsKWTvu+My0 oNZHnNGnWV1hQdGY8EX69/tjgf1IUrxwOdCCTBv+bIbiGvWoJFRRDvPoGjVLZmBxN+81 rukkQK7wBjGi1HdrOofoIu5WkN6o69cIs4V2wQvlu5saXjKnrRswdCjTux0DaIIjJMdr /jzL0xLge8K2gESa9mbEzYmegz/qk8uEXeppPDEES4JMY6bhLRJwEbAi0chSGCDzeK4t VrZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k4iWKXHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz20si82381ejc.459.2021.02.02.14.14.09; Tue, 02 Feb 2021 14:14:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k4iWKXHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbhBBN43 (ORCPT + 99 others); Tue, 2 Feb 2021 08:56:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:38148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbhBBNtm (ORCPT ); Tue, 2 Feb 2021 08:49:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19BEC64FAB; Tue, 2 Feb 2021 13:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273364; bh=TpZbbwr9wlvVCQwnktn8RnArixjRDNYTuiSMPBhjGlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4iWKXHp4A0pdx62CtsUlQUTSWt1abfOSpNXQS8fG3BXuGNqtrn05Vzz1gichUswZ An7yPqW/jeeimvPhkzpG27KQbIXbVS1REt12m47DmBapv2gts71JuY1fYsx8ZntTeL fpdfXhF5Y6qy2OdrXhxBuUOkcineR8/4uXJb5GOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , David Woodhouse , Salvatore Bonaccorso , Jason Andryuk Subject: [PATCH 5.10 048/142] xen: Fix XenStore initialisation for XS_LOCAL Date: Tue, 2 Feb 2021 14:36:51 +0100 Message-Id: <20210202132959.711411117@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Woodhouse commit 5f46400f7a6a4fad635d5a79e2aa5a04a30ffea1 upstream. In commit 3499ba8198ca ("xen: Fix event channel callback via INTX/GSI") I reworked the triggering of xenbus_probe(). I tried to simplify things by taking out the workqueue based startup triggered from wake_waiting(); the somewhat poorly named xenbus IRQ handler. I missed the fact that in the XS_LOCAL case (Dom0 starting its own xenstored or xenstore-stubdom, which happens after the kernel is booted completely), that IRQ-based trigger is still actually needed. So... put it back, except more cleanly. By just spawning a xenbus_probe thread which waits on xb_waitq and runs the probe the first time it gets woken, just as the workqueue-based hack did. This is actually a nicer approach for *all* the back ends with different interrupt methods, and we can switch them all over to that without the complex conditions for when to trigger it. But not in -rc6. This is the minimal fix for the regression, although it's a step in the right direction instead of doing a partial revert and actually putting the workqueue back. It's also simpler than the workqueue. Fixes: 3499ba8198ca ("xen: Fix event channel callback via INTX/GSI") Reported-by: Juergen Gross Signed-off-by: David Woodhouse Reviewed-by: Juergen Gross Link: https://lore.kernel.org/r/4c9af052a6e0f6485d1de43f2c38b1461996db99.camel@infradead.org Signed-off-by: Juergen Gross Cc: Salvatore Bonaccorso Cc: Jason Andryuk Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xenbus/xenbus_probe.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -714,6 +714,23 @@ static bool xs_hvm_defer_init_for_callba #endif } +static int xenbus_probe_thread(void *unused) +{ + DEFINE_WAIT(w); + + /* + * We actually just want to wait for *any* trigger of xb_waitq, + * and run xenbus_probe() the moment it occurs. + */ + prepare_to_wait(&xb_waitq, &w, TASK_INTERRUPTIBLE); + schedule(); + finish_wait(&xb_waitq, &w); + + DPRINTK("probing"); + xenbus_probe(); + return 0; +} + static int __init xenbus_probe_initcall(void) { /* @@ -725,6 +742,20 @@ static int __init xenbus_probe_initcall( !xs_hvm_defer_init_for_callback())) xenbus_probe(); + /* + * For XS_LOCAL, spawn a thread which will wait for xenstored + * or a xenstore-stubdom to be started, then probe. It will be + * triggered when communication starts happening, by waiting + * on xb_waitq. + */ + if (xen_store_domain_type == XS_LOCAL) { + struct task_struct *probe_task; + + probe_task = kthread_run(xenbus_probe_thread, NULL, + "xenbus_probe"); + if (IS_ERR(probe_task)) + return PTR_ERR(probe_task); + } return 0; } device_initcall(xenbus_probe_initcall);