From: Wayne Gong <wayne.gong@oracle.com>
To: James Harper <james.harper@bendigoit.com.au>,
Andy Grover <andy.grover@oracle.com>,
Yansu Li <annie.li@oracle.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: Kurt Hackel <kurt.hackel@oracle.com>
Subject: fix some bugs of WinPv driver WDM version
Date: Mon, 07 Jul 2008 14:27:00 +0800 [thread overview]
Message-ID: <4871B734.6060200@oracle.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 935 bytes --]
Hello james,
Since I don't have privilege to push WinPv driver code to Xen main
upstream, I will send to a patch when push some change to our own
repository every time.
In this patch, fix the following bugs:
1. [XenHide] If we destroy a running vm and reboot it, the boot up
information may larger than 200 bytes. So change the buffer length to 300.
2. [XenHide] Hide a qeme scsi device.
3. [XenPci] From xen 3.1.3 on, each vm can get 32 grant table frames. In
x86 platform, call an hypercall to query the max grant table frames. Set
NR_GRANT_FRAMES to in AMD64 platform since HYPERVISOR_grant_table_op is
not supported in AMD64 platform.
4. [XenVbd] Store each block device mode (read only or writable?) and
set MODE_DSP_WRITE_PROTECT in ModeSense header parameter. This can
protect write operation to a read only block device. (**Note* *: This
approach will be ineffective to a NTFS volume in Win2k.)
Best regards,
Wayne
[-- Attachment #1.2: Type: text/html, Size: 1159 bytes --]
[-- Attachment #2: bug fixer.patch --]
[-- Type: text/plain, Size: 7251 bytes --]
# HG changeset patch
# User Wayne Gong <wayne.gong@oracle.com>
# Date 1215410619 -28800
# Node ID d5e48a07a2134cd6274392079b7c1bcad89417f4
# Parent ab5d87da78e3948530a22d77a94c15e8a747fe38
Merge bug fixer from WDF to WDM.
diff -r ab5d87da78e3 -r d5e48a07a213 xenhide/xenhide.c
--- a/xenhide/xenhide.c Mon Jul 07 09:39:15 2008 +0800
+++ b/xenhide/xenhide.c Mon Jul 07 14:03:39 2008 +0800
@@ -60,8 +60,8 @@
UNICODE_STRING RegValueName;
HANDLE RegHandle;
OBJECT_ATTRIBUTES RegObjectAttributes;
- char Buf[200];
- ULONG BufLen = 200;
+ char Buf[300];// Sometimes bigger then 200 if system reboot from crash
+ ULONG BufLen = 300;
PKEY_VALUE_PARTIAL_INFORMATION KeyPartialValue;
int State = 0;
size_t StartPos = 0;
@@ -249,8 +249,9 @@
if (gplpv)
{
/* hide only specific devices */
- if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_8086&DEV_7010")
- || XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_10EC&DEV_8139"))
+ if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_8086&DEV_7010") // Qemu IDE
+ || XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_10EC&DEV_8139") // Qemu Network
+ || XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_1000&DEV_0012"))// Qemu SCSI
{
hide_type = XENHIDE_TYPE_DEVICE;
}
diff -r ab5d87da78e3 -r d5e48a07a213 xenpci/gnttbl.c
--- a/xenpci/gnttbl.c Mon Jul 07 09:39:15 2008 +0800
+++ b/xenpci/gnttbl.c Mon Jul 07 14:03:39 2008 +0800
@@ -149,28 +149,59 @@
return TRUE;
}
+#if defined(_X86_)
+static unsigned int
+GntTbl_QueryMaxFrames(PXENPCI_DEVICE_DATA xpdd)
+{
+ struct gnttab_query_size query;
+ int rc;
+
+ query.dom = DOMID_SELF;
+
+ rc = HYPERVISOR_grant_table_op(xpdd,GNTTABOP_query_size, &query, 1);
+ if ((rc < 0) || (query.status != GNTST_okay))
+ {
+ KdPrint((__DRIVER_NAME " ***CANNOT QUERY MAX GRANT FRAME***\n"));
+ return 4; /* Legacy max supported number of frames */
+ }
+ return query.max_nr_frames;
+}
+#endif
+
VOID
GntTbl_Init(PXENPCI_DEVICE_DATA xpdd)
{
int i;
-
+ int max_grant_frames = NR_GRANT_FRAMES;
+ int max_grant_entries = NR_GRANT_ENTRIES;
//KdPrint((__DRIVER_NAME " --> GntTbl_Init\n"));
KeInitializeSpinLock(&xpdd->grant_lock);
- for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
+#if defined(_X86_)
+ max_grant_frames = GntTbl_QueryMaxFrames(xpdd);
+ max_grant_entries = min(NR_GRANT_ENTRIES,(max_grant_frames * PAGE_SIZE / sizeof(grant_entry_t)));
+ KdPrint((__DRIVER_NAME " max_grant_entries : %d\n",max_grant_entries));
+#else
+ #if defined(_AMD64_)
+ KdPrint((__DRIVER_NAME " AMD64 cannot support HYPERVISOR_grant_table_op now\n"));
+ #endif
+#endif
+
+ xpdd->gnttab_list = ExAllocatePoolWithTag(NonPagedPool, sizeof(grant_ref_t) * max_grant_entries, XENPCI_POOL_TAG);// Where to free?
+ for (i = NR_RESERVED_ENTRIES; i < max_grant_entries; i++)
GntTbl_PutRef(xpdd, i);
xpdd->gnttab_table_physical = XenPci_AllocMMIO(xpdd,
- PAGE_SIZE * NR_GRANT_FRAMES);
+ PAGE_SIZE * max_grant_frames);
xpdd->gnttab_table = MmMapIoSpace(xpdd->gnttab_table_physical,
- PAGE_SIZE * NR_GRANT_FRAMES, MmNonCached);
+ PAGE_SIZE * max_grant_frames, MmNonCached);
if (!xpdd->gnttab_table)
{
KdPrint((__DRIVER_NAME " Error Mapping Grant Table Shared Memory\n"));
return;
}
- GntTbl_Map(xpdd, 0, NR_GRANT_FRAMES - 1);
+ GntTbl_Map(xpdd, 0, max_grant_frames - 1);
//KdPrint((__DRIVER_NAME " <-- GntTbl_Init table mapped at %p\n", gnttab_table));
}
diff -r ab5d87da78e3 -r d5e48a07a213 xenpci/xenpci.h
--- a/xenpci/xenpci.h Mon Jul 07 09:39:15 2008 +0800
+++ b/xenpci/xenpci.h Mon Jul 07 14:03:39 2008 +0800
@@ -57,7 +57,7 @@
#define XENPCI_POOL_TAG (ULONG) 'XenP'
#define NR_RESERVED_ENTRIES 8
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES 32
#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@@ -184,7 +184,7 @@
grant_entry_t *gnttab_table;
PHYSICAL_ADDRESS gnttab_table_physical;
- grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
+ grant_ref_t *gnttab_list;
ev_action_t ev_actions[NR_EVENTS];
// unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/scsiport.c
--- a/xenvbd/scsiport.c Mon Jul 07 09:39:15 2008 +0800
+++ b/xenvbd/scsiport.c Mon Jul 07 14:03:39 2008 +0800
@@ -170,6 +170,24 @@
{
KdPrint((__DRIVER_NAME " device-type = %s (This probably won't work!)\n", value));
xvdd->device_type = XENVBD_DEVICETYPE_UNKNOWN;
+ }
+ }
+ else if (strcmp(setting, "mode") == 0)
+ {
+ if (strncmp(value, "r", 1) == 0)
+ {
+ KdPrint((__DRIVER_NAME " mode = r\n"));
+ xvdd->device_mode = XENVBD_DEVICEMODE_READ;
+ }
+ else if (strncmp(value, "w", 1) == 0)
+ {
+ KdPrint((__DRIVER_NAME " mode = w\n"));
+ xvdd->device_mode = XENVBD_DEVICEMODE_WRITE;
+ }
+ else
+ {
+ KdPrint((__DRIVER_NAME " mode = unknown\n"));
+ xvdd->device_mode = XENVBD_DEVICEMODE_UNKNOWN;
}
}
break;
@@ -525,6 +543,12 @@
parameter_header->DeviceSpecificParameter = 0;
parameter_header->BlockDescriptorLength = 0;
offset += sizeof(MODE_PARAMETER_HEADER);
+
+ if (xvdd->device_mode == XENVBD_DEVICEMODE_READ)
+ {
+ KdPrint((__DRIVER_NAME " Mode sense to a read only disk.\n"));
+ parameter_header->DeviceSpecificParameter|=MODE_DSP_WRITE_PROTECT;
+ }
if (!cdb->MODE_SENSE.Dbd)
{
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/xenvbd.h
--- a/xenvbd/xenvbd.h Mon Jul 07 09:39:15 2008 +0800
+++ b/xenvbd/xenvbd.h Mon Jul 07 14:03:39 2008 +0800
@@ -90,6 +90,12 @@
XENVBD_DEVICETYPE_CONTROLLER // Not yet used
} XENVBD_DEVICETYPE;
+typedef enum {
+ XENVBD_DEVICEMODE_UNKNOWN,
+ XENVBD_DEVICEMODE_READ,
+ XENVBD_DEVICEMODE_WRITE
+} XENVBD_DEVICEMODE;
+
struct
{
blkif_shadow_t shadows[SHADOW_ENTRIES];
@@ -115,6 +121,7 @@
UCHAR last_additional_sense_code;
blkif_response_t tmp_rep;
XENVBD_DEVICETYPE device_type;
+ XENVBD_DEVICEMODE device_mode;
DISK_GEOMETRY Geometry;
ULONG bytes_per_sector;
ULONGLONG total_sectors;
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/xenvbd.inx
--- a/xenvbd/xenvbd.inx Mon Jul 07 09:39:15 2008 +0800
+++ b/xenvbd/xenvbd.inx Mon Jul 07 14:03:39 2008 +0800
@@ -62,6 +62,7 @@
HKR,"XenConfig\ring-ref", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_RING%
HKR,"XenConfig\event-channel", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_EVENT_CHANNEL_IRQ%
HKR,"XenConfig\device-type", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_READ_STRING_FRONT%
+HKR,"XenConfig\mode", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_READ_STRING_BACK%
HKR,"XenConfig\sectors", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_READ_STRING_BACK%
HKR,"XenConfig\sector-size", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_READ_STRING_BACK%
HKR,"XenConfig\vectors", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_VECTORS%
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2008-07-07 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 6:27 Wayne Gong [this message]
2008-07-07 10:48 ` fix some bugs of WinPv driver WDM version James Harper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4871B734.6060200@oracle.com \
--to=wayne.gong@oracle.com \
--cc=andy.grover@oracle.com \
--cc=annie.li@oracle.com \
--cc=james.harper@bendigoit.com.au \
--cc=kurt.hackel@oracle.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.