]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/log
pvdrivers/win/xenvbd.git
6 years agoUpdate Xen header files
Paul Durrant [Mon, 4 Jun 2018 13:19:52 +0000 (14:19 +0100)]
Update Xen header files

The original patch from Owen contained too much whitespace damage. This
patch replaces it with the results of an invocation of get_xen_headers.py
and includes all resulting header updates.

NOTE: This patch adds one extra header (physdev.h) and a fix to remove
      now-duplicate definitions of DOMID_INVALID from frontend.c.

Suggested-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix line endings
Paul Durrant [Mon, 4 Jun 2018 13:18:58 +0000 (14:18 +0100)]
Fix line endings

Some CRLF nastiness seems to have crept in.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAbort any partially completed SRBs
Owen Smith [Tue, 10 Apr 2018 10:51:18 +0000 (11:51 +0100)]
Abort any partially completed SRBs

When disabling, a SRB may be comprised of requests that have been
prepared and completed. Set the SrbStatus as early as possible, so
that any partially completed SRB is always failed.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove FreshSrbs queue
Owen Smith [Tue, 10 Apr 2018 10:48:38 +0000 (11:48 +0100)]
Remove FreshSrbs queue

Any SRB that fails to prepare will be completed with SRB_STATUS_BUSY,
so that storport can manage the queue. SRBs are prepared in the StartIo
handler, and appended to the PreparedReqs queue. All possible PreparedReqs
are submitted, and if there is more PreparedReqs, the DPC is triggered to
submit more when possible.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoPass SrbExt to RingPrepare* calls
Owen Smith [Tue, 10 Apr 2018 10:45:40 +0000 (11:45 +0100)]
Pass SrbExt to RingPrepare* calls

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRationalize WasQueued semantics
Owen Smith [Tue, 10 Apr 2018 10:41:37 +0000 (11:41 +0100)]
Rationalize WasQueued semantics

Several functions return values were inverted in the call stack,
Fix the meaning of TRUE/FALSE all through the call stack for submitting
requests

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoUse a threaded DPC for ring processing
Owen Smith [Tue, 13 Feb 2018 16:58:28 +0000 (16:58 +0000)]
Use a threaded DPC for ring processing

The current DPC back-off mechanism uses a timer to reschedule long
running DPCs. Timers seem to always have a minimum tick period, so
rescheduled DPCs always have an additional level of latency.
Using a threaded DPC (which executes at PASSIVE_LEVEL) will allow
other drivers to interrupt the vbd DPC, and maintain system
responsiveness. Once the vbd's DPC can be pre-empted by another
DPC, a DPC back-off mechanism is no longer required.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoDo more optimization in release builds and add /Qspectre flag
Paul Durrant [Mon, 29 Jan 2018 17:18:00 +0000 (17:18 +0000)]
Do more optimization in release builds and add /Qspectre flag

Spectre mitigations apparently only work on optimized code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd support for building with Visual Studio 2017
Paul Durrant [Mon, 29 Jan 2018 17:09:32 +0000 (17:09 +0000)]
Add support for building with Visual Studio 2017

Also remove mappings for obsolete versions of VS in build.py.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoMake sure Mdl->StartVa is set by __AllocatePages()
Paul Durrant [Thu, 25 Jan 2018 13:37:22 +0000 (13:37 +0000)]
Make sure Mdl->StartVa is set by __AllocatePages()

wdm.h carries this comment:

// Notice that while in the context of the subject thread, the base virtual
// address of a buffer mapped by an MDL may be referenced using the
// following:
//
//      Mdl->StartVa | Mdl->ByteOffset
//

Hence it is important that a mapped MDL has a valid StartVa field as well
as a valid MappedSystemVa field. Unfortunately, for reasons best known to
Microsoft, MmMapLockedPagesSpecifyCache() does not ensure this is the
case, so it needs to be fixed up by __AllocatePages() itself.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoStop trying to parse a target structure as a text string
Paul Durrant [Mon, 23 Oct 2017 16:43:13 +0000 (17:43 +0100)]
Stop trying to parse a target structure as a text string

