From patchwork Tue Jun 21 16:04:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Lai X-Patchwork-Id: 9190953 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 7C746601C0 for ; Tue, 21 Jun 2016 16:41:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C1AD2818A for ; Tue, 21 Jun 2016 16:41:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F84F282ED; Tue, 21 Jun 2016 16:41:40 +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 B02732818A for ; Tue, 21 Jun 2016 16:41:39 +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 1bFOhr-0007zX-P3; Tue, 21 Jun 2016 16:39:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFOhq-0007zQ-HF for xen-devel@lists.xensource.com; Tue, 21 Jun 2016 16:39:18 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 3F/97-10364-5BD69675; Tue, 21 Jun 2016 16:39:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42Jpa+uQ0N2amxl ucG69qMW9Ke/ZHRg9tvftYg9gjGLNzEvKr0hgzZj1Zxd7wUuFiokfDzI1MG6Q6mLk5BASqJSY 3juDBcSWEOCVOLJsBiuE7S9x7NhydoiaCoktTa+BbC4gezmjxJfj+1khEiUSDS3fwYrYBFQll p+bxAhiiwgoSqxb/Q5sKLOAjsSu+RuYQGxhASuJre+3gNWwANWvmrYcrIZXwFli2r51TBCL5S ROHpsMNp9TwEXi1taljBC7nCXOfljINIGRfwEjwypGjeLUorLUIl0jE72kosz0jJLcxMwcXUM DU73c1OLixPTUnMSkYr3k/NxNjMDwqWdgYNzBeHOy3yFGSQ4mJVFeZuWMcCG+pPyUyozE4oz4 otKc1OJDjDIcHEoSvNbZmeFCgkWp6akVaZk5wECGSUtw8CiJ8LKDpHmLCxJzizPTIVKnGBWlx HkPZwElBEASGaV5cG2w6LnEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZiXH2Q8T2ZeCdz0V0 CLmYAWL+tPB1lckoiQkmpgXHSjTHW+4bRnjPLnFussecB7PXzxp7P/jq7sFrnzb9FWgR8tNxu WrJE1mrSIlbu97pZG1qapPPxGH9lr1fW5HCuX61UKibFfmDRhrsajAKc07j0Sa5+Zzvq9tNX+ 2xzDeeH8nxxv3pinULB+mSPrHIOncz5sLd6x23Xju4QnR1/nSpqL3SmOeK3EUpyRaKjFXFScC AAaTHiwmQIAAA== X-Env-Sender: pclai@intel.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1466527156!45824727!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31582 invoked from network); 21 Jun 2016 16:39:16 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-7.tower-206.messagelabs.com with SMTP; 21 Jun 2016 16:39:16 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 21 Jun 2016 09:39:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,505,1459839600"; d="scan'208";a="992263117" Received: from scymds01.sc.intel.com ([10.82.194.37]) by fmsmga001.fm.intel.com with ESMTP; 21 Jun 2016 09:39:15 -0700 Received: from pclaidev.sc.intel.com (pclaidev.sc.intel.com [143.183.85.146]) by scymds01.sc.intel.com with ESMTP id u5LGdFN6021849; Tue, 21 Jun 2016 09:39:15 -0700 Received: by pclaidev.sc.intel.com (Postfix, from userid 1002) id 3415D228C3; Tue, 21 Jun 2016 09:04:58 -0700 (PDT) From: Paul Lai To: xen-devel@lists.xensource.com Date: Tue, 21 Jun 2016 09:04:48 -0700 Message-Id: <1466525090-1692-2-git-send-email-paul.c.lai@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466525090-1692-1-git-send-email-paul.c.lai@intel.com> References: <1466525090-1692-1-git-send-email-paul.c.lai@intel.com> Cc: ravi.sahita@intel.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v1 Altp2m cleanup 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 Define default behavior in switch Define max and min for range of altp2m macroed values Signed-off-by: Paul Lai --- xen/arch/x86/hvm/hvm.c | 33 +++++++++------------------------ xen/include/asm-x86/hvm/hvm.h | 19 ++++++++++++++++--- xen/include/public/hvm/hvm_op.h | 2 ++ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 22f045e..1595b3e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1926,11 +1926,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 */ @@ -5207,9 +5207,11 @@ 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) || + (a.cmd < HVMOP_cmd_min) || (a.cmd > HVMOP_cmd_max)) + return -EINVAL; + + if (a.cmd > HVMOP_cmd_max) return -EINVAL; d = (a.cmd != HVMOP_altp2m_vcpu_enable_notify) ? @@ -5329,6 +5331,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: + return -EINVAL; } out: @@ -5816,25 +5820,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 f486ee9..231c921 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -589,13 +589,26 @@ 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 ) + return hvm_funcs.altp2m_vcpu_emulate_ve(v); + return 0; +} /* Check CR4/EFER values */ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value, diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index ebb907a..3350492 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -479,6 +479,8 @@ struct xen_hvm_altp2m_op { #define HVMOP_altp2m_set_mem_access 7 /* Change a p2m entry to have a different gfn->mfn mapping */ #define HVMOP_altp2m_change_gfn 8 +#define HVMOP_cmd_min HVMOP_altp2m_get_domain_state +#define HVMOP_cmd_max HVMOP_altp2m_change_gfn domid_t domain; uint16_t pad1; uint32_t pad2;