From: Paul Lai <paul.c.lai@intel.com>
To: xen-devel@lists.xensource.com
Cc: ravi.sahita@intel.com, george.dunlap@citrix.com, jbeulich@suse.com
Subject: [PATCH Altp2m cleanup v4 2/4] altp2m cleanup work
Date: Wed, 7 Sep 2016 15:04:24 -0700 [thread overview]
Message-ID: <1473285866-6868-3-git-send-email-paul.c.lai@intel.com> (raw)
In-Reply-To: <1473285866-6868-1-git-send-email-paul.c.lai@intel.com>
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 <paul.c.lai@intel.com>
---
xen/arch/x86/hvm/hvm.c | 46 ++++++++++++++++++++-----------------------
xen/include/asm-x86/hvm/hvm.h | 19 +++++++++++++++---
2 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 787f055..e63ef0b 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1942,11 +1942,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 */
@@ -5291,12 +5291,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 )
@@ -5413,6 +5426,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:
@@ -5937,25 +5952,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 81b60d5..ed043b2 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -599,13 +599,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 false;
+}
/* Check CR4/EFER values */
const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-07 22:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-07 22:04 [PATCH Altp2m cleanup v4 0/4] Cleaning up altp2m code Paul Lai
2016-09-07 22:04 ` [PATCH Altp2m cleanup v4 1/4] x86/HVM: adjust feature checking in MSR intercept handling Paul Lai
2016-09-08 10:32 ` Jan Beulich
2016-09-08 15:38 ` Lai, Paul C
2016-09-07 22:04 ` Paul Lai [this message]
2016-09-08 14:46 ` [PATCH Altp2m cleanup v4 2/4] altp2m cleanup work Jan Beulich
2016-09-08 15:50 ` Lai, Paul C
2016-09-08 16:06 ` Tamas K Lengyel
2016-09-08 16:45 ` Lai, Paul C
2016-09-12 10:47 ` George Dunlap
2016-09-13 17:38 ` Lai, Paul
2016-09-14 13:39 ` George Dunlap
2016-09-07 22:04 ` [PATCH Altp2m cleanup v4 3/4] Move altp2m specific functions to altp2m files Paul Lai
2016-09-08 15:02 ` Jan Beulich
2016-09-08 18:04 ` Lai, Paul C
2016-09-07 22:04 ` [PATCH Altp2m cleanup v4 4/4] Making altp2m struct dynamically allocated Paul Lai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473285866-6868-3-git-send-email-paul.c.lai@intel.com \
--to=paul.c.lai@intel.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=ravi.sahita@intel.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).