The Verbose() logging call in TargetCreate() is using %s where is means %p.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoReport Inquiry 0xB0 BlockLimits
Owen Smith [Mon, 23 Oct 2017 16:35:33 +0000 (17:35 +0100)]
Report Inquiry 0xB0 BlockLimits

Reports discard-alignment and discard-granularity

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRationalize SCSIOP_* handlers
Owen Smith [Mon, 23 Oct 2017 16:33:52 +0000 (17:33 +0100)]
Rationalize SCSIOP_* handlers

* Use same error handling for invalid buffers, etc.
* Allow for SCSIOP_MODE_SENSE10
* Correctly report VDISK_READONLY flag

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoZero ring stats before ASSERTing ring struct is zeroed
Owen Smith [Mon, 23 Oct 2017 16:29:00 +0000 (17:29 +0100)]
Zero ring stats before ASSERTing ring struct is zeroed

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove unused code and general tidy up
Owen Smith [Mon, 23 Oct 2017 16:27:45 +0000 (17:27 +0100)]
Remove unused code and general tidy up

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove RingReQueueRequests
Owen Smith [Mon, 23 Oct 2017 16:22:38 +0000 (17:22 +0100)]
Remove RingReQueueRequests

Since the Frontend transitions the ring through Closed and back to
Enabled on a resume from suspend, which aborts all queued and
prepared requests, de-queueing and re-queuing all requests from the
Target suspend callback is unneccessary. Also removes the Target
suspend callback and interface which is now unused.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoFix BSOD on shutdown due to freeing NULL pointer
Paul Durrant [Mon, 2 Oct 2017 10:07:45 +0000 (11:07 +0100)]
Fix BSOD on shutdown due to freeing NULL pointer

Unfortunately ExFreePoolWithTag() is not NULL-safe, and Base64Free() is
coded assuming it is. This patch adds an extra check for NULL to fix the
problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoUse CACHE interface for REQUESTs, SEGMENTs and INDIRECTs
Owen Smith [Fri, 29 Sep 2017 16:23:31 +0000 (17:23 +0100)]
Use CACHE interface for REQUESTs, SEGMENTs and INDIRECTs

Replaces the ExLookasideList* calls with CACHE interface.
This allows the INDIRECT object constructor to allocate the indirect
page, and not allocate the indirect page on every object retrieval.
Also defers the indirect page free until the object is destroyed, and
not on every object put.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoTidy up srbext.h
Owen Smith [Fri, 29 Sep 2017 16:15:39 +0000 (17:15 +0100)]
Tidy up srbext.h

* reorders struct definitions
* remove inline functions and unneccessary headers
* replace Request.Id with (ULONG64)(ULONG_PTR)Request

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd override for MaxRingPageOrder
Owen Smith [Fri, 29 Sep 2017 15:58:13 +0000 (16:58 +0100)]
Add override for MaxRingPageOrder

Allow a Windows admin to limit the ring page count without
affecting any other VMs on the host. The override can be used
to restrict blkback's generous 16 page ring to a smaller value.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoUse CACHE interface for bounce buffers
Owen Smith [Fri, 29 Sep 2017 15:45:27 +0000 (16:45 +0100)]
Use CACHE interface for bounce buffers

When the incomming read/write buffer is not aligned, the data needs
bouncing via a page-aligned buffer. Use the CACHE interface to provide
this buffer instead of a custom lookaside collection. Also moves the
storage for mapping the source buffers to the bounce buffer structure,
which will reduce the allocation size of the segments used on the fast
path (aligned buffers). The Indirect pages are also pre-allocated in the
object construction, and not for every object retrieval, and likewise
indirect pages are only freed on object destruction, and not for every
object put.
This will remove the log spam caused by the custom implementation.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoQuery for CACHE interface
Owen Smith [Fri, 29 Sep 2017 15:19:48 +0000 (16:19 +0100)]
Query for CACHE interface

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd missing Verbose() format argument
Owen Smith [Mon, 25 Sep 2017 09:06:59 +0000 (10:06 +0100)]
Add missing Verbose() format argument

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove generic store accessors in frontend
Owen Smith [Fri, 22 Sep 2017 12:24:37 +0000 (13:24 +0100)]
Remove generic store accessors in frontend

