All of lore.kernel.org
 help / color / mirror / Atom feed
* fix some bugs of WinPv driver WDM version
@ 2008-07-07  6:27 Wayne Gong
  2008-07-07 10:48 ` James Harper
  0 siblings, 1 reply; 2+ messages in thread
From: Wayne Gong @ 2008-07-07  6:27 UTC (permalink / raw)
  To: James Harper, Andy Grover, Yansu Li,
	xen-devel@lists.xensource.com
  Cc: Kurt Hackel


[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: fix some bugs of WinPv driver WDM version
  2008-07-07  6:27 fix some bugs of WinPv driver WDM version Wayne Gong
@ 2008-07-07 10:48 ` James Harper
  0 siblings, 0 replies; 2+ messages in thread
From: James Harper @ 2008-07-07 10:48 UTC (permalink / raw)
  To: Wayne Gong, Andy Grover, Yansu Li, xen-devel; +Cc: Kurt Hackel

Applied. Thanks.

> -----Original Message-----
> From: Wayne Gong [mailto:wayne.gong@oracle.com]
> Sent: Monday, 7 July 2008 16:27
> To: James Harper; Andy Grover; Yansu Li; xen-devel@lists.xensource.com
> Cc: Kurt Hackel
> Subject: fix some bugs of WinPv driver WDM version
> 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-07 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07  6:27 fix some bugs of WinPv driver WDM version Wayne Gong
2008-07-07 10:48 ` James Harper

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.