Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp	(revision 8250)
@@ -4262,8 +4262,8 @@
         NdisQueryMdl(CurrentMdl, &pSrc, &CurrLength, NormalPagePriority);
         if (pSrc == NULL)
         {
-            BytesCopied = 0;
-            break;
+			IPOIB_PRINT_EXIT(TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, ("NdisQueryMdl failed\n"));
+            return 0;
         }
         // 
         //  Current buffer length is greater than the offset to the buffer
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/core/al/al_common.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/core/al/al_common.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/core/al/al_common.c	(revision 8250)
@@ -48,8 +48,12 @@
 #include "al_mgr.h"
 #include <complib/cl_math.h>
 #include "ib_common.h"
+#ifdef NTDDI_WIN8
+#include <ntstrsafe.h>
+#else
+#include <strsafe.h>
+#endif
 
-#include <strsafe.h>
 #include <winerror.h>
 
 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/inc/kernel/complib/cl_spinlock_osd.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/inc/kernel/complib/cl_spinlock_osd.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/inc/kernel/complib/cl_spinlock_osd.h	(revision 8250)
@@ -109,7 +109,7 @@
 __drv_at(p_spinlock->lock, __drv_releasesExclusiveResource(KSPIN_LOCK))
 __drv_at(p_spinlock->irql, __drv_restoresIRQL)
 #endif