Replace with specific use functions.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove Inquiry handling into target.c
Owen Smith [Fri, 22 Sep 2017 12:18:34 +0000 (13:18 +0100)]
Move Inquiry handling into target.c

Removes pdoinquiry.[ch] and its opaque inquiry pointer in favour of
making target.c the location of all target SRB handlers.
Removes a XenServer specific extension to the page83 inquiry data.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoTidy up GranterDebugCallback
Owen Smith [Fri, 22 Sep 2017 12:12:21 +0000 (13:12 +0100)]
Tidy up GranterDebugCallback

Make the granter register for its own debug callback, rather than it
being called from the frontend debug callback.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoTidy up FrontendDebugCallback
Owen Smith [Fri, 22 Sep 2017 12:05:56 +0000 (13:05 +0100)]
Tidy up FrontendDebugCallback

Make the frontend register for its own debug callback, rather than it
being called from the target debug callback.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove request prepare/cleanup to ring
Owen Smith [Fri, 22 Sep 2017 12:01:29 +0000 (13:01 +0100)]
Move request prepare/cleanup to ring

Keep the blkif protocol related functions in ring.[ch]. Keep target.[ch]
related to SCSI operations

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoUse macros for Frontend data accessors
Owen Smith [Fri, 22 Sep 2017 11:22:44 +0000 (12:22 +0100)]
Use macros for Frontend data accessors

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMerge Notifier and BlockRing into Ring
Owen Smith [Fri, 22 Sep 2017 11:57:38 +0000 (12:57 +0100)]
Merge Notifier and BlockRing into Ring

Remove the seperation between the event channel and shared ring.
Fixes the debug callback and adds more error messages.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd DPC timeout check
Owen Smith [Mon, 21 Aug 2017 14:37:00 +0000 (15:37 +0100)]
Add DPC timeout check

Check the DPC has not exceeded 1/2 its alloted time every
* 1/4 ring of responses processed
* all outstanding prepared requests submitted
* 1 queued SRB prepared

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdded a function called from DriverEntry where...
Eric Mackay [Wed, 28 Jun 2017 13:54:56 +0000 (14:54 +0100)]
Added a function called from DriverEntry where...

we can safely read registry keys and convert strings at PASSIVE_LEVEL

The MSDN documentation for various registry key access and string
conversion functions requires the caller to be at PASSIVE_LEVEL.
One of the reasons for this is that the string conversion tables used by
functions such as RtlAnsiStringToUnicodeString are stored in paged pool
memory. Both the page fault handler and the process scheduler run at
DISPATCH_LEVEL, therefore you must not touch memory at DISPATCH_LEVEL that
could be paged out. A process running at DISPATCH_LEVEL cannot be
preempted for the page fault handler to run.

To aid Static Driver Verifier code analysis and inform developers, I have
added SAL annotations that indicate PASSIVE_LEVEL is required on certain
registry access functions.

Signed-off-by: Eric Mackay <mackayem@amazon.com>
Re-based onto master and adjusted for style. Note this involved fixing
whitespace issues in frontend.c.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---

v2:
 - Remove unused FeatureName array
 - Make more use of const qualifier for override name

7 years agoMake sure AdapterInitialize is called at PASSIVE_LEVEL
Paul Durrant [Wed, 28 Jun 2017 15:32:45 +0000 (16:32 +0100)]
Make sure AdapterInitialize is called at PASSIVE_LEVEL

AdapterHwFindAdapter() can be called at DISPATCH_LEVEL and therefore it
is not safe to call AdapterInitialize() directly from there.

