From patchwork Thu Jun 23 17:07:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 9195617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 669006075F for ; Thu, 23 Jun 2016 17:09:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E8DA283FB for ; Thu, 23 Jun 2016 17:09:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 406012845C; Thu, 23 Jun 2016 17:09:48 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19E3C28464 for ; Thu, 23 Jun 2016 17:09:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG86Q-0005Jj-9f; Thu, 23 Jun 2016 17:07:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG86P-0005Ht-1B for xen-devel@lists.xenproject.org; Thu, 23 Jun 2016 17:07:41 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 93/06-29837-C571C675; Thu, 23 Jun 2016 17:07:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRWlGSWpSXmKPExsVyMfT+Yd1o8Zx wg4mXdC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy/XXeZCn5LVhxZtpmxgfGsUBcjF4eQwExG iW0tLewgjoRAP6vEvje/mLoYOYGcGIn7q3ug7CqJO8fXMoLYQgIaErdvNrJDdPczSUy6co0ZJ MEmoC3R9noXK4gtIqAkcW/VZCaQImaBhYwSk5omAiU4OIQFAiXm3/UGqWERUJVY+OMHWD2vgL NEZ28zG8QyOYnL0x+A2ZwCLhLbZp9hgljsLHHmzj+2CYz8CxgZVjFqFKcWlaUW6RqZ6iUVZaZ nlOQmZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBIZQPQMD4w7GXe1+hxglOZiURHkZN2eHC/El 5adUZiQWZ8QXleakFh9ilOHgUJLgfSaaEy4kWJSanlqRlpkDDGaYtAQHj5II73SQNG9xQWJuc WY6ROoUozHHlt/X1jJxbJt6by2TEEtefl6qlDjvYpBSAZDSjNI8uEGwKLvEKCslzMvIwMAgxF OQWpSbWYIq/4pRnINRSZhXRwxoCk9mXgncvldApzABnXK3PxvklJJEhJRUA6PEPjOGRkkrpvs tE1X/ffRRYPe60fTnjHZSD+/9Zfei12Z/kNlq5v7Dm2VHpzvfhrfajQ81QvmLXt60VZufsItF O9A7w2FpY41uiIzoZNPO1dv6n+2wTp+U2beMW33tR15+x2dP94h26L9rLTmssNtgXsp9i6B0M 5080anbjy1/pedZcciyX4mlOCPRUIu5qDgRAGupRUCtAgAA X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1466701658!46279322!1 X-Originating-IP: [209.85.223.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6770 invoked from network); 23 Jun 2016 17:07:39 -0000 Received: from mail-io0-f195.google.com (HELO mail-io0-f195.google.com) (209.85.223.195) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Jun 2016 17:07:39 -0000 Received: by mail-io0-f195.google.com with SMTP id s63so12593071ioi.3 for ; Thu, 23 Jun 2016 10:07:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wrKtRc4ycqtDdZ+myS2HWiopDMhh084IymQpJ5WQ2rE=; b=efARxQAdEkfvWY+y8INPhy6ZX9SrjuQLs5m+ug8dvTTa5fqYFatOh30RC4WyqjuBwG APq+5lZ1B5eJIxE529bBs9ERfR1xDKDsSb+MoH//P5P1B6QBZhAxCWUFRcJZLrpAN1aC vkZfgJuxgHKgTmxt96bGeX9/cr3ZIJ12h4UDOTVzsxxkO3w9W+e2mY2oWxfHdb96KtP3 Qc9SSNhPnURkNuD/EaTT8PpFNXbLTg9WsBmL51co1a1H0vxWUfE+2Z5+KXJ1K1hJoDnt NR4sykzGBdCT9f255sYZM3qjJRsUHNRumBgJHfXsOl72lYr1qE4Dlbf07QvJJE/sd2Xm +z6w== X-Gm-Message-State: ALyK8tKaCX/ewoyAh+kfH/neI8DU32s0632QPyDkfNL7LJLKM631iSDIAuqyKgSLBahDTA== X-Received: by 10.107.48.198 with SMTP id w189mr2007232iow.90.1466701658581; Thu, 23 Jun 2016 10:07:38 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id e91sm725356itd.8.2016.06.23.10.07.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 10:07:37 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Thu, 23 Jun 2016 11:07:26 -0600 Message-Id: <1466701647-21733-4-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466701647-21733-1-git-send-email-tamas@tklengyel.com> References: <1466701647-21733-1-git-send-email-tamas@tklengyel.com> Cc: Andrew Cooper , Kevin Tian , Tamas K Lengyel , Jun Nakajima Subject: [Xen-devel] [PATCH v6 4/5] vm_event: clear up return value of vm_event_monitor_traps 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" X-Virus-Scanned: ClamAV using ClamSMTP The return value has not been clearly defined, with the function never returning 0 which seemingly indicated a condition where the guest should crash. In this patch we define -rc as error condition where a subscriber is present but an error prevented the notification from being sent; 0 where there is no subscriber or the notification was sent and the vCPU is not paused (i.e. safe to continue execution as normal); and 1 where the notification was sent with the vCPU paused and we are waiting for a response. Signed-off-by: Tamas K Lengyel Reviewed-by: Jan Beulich Acked-by: Razvan Cojocaru Acked-by: Kevin Tian --- Cc: Jun Nakajima Cc: Kevin Tian Cc: Andrew Cooper v6: Remove unnecessary else clause in vmx --- xen/arch/x86/hvm/monitor.c | 4 ++-- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- xen/common/vm_event.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index f0ab33a..472926c 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -48,8 +48,8 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old .u.write_ctrlreg.old_value = old }; - vm_event_monitor_traps(curr, sync, &req); - return 1; + if ( vm_event_monitor_traps(curr, sync, &req) >= 0 ) + return 1; } return 0; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a56926c..03fcba7 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3388,11 +3388,11 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) break; } else { - int handled = + int rc = hvm_monitor_breakpoint(regs->eip, HVM_MONITOR_SOFTWARE_BREAKPOINT); - if ( handled < 0 ) + if ( !rc ) { struct hvm_trap trap = { .vector = TRAP_int3, @@ -3406,7 +3406,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) hvm_inject_trap(&trap); break; } - else if ( handled ) + if ( rc > 0 ) break; } diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index ca1eced..b303180 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -806,7 +806,7 @@ int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, * If there was no ring to handle the event, then * simply continue executing normally. */ - return 1; + return 0; default: return rc; }; @@ -815,6 +815,7 @@ int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, { req->flags |= VM_EVENT_FLAG_VCPU_PAUSED; vm_event_vcpu_pause(v); + rc = 1; } if ( altp2m_active(d) ) @@ -826,7 +827,7 @@ int vm_event_monitor_traps(struct vcpu *v, uint8_t sync, vm_event_fill_regs(req); vm_event_put_request(d, &d->vm_event->monitor, req); - return 1; + return rc; } /*