Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2451575ybh; Fri, 24 Jul 2020 13:13:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbPNc+wLVMoEYmMJU+O5HVC5zaDiHzYizlQ4yxszJ3HDV2cDFY0QJp7Vvhx8MzQb0+2B97 X-Received: by 2002:a17:906:3b01:: with SMTP id g1mr11191569ejf.353.1595621595613; Fri, 24 Jul 2020 13:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595621595; cv=none; d=google.com; s=arc-20160816; b=H1j/H9sXPzGHXuhV1B17GAoxD8VXltCm70RAth54ytQPsCDbaGC0EL+N7qLqjnjpwq KVAlL9f8iIXDgjOAy3NRN0GxnSVDyvH/9XKT1xZGwIRL8ga99tRUmHzFiuqtKX3kJn+E ip0ZzJKHSKLf3s6gfibSURViZItCp2LrHMUixmoKGL1P5cmDfMk3Zl4sE6Qysj0yjy56 YESSR1Inlz0KXJoDYLovFqqZ4XruaKYv8C+G5EMZYt9jmNOTGh1awSgCiTAPbEw0m4pE e34uDvPrEtfkbiLG9u1q6ijA82d0neYPUhvY0GgrhLCSttT5tGKLOErlHgMhD8uzHJQ8 JUVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=XtFCHFgAKaj5JdV4fyEA7k9jyYeHwTAiKGd37VnG1Mk=; b=uqoSE5UU4xusZzsAp1Iiq1vbfnisdzE9V8H+2i64WoORxhJNs5DMTZTgcCA5wVW2Pd 0puKLSqO9oZh7Ib0YcWip3XcKgBVc2fQXqWr9bVp7qr+adLlYlZ6ubYn58w1rIq8B7vD X70SkHJ9m2bCZaAmxW2bF2HXvqzx7kjqG8uKHLYB55C8oKeQEKTX8JD0o8JOujDykziT Sl7waOBc6NxUqjszFEqh6wWOKOxWgejjFkFMdJcolgIq6NivZSu+9IAo9orz840bAxIr HjiJMRsnPlmgd0HNJeodYcf60MD1zNDpvrKCRPaWmiVyxtO4pxqBoNT9fpoR3C6OmO8M LZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=QjRRqZCb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc11si1117338edb.259.2020.07.24.13.12.53; Fri, 24 Jul 2020 13:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=QjRRqZCb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbgGXULm (ORCPT + 99 others); Fri, 24 Jul 2020 16:11:42 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:40210 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgGXULl (ORCPT ); Fri, 24 Jul 2020 16:11:41 -0400 Date: Fri, 24 Jul 2020 20:11:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595621498; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XtFCHFgAKaj5JdV4fyEA7k9jyYeHwTAiKGd37VnG1Mk=; b=QjRRqZCbOKly0YYx6bdAut5VEu1K7fecXd7rnjN7Nmq4p2+8TIDTCaM46ZBpXo2uc4V/TR wnNtmXJxb752LGva1p6JM908ZRWjJVSTcSDSwpO8O0uqEKIC4Nj9xJKHy6z5JTL3MAz9ZP dCIAJN80VAx7cEFB9G+aoSsjzimClh9H1ElepnHIoSxJX+v4uUDCO7pdS1n2VM+M5sQ/iy ISaLktwfhwH0WqOQx8jFYMdI1gy/xJvDnDDG1LMDi00HzcY7mBpO7InEvaXmMddW07bSIh yWJNKvjWa4veDGnsiKoftZ01pItWtvXEs2Fk2HZ6E3rNWtJdWB72Cz8REYsFGA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595621498; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XtFCHFgAKaj5JdV4fyEA7k9jyYeHwTAiKGd37VnG1Mk=; b=bx8MiBTNjA3FGiovNzXK9M4r8KT1EIYl/PYxCPcOIZWHSMqU3OW8WBHBZu+Bc/4QkKz6Er 1xYvCBbhyhIgvfCQ== From: "tip-bot2 for Thomas Gleixner" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/kvm: Use generic xfer to guest work function Cc: Thomas Gleixner , x86 , LKML In-Reply-To: <20200722220520.979724969@linutronix.de> References: <20200722220520.979724969@linutronix.de> MIME-Version: 1.0 Message-ID: <159562149754.4006.8865086246836564879.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: 72c3c0fe54a3f3ddea8f5ca468ddf9deaf2100b7 Gitweb: https://git.kernel.org/tip/72c3c0fe54a3f3ddea8f5ca468ddf9deaf2100b7 Author: Thomas Gleixner AuthorDate: Thu, 23 Jul 2020 00:00:09 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 24 Jul 2020 15:05:01 +02:00 x86/kvm: Use generic xfer to guest work function Use the generic infrastructure to check for and handle pending work before transitioning into guest mode. This now handles TIF_NOTIFY_RESUME as well which was ignored so far. Handling it is important as this covers task work and task work will be used to offload the heavy lifting of POSIX CPU timers to thread context. Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200722220520.979724969@linutronix.de --- arch/x86/kvm/Kconfig | 1 + arch/x86/kvm/vmx/vmx.c | 11 +++++------ arch/x86/kvm/x86.c | 15 ++++++--------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index b277a2d..fbd5bd7 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -42,6 +42,7 @@ config KVM select HAVE_KVM_MSI select HAVE_KVM_CPU_RELAX_INTERCEPT select HAVE_KVM_NO_POLL + select KVM_XFER_TO_GUEST_WORK select KVM_GENERIC_DIRTYLOG_READ_PROTECT select KVM_VFIO select SRCU diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 13745f2..9909375 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -5373,14 +5374,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) } /* - * Note, return 1 and not 0, vcpu_run() is responsible for - * morphing the pending signal into the proper return code. + * Note, return 1 and not 0, vcpu_run() will invoke + * xfer_to_guest_mode() which will create a proper return + * code. */ - if (signal_pending(current)) + if (__xfer_to_guest_mode_work_pending()) return 1; - - if (need_resched()) - schedule(); } return 1; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 88c593f..82d4a9e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -1587,7 +1588,7 @@ EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr); bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu) { return vcpu->mode == EXITING_GUEST_MODE || kvm_request_pending(vcpu) || - need_resched() || signal_pending(current); + xfer_to_guest_mode_work_pending(); } EXPORT_SYMBOL_GPL(kvm_vcpu_exit_request); @@ -8681,15 +8682,11 @@ static int vcpu_run(struct kvm_vcpu *vcpu) break; } - if (signal_pending(current)) { - r = -EINTR; - vcpu->run->exit_reason = KVM_EXIT_INTR; - ++vcpu->stat.signal_exits; - break; - } - if (need_resched()) { + if (xfer_to_guest_mode_work_pending()) { srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); - cond_resched(); + r = xfer_to_guest_mode_handle_work(vcpu); + if (r) + return r; vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); } }