This patch, instead, calls StorPortEnablePassiveInitialization() from
AdapterHwInitialize() to request a PASSIVE_LEVEL initialization routine
is called immediately after AdapterHwFindAdapter() so that
AdapterInitialize() can be called from there.

Suggested-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoTidy up target.h
Owen Smith [Thu, 22 Jun 2017 08:52:15 +0000 (09:52 +0100)]
Tidy up target.h

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove suspend callback into target.c
Owen Smith [Wed, 21 Jun 2017 15:44:04 +0000 (16:44 +0100)]
Move suspend callback into target.c

Remove chained call from adapter.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoScope TargetDebugCallback in target.c
Owen Smith [Wed, 21 Jun 2017 14:31:30 +0000 (15:31 +0100)]
Scope TargetDebugCallback in target.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRefactor target.c
Owen Smith [Wed, 21 Jun 2017 14:21:20 +0000 (15:21 +0100)]
Refactor target.c

* Adds property accessors
* Moves PNP SRB handler to adapter.c
* Streamlines header

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRefactor BuildIo and StartIo calls
Owen Smith [Wed, 21 Jun 2017 12:36:43 +0000 (13:36 +0100)]
Refactor BuildIo and StartIo calls

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove scatter gather list parsing to adapter.c
Owen Smith [Wed, 21 Jun 2017 10:15:56 +0000 (11:15 +0100)]
Move scatter gather list parsing to adapter.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoInline MapSegmentBuffer()
Owen Smith [Tue, 20 Jun 2017 16:20:37 +0000 (17:20 +0100)]
Inline MapSegmentBuffer()

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoPass PXENVBD_SRBEXT, not PSCSI_REQUEST_BLOCK
Owen Smith [Tue, 20 Jun 2017 16:10:03 +0000 (17:10 +0100)]
Pass PXENVBD_SRBEXT, not PSCSI_REQUEST_BLOCK

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove StorPort*() calls to adapter.c
Owen Smith [Tue, 20 Jun 2017 14:17:10 +0000 (15:17 +0100)]
Move StorPort*() calls to adapter.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove unused code
Owen Smith [Mon, 19 Jun 2017 09:09:48 +0000 (10:09 +0100)]
Remove unused code

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoFix SDV
Paul Durrant [Wed, 31 May 2017 10:07:18 +0000 (11:07 +0100)]
Fix SDV

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRefactor Adapter.c
Owen Smith [Wed, 5 Apr 2017 15:33:21 +0000 (16:33 +0100)]
Refactor Adapter.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoTidy up Driver.h/.c
Owen Smith [Wed, 5 Apr 2017 13:05:36 +0000 (14:05 +0100)]
Tidy up Driver.h/.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRename Pdo -> Target
Owen Smith [Wed, 5 Apr 2017 12:35:36 +0000 (13:35 +0100)]
Rename Pdo -> Target

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRename Fdo -> Adapter
Owen Smith [Wed, 5 Apr 2017 12:23:39 +0000 (13:23 +0100)]
Rename Fdo -> Adapter

Also remove reference counts

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRemove VS2012 and VS2013 build scripts
Paul Durrant [Thu, 18 May 2017 14:12:26 +0000 (15:12 +0100)]
Remove VS2012 and VS2013 build scripts

This patch removes the scripts for building under VS2013 and VS2013 and
also fixes the package destination when building using VS2015.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoReboot request keys should be volatile
Paul Durrant [Mon, 8 May 2017 16:09:02 +0000 (17:09 +0100)]
Reboot request keys should be volatile

When a driver makes a reboot request it should use a volatile registry key.
The monitor service will explicitly remove the key prior to reboot but,
if the reboot is initiated in some other way and the key is non-volatile,
the monitor service will then needlessly prompt for a second reboot.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoTake notice of 'discard-enable' in xenstore
Andreas Kinzler [Mon, 20 Feb 2017 14:09:04 +0000 (14:09 +0000)]
Take notice of 'discard-enable' in xenstore