-#pragma prefast(suppress: 28157, "The irql level remains the same and equals to DISPATH_LEVEL")
+#pragma prefast(suppress: 28157, "The irql level remains the same if restored from DISPATH_LEVEL")
 CL_INLINE void cl_spinlock_release(
 	IN	cl_spinlock_t* const	p_spinlock )
 {
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/l2w/l2w_precomp.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/l2w/l2w_precomp.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/l2w/l2w_precomp.h	(revision 8250)
@@ -10,7 +10,6 @@
 
 #include <stdarg.h>
 #include <string.h>
-#include <strsafe.h>
 #include <stdio.h>
 
 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c	(revision 8250)
@@ -228,6 +228,7 @@
 	struct mlx4_priv *priv = mlx4_priv(dev);
 	struct mlx4_slave_state *ctx = &priv->mfunc.master.slave_state[slave];
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	UNUSED_PARAM(inbox);
 	UNUSED_PARAM(outbox);
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/qp.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/qp.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/qp.c	(revision 8250)
@@ -443,6 +443,7 @@
 {
     struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
     unsigned long flags;
+	UNUSED_PARAM(flags);
 
     spin_lock_irqsave(&qp_table->lock, &flags);
     radix_tree_delete(&dev->qp_table_tree, qp->qpn & (dev->caps.num_qps - 1));
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c	(revision 8250)
@@ -51,6 +51,7 @@
 int mlx4_dispatch_reset_event(struct ib_device *ibdev, enum ib_event_type type)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	struct ib_event event;
 	struct ib_event_handler *handler;
 	int num_notified_childs = 0;
@@ -99,6 +100,7 @@
 static void get_event_handlers(struct ib_device *device, struct list_head *tlist)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	struct ib_event_handler *handler, *thandler;
 
 	spin_lock_irqsave(&device->event_handler_lock, &flags);
@@ -263,6 +265,7 @@
 {
 	int n_not_ready = 0;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	struct ib_event_handler *handler;
 	struct ib_device *ibdev = event_handler->device;
 
@@ -286,6 +289,7 @@
 int mlx4_reset_ready( struct ib_event_handler *event_handler )
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	struct ib_device *ibdev = event_handler->device;
 
 	ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
@@ -396,6 +400,7 @@
 	struct mlx4_dev *dev;
 
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	ibdev = event_handler->device;
 	if (ibdev == NULL)
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/device.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/device.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/device.c	(revision 8250)
@@ -202,7 +202,7 @@
 {
 	struct ib_client_data *context;
 	unsigned long flags;
-
+	UNUSED_PARAM(flags);
 	context = (ib_client_data *)kmalloc(sizeof *context, GFP_KERNEL);
 	if (!context) {
 		MLX4_PRINT(TRACE_LEVEL_WARNING, MLX4_DBG_DRV,( "Couldn't allocate client context for %s/%s\n",
@@ -337,6 +337,7 @@
 	struct ib_client *client;
 	struct ib_client_data *context, *tmp;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	if(device->reg_state != ib_device::IB_DEV_REGISTERED) {
 		ASSERT(device->reg_state == ib_device::IB_DEV_REGISTERED);
@@ -422,6 +423,7 @@
 	struct ib_client_data *context, *tmp;
 	struct ib_device *device;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	mutex_lock(&device_mutex);
 
@@ -456,6 +458,7 @@
 	struct ib_client_data *context;
 	void *ret = NULL;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	spin_lock_irqsave(&device->client_data_lock, &flags);
 	list_for_each_entry(context, &device->client_data_list, list, struct ib_client_data)
@@ -483,6 +486,7 @@
 {
 	struct ib_client_data *context;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	spin_lock_irqsave(&device->client_data_lock, &flags);
 	list_for_each_entry(context, &device->client_data_list, list, struct ib_client_data)
@@ -511,6 +515,7 @@
 int ib_register_event_handler  (struct ib_event_handler *event_handler)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	spin_lock_irqsave(&event_handler->device->event_handler_lock, &flags);
 	list_add_tail(&event_handler->list,
@@ -531,6 +536,7 @@
 int ib_unregister_event_handler(struct ib_event_handler *event_handler)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	spin_lock_irqsave(&event_handler->device->event_handler_lock, &flags);
 	list_del(&event_handler->list);
@@ -552,6 +558,7 @@
 void ib_dispatch_event(struct ib_event *event)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	struct ib_event_handler *handler;
 	u8 port_num = event->element.port_num;
 	struct ib_device *ibdev = event->device;
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c	(revision 8250)
@@ -84,7 +84,8 @@
 	union ib_gid cgid;
 	struct ib_gid_cache *cache;
 	unsigned long flags;
-
+	UNUSED_PARAM(flags);
+	
 	if (mlx4_is_barred(device->dma_device))
 		return -EFAULT;
 
@@ -115,6 +116,7 @@
 {
 	struct ib_gid_cache *cache;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int p, i;
 
 	if (mlx4_is_barred(device->dma_device))
@@ -155,6 +157,7 @@
 	struct ib_pkey_cache *cache;
 	__be16 cpkey;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	if (mlx4_is_barred(device->dma_device))
 		return -EFAULT;
@@ -186,6 +189,7 @@
 {
 	struct ib_pkey_cache *cache;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int i;
 
 	if (mlx4_is_barred(device->dma_device))
@@ -221,6 +225,7 @@
 		      u8                *lmc)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	u8 clmc;
 	int ret = 0;
 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/inc/doorbell.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/inc/doorbell.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/inc/doorbell.h	(revision 8250)
@@ -71,6 +71,7 @@
 				spinlock_t *doorbell_lock)
 {
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 
 	spin_lock_irqsave(doorbell_lock, &flags);
 	__raw_writel((__force u32) val[0], dest);
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/cq.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/cq.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/cq.c	(revision 8250)
@@ -629,6 +629,7 @@
 	struct mlx4_ib_cq *cq = to_mcq(ibcq);
 	struct mlx4_ib_qp *cur_qp = NULL;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int npolled;
 	int err = 0;
 
@@ -658,6 +659,7 @@
 	struct mlx4_ib_cq *cq = to_mcq(ibcq);
 	struct mlx4_ib_qp *cur_qp = NULL;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int err = 0;
 	int npolled = 0;
 	ib_wc_t		*wc_p, **next_pp;
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/srq.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/srq.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/srq.c	(revision 8250)
@@ -329,6 +329,7 @@
 	struct mlx4_wqe_srq_next_seg *next;
 	struct mlx4_wqe_data_seg *scat;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int err = 0;
 	int nreq;
 	int i;
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/qp.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/qp.c	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/ib/qp.c	(revision 8250)
@@ -2012,6 +2012,7 @@
 	struct mlx4_wqe_ctrl_seg *ctrl = NULL;
 	struct mlx4_wqe_data_seg *dseg;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int nreq;
 	int err = 0;
 	int ind;
@@ -2336,6 +2337,7 @@
 	struct mlx4_ib_qp *qp = to_mqp(ibqp);
 	struct mlx4_wqe_data_seg *scat;
 	unsigned long flags;
+	UNUSED_PARAM(flags);
 	int err = 0;
 	int nreq;
 	int ind;
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/inc/l2w_spinlock.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/inc/l2w_spinlock.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/inc/l2w_spinlock.h	(revision 8250)
@@ -103,23 +103,9 @@
 
 #define DEFINE_SPINLOCK(lock)		spinlock_t lock
 
-static inline void
-spin_lock_irqsave( 
-	IN		spinlock_t* const	l,
-	IN		unsigned long 	*	flags)
-{
-	UNUSED_PARAM(flags);
-	spin_lock(l);
-}
 
-static inline void
-spin_unlock_irqrestore( 
-	IN		spinlock_t* const	l,
-	IN		unsigned long 		flags)
-{
-	UNUSED_PARAM(flags);
-	spin_unlock(l);
-}
+#define spin_lock_irqsave(_lock_, flags) cl_spinlock_acquire((cl_spinlock_t *)(_lock_))
+#define spin_unlock_irqrestore(_lock_, flags) cl_spinlock_release((cl_spinlock_t *)(_lock_))
 
 static inline void
 spin_lock_sync( 
@@ -138,8 +124,8 @@
 
 /* Windows doesn't support such kind of spinlocks so far, but may be tomorrow ... */
 #define rwlock_init							spin_lock_init
-#define read_lock_irqsave					spin_lock_irqsave
-#define read_unlock_irqrestore				spin_unlock_irqrestore
+#define read_lock_irqsave(lock, flags) 		cl_spinlock_acquire(lock)
+#define read_unlock_irqrestore(lock, flags) cl_spinlock_release(lock)
 #define write_lock_irq						spin_lock_irq
 #define write_unlock_irq					spin_unlock_irq
 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_utils.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_utils.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_utils.h	(revision 8250)
@@ -587,12 +587,18 @@
 #ifdef NTDDI_WIN8   
     _IRQL_requires_max_(DISPATCH_LEVEL)
     _IRQL_raises_(DISPATCH_LEVEL)
+    __drv_at(m_SpinLock, __drv_acquiresExclusiveResource(KSPIN_LOCK))
+    __drv_at(m_OldIrql, __drv_savesIRQL)
 #endif    
     void Lock() 
     {
         KeAcquireSpinLock(&m_SpinLock, &m_OldIrql);
     }
 
+#ifdef NTDDI_WIN8   
+        __drv_at(m_SpinLock, __drv_releasesExclusiveResource(KSPIN_LOCK))
+        __drv_at(m_OldIrql, __drv_restoresIRQL)
+#endif 
     void Unlock() 
     {
         KIRQL  OldIrql = m_OldIrql;
@@ -600,6 +606,7 @@
 #if DBG        
         m_OldIrql = 0xff;
 #endif
+#pragma prefast(suppress: 28151, "oldIrql can't get invalid IRQL value (0xFF) because it's always set in Lock")
         KeReleaseSpinLock(&m_SpinLock, OldIrql);
     }
 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_precomp.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_precomp.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/genutils/gu_precomp.h	(revision 8250)
@@ -23,7 +23,9 @@
 #include <stdio.h>
 #include <WinDef.h>
 #include <ntstrsafe.h>
+#ifndef NTDDI_WIN8
 #include <strsafe.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 extern "C" {
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mthca/kernel/mt_spinlock.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mthca/kernel/mt_spinlock.h	(revision 8249)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mthca/kernel/mt_spinlock.h	(revision 8250)
@@ -1,6 +1,10 @@
 #ifndef MT_SPINLOCK_H
 #define MT_SPINLOCK_H
+#pragma once
 
+#include <complib/cl_spinlock.h>
+
+
 typedef struct spinlock {
 	KSPIN_LOCK			lock;
 
@@ -129,15 +133,17 @@
 #define spin_unlock_irq 					spin_unlock
 
 /* no diff in Windows */
-#define spin_lock_irqsave 				spin_lock_irq
-#define spin_unlock_irqrestore 			spin_unlock_irq
+#define spin_lock_irqsave (lock, flags) cl_spinlock_acquire(lock)
+#define spin_unlock_irqrestore (lock, flags) cl_spinlock_release(lock)
 
+
 /* Windows doesn't support such kind of spinlocks so far, but may be tomorrow ... */
-#define rwlock_init						spin_lock_init
-#define read_lock_irqsave				spin_lock_irqsave
-#define read_unlock_irqrestore			spin_unlock_irqrestore
-#define write_lock_irq					spin_lock_irq
+#define rwlock_init							spin_lock_init
+#define read_lock_irqsave(lock, flags) 		cl_spinlock_acquire(lock)
+#define read_unlock_irqrestore(lock, flags) cl_spinlock_release(lock)
+#define write_lock_irq						spin_lock_irq
 #define write_unlock_irq					spin_unlock_irq
 
+
 #endif
 

