From patchwork Wed Feb 20 20:15:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 10822669 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 857ED922 for ; Wed, 20 Feb 2019 20:20:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BCA52F14F for ; Wed, 20 Feb 2019 20:20:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A89F72F0EF; Wed, 20 Feb 2019 20:20:16 +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 2EFF42F17A for ; Wed, 20 Feb 2019 20:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728002AbfBTUSs (ORCPT ); Wed, 20 Feb 2019 15:18:48 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:53128 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbfBTUSl (ORCPT ); Wed, 20 Feb 2019 15:18:41 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1KK8Uhf081679; Wed, 20 Feb 2019 20:18:27 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=ObvMkIO580oz+cYvFFnQV9+Yfz6Iys4YkrQlTPQzc0g=; b=ijkbP7HLCyY94yv4cDu+h4kxzcpki4HqC431yvgCZOoK72QjWVl6RIYmthE0Jfmepdbk qFuRHDXxleVoa9Fq7/eJdpm9LT/rq5H4v16dBci38UNVfvGsZyVBuEKIqMclIvXus7nQ 6QJ/x+MTR6oLAu6SL5hKa1GoUQPWR70FjGdTz3l/exZ6u1TQ14XFhU4Yg4yNuy3Zl3VS OWEBCbNQToKGrW3hzJw4CaDJYyR9JdWSYUYCHYZQHzS0sqkzNyfuIu8IeovREK38QnLH pjKqkntfnxpvDcdKwQNhu5gTKJSBTAhC5PwWcCsoFU+p5jq/62lmMdih31GPjieRbr8t BQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qp9xu3xmq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:18:26 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKIQ2K007388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:18:26 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKIQ84010001; Wed, 20 Feb 2019 20:18:26 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Feb 2019 12:18:25 -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 29/39] KVM: x86/xen: evtchn unmask support Date: Wed, 20 Feb 2019 20:15:59 +0000 Message-Id: <20190220201609.28290-30-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=828 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 From: Ankur Arora Handle hypercall to unmasks event channel ports. A subtlety here is that we deliver an upcall if an actual unmask happened and the event channel was pending (and if the vcpu-wide evtchn_pending_sel was not already marked pending.) Co-developed-by: Joao Martins Signed-off-by: Ankur Arora Signed-off-by: Joao Martins --- arch/x86/kvm/xen.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 420e3ebb66bc..1988ed3866bf 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -2102,6 +2102,29 @@ static int shim_hcall_evtchn_send(struct kvm_xen *dom0, struct evtchn_send *snd) return 0; } +static int shim_hcall_evtchn_unmask(struct kvm_xen *dom0, int port) +{ + struct shared_info *s = HYPERVISOR_shared_info; + struct evtchnfd *evtchnfd; + struct vcpu_info *v; + + evtchnfd = idr_find(&dom0->port_to_evt, port); + if (!evtchnfd) + return -ENOENT; + + v = per_cpu(xen_vcpu, evtchnfd->vcpu); + + if (test_and_clear_bit(port, (unsigned long *) s->evtchn_mask) && + test_bit(port, (unsigned long *) s->evtchn_pending) && + !test_and_set_bit(port / BITS_PER_EVTCHN_WORD, + (unsigned long *) &v->evtchn_pending_sel)) { + kvm_xen_evtchn_2l_vcpu_set_pending(v); + return kvm_xen_evtchn_call_function(evtchnfd); + } + + return 0; +} + static int shim_hcall_evtchn(int op, void *p) { int ret; @@ -2151,6 +2174,13 @@ static int shim_hcall_evtchn(int op, void *p) un->port = evt.port; break; } + case EVTCHNOP_unmask: { + struct evtchn_unmask *unmask; + + unmask = (struct evtchn_unmask *) p; + ret = shim_hcall_evtchn_unmask(xen_shim, unmask->port); + break; + } case EVTCHNOP_send: { struct evtchn_send *send;