* [PATCH Altp2m cleanup v6] Cleaning up altp2m code
@ 2016-09-26 17:52 Paul Lai
2016-09-26 17:52 ` [PATCH Altp2m cleanup v6] altp2m cleanup work Paul Lai
0 siblings, 1 reply; 3+ messages in thread
From: Paul Lai @ 2016-09-26 17:52 UTC (permalink / raw)
To: xen-devel; +Cc: ravi.sahita, george.dunlap, jbeulich
Altp2m cleanup work
The altp2m clean work is motivated by the following URLs:
https://lists.xenproject.org/archives/html/xen-devel/2015-07/msg04323.html
Most of the work has been:
Lots of white space, indentation, and other coding style preference
corrections.
Lots of function return type corrections (and checking).
Better sanity checking of values before processing in do_altp2m_op().
Using 'bool' instead of 'bool_t' for stronger checking.
Paul Lai (1):
altp2m cleanup work.
xen/arch/x86/hvm/hvm.c | 47 ++++++++++++++++++++-----------------------
xen/include/asm-x86/hvm/hvm.h | 26 +++++++++++++++++++-----
2 files changed, 43 insertions(+), 30 deletions(-)
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH Altp2m cleanup v6] altp2m cleanup work.
2016-09-26 17:52 [PATCH Altp2m cleanup v6] Cleaning up altp2m code Paul Lai
@ 2016-09-26 17:52 ` Paul Lai
2016-09-28 14:45 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Paul Lai @ 2016-09-26 17:52 UTC (permalink / raw)
To: xen-devel; +Cc: ravi.sahita, george.dunlap, jbeulich
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.
Changes since last version:
Fixing fall through in switch statement above ASSERT_UNREACHABLE() (in
do_altp2m_op()).
Make hvm_funcs.altp2m_supported "bool" instead of "bool_t".
Make hvm_altp2m_supported() and altp2m_vcpu_emulate_ve() return
bool (rather than return void()).
Signed-off-by: Paul Lai <paul.c.lai@intel.com>
---
xen/arch/x86/hvm/hvm.c | 47 ++++++++++++++++++++-----------------------
xen/include/asm-x86/hvm/hvm.h | 26 +++++++++++++++++++-----
2 files changed, 43 insertions(+), 30 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 7bad845..3a4ea56 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1959,11 +1959,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 */
@@ -5308,12 +5308,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 )
@@ -5430,6 +5443,9 @@ 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));
+ break;
+ default:
+ ASSERT_UNREACHABLE();
}
out:
@@ -5954,25 +5970,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..b1be6bd 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -100,7 +100,7 @@ struct hvm_function_table {
bool_t pvh_supported;
/* Necessary hardware support for alternate p2m's? */
- bool_t altp2m_supported;
+ bool altp2m_supported;
/* Indicate HAP capabilities. */
unsigned int hap_capabilities;
@@ -593,19 +593,35 @@ static inline bool_t hvm_is_singlestep_supported(void)
}
/* returns true if hardware supports alternate p2m's */
-static inline bool_t hvm_altp2m_supported(void)
+static inline bool hvm_altp2m_supported(void)
{
return hvm_funcs.altp2m_supported;
}
/* 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 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,
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH Altp2m cleanup v6] altp2m cleanup work.
2016-09-26 17:52 ` [PATCH Altp2m cleanup v6] altp2m cleanup work Paul Lai
@ 2016-09-28 14:45 ` Jan Beulich
0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2016-09-28 14:45 UTC (permalink / raw)
To: Paul Lai; +Cc: xen-devel, ravi.sahita, george.dunlap
>>> On 26.09.16 at 19:52, <paul.c.lai@intel.com> wrote:
> 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.
>
> Changes since last version:
>
> Fixing fall through in switch statement above ASSERT_UNREACHABLE() (in
> do_altp2m_op()).
> Make hvm_funcs.altp2m_supported "bool" instead of "bool_t".
> Make hvm_altp2m_supported() and altp2m_vcpu_emulate_ve() return
> bool (rather than return void()).
This changes section belongs ...
> Signed-off-by: Paul Lai <paul.c.lai@intel.com>
> ---
... here, as it shouldn't end up in the commit message.
> @@ -5308,12 +5308,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;
Quite recently a patch went in to eliminate such bogus -ENOSYS
instances. Please use -EOPNOTSUPP instead.
With that corrected,
Acked-by: Jan Beulich <jbeulich@suse.com>
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-28 14:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-26 17:52 [PATCH Altp2m cleanup v6] Cleaning up altp2m code Paul Lai
2016-09-26 17:52 ` [PATCH Altp2m cleanup v6] altp2m cleanup work Paul Lai
2016-09-28 14:45 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.