From patchwork Wed Feb 20 20:15:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 10822633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35B291399 for ; Wed, 20 Feb 2019 20:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 224E82E97D for ; Wed, 20 Feb 2019 20:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 131E52EABB; Wed, 20 Feb 2019 20:17:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE8452E97D for ; Wed, 20 Feb 2019 20:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727604AbfBTURz (ORCPT ); Wed, 20 Feb 2019 15:17:55 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:33106 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727538AbfBTURw (ORCPT ); Wed, 20 Feb 2019 15:17:52 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1KK8e45087617; Wed, 20 Feb 2019 20:17:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=y2ywQsg8ZwocwXwGKOAVPtXD+yYTYrFhFyWzqli6irA=; b=vip4g3s1j01PcCB7aJEcvW5bIh5NTRelBrf8d5VELn1ejI5Hf4lxTVMQ5C7dlGwvIgRY 2ULqlnlcLUfcvqgKW1UKnwd9GDrUnLL+8nDtnPAIANF3f8RmMOHKMYRNM3Ptc9yiIvb7 ESA3TZ9X7DVPwXQil9Inx1WRBjFT5ZEFluxhlTIQcLsL8xpPa0ux7pbwg5c4tv7og+tN N+IN05uHAjz6nQ6TjwgA3m6aE5K5RNQfeObGMyN3JN/YW/FpUPan2b9EBpX1hrCv6EZu gMNkwuk3TJrBheZk7qM1ovZSBRlUelyzjFwSxhX7IO/Sy5lnB9cL/aQEgWsmVaOu0/j8 lw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2qp81ec39n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:17:39 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKHcjF022141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:17:38 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1KKHc8q018497; Wed, 20 Feb 2019 20:17:38 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Feb 2019 12:17:38 -0800 From: Joao Martins To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ankur Arora , Boris Ostrovsky , Joao Martins , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH RFC 14/39] KVM: x86/xen: handle PV IPI vcpu yield Date: Wed, 20 Feb 2019 20:15:44 +0000 Message-Id: <20190220201609.28290-15-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190220201609.28290-1-joao.m.martins@oracle.com> References: <20190220201609.28290-1-joao.m.martins@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9173 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=907 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200138 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cooperative Linux guests after an IPI-many may yield vcpu if any of the IPI'd vcpus were preempted (i.e. runstate is 'runnable'.) Support SCHEDOP_yield for handling yield. Signed-off-by: Joao Martins --- arch/x86/kvm/xen.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index ec40cb1de6b6..753a6d2c11cd 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "trace.h" @@ -668,6 +669,31 @@ static int kvm_xen_hcall_set_timer_op(struct kvm_vcpu *vcpu, uint64_t timeout) return 0; } +static int kvm_xen_hcall_sched_op(struct kvm_vcpu *vcpu, int cmd, u64 param) +{ + int ret = -ENOSYS; + gpa_t gpa; + int idx; + + idx = srcu_read_lock(&vcpu->kvm->srcu); + gpa = kvm_mmu_gva_to_gpa_system(vcpu, param, NULL); + srcu_read_unlock(&vcpu->kvm->srcu, idx); + + if (!gpa) + return -EFAULT; + + switch (cmd) { + case SCHEDOP_yield: + kvm_vcpu_on_spin(vcpu, true); + ret = 0; + break; + default: + break; + } + + return ret; +} + int kvm_xen_hypercall(struct kvm_vcpu *vcpu) { bool longmode; @@ -714,6 +740,11 @@ int kvm_xen_hypercall(struct kvm_vcpu *vcpu) if (!r) goto hcall_success; break; + case __HYPERVISOR_sched_op: + r = kvm_xen_hcall_sched_op(vcpu, params[0], params[1]); + if (!r) + goto hcall_success; + break; /* fallthrough */ default: break;