When enabling discard in the frontend, both the 'feature-discard' and
'discard-enable' flags should be taken into account.

Signed-off-by: Andreas Kinzler <ml-ak@posteo.de>
[Added commit comment]
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix race setting SrbStatus
Paul Durrant [Mon, 20 Feb 2017 14:03:50 +0000 (14:03 +0000)]
Fix race setting SrbStatus

SrbStatus needs to be set to PENDING right at the beginning of the
prepare functions, before the SRB has been added to any queue, otherwise
we risk a race with the completion code.

Reported-by: Andreas Kinzler <ml-ak@posteo.de>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix race calculating SrbExt->Count
Owen Smith [Fri, 17 Feb 2017 15:29:35 +0000 (15:29 +0000)]
Fix race calculating SrbExt->Count

It is possible under heavy loads for the backend to
start completing sub-requests of a Srb before the
SrbExt Count is set. This would leave the count unable
to reach 0 (as 1 or more requests are skipped by count
being overridden)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoEnsure event channel is unmasked
Owen Smith [Fri, 17 Feb 2017 15:27:03 +0000 (15:27 +0000)]
Ensure event channel is unmasked

If the Pdo is paused, the notifier dpc will not
unmask the event channel. When the Pdo is unpaused, the
event channel remains masked, so no more interrupts
get delivered.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoAdd registry overrides for features
Owen Smith [Fri, 3 Feb 2017 14:03:52 +0000 (14:03 +0000)]
Add registry overrides for features

Add a REG_DWORD to XenVbd's Parameters key, with names based
on the features, as per xenstore value, and set to 0 to
override use of that feature.

For example,
 "HKLM\System\CCS\Services\XenVbd\Parameters" "feature-barrier" 0
  will prevent the frontend issuing BLKIF_OP_WRITE_BARRIERs
 "HKLM\System\CCS\Services\XenVbd\Parameters" "feature-discard" 0
  will prevent the frontend issuing BLKIF_OP_DISCARDs

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoSquashing build warnings is not enough for SDV
Paul Durrant [Fri, 6 Jan 2017 15:58:09 +0000 (15:58 +0000)]
Squashing build warnings is not enough for SDV

An ASSERT will hopefully keep it quiet.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix SDV error
Paul Durrant [Fri, 6 Jan 2017 15:13:08 +0000 (15:13 +0000)]
Fix SDV error

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSquash build warning
Paul Durrant [Fri, 6 Jan 2017 15:03:07 +0000 (15:03 +0000)]
Squash build warning

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUnify the three variants of util.h
Paul Durrant [Fri, 6 Jan 2017 14:54:00 +0000 (14:54 +0000)]
Unify the three variants of util.h

The new header is placed a new src/common sub-directory.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix memory leak in __FreePages()
Paul Durrant [Fri, 6 Jan 2017 13:02:32 +0000 (13:02 +0000)]
Fix memory leak in __FreePages()

The pool memory for the MDL also needs to be freed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix pool leaks exposed by DriverVerifier
Owen Smith [Fri, 6 Jan 2017 12:02:55 +0000 (12:02 +0000)]
Fix pool leaks exposed by DriverVerifier

* RegistryCloseKey was not called in DriverRequestReboot
* RegistryTeardown was not being called in DriverUnload
* __RegistryFree was not being called in RegistryCreateKey
* Reordered DriverEntry slightly for improved code consistancy

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoMake sure we don't leave SRBs in state PENDING
Paul Durrant [Fri, 16 Dec 2016 15:39:45 +0000 (15:39 +0000)]
Make sure we don't leave SRBs in state PENDING

When we fail to prepare an SRB, it should not be left in state PENDING
otherwise Windows will expect a completion at some point.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix packaging bug
Paul Durrant [Thu, 15 Dec 2016 10:43:19 +0000 (10:43 +0000)]
Fix packaging bug

The xenvbd.inf file was missing from the package

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove spurious FORCEINLINE
Paul Durrant [Wed, 14 Dec 2016 17:28:27 +0000 (17:28 +0000)]
Remove spurious FORCEINLINE

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd missing files
Paul Durrant [Wed, 14 Dec 2016 17:28:05 +0000 (17:28 +0000)]
Add missing files

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate BUILD.md with VS2015/WDK10 information
Paul Durrant [Wed, 14 Dec 2016 16:29:21 +0000 (16:29 +0000)]
Update BUILD.md with VS2015/WDK10 information

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFixes for VS2015/WDK10 build
Paul Durrant [Wed, 14 Dec 2016 16:13:10 +0000 (16:13 +0000)]
Fixes for VS2015/WDK10 build

The package build was not working correctly and caused the overall build
to fail.
At least part of the reason for this is that Microsoft, in their infinite
wisdom, have removed the DIFx redist from WDK10. This patch makes use of
a new environment variable 'DPINST_REDIST' to find the copy of dpinst.exe
to package such that this can be pointed at an older WDK or alternative
location where dpinst.exe can be found.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd support for building under VS2015/WDK10
Paul Durrant [Tue, 13 Dec 2016 14:55:25 +0000 (14:55 +0000)]
Add support for building under VS2015/WDK10

Moving to the new toolchain also threw up a few new warnings, which this
patch either fixes or squashes. Also, SDV appears to be fragile in new
ways (and whinge about some new things) so there are fixes for that too.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate driver version from 8.2.0 to 9.0.0
Paul Durrant [Tue, 13 Dec 2016 10:48:23 +0000 (10:48 +0000)]
Update driver version from 8.2.0 to 9.0.0

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't disconnect/connect ring when target is reset 8.2.0-rc1
Owen Smith [Fri, 9 Dec 2016 10:54:35 +0000 (10:54 +0000)]
Don't disconnect/connect ring when target is reset

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoAdd registry override to prevent interception of Trim requests
Paul Durrant [Tue, 6 Dec 2016 17:16:22 +0000 (17:16 +0000)]
Add registry override to prevent interception of Trim requests

Add a REG_DWORD called 'InterceptTrim' to XENDISK's parameters key
(now created by xenvbd.inf). Set the value to zero to disable Trim
interception.

This patch also adds registry code to XENDISK, brings util.h up to date,
and fixes some cosmetic issues in thread.c.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSucceed SRBs that the backend doesnt support
Owen Smith [Mon, 5 Dec 2016 15:58:46 +0000 (15:58 +0000)]
Succeed SRBs that the backend doesnt support

If the backend does not support BLKIF_OP_DISCARD, BLKIF_OP_WRITE_BARRIER,
or BLKIF_OP_FLUSH_DISKCACHE, the first request will be failed and
subsiquent requests will be succeeded instead of being passed to the
backend. Bring the SRB status into line in both of these situations.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Remove rather scary warning and instead log any features being disabled.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSend BLKIF_OP_FLUSH_DISKCACHE
Owen Smith [Tue, 22 Nov 2016 15:09:55 +0000 (15:09 +0000)]
Send BLKIF_OP_FLUSH_DISKCACHE

If the backend supports flush, send BLKIF_OP_FLUSH_DISKCACHE in
response to SCSIOP_SYNCHRONIZE_CACHE, and advertise the cache
to Windows. Also tracks count of cache operations. If the backend
does not support flush, but supports barrier, send
BLKIF_OP_WRITE_BARRIER instead, but do not advertise the cache to
Windows, as its assumed the backend will guarantee writes are
flushed if the storage requires flushing.

8 years agoRead backend features and disk info before setting Connected
Owen Smith [Tue, 22 Nov 2016 15:08:29 +0000 (15:08 +0000)]
Read backend features and disk info before setting Connected

Setting connected should be the last step of the connection
state transitions.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoFix VS2012 build
Paul Durrant [Thu, 3 Nov 2016 11:14:48 +0000 (11:14 +0000)]
Fix VS2012 build

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix build warnings
Paul Durrant [Thu, 3 Nov 2016 10:42:25 +0000 (10:42 +0000)]
Fix build warnings

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoMake use of the 'physical-sector-size' reported by the backend
Paul Durrant [Thu, 6 Oct 2016 13:48:09 +0000 (14:48 +0100)]
Make use of the 'physical-sector-size' reported by the backend

