Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7462196ybi; Thu, 1 Aug 2019 08:32:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoXBSwaIB7lRAR1BiKw8v2xE2OakoaLpqH77BNREU7uGyhMY68c65En3HnwDWrcWAB+bjA X-Received: by 2002:a63:ff03:: with SMTP id k3mr24689150pgi.40.1564673525378; Thu, 01 Aug 2019 08:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564673525; cv=none; d=google.com; s=arc-20160816; b=DY3KAFrPWPBnS+kcv4qZaD4GAxuxwRcWNl5siL4XuESfqRzlw3OdwbRoMqMzB+8C6y pSoKTt/QizQkTyAGlY20n/WebU+jlhOIHMuLt+OVata4LrqHnFrfTBmGnTBzKbdwEB8T 9I80CdZ3eI5OiIQsXtxNSePEJ/4AsWLvAogq/dAkE6+HJQM8upRuMmkpc2DXGuV5AJV+ Or2UnvYa8gMKdc38uNS/57HeHhRxdBGUt62/x9/OVseoGJ7P2+Gh/fIkRZwHqfwkCmw5 1aoMmMfeHwTWBoehocPCbt3UMU+reGjcwFuLuRXcP0zjTkrSr+HdWZoP9ad35fdGQZmf PoDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=D8kl03OKrw25sirDAHzzTUPocixkR6HcwsWTRJdGzAU=; b=HQzkoUbE38o05YAXn8AJ7VDrHwx5GpaMjsbEFLmiGz3GNv6kDq34dfxryv/ECB+EyK CHzus0CKDuubYIwAGqTpxvdtrhT6U4Ifo3pjOu1lqwRj+RpLbkQYBijqK9eUxJRhICWu cHYoJo6TqeB7F1YMKe1D1a/ZXGj/osXOoKhG37aVWRUTJfIUtkR7h6qH/X8DrueeRw9d cvEkfnrXsBl4YGCeisFNWKnuzZvbDODfr9MB2kZOFVErfVLDZIapk/YCG3og9UzYZc5k 86Y0IVGESQ2B9ZvX2UWUaiVBu2BxdxgW0Wxg9VwVFSPirGLHjWM2oIOhedWjQ+BV2M4d dDtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205si7715094pge.295.2019.08.01.08.31.49; Thu, 01 Aug 2019 08:32:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732181AbfHAOi3 (ORCPT + 99 others); Thu, 1 Aug 2019 10:38:29 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:36235 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732157AbfHAOi0 (ORCPT ); Thu, 1 Aug 2019 10:38:26 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1htCDW-0000m4-17; Thu, 01 Aug 2019 16:38:06 +0200 Message-Id: <20190801143657.887648487@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 01 Aug 2019 16:32:52 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Peter Zijlstra , Ingo Molnar , Sebastian Siewior , Anna-Maria Gleixner , Steven Rostedt , Julia Cartwright , Paul McKenney , Frederic Weisbecker , kvm@vger.kernel.org, Radim Krcmar , Paolo Bonzini , Oleg Nesterov , John Stultz , Andy Lutomirski , "Paul E. McKenney" Subject: [patch 2/5] x86/kvm: Handle task_work on VMENTER/EXIT References: <20190801143250.370326052@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TIF_NOTITY_RESUME is evaluated on return to user space along with other TIF flags. >From the kernels point of view a VMENTER is more or less equivalent to return to user space which means that at least a subset of TIF flags needs to be evaluated and handled. Currently KVM handles only TIF_SIGPENDING and TIF_NEED_RESCHED, but TIF_NOTIFY_RESUME is ignored. So pending task_work etc, is completely ignored until the vCPU thread actually goes all the way back into userspace/qemu. Use the newly provided notify_resume_pending() and tracehook_handle_notify_resume() to solve this similar to the existing handling of SIGPENDING. Signed-off-by: Thomas Gleixner Cc: kvm@vger.kernel.org Cc: Radim Krcmar Cc: Paolo Bonzini --- arch/x86/kvm/x86.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -7972,7 +7973,8 @@ static int vcpu_enter_guest(struct kvm_v kvm_x86_ops->sync_pir_to_irr(vcpu); if (vcpu->mode == EXITING_GUEST_MODE || kvm_request_pending(vcpu) - || need_resched() || signal_pending(current)) { + || need_resched() || signal_pending(current) + || notify_resume_pending()) { vcpu->mode = OUTSIDE_GUEST_MODE; smp_wmb(); local_irq_enable(); @@ -8172,6 +8174,10 @@ static int vcpu_run(struct kvm_vcpu *vcp ++vcpu->stat.signal_exits; break; } + + if (notify_resume_pending()) + tracehook_handle_notify_resume(); + if (need_resched()) { srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); cond_resched();