Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4788392iob; Mon, 9 May 2022 01:26:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCYAPML+HtHm7Cbsqex5E/yRPYbsmEqsUYbcFwkq1WmuTY9+3gzfguggSCepNZV+isa67M X-Received: by 2002:a63:87c6:0:b0:3c6:a7d9:5d01 with SMTP id i189-20020a6387c6000000b003c6a7d95d01mr5161761pge.341.1652084810458; Mon, 09 May 2022 01:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652084810; cv=none; d=google.com; s=arc-20160816; b=sCNHj2IvPfyzw+inDRkYRaeEEE4eF0Rp6mECv15pTOiUniIRUtWZ70mEqw0d6DiDfs /uhMIvYVPzAQ5pjkr4qc6wQ+9Lz0/jK0uJceOhctvvBrmoKfnsd6c9TWCoS8DDj2PZLc X4OCa0RLrxSS8oYBbU0BstACeBf2mWoWNaYFnErYOllbMjNtED7QDRlJ22ofjfSTlN0/ wRlefm//VgtBlKSsWqD7tjI8XP8dWBglqBcCjIKRlMbMS1j2o3EyQ73dXTQ2ep0BkYkt RmcQxz5AGekhFKoxiGeSBZi9liDHqxAuKG3oJuhJ2KGkJuGHyR+Hzg+cuS7x8jq1WnD0 /cPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=wj9NIEsAO1j71H22rlpbiey9ugoj4DK8XLauASE/IAs=; b=R3Mq36EbXa6c38qh6OjgpdxqBezrtlj8vFJvCdcTAAoRmI//l1lElem6gNnzecqGeH XnFNpKgL8bgS61/8CkW3PrKuKZ/2D9kY54u9VFpQ8ibLLtq5O97VH5I8X9mOMNocSQ+9 slSRTwqStH3GPunYPUEKFQm7TQNNwGCEcHRQN3KBDEjBoJfGaAPk0T+n2vZaeEWl514V H5QVf+9T4wnJeSOLXc8hgjQdTMfkPtpFmwdIKk+qEpAAaYs6P0drxsZ31XaNNLnf5MN1 cnoiLR0XYL03qKFvbkXJ+waH1GrmLRb8qHfhTIqjvPGkSTBb+1zU2+05cZA+/SEfjPyX 5Ijg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ij10-20020a170902ab4a00b0015ee24aee67si9404065plb.617.2022.05.09.01.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 01:26:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F13C51A4774; Mon, 9 May 2022 01:11:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377224AbiEDSfk (ORCPT + 99 others); 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 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;Seth Forshee X-Spam-Relay-Country: X-Spam-Timing: total 627 ms - load_scoreonly_sql: 0.10 (0.0%), signal_user_changed: 13 (2.0%), b_tie_ro: 11 (1.7%), parse: 1.21 (0.2%), extract_message_metadata: 22 (3.4%), get_uri_detail_list: 1.97 (0.3%), tests_pri_-1000: 34 (5.4%), tests_pri_-950: 1.52 (0.2%), tests_pri_-900: 1.27 (0.2%), tests_pri_-90: 223 (35.6%), check_bayes: 214 (34.1%), b_tokenize: 10 (1.7%), b_tok_get_all: 9 (1.4%), b_comp_prob: 2.6 (0.4%), b_tok_touch_all: 186 (29.7%), b_finish: 1.47 (0.2%), tests_pri_0: 314 (50.0%), check_dkim_signature: 0.52 (0.1%), check_dkim_adsp: 2.9 (0.5%), poll_dns_idle: 0.98 (0.2%), tests_pri_10: 3.0 (0.5%), tests_pri_500: 11 (1.8%), rewrite_mail: 0.00 (0.0%) 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: linux-kernel@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; > }