[HCA] Add calls to secure address ranges associated with
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 11 Oct 2005 22:15:58 +0000 (22:15 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 11 Oct 2005 22:15:58 +0000 (22:15 +0000)
user-mode memory registrations.

Signed-off-by: Fab Tillier (ftillier@silverstorm.com)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@110 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mt23108/vapi/mlxsys/mosal/os_dep/win/mosal_iobuf.c
hw/mt23108/vapi/mlxsys/mosal/os_dep/win/mosal_iobuf_imp.h

index 1e9cbea..a43e37e 100644 (file)
@@ -202,7 +202,31 @@ check_va_validity:
        rc = MT_EPERM;\r
        goto err2;\r
   }\r
-       \r
+\r
+  if( mode == UserMode )\r
+  {\r
+       if (req_perm & MOSAL_PERM_WRITE)\r
+       {\r
+               new_iobuf->h_secure = MmSecureVirtualMemory(\r
+                       (PVOID)va, (SIZE_T)size, PAGE_READWRITE );\r
+       }\r
+       else\r
+       {\r
+               new_iobuf->h_secure = MmSecureVirtualMemory(\r
+                       (PVOID)va, (SIZE_T)size, PAGE_READONLY );\r
+       }\r
+\r
+       if( !new_iobuf->h_secure )\r
+       {\r
+               rc = MT_EPERM;\r
+               goto err3;\r
+       }\r
+  }\r
+  else\r
+  {\r
+       new_iobuf->h_secure = NULL;\r
+  }\r
+\r
   // fill IOBUF object\r
   new_iobuf->va = va;\r
   new_iobuf->size= size;\r
@@ -212,6 +236,8 @@ check_va_validity:
   MOSAL_dlist_insert_tail( &iobuf_p->seg_que, &new_iobuf->link );\r
   return MT_OK;\r
 \r
+err3:\r
+  MmUnlockPages( mdl_p );\r
 err2:\r
   IoFreeMdl(mdl_p);\r
 err1:  \r
@@ -222,6 +248,8 @@ err0:
 \r
 static void deregister_segment(MOSAL_iobuf_seg_t iobuf_seg_p)\r
 {\r
+       if( iobuf_seg_p->h_secure )\r
+               MmUnsecureVirtualMemory( iobuf_seg_p->h_secure);\r
   MmUnlockPages( iobuf_seg_p->mdl_p );    // unlock the buffer \r
   IoFreeMdl( iobuf_seg_p->mdl_p );        // free MDL\r
   FREE(iobuf_seg_p);\r
index ff19b19..85e8fcd 100644 (file)
@@ -44,6 +44,7 @@ struct mosal_iobuf_seg_st {
   MT_size_t size;     /* size in bytes of the buffer */\r
   u_int32_t nr_pages;\r
   MOSAL_prot_ctx_t prot_ctx;\r
+  void         *h_secure;\r
 };\r
 \r
 typedef struct mosal_iobuf_seg_st  * MOSAL_iobuf_seg_t;\r