From patchwork Tue Sep 13 16:46:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Lai X-Patchwork-Id: 9329457 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 549FB6077F for ; Tue, 13 Sep 2016 16:46:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46A5C2956B for ; Tue, 13 Sep 2016 16:46:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B20229574; Tue, 13 Sep 2016 16:46:19 +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 BC1BB2956B for ; Tue, 13 Sep 2016 16:46:18 +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 1bjqoW-0001NL-Ab; Tue, 13 Sep 2016 16:44:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjqoV-0001NA-0H for xen-devel@lists.xensource.com; Tue, 13 Sep 2016 16:44:03 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id DC/12-08498-2DC28D75; Tue, 13 Sep 2016 16:44:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42Jpa+uQ172ocyP c4FiDrMW9Ke/ZHRg9tvftYg9gjGLNzEvKr0hgzfj4fwNbwVPFih2nj7E0MM6V7mLk4BASqJA4 M825i5GTQ0KAV+LIshmsELa/xPGFE9hhSn7fk+pi5AIylzFK7Gxbzw5SIyRQIjFxzVYmEJtNQ FVi+blJjCC2iICixLrV71hAbGYBN4kvl9+B1QsLWEu8ufoEzGYBqf/9FGwXr4CLxKLbv9kh9s pJ3DzXyQxicwq4SlzsbmWE2OUi8fTuOaYJjPwLGBlWMWoUpxaVpRbpGpnpJRVlpmeU5CZm5ug aGpjp5aYWFyemp+YkJhXrJefnbmIEhg4DEOxgPLMg8BCjJAeTkijv/DXXw4X4kvJTKjMSizPi i0pzUosPMcpwcChJ8LZq3wgXEixKTU+tSMvMAQYxTFqCg0dJhHcVSJq3uCAxtzgzHSJ1ilFRS py3GCQhAJLIKM2Da4NFziVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ824BmcKTmVcCN/0V0G ImoMVbQG7mLS5JREhJNTAeN24yujtlzqr/FktPM1n7Tg78aK9cJxHTsKPU51jLFbnisCDBiRe vBqqKpzK8en1i8d21q24e/mvgt+ihY4X4jkLNl47/7XTvultvYbuZ3LlCQXfdeV/dq/vKc1RO ZwVo9j56sVOrxoGBb2PzDc5dlztUjI6HO1Xu1Py+TcrfWPTnNo5SCWUlluKMREMt5qLiRAABB VjLlwIAAA== X-Env-Sender: pclai@intel.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1473785039!33108296!1 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38085 invoked from network); 13 Sep 2016 16:44:01 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-12.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Sep 2016 16:44:01 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 13 Sep 2016 09:43:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,329,1470726000"; d="scan'208";a="878331146" Received: from scymds02.sc.intel.com ([10.82.195.37]) by orsmga003.jf.intel.com with ESMTP; 13 Sep 2016 09:43:52 -0700 Received: from pclaidev.sc.intel.com (pclaidev.sc.intel.com [143.183.85.56]) by scymds02.sc.intel.com with ESMTP id u8DGhpSj000608; Tue, 13 Sep 2016 09:43:51 -0700 Received: by pclaidev.sc.intel.com (Postfix, from userid 1002) id 5BE382027D; Tue, 13 Sep 2016 09:46:05 -0700 (PDT) From: Paul Lai To: xen-devel@lists.xensource.com Date: Tue, 13 Sep 2016 09:46:03 -0700 Message-Id: <1473785165-11137-2-git-send-email-paul.c.lai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473785165-11137-1-git-send-email-paul.c.lai@intel.com> References: <1473785165-11137-1-git-send-email-paul.c.lai@intel.com> Cc: ravi.sahita@intel.com, george.dunlap@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH Altp2m cleanup v5 1/3] altp2m cleanup work. 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 Indent goto labels by one space. Inline (header) altp2m functions. In do_altp2m_op(), during the sanity check of the passed command, return -ENONSYS if not a valid command. In do_altp2m_op(), when evaluating a command, ASSERT_UNREACHABLE() if the command is not recognizable. The sanity check above should have triggered the return of -ENOSYS. Make altp2m_vcpu_emulate_ve() return actual bool_t (rather than return void()). Signed-off-by: Paul Lai --- xen/arch/x86/hvm/hvm.c | 46 ++++++++++++++++++++----------------------- xen/include/asm-x86/hvm/hvm.h | 22 ++++++++++++++++++--- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 2c89984..1bf2d01 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1932,11 +1932,11 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, * Otherwise, this is an error condition. */ rc = fall_through; -out_put_gfn: + out_put_gfn: __put_gfn(p2m, gfn); if ( ap2m_active ) __put_gfn(hostp2m, gfn); -out: + out: /* All of these are delayed until we exit, since we might * sleep on event ring wait queues, and we must not hold * locks in such circumstance */ @@ -5227,12 +5227,25 @@ static int do_altp2m_op( return -EFAULT; if ( a.pad1 || a.pad2 || - (a.version != HVMOP_ALTP2M_INTERFACE_VERSION) || - (a.cmd < HVMOP_altp2m_get_domain_state) || - (a.cmd > HVMOP_altp2m_change_gfn) ) + (a.version != HVMOP_ALTP2M_INTERFACE_VERSION) ) return -EINVAL; - d = (a.cmd != HVMOP_altp2m_vcpu_enable_notify) ? + switch ( a.cmd ) + { + case HVMOP_altp2m_get_domain_state: + case HVMOP_altp2m_set_domain_state: + case HVMOP_altp2m_vcpu_enable_notify: + case HVMOP_altp2m_create_p2m: + case HVMOP_altp2m_destroy_p2m: + case HVMOP_altp2m_switch_p2m: + case HVMOP_altp2m_set_mem_access: + case HVMOP_altp2m_change_gfn: + break; + default: + return -ENOSYS; + } + + d = ( a.cmd != HVMOP_altp2m_vcpu_enable_notify ) ? rcu_lock_domain_by_any_id(a.domain) : rcu_lock_current_domain(); if ( d == NULL ) @@ -5349,6 +5362,8 @@ static int do_altp2m_op( rc = p2m_change_altp2m_gfn(d, a.u.change_gfn.view, _gfn(a.u.change_gfn.old_gfn), _gfn(a.u.change_gfn.new_gfn)); + default: + ASSERT_UNREACHABLE(); } out: @@ -5873,25 +5888,6 @@ void hvm_toggle_singlestep(struct vcpu *v) v->arch.hvm_vcpu.single_step = !v->arch.hvm_vcpu.single_step; } -void altp2m_vcpu_update_p2m(struct vcpu *v) -{ - if ( hvm_funcs.altp2m_vcpu_update_p2m ) - hvm_funcs.altp2m_vcpu_update_p2m(v); -} - -void altp2m_vcpu_update_vmfunc_ve(struct vcpu *v) -{ - if ( hvm_funcs.altp2m_vcpu_update_vmfunc_ve ) - hvm_funcs.altp2m_vcpu_update_vmfunc_ve(v); -} - -bool_t altp2m_vcpu_emulate_ve(struct vcpu *v) -{ - if ( hvm_funcs.altp2m_vcpu_emulate_ve ) - return hvm_funcs.altp2m_vcpu_emulate_ve(v); - return 0; -} - int hvm_set_mode(struct vcpu *v, int mode) { diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 5d463e0..f3c996d 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -589,13 +589,29 @@ static inline bool_t hvm_altp2m_supported(void) } /* updates the current hardware p2m */ -void altp2m_vcpu_update_p2m(struct vcpu *v); +static inline void altp2m_vcpu_update_p2m(struct vcpu *v) +{ + if ( hvm_funcs.altp2m_vcpu_update_p2m ) + hvm_funcs.altp2m_vcpu_update_p2m(v); +} /* updates VMCS fields related to VMFUNC and #VE */ -void altp2m_vcpu_update_vmfunc_ve(struct vcpu *v); +static inline void altp2m_vcpu_update_vmfunc_ve(struct vcpu *v) +{ + if ( hvm_funcs.altp2m_vcpu_update_vmfunc_ve ) + hvm_funcs.altp2m_vcpu_update_vmfunc_ve(v); +} /* emulates #VE */ -bool_t altp2m_vcpu_emulate_ve(struct vcpu *v); +static inline bool_t altp2m_vcpu_emulate_ve(struct vcpu *v) +{ + if ( hvm_funcs.altp2m_vcpu_emulate_ve ) + { + hvm_funcs.altp2m_vcpu_emulate_ve(v); + return true; + } + return false; +} /* Check CR4/EFER values */ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,