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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A676C433EF for ; Wed, 4 May 2022 18:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377111AbiEDSfk (ORCPT ); Wed, 4 May 2022 14:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376981AbiEDSf2 (ORCPT ); Wed, 4 May 2022 14:35:28 -0400 Received: from out03.mta.xmission.com (out03.mta.xmission.com [166.70.13.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A7653B71; Wed, 4 May 2022 11:16:12 -0700 (PDT) Received: from in02.mta.xmission.com ([166.70.13.52]:60554) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nmJXm-00DeTi-SS; Wed, 04 May 2022 12:16:10 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:36950 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nmJXl-00F03n-L3; Wed, 04 May 2022 12:16:10 -0600 From: "Eric W. Biederman" To: Seth Forshee Cc: Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Paolo Bonzini , Sean Christopherson , Jens Axboe , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, kvm@vger.kernel.org References: <20220504180840.2907296-1-sforshee@digitalocean.com> Date: Wed, 04 May 2022 13:16:02 -0500 In-Reply-To: <20220504180840.2907296-1-sforshee@digitalocean.com> (Seth Forshee's message of "Wed, 4 May 2022 13:08:40 -0500") Message-ID: <878rrhcgf1.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1nmJXl-00F03n-L3;;;mid=<878rrhcgf1.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=softfail X-XM-AID: U2FsdGVkX19xSYDYzW0+xU2ATA3vhYA4gZqv0as7Rxc= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] entry/kvm: Exit to user mode when TIF_NOTIFY_SIGNAL is set X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Seth Forshee writes: > 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: "Eric W. Biederman" > --- > kernel/entry/kvm.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/kernel/entry/kvm.c b/kernel/entry/kvm.c > index 9d09f489b60e..2e0f75bcb7fd 100644 > --- a/kernel/entry/kvm.c > +++ b/kernel/entry/kvm.c > @@ -9,12 +9,6 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work) > int ret; > > if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) { > - clear_notify_signal(); > - if (task_work_pending(current)) > - task_work_run(); > - } > - > - if (ti_work & _TIF_SIGPENDING) { > kvm_handle_signal_exit(vcpu); > return -EINTR; > }