From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DA8C388F9 for ; Tue, 27 Oct 2020 17:07:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9D2420725 for ; Tue, 27 Oct 2020 17:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818444; bh=ChXSg92q0KDDStYfIpuZUm65CrxV/X8/S/XpJifQi6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nTCnH0D/9oiCK8d8JoNlB4a1AVcP8uXzWxhG3iDkrPKSjXC4aZDgwzhyXaU1ev40e YbcoucoZEKLX1i2jDilmBnxQfbXXz4DhATx6K3SxAaoWI114WNqb1tD2TPM+TK/fz8 Z3MFi6NpvrPZ/h9aVrJMK6zF3BRN/aSg2DlBDOgU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S369114AbgJ0RHW (ORCPT ); Tue, 27 Oct 2020 13:07:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:41048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793527AbgJ0PGs (ORCPT ); Tue, 27 Oct 2020 11:06:48 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B42F122453; Tue, 27 Oct 2020 15:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811205; bh=ChXSg92q0KDDStYfIpuZUm65CrxV/X8/S/XpJifQi6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWQewhQWIHBkv/GVPTefnO5O7wsWFlKLEaMjEaK6x6hS65lK24B6WZNJwbUDgozNF +f0Y1UvYbXRk01h5eoqQ3oEnbctW2j96e9K9mCBzn19vf4mlJ3cJHyRwsfnZX0JfBk zHR+WwBTlinu+zCCI7Kh4QCz91VE5bQjGeIBHRa4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 5.8 409/633] um: time-travel: Fix IRQ handling in time_travel_handle_message() Date: Tue, 27 Oct 2020 14:52:32 +0100 Message-Id: <20201027135541.910190231@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Johannes Berg [ Upstream commit ebef8ea2ba967026192a26f4529890893919bc57 ] As the comment here indicates, we need to do the polling in the idle loop without blocking interrupts, since interrupts can be vhost-user messages that we must process even while in our idle loop. I don't know why I explained one thing and implemented another, but we have indeed observed random hangs due to this, depending on the timing of the messages. Fixes: 88ce64249233 ("um: Implement time-travel=ext") Signed-off-by: Johannes Berg Acked-By: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/kernel/time.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 25eaa6a0c6583..c07436e89e599 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c @@ -70,13 +70,17 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg, * read of the message and write of the ACK. */ if (mode != TTMH_READ) { + bool disabled = irqs_disabled(); + + BUG_ON(mode == TTMH_IDLE && !disabled); + + if (disabled) + local_irq_enable(); while (os_poll(1, &time_travel_ext_fd) != 0) { - if (mode == TTMH_IDLE) { - BUG_ON(!irqs_disabled()); - local_irq_enable(); - local_irq_disable(); - } + /* nothing */ } + if (disabled) + local_irq_disable(); } ret = os_read_file(time_travel_ext_fd, msg, sizeof(*msg)); -- 2.25.1