Skip to contentSkip to conversation

fix some bugs of WinPv driver WDM version

PATCH Applied Wayne Gong 2 participants 2 messages Jul 7, 2008

lore
Share & tools
lore

Wayne Gong

author
#0 lore raw

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

# HG changeset patch
# User Wayne Gong <[email protected]> # Date 1215410619 -28800
# Node ID d5e48a07a2134cd6274392079b7c1bcad89417f4 # Parent ab5d87da78e3948530a22d77a94c15e8a747fe38 Merge bug fixer from WDF to WDM.

xenhide/xenhide.c +5 -4
diff -r ab5d87da78e3 -r d5e48a07a213 xenhide/xenhide.c
@@ -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;
     }
xenpci/gnttbl.c +36 -5

64 lines not on this page · raw message

xenpci/xenpci.h +2 -2
diff -r ab5d87da78e3 -r d5e48a07a213 xenpci/xenpci.h
@@ -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))];
xenvbd/scsiport.c +24 -0
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/scsiport.c
@@ -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)
   {
xenvbd/xenvbd.h +7 -0
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/xenvbd.h
@@ -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;
xenvbd/xenvbd.inx +1 -0
diff -r ab5d87da78e3 -r d5e48a07a213 xenvbd/xenvbd.inx
@@ -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%

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Applied
#1 lore raw

Applied. Thanks.

Quoted 9 lines

-----Original Message-----
From: Wayne Gong [mailto:[email protected]]
Sent: Monday, 7 July 2008 16:27
To: James Harper; Andy Grover; Yansu Li; [email protected]
Cc: Kurt Hackel
Subject: fix some bugs of WinPv driver WDM version

Hello james,

Quoted 7 lines

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.

Quoted 2 lines

2. [XenHide] Hide a qeme scsi device.
3. [XenPci] From xen 3.1.3 on, each vm can get 32 grant table frames.

In

Quoted 1 line

x86 platform, call an hypercall to query the max grant table frames.

Set

Quoted 1 line

NR_GRANT_FRAMES to in AMD64 platform since HYPERVISOR_grant_table_op

is

Quoted 2 lines

not supported in AMD64 platform.
4. [XenVbd] Store each block device mode (read only or writable?) and

set

Quoted 2 lines

MODE_DSP_WRITE_PROTECT in ModeSense header parameter. This can protect write operation to a read only block device. (*Note* : This approach

will

Quoted 4 lines

be ineffective to a NTFS volume in Win2k.)

Best regards,
Wayne