blkif backends can report a 'physical-sector-size' as will as
'sector-size'. XENVBD currently reads this xenstore key but does
nothing with the value. This patch makes use of the value to set the
LogicalPerPhysicalExponent field in the READ_CAPACITY16_DATA structure
which is populated in response to a SCSIOP_READ_CAPACITY16 CDB.

The patch also modifies XENDISK to discover the logical block size by
sending a SCSIOP_READ_CAPACITY16 rather than relying on an IOCTL to
query StorageAccessAlignmentProperty being sent down the stack and
succeeded by STORPORT (which does not seem to be the case for Windows 10).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't include null terminator in synthesized VendorId identifier
Owen Smith [Mon, 3 Oct 2016 07:31:44 +0000 (08:31 +0100)]
Don't include null terminator in synthesized VendorId identifier

The VendorId identifier on SCSI page 83 is 16 bytes long (+header).
When synthesizing the inquiry data, either by global flag, or missing
xenstore data (sm-data/scsi/0x12/0x83), the NULL terminator on the
VendorId should not be included in the field. When this happens, any
query will decode 3 identifiers (VendorId, EUI64, VendorSpecific) instead
of the intended 2 (VendorId, VendorSpecific). This breaks the XenServer
VSS provider that uses the VendorSpecific identifier to retrieve the
vdi-uuid. This is only an issue when the inquiry data is synthesized and
additional identifiers are required, which is not a common use case.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoStop checked builds from crashing
Paul Durrant [Fri, 30 Sep 2016 12:50:26 +0000 (13:50 +0100)]
Stop checked builds from crashing

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoThe SOFTWARE registry hive is not accessible at boot time
Paul Durrant [Mon, 22 Aug 2016 07:44:36 +0000 (08:44 +0100)]
The SOFTWARE registry hive is not accessible at boot time

Hence it cannot be used for the monitor request key, otherwise XENVBD
cannot necessarily access it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate registry code
Paul Durrant [Fri, 19 Aug 2016 10:58:51 +0000 (11:58 +0100)]
Update registry code

Bring in new registry code from XENBUS to fix RegistryCreateKey()'s
semantics.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix SDV build
Paul Durrant [Wed, 17 Aug 2016 14:05:08 +0000 (15:05 +0100)]
Fix SDV build

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoCreate, rather than open, the RequestKey
Paul Durrant [Wed, 17 Aug 2016 13:34:14 +0000 (14:34 +0100)]
Create, rather than open, the RequestKey

It's possible that, on upgrade, XENVBD is installed before XENBUS and so
the RequestKey may not exist.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix typo
Paul Durrant [Tue, 9 Aug 2016 15:06:22 +0000 (16:06 +0100)]
Fix typo

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUse new monitor request key
Paul Durrant [Tue, 9 Aug 2016 14:19:29 +0000 (15:19 +0100)]
Use new monitor request key

The monitor service now uses a request key in registry under HKLM/SOFTWARE.
This patch modifies __DriverRequestReboot() to use the new key, which is
now set as a parameter by the INF file.

This patch also takes this opportunity to update the registry source module
to being it up to date with the XENBUS source base, and make wider use of it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoClean up the xenstore frontend area when hibernating/crashing
Paul Durrant [Tue, 2 Aug 2016 09:58:28 +0000 (10:58 +0100)]
Clean up the xenstore frontend area when hibernating/crashing

The frontend code in XENCRSH needs to clean up to avoid fooling the backend
into thinking it handles multi-page rings.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't send a NUL terminator to QEMU's debug port
Paul Durrant [Tue, 2 Aug 2016 09:56:23 +0000 (10:56 +0100)]
Don't send a NUL terminator to QEMU's debug port

