From patchwork Mon Dec 5 10:09:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9460771 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 604FD6074E for ; Mon, 5 Dec 2016 10:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59A4B22ADC for ; Mon, 5 Dec 2016 10:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E51D25EA6; Mon, 5 Dec 2016 10:11:50 +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 10BED26490 for ; Mon, 5 Dec 2016 10:11:50 +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 1cDqDK-0007kG-5Q; Mon, 05 Dec 2016 10:09:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cDqDI-0007ji-BT for xen-devel@lists.xen.org; Mon, 05 Dec 2016 10:09:36 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id C1/6E-28694-FDC35485; Mon, 05 Dec 2016 10:09:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrrBXve+jWu Ewb83whZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aWqatZC+ZwVMza+529gfE6WxcjJ4eEgL/E j941LCA2m4C+xO4Xn5hAbBEBdYnTHRdZuxg5OJgF/CQOPfAFCQsL+Ei0tD4Ca2URUJH4PmsLI 4jNK+ApsW3VenaIkXIS54//ZAaxOQW8JJbO3go2Xgio5vfHPiYIW03iWv8ldoheQYmTM5+A1T ALSEgcfPGCeQIj7ywkqVlIUgsYmVYxahSnFpWlFukaGeslFWWmZ5TkJmbm6BoamOnlphYXJ6a n5iQmFesl5+duYgSGDgMQ7GD8Mz/wEKMkB5OSKG+LoWuEEF9SfkplRmJxRnxRaU5q8SFGGQ4O JQleBWAoCgkWpaanVqRl5gCDGCYtwcGjJMKbCZLmLS5IzC3OTIdInWJUlBLnPWENlBAASWSU5 sG1wSLnEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5z4BM4cnMK4Gb/gpoMRPQ4hPHnUEWly QipKQaGNUvdz+Z+ik3RETBoqHodX/5mhMqb7g48ysPMDWrKdVvcLw3dcmLh89/Cn3Yum7a06O KT6eXiOR+iufyXjGndPGrexbBDx5Wn7yVmL724M0mpkIewd4dOzy+nI1KZL9gvcvxhv2/NcGT 1YTlL3I2/sx3/WaVks71/GjwE61Z9UuifPM012o1n1diKc5INNRiLipOBAAF2Cn1lwIAAA== X-Env-Sender: prvs=140b549e8=Andrew.Cooper3@citrix.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1480932573!23204456!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7637 invoked from network); 5 Dec 2016 10:09:35 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 5 Dec 2016 10:09:35 -0000 X-IronPort-AV: E=Sophos;i="5.33,747,1477958400"; d="scan'208";a="401794092" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Dec 2016 10:09:26 +0000 Message-ID: <1480932571-23547-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1480932571-23547-1-git-send-email-andrew.cooper3@citrix.com> References: <1480932571-23547-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 3/8] x86/hvm: Assert some expectations in hvm_inject_event() 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Check that event->error_code is appropriate for the type/vector combination. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich --- xen/arch/x86/hvm/hvm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e0f936b..ac207e4 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1679,6 +1679,15 @@ void hvm_triple_fault(void) void hvm_inject_event(const struct x86_event *event) { struct vcpu *curr = current; + const uint8_t vector = event->vector; + const bool has_ec = ((event->type == X86_EVENTTYPE_HW_EXCEPTION) && + (vector < 32) && ((TRAP_HAVE_EC & 1u << vector))); + + ASSERT(vector == event->vector); /* Confirm no truncation. */ + if ( has_ec ) + ASSERT(event->error_code != X86_EVENT_NO_EC); + else + ASSERT(event->error_code == X86_EVENT_NO_EC); if ( nestedhvm_enabled(curr->domain) && !nestedhvm_vmswitch_in_progress(curr) &&