Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1606483iob; Thu, 5 May 2022 05:04:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSqSa8pIpbSrBhq7ZIM7RZTbhUFu8ZGK3+INICbi303iQkdBSwu26PIafyyCawt/Zkwjxc X-Received: by 2002:a17:90b:4d09:b0:1dc:5fb0:a8ce with SMTP id mw9-20020a17090b4d0900b001dc5fb0a8cemr5654634pjb.187.1651752299228; Thu, 05 May 2022 05:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651752299; cv=none; d=google.com; s=arc-20160816; b=BSm9WzfaTvzL7rfxgyXVs8wbIQdO2y1irkmHXPb5/lOjrYczAVWsXftk2UYJqp4Y/8 0HYzLVf4vFVaaFBx1bXW64MRPzGs1vE4eAphMoQfn+zJjQBUyL8+8LC2UccuSDsgEdjA NGPTdphjQqvZ6podNsDRhV9VOV7ty/8qhseuUlcUtPhhlNVVw9iGuh6yyrs2MX4bOl2C S2rKhq1Vqz3KY2YUjyf5q57twFMrAkZbQTyV+7lF0XQFCMZeQnydX8AU8DeyzHioX7Do XiHQ/M7YnJ4xWu2D7XQ7rht/Riw9/8InriawbKeyCKPSt7YFyo+4mXeCK8rKwQZfN0nv hcmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nE16YHxkykoSrYb5ppE/4Wm9bfyWOoQgK4gKYSfmfNk=; b=jqkhSBY3+o08jOUV1dEglmaVvaXLBqHhi2TLVZPuSPeGtLqeyOXOrv1Lbuld0TjIC5 7QO/49GgvYHMgrjichUK4U1xSBQu4KO+uzHwHHWr2QmI0JNtjccNWT2tnW2pWidpqJWS w9IFBaqXJ2Cg5DTNjjCOy1Imu7GhpN4zx6vGjwqPuB2/L3Cha9Gu/fNwshNDsTfU6xTl JpLIMs0KA4di24KfLzpFHA85jqXBz+2kVKWsbHaY5OHOX1K+auQkkTmHU5YA9ZyUctIf PknOpcfNed0Zva333XCAUCmLhxItZ10WGkw2xw1jnwTxI43ivsP8Aivxyf8Hf2RrLZpJ jghA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=C0jbTpjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a056a00135000b005104fe7eeefsi1625601pfu.108.2022.05.05.05.04.36; Thu, 05 May 2022 05:04:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=C0jbTpjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344749AbiEEHeH (ORCPT + 99 others); Thu, 5 May 2022 03:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344928AbiEEHeF (ORCPT ); Thu, 5 May 2022 03:34:05 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEDE1573E; Thu, 5 May 2022 00:30:24 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A7E071F37F; Thu, 5 May 2022 07:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651735823; h=from:from:reply-to: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=nE16YHxkykoSrYb5ppE/4Wm9bfyWOoQgK4gKYSfmfNk=; b=C0jbTpjcPi2HFtdLiPewTLoQQr708MZQKCCrekVCiKYCa8OEIjSSWYlqFn6bD8qYfCgY4w TWC7fKA2MYeRGix57Ph3k1OUA3rxssYx1V5nZbSz5DQVZMnCouA45YBXZMJQ8Swod2BUKo 6m5XPiRSTin905PojK4TTAK4rH3zOfA= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 4EA872C141; Thu, 5 May 2022 07:30:23 +0000 (UTC) Date: Thu, 5 May 2022 09:30:20 +0200 From: Petr Mladek To: Seth Forshee Cc: Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Paolo Bonzini , Sean Christopherson , Jens Axboe , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, kvm@vger.kernel.org, "Eric W. Biederman" Subject: Re: [PATCH] entry/kvm: Exit to user mode when TIF_NOTIFY_SIGNAL is set Message-ID: References: <20220504180840.2907296-1-sforshee@digitalocean.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220504180840.2907296-1-sforshee@digitalocean.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed 2022-05-04 13:08:40, Seth Forshee wrote: > A livepatch transition may stall indefinitely when a kvm vCPU is heavily > loaded. To the host, the vCPU task is a user thread which is spending a > very long time in the ioctl(KVM_RUN) syscall. During livepatch > transition, set_notify_signal() will be called on such tasks to > interrupt the syscall so that the task can be transitioned. This > interrupts guest execution, but when xfer_to_guest_mode_work() sees that > TIF_NOTIFY_SIGNAL is set but not TIF_SIGPENDING it concludes that an > exit to user mode is unnecessary, and guest execution is resumed without > transitioning the task for the livepatch. > > This handling of TIF_NOTIFY_SIGNAL is incorrect, as set_notify_signal() > is expected to break tasks out of interruptible kernel loops and cause > them to return to userspace. Change xfer_to_guest_mode_work() to handle > TIF_NOTIFY_SIGNAL the same as TIF_SIGPENDING, signaling to the vCPU run > loop that an exit to userpsace is needed. Any pending task_work will be > run when get_signal() is called from exit_to_user_mode_loop(), so there > is no longer any need to run task work from xfer_to_guest_mode_work(). > > Suggested-by: "Eric W. Biederman" > Cc: Petr Mladek > Signed-off-by: Seth Forshee Acked-by: Petr Mladek Thanks Seth for discovering the problem. Thanks everyone who helped to find the right solution. Best Regards. Petr