From patchwork Tue Feb 21 11:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94254 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396443qgi; Tue, 21 Feb 2017 03:28:12 -0800 (PST) X-Received: by 10.36.8.70 with SMTP id 67mr10613938itc.20.1487676492399; Tue, 21 Feb 2017 03:28:12 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n5si19968178iof.45.2017.02.21.03.28.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:12 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aT-0002kW-95; Tue, 21 Feb 2017 11:26:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aS-0002jm-Ci for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:28 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 77/21-13524-3E32CA85; Tue, 21 Feb 2017 11:26:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsrPtQeU2 Ewdd7Jhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a1h3uYC7bLVDQf3cjcwHhRrIuRi0NIYCaj xPnW/4wgDovAPGaJs9fWsIA4EgL9rBJ3W/vZuxg5gZwYiX+/PzFC2BUSbTtuMoHYQgJaEkdPz WaFGNXKJHFm4QegBAcHm4CJxKwOCZAaEQEliXurJoPVMwuESvx71gY2U1igROL1qQdgcRYBVY kDF0+DxXkFvCVe/v3HCrFLTuLmuU5mEJtTwEfi776X7BB7vSWm3VnBNoFRYAEjwypGjeLUorL UIl0jC72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMDQYgCCHYzn1wYeYpTkYFIS 5c2WWhMhxJeUn1KZkVicEV9UmpNafIhRhoNDSYJ3jhJQTrAoNT21Ii0zBxjkMGkJDh4lEd4ji kBp3uKCxNzizHSI1ClGY45TN06/ZOLYtevySyYhlrz8vFQpcd4ykEkCIKUZpXlwg2DRd4lRVk qYlxHoNCGegtSi3MwSVPlXjOIcjErCvBzAWBbiycwrgdv3CugUJqBTbnqsBDmlJBEhJdXA6KA /M39vHONExvN/FJpDtfN+l/x7Pi9iWsqbgmXrUzu7ebZy9/75WSDAweXF4ddc+O7SirbfX9yz ls5ZZ73UoLF47uGaX8rbY36+OvHDt3Vr/wPmBW7Pvm25H3bButT45eqT/1bfDrLYUpEp2Njd+ U2QmWd290O/tRdnlvBoR9/ZfvfU2Yf/jymxFGckGmoxFxUnAgDntz4quQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1487676384!52965562!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57669 invoked from network); 21 Feb 2017 11:26:25 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-14.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:25 -0000 Received: by mail-pg0-f51.google.com with SMTP id a123so33306486pgc.0 for ; Tue, 21 Feb 2017 03:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YbDdgvYJAB5qY+CEQBs44Dp+uG0b76kajL+9CESUG0w=; b=UpLP7VAGjx53oo9QICyv91PgMk9ZOkucEbLbVysvJ6dfy5xkDLJGJig4WTAZa0Ys+f ySsqRfkV/bJsoMbvQ9oZy69pep+jag0WMgJhhbbbtCwhzsCAPgxmyqSmTDbMGAaFB3+N Ud5HIGtj2rQyWsdOhV6h7ebGvKM1tllYvyUVs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YbDdgvYJAB5qY+CEQBs44Dp+uG0b76kajL+9CESUG0w=; b=L702/vk6OcqRPt6wbof8JaRSzKvRVc/K77ChIDIOg0Kog3SukUkrQZ3hwK0MQaG6ZQ OY9VXbmrFgxIs9HVeXuWi8OKEB19kFPAi77hVlNc8Jf6WUBEUZEEtfrqMdg9SahqE5pm +4+j9WTZR7KVaBVyHvcFXehDciuhAlIRms2Czvp1PFjatG1SrDxoLrcAkSoQEM08uVtt cmQxZFMSjq2IewnN3ACWjrRWubxUTIMhY3Isk0icZ/zpj4+NEdPsm3R5GPAj40204S4O zYb3BTuSVzIHmxgXtHd1cO42g/sapgB68UpI7KYUVlJf3n7RV+FUOCmBnk7J+CTDH2S5 J0Qg== X-Gm-Message-State: AMke39nuqZHQxuAKyTVuTgeCKq/QYVgtz3ijmYw3I0ezc9jTy5qVXp1srMvVo8A5SChYn2fA X-Received: by 10.84.217.65 with SMTP id e1mr39260441plj.40.1487676384397; Tue, 21 Feb 2017 03:26:24 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:23 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:00 +0530 Message-Id: <1487676368-22356-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 03/11] xen/arm: vpl011: Refactor evtchn_send in Xen to allow sending events from a xen bound channel X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Breakup evtchn_send() to allow sending events for a Xen bound channel. Currently, there is a check in evtchn_send() i.e. is_consumer_xen() that if the event channel is bound to a xen consumer then event generation is not allowed for that channel. This check is to disallow a guest from raising an event via this channel. However, it should allow Xen to send a event via this channel as it is required for sending vpl011 event to the dom0. This change introduces a new function raw_evtchn_send() which sends the event without this check. The current evtchn_send() calls this function after doing the xen consumer check. Xen uses the raw_evtchm_send() version to send the event thus bypassing the check. Signed-off-by: Bhupinder Thakur --- xen/common/event_channel.c | 49 ++++++++++++++++++++++++++++++++++------------ xen/include/xen/event.h | 6 ++++++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 638dc5e..4b039f3 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -650,25 +651,21 @@ static long evtchn_close(struct domain *d1, int port1, bool_t guest) return rc; } -int evtchn_send(struct domain *ld, unsigned int lport) +int raw_evtchn_send(struct domain *ld, unsigned int lport, void *data) { struct evtchn *lchn, *rchn; struct domain *rd; - int rport, ret = 0; + int rport, ret=0; - if ( !port_is_valid(ld, lport) ) - return -EINVAL; - - lchn = evtchn_from_port(ld, lport); - - spin_lock(&lchn->lock); - - /* Guest cannot send via a Xen-attached event channel. */ - if ( unlikely(consumer_is_xen(lchn)) ) + if ( !data ) { - ret = -EINVAL; - goto out; + if ( !port_is_valid(ld, lport) ) + return -EINVAL; + lchn = evtchn_from_port(ld, lport); + spin_lock(&lchn->lock); } + else + lchn = (struct evtchn *)data; ret = xsm_evtchn_send(XSM_HOOK, ld, lchn); if ( ret ) @@ -696,6 +693,32 @@ int evtchn_send(struct domain *ld, unsigned int lport) } out: + if ( !data ) + spin_unlock(&lchn->lock); + + return ret; +} + +int evtchn_send(struct domain *ld, unsigned int lport) +{ + struct evtchn *lchn; + int ret; + + if ( !port_is_valid(ld, lport) ) + return -EINVAL; + + lchn = evtchn_from_port(ld, lport); + + spin_lock(&lchn->lock); + + if ( unlikely(consumer_is_xen(lchn)) ) + { + printk("evtchn_send failed to send via xen event channel\n"); + return -EINVAL; + } + + ret = raw_evtchn_send(ld, lport, lchn); + spin_unlock(&lchn->lock); return ret; diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 5008c80..9bd17db 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -45,6 +45,12 @@ void send_guest_pirq(struct domain *, const struct pirq *); /* Send a notification from a given domain's event-channel port. */ int evtchn_send(struct domain *d, unsigned int lport); +/* + * This function is same as evntchn_send() except it does not do xen consumer check + * to allow the events to be sent from xen bound channels. + */ +int raw_evtchn_send(struct domain *ld, unsigned int lport, void *data); + /* Bind a local event-channel port to the specified VCPU. */ long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id);