Logging a NUL terminator via QEMU's debug port seems to upset upstream
QEMU. It's also unnecessary anyway as QEMU will break log lines at a
newline character.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove reboot request from the co-installer...
Paul Durrant [Fri, 22 Jul 2016 09:37:12 +0000 (10:37 +0100)]
Remove reboot request from the co-installer...

...and use the XENBUS_MONITOR service instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd the missing package name to the INF file
Paul Durrant [Thu, 21 Jul 2016 11:08:18 +0000 (12:08 +0100)]
Add the missing package name to the INF file

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRevert "Remove PdoPnpSrb, since StorPort doesn't call for targets"
Ben Chalmers [Tue, 12 Jul 2016 08:03:53 +0000 (09:03 +0100)]
Revert "Remove PdoPnpSrb, since StorPort doesn't call for targets"

This reverts commit 0f9f5421099d1dabed11d988b3144fb8f6bfed3b.

It appears that this code is called when determining if Windows
can remove a PV disk.  Without it Windows will not know the
disk is removable and will refuse to allow it to be removed

Signed-off-by: Ben.Chalmers@citrix.com
8 years agoOnly break FrontendBackend thread loop when alerted
Ben Chalmers [Mon, 11 Jul 2016 13:29:04 +0000 (14:29 +0100)]
Only break FrontendBackend thread loop when alerted

Returns a missed '!' character without which the FrontendBackend
thread exits immediately - rather than when we Alert the thread
that we wish it to exit

Signed-off-by : Ben.Chalmers@citrix.com

9 years agoFix compile errors
Paul Durrant [Mon, 9 May 2016 12:41:19 +0000 (13:41 +0100)]
Fix compile errors

Two variables were being initialized but not used, leading to a compiler
warning.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoRemove logging from failed Pdo Pnp IRPs
Owen Smith [Fri, 22 Apr 2016 10:29:31 +0000 (11:29 +0100)]
Remove logging from failed Pdo Pnp IRPs

Logging fail codes for unhandled Pnp IRPs is unneccesary and adds
significant noise with multiple VBDs. Its unlikely the return value
from storport is going to add significant insight to diagnose
problems.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoChange enumeration function to take PANSI_STRING array...
Owen Smith [Wed, 20 Apr 2016 15:43:11 +0000 (16:43 +0100)]
Change enumeration function to take PANSI_STRING array...

...to simplify parsing of the data returned by STORE(Directory)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoWrap all driver.c globals in a struct
Owen Smith [Wed, 20 Apr 2016 14:30:20 +0000 (15:30 +0100)]
Wrap all driver.c globals in a struct

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoCreate a seperate thread per VBD to handle backend change watches
Owen Smith [Tue, 19 Apr 2016 15:50:08 +0000 (16:50 +0100)]
Create a seperate thread per VBD to handle backend change watches

Using a single thread for all backend watch events pust unneccesary
strain on xenstore when multiple vbds are in use, as each change
causes XenVbd to check several values in all backend areas.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoDont create Pdo for emulated devices
Owen Smith [Tue, 19 Apr 2016 14:25:31 +0000 (15:25 +0100)]
Dont create Pdo for emulated devices

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoRework enumeration code to work at PASSIVE_LEVEL in the scan thread
Owen Smith [Tue, 19 Apr 2016 14:12:38 +0000 (15:12 +0100)]
Rework enumeration code to work at PASSIVE_LEVEL in the scan thread

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoRefactor Pnp/Power handlers
Owen Smith [Tue, 19 Apr 2016 10:28:15 +0000 (11:28 +0100)]
Refactor Pnp/Power handlers

Moves the mapping of DeviceObject to Pdo into the Fdo code

Signed-off-by: Owen Smith <owen.smith@citrix.com>
9 years agoSimplify StorPort entry points
Owen Smith [Tue, 19 Apr 2016 09:30:05 +0000 (10:30 +0100)]
Simplify StorPort entry points

Signed-off-by: Owen Smith <owen.smith@citrix.com>