diff mbox

[3/6] x86/HVM: adjust hvm_set_mem_pinned_cacheattr() error indications

Message ID 56D8764802000078000D8F4A@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich March 3, 2016, 4:37 p.m. UTC
Make it return an error on bad domain kind or obviously bad GFN range.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86/HVM: adjust hvm_set_mem_pinned_cacheattr() error indications

Make it return an error on bad domain kind or obviously bad GFN range.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -591,8 +591,11 @@ int32_t hvm_set_mem_pinned_cacheattr(
     struct hvm_mem_pinned_cacheattr_range *range;
     int rc = 1;
 
-    if ( !is_hvm_domain(d) || gfn_end < gfn_start )
-        return 0;
+    if ( !is_hvm_domain(d) )
+        return -EOPNOTSUPP;
+
+    if ( gfn_end < gfn_start || (gfn_start | gfn_end) >> paddr_bits )
+        return -EINVAL;
 
     if ( type == XEN_DOMCTL_DELETE_MEM_CACHEATTR )
     {

Comments

Andrew Cooper March 3, 2016, 5:37 p.m. UTC | #1
On 03/03/16 16:37, Jan Beulich wrote:
> Make it return an error on bad domain kind or obviously bad GFN range.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox

Patch

--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -591,8 +591,11 @@  int32_t hvm_set_mem_pinned_cacheattr(
     struct hvm_mem_pinned_cacheattr_range *range;
     int rc = 1;
 
-    if ( !is_hvm_domain(d) || gfn_end < gfn_start )
-        return 0;
+    if ( !is_hvm_domain(d) )
+        return -EOPNOTSUPP;
+
+    if ( gfn_end < gfn_start || (gfn_start | gfn_end) >> paddr_bits )
+        return -EINVAL;
 
     if ( type == XEN_DOMCTL_DELETE_MEM_CACHEATTR )
     {