Skip to contentSkip to conversation

memory: fix compat handling of XENMEM_access_op

PATCH In review Jan Beulich 3 participants 5 messages Aug 30, 2016 – Sep 2, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: fix compat handling of XENMEM_access_op

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

---
Compile tested only.

xen/common/compat/memory.c +5 -4
@@ -320,6 +320,11 @@ int compat_memory_op(unsigned int cmd, X
             break;
         }
 
+        case XENMEM_access_op:
+            return mem_access_memop(cmd,
+                                    guest_handle_cast(compat,
+                                                      xen_mem_access_op_t));
+
         case XENMEM_get_vnumainfo:
         {
             enum XLAT_vnuma_topology_info_vdistance vdistance =
@@ -495,10 +500,6 @@ int compat_memory_op(unsigned int cmd, X
             break;
         }
 
-        case XENMEM_access_op:
-            rc = mem_access_memop(cmd, guest_handle_cast(compat, xen_mem_access_op_t));
-            break;
-
         case XENMEM_add_to_physmap_batch:
             start_extent = end_extent;
             break;

memory: fix compat handling of XENMEM_access_op

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

---
Compile tested only.

xen/common/compat/memory.c +5 -4
@@ -320,6 +320,11 @@ int compat_memory_op(unsigned int cmd, X
             break;
         }
 
+        case XENMEM_access_op:
+            return mem_access_memop(cmd,
+                                    guest_handle_cast(compat,
+                                                      xen_mem_access_op_t));
+
         case XENMEM_get_vnumainfo:
         {
             enum XLAT_vnuma_topology_info_vdistance vdistance =
@@ -495,10 +500,6 @@ int compat_memory_op(unsigned int cmd, X
             break;
         }
 
-        case XENMEM_access_op:
-            rc = mem_access_memop(cmd, guest_handle_cast(compat, xen_mem_access_op_t));
-            break;
-
         case XENMEM_add_to_physmap_batch:
             start_extent = end_extent;
             break;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 7 lines · Jan Beulich

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

---
Compile tested only.

Looks good to me, and I can try to actually test the code if there's a way to do it without having to install a 32-bit dom0.

Is there a hypervisor command line argument that can help with testing?

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 11:46, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

Quoted 8 lines
Quoted 3 lines

---
Compile tested only.

Looks good to me, and I can try to actually test the code if there's a way to do it without having to install a 32-bit dom0.

Is there a hypervisor command line argument that can help with testing?

I'm afraid this can only be tested by invoking the operation from a 32-bit domain. I don't think that you'd need a Dom0 for that though:
For a DomU, error codes should differ between old and new code (-ENOSYS vs -EINVAL afaics).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Tested-by
#3 lore raw
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 11:46, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

---
Compile tested only.

Looks good to me, and I can try to actually test the code if there's a way to do it without having to install a 32-bit dom0.

Quoted 6 lines
Quoted 1 line

Is there a hypervisor command line argument that can help with testing?

I'm afraid this can only be tested by invoking the operation from a 32-bit domain. I don't think that you'd need a Dom0 for that though:
For a DomU, error codes should differ between old and new code (-ENOSYS vs -EINVAL afaics).

I've set up a 32-bit Ubuntu-based PV DomU:

# uname -a
Linux ubuntu 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:27
UTC 2016 i686 i686 i686 GNU/Linux

Without your patch, I get this when trying to run the mem_access.c test on a 64-bit domain running in Dom0:

# ./xen-access 4 write
xenaccess init
max_gpfn = 10fc01
starting write 4
Error -1 setting default mem access type

xenaccess exit code -1

With the patch applied, it's working as expected. Thank you for the patch!

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#4 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich

Within compat_memory_op() this needs to be placed in the first switch() statement, or it ends up being dead code (as that first switch() has a default case chaining to compat_arch_memory_op()).

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel