Re: [Xen-devel] [PATCH v4 11/53] xen/arch/x86/hvm/vmx/vmcs.c: let custom parameter parsing routines return errno

2017-08-24 Thread Tian, Kevin
> From: Juergen Gross [mailto:jgr...@suse.com]
> Sent: Thursday, August 24, 2017 1:34 AM
> 
> Modify the custom parameter parsing routines in:
> 
> xen/arch/x86/hvm/vmx/vmcs.c
> 
> to indicate whether the parameter value was parsed successfully.
> 
> Cc: Jun Nakajima 
> Cc: Kevin Tian 
> Cc: Jan Beulich 
> Cc: Andrew Cooper 
> Signed-off-by: Juergen Gross 

Acked-by: Kevin Tian 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 11/53] xen/arch/x86/hvm/vmx/vmcs.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/hvm/vmx/vmcs.c

to indicate whether the parameter value was parsed successfully.

Cc: Jun Nakajima 
Cc: Kevin Tian 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
---
V3:
- dont modify option value in parsing function
---
 xen/arch/x86/hvm/vmx/vmcs.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 7854802cba..02f54e7f84 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -74,9 +74,10 @@ static s8 __read_mostly opt_ept_ad = -1;
  *  pml Enable PML
  *  ad  Use A/D bits
  */
-static void __init parse_ept_param(char *s)
+static int __init parse_ept_param(const char *s)
 {
-char *ss;
+const char *ss;
+int rc = 0;
 
 do {
 bool_t val = !!strncmp(s, "no-", 3);
@@ -85,16 +86,20 @@ static void __init parse_ept_param(char *s)
 s += 3;
 
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
+if ( !ss )
+ss = strchr(s, '\0');
 
-if ( !strcmp(s, "pml") )
+if ( !strncmp(s, "pml", ss - s) )
 opt_pml_enabled = val;
-else if ( !strcmp(s, "ad") )
+else if ( !strncmp(s, "ad", ss - s) )
 opt_ept_ad = val;
+else
+rc = -EINVAL;
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 custom_param("ept", parse_ept_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel