]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/log
pvdrivers/win/xenvbd.git
5 years agoMAINTAINERS: Update my email address staging-9.0 9.0.0 9.0.0-rc1
Paul Durrant [Thu, 14 Nov 2019 10:11:28 +0000 (10:11 +0000)]
MAINTAINERS: Update my email address

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
5 years agoFix > 2TB disks
Owen Smith [Fri, 11 Oct 2019 13:51:10 +0000 (14:51 +0100)]
Fix > 2TB disks

In order to determine the size of a disk, Windows will issue a
SCSIOP_READ_CAPACITY. Disks larger than 2TB will respond with a max LBA
of 0xFFFFFFFF, which causes Windows to issue a SCSIOP_READ_CAPACITY16.
The read capacity 16 is passed with a 12 byte buffer to be filled in
using the READ_CAPACITY_DATA_EX structure, not the 16 or 32byte
(depending on packing) READ_CAPACITY16_DATA buffer.
Also adds Error labels to the failure conditions.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoTrack StartIo and Failed SRB counts
Owen Smith [Wed, 9 Oct 2019 19:07:24 +0000 (20:07 +0100)]
Track StartIo and Failed SRB counts

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoIncrease buffer size
Owen Smith [Wed, 9 Oct 2019 19:03:29 +0000 (20:03 +0100)]
Increase buffer size

sizeof("device/vbd/XXXXXXXX") is too small for some of the higher device
identifiers. Increase the size to allow for longer device ids.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoUpdate to the new version of the XENFILT_EMULATED interface
Paul Durrant [Wed, 2 Oct 2019 12:20:34 +0000 (13:20 +0100)]
Update to the new version of the XENFILT_EMULATED interface

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoFix LNK2005
Owen Smith [Mon, 23 Sep 2019 15:33:53 +0000 (16:33 +0100)]
Fix LNK2005

VS2019 project fails to link with LNK2005 for functions defined in
libcntpr.lib. Remove the unneccessary linker input.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd support for EWDK_19h1_release_svc_prod3_18362_190416-1111
Paul Durrant [Thu, 19 Sep 2019 09:56:59 +0000 (10:56 +0100)]
Add support for EWDK_19h1_release_svc_prod3_18362_190416-1111

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoMAINTAINERS: Update my email address
Paul Durrant [Thu, 19 Sep 2019 09:28:42 +0000 (10:28 +0100)]
MAINTAINERS: Update my email address

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoRemove the old python build scripts and document use of the EWDK
Paul Durrant [Thu, 19 Sep 2019 09:27:54 +0000 (10:27 +0100)]
Remove the old python build scripts and document use of the EWDK

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoAttempt to process responses on the ring
Owen Smith [Thu, 19 Sep 2019 08:44:15 +0000 (09:44 +0100)]
Attempt to process responses on the ring

When Disabling the ring, outstanding responses need to be completed.
Poll the ring to complete outstanding responses if the backend is still
connected and valid.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoRework BlkifRingDisable
Owen Smith [Thu, 19 Sep 2019 08:30:41 +0000 (09:30 +0100)]
Rework BlkifRingDisable

Clean up all prepared and submitted requests when the ring is disabled,
so that outstanding SRBs are returned to storport for queueing. This is
especially important on the return from suspend path, as the ring is no
longer valid, and any submitted requests would be lost and trigger a
storport target reset.
Also ignores missing requests for responses.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAttempt to process responses on the ring
Owen Smith [Thu, 19 Sep 2019 08:24:28 +0000 (09:24 +0100)]
Attempt to process responses on the ring

When Disabling the ring, outstanding responses need to be completed.
Poll the ring to complete outstanding responses if the backend is still
connected and valid.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoReplace XENVBD_SRB_STATE with LIST_ENTRY
Owen Smith [Wed, 18 Sep 2019 16:24:40 +0000 (17:24 +0100)]
Replace XENVBD_SRB_STATE with LIST_ENTRY

Dont treat the prepared queue differently to any other list.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoPrevent IsZeroMemory() ASSERTions when XENDISK shuts down
Paul Durrant [Wed, 18 Sep 2019 16:19:19 +0000 (17:19 +0100)]
Prevent IsZeroMemory() ASSERTions when XENDISK shuts down

Pdo->PhysSectorSize needs to be zeroed out.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoRework request submission
Owen Smith [Thu, 5 Sep 2019 15:29:04 +0000 (16:29 +0100)]
Rework request submission

Make BlkifRingPostRequests return success for submitting 0 or more requests,
or failure when the ring is full. This prevents the loop in
BlkifRingSchedule() from preparing the next SRB when the ring is already
full.
Also attempt to notify the backend of changes every iteration of the loop in
BlkifRingSchedule(), to trigger the backend as soon as possible.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoFix debug callback output
Owen Smith [Thu, 5 Sep 2019 08:57:31 +0000 (09:57 +0100)]
Fix debug callback output

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoUpdate rsp_event during BlkifRingPoll()
Owen Smith [Thu, 5 Sep 2019 08:42:38 +0000 (09:42 +0100)]
Update rsp_event during BlkifRingPoll()

Currently, by updating it in __BlkifRingPushRequests(), the code is
attempting to defer events until all of the posted requests have responses
on the ring. This is likely to lead to a cycle of fill...empty...fill...
empty etc., which is bad for performance.

This patch instead updates rsp_event when BlkifRingPoll() completes, such
that the very next response placed on the ring by the backend should
cause an event to be sent.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
[Expanded commit message]
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoRate limit BLKIF_OP failure log messages
Daniel Davis [Fri, 19 Jul 2019 09:10:31 +0000 (10:10 +0100)]
Rate limit BLKIF_OP failure log messages

Signed-off-by: Daniel Davis <Daniel.Davis@citrix.com>
5 years agoUse genfiles to set DriverVer
Owen Smith [Wed, 17 Jul 2019 12:55:30 +0000 (13:55 +0100)]
Use genfiles to set DriverVer

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd PowerShell build scripts, version.vcxproj
Owen Smith [Fri, 14 Jun 2019 15:42:49 +0000 (16:42 +0100)]
Add PowerShell build scripts, version.vcxproj

Based on the sequence of commits to xenbus, add powershell scripts to
build the solution using the EWDK
version.vcxproj generates versioned files (version.h and xenvbd.inf) using
scripts/genfiles.ps1
Strips duplicated functionality from build.py to produce consistant
builds between python and powershell.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd BUILD_NUMBER to reported version
Owen Smith [Fri, 14 Jun 2019 15:21:05 +0000 (16:21 +0100)]
Add BUILD_NUMBER to reported version

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoTry to avoid dumping non-RAM pages
Paul Durrant [Fri, 26 Apr 2019 08:53:34 +0000 (09:53 +0100)]
Try to avoid dumping non-RAM pages

When XENCRSH sets up blkif requests they may end up referring to PFNs that
are ballooned out. When these requests reach the backend driver, it will
unsurprisingly encounter failures when trying to map or copy the data from
these PFNs, generally resulting in the request as a whole being failed and
a lot of noise being emitted to various logs.

This patch adds a check into PrepareReadWrite() to check the P2M type of
PFNs being dumped. If the type is found to be anything other than writable
RAM then the PFN is substituted with a buffer PFN, which will just contain
zeroes. The storage backend will be able to map or copy these pages, so
stalls in the dump process and useless log messages will be avoided.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoReport disk size and logical sector size in XENDISK...
Paul Durrant [Tue, 9 Apr 2019 16:03:08 +0000 (17:03 +0100)]
Report disk size and logical sector size in XENDISK...

...rather than XENVBD.

This allows us to use the PDO name rather than the more obscure target
number. Also, report the size in MB rather rather than in sectors (now
that sector size may be something other than 512B).

Also fix some whitespace bugs while in the neighbourhood.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoGive XENDISK PDOs a name
Paul Durrant [Tue, 9 Apr 2019 15:45:19 +0000 (16:45 +0100)]
Give XENDISK PDOs a name

Use DeviceID/InstanceID to give PDOs a meaningful name that can be used
in log messages.

Also fix some whitespace bugs while in the neighbourhood.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoAdd 'feature-large-sector-size'
Paul Durrant [Fri, 5 Apr 2019 15:51:08 +0000 (16:51 +0100)]
Add 'feature-large-sector-size'

As explained in Xen commit 67e1c050 "public/io/blkif.h: try to fix the
semantics of sector based quantities" [1], frontends that always
supply and interpret sector based quantities in terms of the 'sector-size'
of the backend should declare 'feature-large-sector-size'.

[1] http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=67e1c050e36b2c9900cca83618e56189effbad98

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoMake PdoSendTrimSynchronous less noisy
Paul Durrant [Fri, 5 Apr 2019 15:38:45 +0000 (16:38 +0100)]
Make PdoSendTrimSynchronous less noisy

Remove the 'TRIM' Trace statement. Also fix some hard-tab nonsense in
nearby code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoImplement query for StorageAccessAlignmentProperty
Paul Durrant [Fri, 5 Apr 2019 15:15:47 +0000 (16:15 +0100)]
Implement query for StorageAccessAlignmentProperty

XENDISK already issues a SCSIOP_READ_CAPACITY16 down to XENVBD and so it
may as well handle a query for StorageAccessAlignmentProperty.

NOTE: This patch also adds a name decoder for STORAGE_QUERY_TYPE and adds
      some missing entries to the name decoder for STORAGE_PROPERTY_ID.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoForce crashdump driver to use single ring
Owen Smith [Wed, 27 Mar 2019 09:52:33 +0000 (09:52 +0000)]
Force crashdump driver to use single ring

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoTrack State.Count in BlkifRingDisable
Owen Smith [Wed, 27 Mar 2019 09:51:30 +0000 (09:51 +0000)]
Track State.Count in BlkifRingDisable

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoRemove duplicate xenstore-write
Owen Smith [Wed, 27 Mar 2019 09:50:33 +0000 (09:50 +0000)]
Remove duplicate xenstore-write

Also shows num/max queues in debug callback

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoFix ASSERTion failure during disk unplug
Paul Durrant [Tue, 22 Jan 2019 16:21:53 +0000 (16:21 +0000)]
Fix ASSERTion failure during disk unplug

BlkifRing->Path is not being NULL-ed out after freeing.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix BSOD on RingDestroy
Owen Smith [Wed, 26 Sep 2018 09:47:36 +0000 (10:47 +0100)]
Fix BSOD on RingDestroy

Zero Frontend->MaxQueues after calling RingDestroy, as RingDestroy will
query this value to free each BlkifRing, which will decrement an
unsigned value below 0.
Also adds an ASSERT to detect if FrontendGetMaxQueues returns 0.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Test that Index != 0 rather than > 0, since it is an unsigned quantity.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoConditionally package DPInst
Owen Smith [Fri, 24 Aug 2018 16:46:43 +0000 (17:46 +0100)]
Conditionally package DPInst

Since DPInst.exe is not shipped with the Windows Driver Kit 10, an
environment variable must point to local copies. Make the inclusion of
DPInst conditional on DPINST_REDIST being defined and that path
existing. This simplifies building packages which do not require DPInst
for installation, and removes a required step to create a working build.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoRemove bogus ASSERTion
Paul Durrant [Mon, 6 Aug 2018 09:47:58 +0000 (10:47 +0100)]
Remove bogus ASSERTion

In a checked build the code in BlkifRingSchedule() sometimes hits the
ASSERTion:

ASSERT3U(State->Count, ==, 0);

This check is there because this code was ported across from XENVIF. In
the context of that driver the check is valid because it should never be
possible to post a partial sequence of netif requests (since that would
violate the protocol). However, in the context of XENVBD posting blkif
requests, it is perfectly reasonable for a subset of blkif requests for
a single SRB to be posted, and hence __BlkifRingPostRequests() may exit
before State->Count falls to zero. Thus the ASSERTion is invalid in this
context and needs to be removed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoAdd some sensible default overrides
Owen Smith [Fri, 3 Aug 2018 13:48:17 +0000 (14:48 +0100)]
Add some sensible default overrides

Without overrides, "max-ring-page-order" and "multi-queue-max-queues"
use values that will consume large amounts of grant references.
"max-ring-page-order" will default to 4 (16 pages per ring)
"multi-queue-max-queues" will default to the lowest of guest vCPU count
or backend's vCPU count.

Override "max-ring-page-order" to 1 (2 pages per ring) and
"multi-queue-max-queues" to 2 (2 rings per block device)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoWork around bug in VS2017 SDV
Paul Durrant [Thu, 19 Jul 2018 09:52:24 +0000 (10:52 +0100)]
Work around bug in VS2017 SDV

XENBUS commit 868cd40f (of the same name) introduced a workaround for a
quoting bug in SDV. This commit applies a similar workaround for XENVBD.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix SDV release parameter
Paul Durrant [Wed, 18 Jul 2018 14:23:21 +0000 (15:23 +0100)]
Fix SDV release parameter

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoDisable spectre mitigation warnings
Paul Durrant [Tue, 10 Jul 2018 15:02:42 +0000 (16:02 +0100)]
Disable spectre mitigation warnings

These are not terribly useful and cause the build to fail.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoUpdate EVTCHN, GNTTAB and STORE interface headers
Owen Smith [Tue, 26 Jun 2018 11:52:35 +0000 (12:52 +0100)]
Update EVTCHN, GNTTAB and STORE interface headers

Updates revision to 09000004
Fixes Evtchn Unmask calls
Updates xenbus interface headers to latest versions

This will resolve an issue where, under certain timing conditions,
xenvbd will request a second reboot before functioning correctly.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoFix SDV build error
Paul Durrant [Mon, 4 Jun 2018 16:48:02 +0000 (17:48 +0100)]
Fix SDV build error

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix VS2015 build
Paul Durrant [Mon, 4 Jun 2018 15:34:31 +0000 (16:34 +0100)]
Fix VS2015 build

STOR_PERF_NO_SGL does not appear to exist in the older WDK.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoSet StorPortInitializePerfOpts
Owen Smith [Mon, 4 Jun 2018 14:37:36 +0000 (15:37 +0100)]
Set StorPortInitializePerfOpts

Sets DPC_REDIRECTION, OPTIMIZE_FOR_COMPLETION_DURING_STARTIO and
CONCURRENT_CHANNELS (to "multi-queue-max-queues") to improve StorPort's
distribution of SRBs to vCPUs.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoMove query of "multi-queue-max-queues" to driver.c
Owen Smith [Mon, 4 Jun 2018 14:34:23 +0000 (15:34 +0100)]
Move query of "multi-queue-max-queues" to driver.c

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoRemove queue.h/.c
Owen Smith [Mon, 4 Jun 2018 14:30:55 +0000 (15:30 +0100)]
Remove queue.h/.c

XENVBD_QUEUE has been replaced by LIST_ENTRY, and is no longer used.
Remove queue.h/.c and any include directives

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoImplement multi-queues
Owen Smith [Mon, 4 Jun 2018 14:11:26 +0000 (15:11 +0100)]
Implement multi-queues

Splits XENVBD_RING into multiple XENVBD_BLKIF_RINGs, one for each shared
ring. Up-to "multi-queue-max-queues" rings are used to pass
blkif_requests and blkif_responses between frontend and backend. Reworks
the ring interactions to remove the locks used by XENVBD_QUEUE,
implementing a queue system similar to XenVifs transmitter queues.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
s/Packets/SRBs in ring.c

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoForce single queue in crash/hibernate path
Owen Smith [Mon, 4 Jun 2018 13:57:43 +0000 (14:57 +0100)]
Force single queue in crash/hibernate path

Remove "multi-queue-num-queues" from frontend area when the crashump
driver is active. This will force the backend to use a single queue,
which the crashdump frontend is supplying

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Add whitespace after cast for consistency with other code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoDont close ring during FrontendReset
Owen Smith [Mon, 4 Jun 2018 13:47:15 +0000 (14:47 +0100)]
Dont close ring during FrontendReset

Closing the ring (and destroying the shared pages, etc) is not required
when a HwStorResetBus or SRB_FUNCTION_RESET_DEVICE is triggered.
Disabling the ring will cause any outstanding blkif_requests and SRBs to
be failed.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoRemove RingTrigger
Owen Smith [Mon, 4 Jun 2018 13:42:23 +0000 (14:42 +0100)]
Remove RingTrigger

RingTrigger calls XENBUS_EVTCHN(Trigger..) on during the suspend
callback. Just before this, the ring is recreated and enabled, which
also calls XENBUS_EVTCHN(Trigger..). The explicit call RingTrigger is
unneccessary

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoQuery "multi-queue-max-queues"
Owen Smith [Mon, 4 Jun 2018 13:36:21 +0000 (14:36 +0100)]
Query "multi-queue-max-queues"

Query "multi-queue-max-queues", and override if neccessary, and work
out a suitable value for the number of queues used. Also adds the
commented out writing code to set "multi-queue-num-queues"

Signed-off-by: Owen Smith <owen.smith@citrix.com>
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>
7 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>