All of lore.kernel.org
 help / color / mirror / Atom feed
* PV drivers for HVM guests
@ 2006-10-03 20:31 Ky Srinivasan
  2006-10-03 22:19 ` Andrew D. Ball
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-03 20:31 UTC (permalink / raw)
  To: xen-devel

I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 2.6.5 kernel. Since the PV driver code is really designed for the latest kernel release, I have had many issues/problems in building the PV drivers for older Linux OS targets - I have only been looking at the issues with 2.6.5 kernel base and I suspect the problem will be even worse if one were to look at older Linux kernels. This is unfortunate since PV drivers are so critical for HVM guests and there is considerable interest in supporting legacy Linux environments as HVM guests. The problems I have had to deal with can be broadly classified into:

a) Compiler related issues
b) Missing functionality in the legacy kernel - this includes features as well as changed data structures
c) Implementation differences of a given feature

These differences can be dealt with in a couple of different ways:
1) Modify the code in the PV drivers under appropriate compilation switches to deal with the differences in the base kernels.
2)  Introduce  a compatibility component that bridges the gap between the current PV code and a given Linux target and leave much of the PV driver  code untouched.

I have implemented both these schemes for the sles9 kernel and would like to get your input on your preference. I personally like option 2. Going forward, the evolution of PV drivers needs to be constrained by the required support for legacy Linux environments. 

Regards,

K. Y. Srinivasan 

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

* Re: PV drivers for HVM guests
  2006-10-03 20:31 Ky Srinivasan
@ 2006-10-03 22:19 ` Andrew D. Ball
  2006-10-03 22:31 ` Steve Ofsthun
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Andrew D. Ball @ 2006-10-03 22:19 UTC (permalink / raw)
  To: Ky Srinivasan; +Cc: xen-devel

Interesting!  Ideally, there would be better performance in the base HVM
device model.  I think I know of some people that are working hard on
that.

I'm curious to see what you've done for (1) and (2).

Peace.
Andrew

On Tue, 2006-10-03 at 16:31 -0400, Ky Srinivasan wrote:
> I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 2.6.5 kernel. Since the PV driver code is really designed for the latest kernel release, I have had many issues/problems in building the PV drivers for older Linux OS targets - I have only been looking at the issues with 2.6.5 kernel base and I suspect the problem will be even worse if one were to look at older Linux kernels. This is unfortunate since PV drivers are so critical for HVM guests and there is considerable interest in supporting legacy Linux environments as HVM guests. The problems I have had to deal with can be broadly classified into:
> 
> a) Compiler related issues
> b) Missing functionality in the legacy kernel - this includes features as well as changed data structures
> c) Implementation differences of a given feature
> 
> These differences can be dealt with in a couple of different ways:
> 1) Modify the code in the PV drivers under appropriate compilation switches to deal with the differences in the base kernels.
> 2)  Introduce  a compatibility component that bridges the gap between the current PV code and a given Linux target and leave much of the PV driver  code untouched.
> 
> I have implemented both these schemes for the sles9 kernel and would like to get your input on your preference. I personally like option 2. Going forward, the evolution of PV drivers needs to be constrained by the required support for legacy Linux environments. 
> 
> Regards,
> 
> K. Y. Srinivasan 
> 
> 
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

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

* Re: PV drivers for HVM guests
  2006-10-03 20:31 Ky Srinivasan
  2006-10-03 22:19 ` Andrew D. Ball
@ 2006-10-03 22:31 ` Steve Ofsthun
  2006-10-04  7:56 ` Keir Fraser
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Steve Ofsthun @ 2006-10-03 22:31 UTC (permalink / raw)
  To: Ky Srinivasan; +Cc: xen-devel

Ky Srinivasan wrote:
> I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 2.6.5 kernel. Since the PV driver code is really designed for the latest kernel release, I have had many issues/problems in building the PV drivers for older Linux OS targets - I have only been looking at the issues with 2.6.5 kernel base and I suspect the problem will be even worse if one were to look at older Linux kernels. This is unfortunate since PV drivers are so critical for HVM guests and there is considerable interest in supporting legacy Linux environments as HVM guests. The problems I have had to deal with can be broadly classified into:
> 
> a) Compiler related issues
> b) Missing functionality in the legacy kernel - this includes features as well as changed data structures
> c) Implementation differences of a given feature
> 
> These differences can be dealt with in a couple of different ways:
> 1) Modify the code in the PV drivers under appropriate compilation switches to deal with the differences in the base kernels.
> 2)  Introduce  a compatibility component that bridges the gap between the current PV code and a given Linux target and leave much of the PV driver  code untouched.
> 
> I have implemented both these schemes for the sles9 kernel and would like to get your input on your preference. I personally like option 2. Going forward, the evolution of PV drivers needs to be constrained by the required support for legacy Linux environments.

We have generally taken approach 1, for supporting SLES9 32/64 & RHEL4 32/64, with others 
under development.  While the code is uglier, it is also more obvious to a maintainer when 
they run across something like the following:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
         elevator_init(rq, "noop");
#else
         elevator_init(rq, &elevator_noop);
#endif

or

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
                         end_that_request_last(
                                 req, (bret->status == BLKIF_RSP_OKAY));
#else
                         end_that_request_last(req);
#endif

In this way, the sensitive areas of the code are obvious.  As the PV drivers move forward, 
new kernel interface changes require similar changes.  As you mention, which ever method 
is used, some level of discipline is required in maintaining the PV drivers.

With your suggested option 2, does this require separate "compatibility component" code 
for each supported kernel version?  Or do you envision a single compatibility layer that 
would hide the conditionally compiled code from the PV drivers proper?

There is also the issue of whether the PV drivers can/should support multiple hypervisor 
versions moving forward.

Steve
-- 
Steve Ofsthun - Virtual Iron Software, Inc.

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

* Re: PV drivers for HVM guests
  2006-10-03 20:31 Ky Srinivasan
  2006-10-03 22:19 ` Andrew D. Ball
  2006-10-03 22:31 ` Steve Ofsthun
@ 2006-10-04  7:56 ` Keir Fraser
  2006-10-04  8:15   ` Muli Ben-Yehuda
  2006-10-04 10:24 ` Steven Smith
  2006-10-05 15:21 ` Ian Campbell
  4 siblings, 1 reply; 22+ messages in thread
From: Keir Fraser @ 2006-10-04  7:56 UTC (permalink / raw)
  To: Ky Srinivasan, xen-devel

On 3/10/06 9:31 pm, "Ky Srinivasan" <ksrinivasan@novell.com> wrote:

> These differences can be dealt with in a couple of different ways:
> 1) Modify the code in the PV drivers under appropriate compilation switches to
> deal with the differences in the base kernels.
> 2)  Introduce  a compatibility component that bridges the gap between the
> current PV code and a given Linux target and leave much of the PV driver  code
> untouched.
> 
> I have implemented both these schemes for the sles9 kernel and would like to
> get your input on your preference. I personally like option 2. Going forward,
> the evolution of PV drivers needs to be constrained by the required support
> for legacy Linux environments.

A shim layer (i.e., a set of compat macros) that avoids ifdef'ing the core
driver code is definitely the way to go.

 -- Keir

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

* Re: PV drivers for HVM guests
  2006-10-04  7:56 ` Keir Fraser
@ 2006-10-04  8:15   ` Muli Ben-Yehuda
  2006-10-04  8:17     ` Keir Fraser
  2006-10-04 11:02     ` Gerd Hoffmann
  0 siblings, 2 replies; 22+ messages in thread
From: Muli Ben-Yehuda @ 2006-10-04  8:15 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Ky Srinivasan, xen-devel

On Wed, Oct 04, 2006 at 08:56:45AM +0100, Keir Fraser wrote:

> > I have implemented both these schemes for the sles9 kernel and
> > would like to get your input on your preference. I personally like
> > option 2. Going forward, the evolution of PV drivers needs to be
> > constrained by the required support for legacy Linux environments.
> 
> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing
> the core driver code is definitely the way to go.

FWIW, neither option has a chance of being accepted upstream. For
upstream acceptance (assuming that it is a goal - it should be,
otherwise you forever chase the latest kernel API change, multiplied
by the number of different distro kernel trees you support) just write
the latest version of the driver to the latest kernel version. But I
suspect you already know this :-)

Cheers,
Muli

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

* Re: PV drivers for HVM guests
  2006-10-04  8:15   ` Muli Ben-Yehuda
@ 2006-10-04  8:17     ` Keir Fraser
  2006-10-04 11:02     ` Gerd Hoffmann
  1 sibling, 0 replies; 22+ messages in thread
From: Keir Fraser @ 2006-10-04  8:17 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Ky Srinivasan, xen-devel

On 4/10/06 9:15 am, "Muli Ben-Yehuda" <muli@il.ibm.com> wrote:

>> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing
>> the core driver code is definitely the way to go.
> 
> FWIW, neither option has a chance of being accepted upstream. For
> upstream acceptance (assuming that it is a goal - it should be,
> otherwise you forever chase the latest kernel API change, multiplied
> by the number of different distro kernel trees you support) just write
> the latest version of the driver to the latest kernel version. But I
> suspect you already know this :-)

The versions in the upstream patches get cleaned up as necessary for
acceptance. Yes, our aim is to get all the code support needed for PV-on-HVM
drivers out of the external unmodified_drivers directory and properly into
the Linux tree so that they can be built in-tree either for a PV kernel or a
native kernel. Then the unmodified_drivers directory will contain only some
build-system magic to make it easier to build drivers out-of-tree.

 -- Keir

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

* Re: PV drivers for HVM guests
  2006-10-03 20:31 Ky Srinivasan
                   ` (2 preceding siblings ...)
  2006-10-04  7:56 ` Keir Fraser
@ 2006-10-04 10:24 ` Steven Smith
  2006-10-05 15:21 ` Ian Campbell
  4 siblings, 0 replies; 22+ messages in thread
From: Steven Smith @ 2006-10-04 10:24 UTC (permalink / raw)
  To: Ky Srinivasan; +Cc: xen-devel, sos22


[-- Attachment #1.1: Type: text/plain, Size: 437 bytes --]

> These differences can be dealt with in a couple of different ways:
> 1) Modify the code in the PV drivers under appropriate compilation
> switches to deal with the differences in the base kernels.
> 2) Introduce a compatibility component that bridges the gap between
> the current PV code and a given Linux target and leave much of the
> PV driver code untouched.
How much code is actually required in this abstraction layer?

Steven.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: 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] 22+ messages in thread

* Re: PV drivers for HVM guests
  2006-10-04  8:15   ` Muli Ben-Yehuda
  2006-10-04  8:17     ` Keir Fraser
@ 2006-10-04 11:02     ` Gerd Hoffmann
  2006-10-04 15:54       ` Andi Kleen
  1 sibling, 1 reply; 22+ messages in thread
From: Gerd Hoffmann @ 2006-10-04 11:02 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: xen-devel, Ky Srinivasan

Muli Ben-Yehuda wrote:
>> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing
>> the core driver code is definitely the way to go.
> 
> FWIW, neither option has a chance of being accepted upstream.

Exactly thats why a shim layer is the way to go (if possible, doesn't
work for all changes but for most).  Did that that quite some time while
maintaining the v4l subsystem.  Making driver source code use the
2.6.latest conventions and have some compat.h header file full of stuff
like this ...

  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,xx)
  # define foo gryyz
  #endif

or (better if possible as it catches distro backports, which does happen
now and then for compiling recent drivers on old distro kernels).

  #ifndef bar
  # define bar xyzzy
  #endif

nicely separates out the compat bits.  It makes the code more readable
and also is less work when submitting code upstream.

cheers,

  Gerd

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

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

* Re: PV drivers for HVM guests
  2006-10-04 11:02     ` Gerd Hoffmann
@ 2006-10-04 15:54       ` Andi Kleen
  0 siblings, 0 replies; 22+ messages in thread
From: Andi Kleen @ 2006-10-04 15:54 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Ky Srinivasan, xen-devel

Gerd Hoffmann <kraxel@suse.de> writes:

> Muli Ben-Yehuda wrote:
> >> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing
> >> the core driver code is definitely the way to go.
> > 
> > FWIW, neither option has a chance of being accepted upstream.
> 
> Exactly thats why a shim layer is the way to go (if possible, doesn't
> work for all changes but for most).  Did that that quite some time while
> maintaining the v4l subsystem.  Making driver source code use the
> 2.6.latest conventions and have some compat.h header file full of stuff
> like this ...
> 
>   #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,xx)
>   # define foo gryyz
>   #endif
> 
> or (better if possible as it catches distro backports, which does happen
> now and then for compiling recent drivers on old distro kernels).
> 
>   #ifndef bar
>   # define bar xyzzy
>   #endif
> 
> nicely separates out the compat bits.  It makes the code more readable
> and also is less work when submitting code upstream.

I hate to point out the obvious, but often when calls get renamed upstream
it is actually because the semantics changed subtly (the point of the rename
was to enforce a audit and proper fix of the driver)  Typically then
using define bar xyz is then not the right thing to do. 

Especially when you do

#define oldfunctionname newfunctionname

without any translation you very likely have a bug.

A shim layer can be the right thing to do still, but you have to be very
careful to not miss such a semantics change.

-Andi

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

* Re: PV drivers for HVM guests
@ 2006-10-04 18:40 Ky Srinivasan
  0 siblings, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-04 18:40 UTC (permalink / raw)
  To: Steve Ofsthun; +Cc: xen-devel



>>> On Tue, Oct 3, 2006 at  6:31 PM, in message <4522E4AA.4020700@virtualiron.com>,
Steve Ofsthun <sofsthun@virtualiron.com> wrote: 
> Ky Srinivasan wrote:
>> I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 
> 2.6.5 kernel. Since the PV driver code is really designed for the latest 
> kernel release, I have had many issues/problems in building the PV drivers 
> for older Linux OS targets -   I have only been looking at the issues with 2.6.5 
> kernel base and I suspect the problem will be even worse if one were to look 
> at older Linux kernels. This is unfortunate since PV drivers are so critical 
> for HVM guests and there is considerable interest in supporting legacy Linux 
> environments as HVM guests. The problems I have had to deal with can be 
> broadly classified into:
>> 
>> a) Compiler related issues
>> b) Missing functionality in the legacy kernel -   this includes features as 
> well as changed data structures
>> c) Implementation differences of a given feature
>> 
>> These differences can be dealt with in a couple of different ways:
>> 1) Modify the code in the PV drivers under appropriate compilation switches 
> to deal with the differences in the base kernels.
>> 2)  Introduce  a compatibility component that bridges the gap between the 
> current PV code and a given Linux target and leave much of the PV driver  
> code untouched.
>> 
>> I have implemented both these schemes for the sles9 kernel and would like to 
> get your input on your preference. I personally like option 2. Going forward, 
> the evolution of PV drivers needs to be constrained by the required support 
> for legacy Linux environments.
> 
> We have generally taken approach 1, for supporting SLES9 32/64 & RHEL4 32/64, 
> with others 
> under development.  While the code is uglier, it is also more obvious to a 
> maintainer when 
> they run across something like the following:
> 
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
>          elevator_init(rq, "noop");
> #else
>          elevator_init(rq, &elevator_noop);
> #endif
> 
> or
> 
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
>                          end_that_request_last(
>                                  req, (bret-  >status == BLKIF_RSP_OKAY));
> #else
>                          end_that_request_last(req);
> #endif
> 
> In this way, the sensitive areas of the code are obvious.  As the PV drivers 
> move forward, 
> new kernel interface changes require similar changes.  As you mention, which 
> ever method 
> is used, some level of discipline is required in maintaining the PV drivers.
> 
> With your suggested option 2, does this require separate "compatibility 
> component" code 
> for each supported kernel version?  Or do you envision a single 
> compatibility layer that 
> would hide the conditionally compiled code from the PV drivers proper?

Based on the nature and extent of the changes we may either go with one compatibility component for all legacy kernel targets or one for each. 
> 
> There is also the issue of whether the PV drivers can/should support 
> multiple hypervisor 
> versions moving forward.
Good point. 
> 
> Steve

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

* Re: PV drivers for HVM guests
@ 2006-10-04 18:42 Ky Srinivasan
  2006-10-05 14:59 ` Andrew D. Ball
  0 siblings, 1 reply; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-04 18:42 UTC (permalink / raw)
  To: aball; +Cc: xen-devel

Andrew,

The I/O performance of HVM guests with PV drivers is SIGNIFICANTLY better than what we get without PV drivers. I will post the patches after some additional testing and code cleanup.

Regards,

K. Y

>>> On Tue, Oct 3, 2006 at  6:19 PM, in message
<1159913996.27206.37.camel@localhost>, "Andrew D. Ball" <aball@us.ibm.com>
wrote: 
> Interesting!  Ideally, there would be better performance in the base HVM
> device model.  I think I know of some people that are working hard on
> that.
> 
> I'm curious to see what you've done for (1) and (2).
> 
> Peace.
> Andrew
> 
> On Tue, 2006-  10-  03 at 16:31 -  0400, Ky Srinivasan wrote:
>> I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 
> 2.6.5 kernel. Since the PV driver code is really designed for the latest 
> kernel release, I have had many issues/problems in building the PV drivers 
> for older Linux OS targets -   I have only been looking at the issues with 2.6.5 
> kernel base and I suspect the problem will be even worse if one were to look 
> at older Linux kernels. This is unfortunate since PV drivers are so critical 
> for HVM guests and there is considerable interest in supporting legacy Linux 
> environments as HVM guests. The problems I have had to deal with can be 
> broadly classified into:
>> 
>> a) Compiler related issues
>> b) Missing functionality in the legacy kernel -   this includes features as 
> well as changed data structures
>> c) Implementation differences of a given feature
>> 
>> These differences can be dealt with in a couple of different ways:
>> 1) Modify the code in the PV drivers under appropriate compilation switches 
> to deal with the differences in the base kernels.
>> 2)  Introduce  a compatibility component that bridges the gap between the 
> current PV code and a given Linux target and leave much of the PV driver  
> code untouched.
>> 
>> I have implemented both these schemes for the sles9 kernel and would like to 
> get your input on your preference. I personally like option 2. Going forward, 
> the evolution of PV drivers needs to be constrained by the required support 
> for legacy Linux environments. 
>> 
>> Regards,
>> 
>> K. Y. Srinivasan 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Xen-  devel mailing list
>> Xen-  devel@lists.xensource.com
>> http://lists.xensource.com/xen-  devel
> 
> 
> _______________________________________________
> Xen-  devel mailing list
> Xen-  devel@lists.xensource.com
> http://lists.xensource.com/xen-  devel

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

* Re: PV drivers for HVM guests
@ 2006-10-04 18:45 Ky Srinivasan
  0 siblings, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-04 18:45 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel



>>> On Wed, Oct 4, 2006 at  3:56 AM, in message
<C14927CD.2084%Keir.Fraser@cl.cam.ac.uk>, Keir Fraser
<Keir.Fraser@cl.cam.ac.uk> wrote: 
> On 3/10/06 9:31 pm, "Ky Srinivasan" <ksrinivasan@novell.com> wrote:
> 
>> These differences can be dealt with in a couple of different ways:
>> 1) Modify the code in the PV drivers under appropriate compilation switches 
> to
>> deal with the differences in the base kernels.
>> 2)  Introduce  a compatibility component that bridges the gap between the
>> current PV code and a given Linux target and leave much of the PV driver  
> code
>> untouched.
>> 
>> I have implemented both these schemes for the sles9 kernel and would like to
>> get your input on your preference. I personally like option 2. Going 
> forward,
>> the evolution of PV drivers needs to be constrained by the required support
>> for legacy Linux environments.
> 
> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing the core
> driver code is definitely the way to go.
> 
>  --   Keir

Thanks Kier; this is also my preference. To keep the shim layer small, we may still have some ifdefs in the driver code  though(to deal with non-existent header files that are included etc).

Regards,

K. Y 

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

* Re: PV drivers for HVM guests
@ 2006-10-04 18:47 Ky Srinivasan
  0 siblings, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-04 18:47 UTC (permalink / raw)
  To: Keir Fraser, Muli Ben-Yehuda; +Cc: xen-devel



>>> On Wed, Oct 4, 2006 at  4:15 AM, in message
<20061004081551.GC6274@rhun.haifa.ibm.com>, Muli Ben-Yehuda <muli@il.ibm.com>
wrote: 
> On Wed, Oct 04, 2006 at 08:56:45AM +0100, Keir Fraser wrote:
> 
>> > I have implemented both these schemes for the sles9 kernel and
>> > would like to get your input on your preference. I personally like
>> > option 2. Going forward, the evolution of PV drivers needs to be
>> > constrained by the required support for legacy Linux environments.
>> 
>> A shim layer (i.e., a set of compat macros) that avoids ifdef'ing
>> the core driver code is definitely the way to go.
> 
> FWIW, neither option has a chance of being accepted upstream. For
> upstream acceptance (assuming that it is a goal -   it should be,
> otherwise you forever chase the latest kernel API change, multiplied
> by the number of different distro kernel trees you support) just write
> the latest version of the driver to the latest kernel version. But I
> suspect you already know this :-  )
Agreed. Having a clean shim should help in getting the PV driver code upstream. 

Regards,

K. Y

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

* Re: PV drivers for HVM guests
@ 2006-10-04 18:50 Ky Srinivasan
  0 siblings, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-04 18:50 UTC (permalink / raw)
  To: Steven Smith; +Cc: xen-devel, sos22



>>> Steven Smith <sos22-xen@srcf.ucam.org> 10/04/06 6:24 AM >>> 
>> These differences can be dealt with in a couple of different ways:
>> 1) Modify the code in the PV drivers under appropriate compilation
>> switches to deal with the differences in the base kernels.
>> 2) Introduce a compatibility component that bridges the gap between
>> the current PV code and a given Linux target and leave much of the
>> PV driver code untouched.
>How much code is actually required in this abstraction layer?

Not a whole lot. The shim layer I currently have is about 80 lines (about 40 lines in a header file and about 40 lines in a c file). Along with this I have a few ifdefs in the PV driver code to deal with non-existent header files and non-existent fields in data structures such as struct bus_type, struct device etc. 

Regards,

K. Y

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

* Re: PV drivers for HVM guests
  2006-10-04 18:42 PV drivers for HVM guests Ky Srinivasan
@ 2006-10-05 14:59 ` Andrew D. Ball
  2006-10-05 15:13   ` Ky Srinivasan
  0 siblings, 1 reply; 22+ messages in thread
From: Andrew D. Ball @ 2006-10-05 14:59 UTC (permalink / raw)
  To: Ky Srinivasan; +Cc: xen-devel

Agreed.  What I meant is that it would be nice if the device model
were modified to have better performance for things like OS/2, where
writing paravirtual drivers would be less emphasized.

Peace.
Andrew

Ky Srinivasan wrote:
> Andrew,
> 
> The I/O performance of HVM guests with PV drivers is SIGNIFICANTLY better than what we get without PV drivers. I will post the patches after some additional testing and code cleanup.
> 
> Regards,
> 
> K. Y
> 
> 
>>>>On Tue, Oct 3, 2006 at  6:19 PM, in message
> 
> <1159913996.27206.37.camel@localhost>, "Andrew D. Ball" <aball@us.ibm.com>
> wrote: 
> 
>>Interesting!  Ideally, there would be better performance in the base HVM
>>device model.  I think I know of some people that are working hard on
>>that.
>>
>>I'm curious to see what you've done for (1) and (2).
>>
>>Peace.
>>Andrew
>>
>>On Tue, 2006-  10-  03 at 16:31 -  0400, Ky Srinivasan wrote:
>>
>>>I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 
>>
>>2.6.5 kernel. Since the PV driver code is really designed for the latest 
>>kernel release, I have had many issues/problems in building the PV drivers 
>>for older Linux OS targets -   I have only been looking at the issues with 2.6.5 
>>kernel base and I suspect the problem will be even worse if one were to look 
>>at older Linux kernels. This is unfortunate since PV drivers are so critical 
>>for HVM guests and there is considerable interest in supporting legacy Linux 
>>environments as HVM guests. The problems I have had to deal with can be 
>>broadly classified into:
>>
>>>a) Compiler related issues
>>>b) Missing functionality in the legacy kernel -   this includes features as 
>>
>>well as changed data structures
>>
>>>c) Implementation differences of a given feature
>>>
>>>These differences can be dealt with in a couple of different ways:
>>>1) Modify the code in the PV drivers under appropriate compilation switches 
>>
>>to deal with the differences in the base kernels.
>>
>>>2)  Introduce  a compatibility component that bridges the gap between the 
>>
>>current PV code and a given Linux target and leave much of the PV driver  
>>code untouched.
>>
>>>I have implemented both these schemes for the sles9 kernel and would like to 
>>
>>get your input on your preference. I personally like option 2. Going forward, 
>>the evolution of PV drivers needs to be constrained by the required support 
>>for legacy Linux environments. 
>>
>>>Regards,
>>>
>>>K. Y. Srinivasan 
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>Xen-  devel mailing list
>>>Xen-  devel@lists.xensource.com
>>>http://lists.xensource.com/xen-  devel
>>
>>
>>_______________________________________________
>>Xen-  devel mailing list
>>Xen-  devel@lists.xensource.com
>>http://lists.xensource.com/xen-  devel
> 
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 

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

* Re: PV drivers for HVM guests
  2006-10-05 14:59 ` Andrew D. Ball
@ 2006-10-05 15:13   ` Ky Srinivasan
  0 siblings, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-05 15:13 UTC (permalink / raw)
  To: Andrew D. Ball; +Cc: xen-devel

Agreed.

K. Y

>>> On Thu, Oct 5, 2006 at 10:59 AM, in message <45251DEB.1070708@us.ibm.com>,
"Andrew D. Ball" <aball@us.ibm.com> wrote: 
> Agreed.  What I meant is that it would be nice if the device model
> were modified to have better performance for things like OS/2, where
> writing paravirtual drivers would be less emphasized.
> 
> Peace.
> Andrew
> 
> Ky Srinivasan wrote:
>> Andrew,
>> 
>> The I/O performance of HVM guests with PV drivers is SIGNIFICANTLY better 
> than what we get without PV drivers. I will post the patches after some 
> additional testing and code cleanup.
>> 
>> Regards,
>> 
>> K. Y
>> 
>> 
>>>>>On Tue, Oct 3, 2006 at  6:19 PM, in message
>> 
>> <1159913996.27206.37.camel@localhost>, "Andrew D. Ball" <aball@us.ibm.com>
>> wrote: 
>> 
>>>Interesting!  Ideally, there would be better performance in the base HVM
>>>device model.  I think I know of some people that are working hard on
>>>that.
>>>
>>>I'm curious to see what you've done for (1) and (2).
>>>
>>>Peace.
>>>Andrew
>>>
>>>On Tue, 2006-   10-   03 at 16:31 -   0400, Ky Srinivasan wrote:
>>>
>>>>I am trying to build PV drivers for SLES9 HVM guests. SLES 9 is based on the 
>>>
>>>2.6.5 kernel. Since the PV driver code is really designed for the latest 
>>>kernel release, I have had many issues/problems in building the PV drivers 
>>>for older Linux OS targets -    I have only been looking at the issues with 
> 2.6.5 
>>>kernel base and I suspect the problem will be even worse if one were to look 
>>>at older Linux kernels. This is unfortunate since PV drivers are so critical 
>>>for HVM guests and there is considerable interest in supporting legacy Linux 
>>>environments as HVM guests. The problems I have had to deal with can be 
>>>broadly classified into:
>>>
>>>>a) Compiler related issues
>>>>b) Missing functionality in the legacy kernel -    this includes features as 
>>>
>>>well as changed data structures
>>>
>>>>c) Implementation differences of a given feature
>>>>
>>>>These differences can be dealt with in a couple of different ways:
>>>>1) Modify the code in the PV drivers under appropriate compilation switches 
>>>
>>>to deal with the differences in the base kernels.
>>>
>>>>2)  Introduce  a compatibility component that bridges the gap between the 
>>>
>>>current PV code and a given Linux target and leave much of the PV driver  
>>>code untouched.
>>>
>>>>I have implemented both these schemes for the sles9 kernel and would like to 
>>>
>>>get your input on your preference. I personally like option 2. Going forward, 
> 
>>>the evolution of PV drivers needs to be constrained by the required support 
>>>for legacy Linux environments. 
>>>
>>>>Regards,
>>>>
>>>>K. Y. Srinivasan 
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>_______________________________________________
>>>>Xen-   devel mailing list
>>>>Xen-   devel@lists.xensource.com
>>>>http://lists.xensource.com/xen-   devel
>>>
>>>
>>>_______________________________________________
>>>Xen-   devel mailing list
>>>Xen-   devel@lists.xensource.com
>>>http://lists.xensource.com/xen-   devel
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Xen- devel mailing list
>> Xen- devel@lists.xensource.com
>> http://lists.xensource.com/xen- devel
>> 

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

* Re: PV drivers for HVM guests
  2006-10-03 20:31 Ky Srinivasan
                   ` (3 preceding siblings ...)
  2006-10-04 10:24 ` Steven Smith
@ 2006-10-05 15:21 ` Ian Campbell
  2006-10-05 16:47   ` Ky Srinivasan
  2006-10-10  8:00   ` DOI Tsunehisa
  4 siblings, 2 replies; 22+ messages in thread
From: Ian Campbell @ 2006-10-05 15:21 UTC (permalink / raw)
  To: Ky Srinivasan; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]

On Tue, 2006-10-03 at 16:31 -0400, Ky Srinivasan wrote:
> 2)  Introduce  a compatibility component that bridges the gap between
> the current PV code and a given Linux target and leave much of the PV
> driver  code untouched.
> 
> I have implemented both these schemes for the sles9 kernel 

FWIW I have a half complete implementation (compile tested only) of such
a scheme which I've attached, perhaps you can crib something useful from
it ;-).

Basically it adds a compat-include directory to the end of the include
search path which contains compatibility versions of headers which may
not present in older kernels and adds compat.h which defines other
missing bits where necessary.

It covers most of the issues compiling against a RHEL4 (2.6.9) or SLES9
(2.6.5) kernel, although compatibility shims for
schedule_timeout_interruptible() and nonseekable_open() are still
missing and the versions used for triggering compatibility code are
certainly totally wrong (just right for RHEL4 and SLES9 though ;-)).

I'm fairly unhappy about the number of ifdef's in xenbus_probe.c. I
reckon some function reordering could coalesce a lot of them. Perhaps
they are candidates for splitting into a separate file.

This work will also be useful for the fully PV vendor kernel ports which
is why I'm interested.

Ian.

[-- Attachment #2: pvdriver-compat.diff --]
[-- Type: text/x-patch, Size: 23890 bytes --]

diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 05 11:45:07 2006 +0100
@@ -48,6 +48,10 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
@@ -468,6 +472,27 @@ int blkif_ioctl(struct inode *inode, str
 		      command, (long)argument, inode->i_rdev);
 
 	switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	case HDIO_GETGEO: {
+		struct block_device *bd = inode->i_bdev;
+		struct hd_geometry geo;
+		int ret;
+
+                if (!argument)
+                        return -EINVAL;
+
+		geo.start = get_start_sect(bd);
+		ret = blkif_getgeo(bd, &geo);
+		if (ret)
+			return ret;
+
+		if (copy_to_user((struct hd_geometry __user *)argument, &geo,
+				 sizeof(geo)))
+                        return -EFAULT;
+
+                return 0;
+	}
+#endif
 	case CDROMMULTISESSION:
 		DPRINTK("FIXME: support multisession CDs later\n");
 		for (i = 0; i < sizeof(struct cdrom_multisession); i++)
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Wed Oct 04 15:59:00 2006 +0100
@@ -36,6 +36,10 @@
 #include <linux/blkdev.h>
 #include <linux/list.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -91,7 +95,9 @@ static struct block_device_operations xl
 	.open = blkif_open,
 	.release = blkif_release,
 	.ioctl  = blkif_ioctl,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) /* TODO: check version */
 	.getgeo = blkif_getgeo
+#endif
 };
 
 DEFINE_SPINLOCK(blkif_io_lock);
@@ -186,7 +192,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
 	if (rq == NULL)
 		return -1;
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	elevator_init(rq, "noop");
+#else
+	elevator_init(rq, &elevator_noop);
+#endif
 
 	/* Hard sector size and max sectors impersonate the equiv. hardware. */
 	blk_queue_hardsect_size(rq, sector_size);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/core/features.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Wed Oct 04 15:17:34 2006 +0100
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Oct 04 15:20:24 2006 +0100
@@ -44,6 +44,10 @@
 #include <asm/io.h>
 #include <xen/interface/memory.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
 
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 05 14:17:04 2006 +0100
@@ -64,6 +64,10 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Oct 04 15:20:36 2006 +0100
@@ -34,6 +34,10 @@
 #include <xen/gnttab.h>
 #include <xen/xenbus.h>
 #include <xen/driver_util.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Oct 04 15:26:30 2006 +0100
@@ -39,6 +39,10 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 05 16:09:05 2006 +0100
@@ -56,6 +56,10 @@
 
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 int xen_store_evtchn;
 struct xenstore_domain_interface *xen_store_interface;
 static unsigned long xen_store_mfn;
@@ -67,13 +71,17 @@ static void wait_for_devices(struct xenb
 static void wait_for_devices(struct xenbus_driver *xendrv);
 
 static int xenbus_probe_frontend(const char *type, const char *name);
+#ifdef CONFIG_XEN_BACKEND
 static int xenbus_uevent_backend(struct device *dev, char **envp,
 				 int num_envp, char *buffer, int buffer_size);
 static int xenbus_probe_backend(const char *type, const char *domid);
+#endif
 
 static int xenbus_dev_probe(struct device *_dev);
 static int xenbus_dev_remove(struct device *_dev);
+#ifdef CONFIG_XEN_BACKEND
 static void xenbus_dev_shutdown(struct device *_dev);
+#endif
 
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
@@ -176,10 +184,12 @@ static int read_backend_details(struct x
 }
 
 
+#ifdef CONFIG_XEN_BACKEND
 static int read_frontend_details(struct xenbus_device *xendev)
 {
 	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
+#endif
 
 
 /* Bus type for frontend drivers. */
@@ -191,15 +201,18 @@ static struct xen_bus_type xenbus_fronte
 	.bus = {
 		.name     = "xen",
 		.match    = xenbus_match,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 		.probe    = xenbus_dev_probe,
 		.remove   = xenbus_dev_remove,
 		.shutdown = xenbus_dev_shutdown,
+#endif
 	},
 	.dev = {
 		.bus_id = "xen",
 	},
 };
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
@@ -299,6 +312,7 @@ static int xenbus_uevent_backend(struct 
 
 	return 0;
 }
+#endif
 
 static void otherend_changed(struct xenbus_watch *watch,
 			     const char **vec, unsigned int len)
@@ -423,6 +437,7 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 static void xenbus_dev_shutdown(struct device *_dev)
 {
 	struct xenbus_device *dev = to_xenbus_device(_dev);
@@ -443,6 +458,7 @@ static void xenbus_dev_shutdown(struct d
  out:
 	put_device(&dev->dev);
 }
+#endif
 
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
@@ -451,7 +467,13 @@ static int xenbus_register_driver_common
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 	drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
+#endif
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -476,6 +498,7 @@ int xenbus_register_frontend(struct xenb
 }
 EXPORT_SYMBOL_GPL(xenbus_register_frontend);
 
+#ifdef CONFIG_XEN_BACKEND
 int xenbus_register_backend(struct xenbus_driver *drv)
 {
 	drv->read_otherend_details = read_frontend_details;
@@ -483,6 +506,7 @@ int xenbus_register_backend(struct xenbu
 	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL_GPL(xenbus_register_backend);
+#endif
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
@@ -581,14 +605,20 @@ char *kasprintf(const char *fmt, ...)
 }
 
 static ssize_t xendev_show_nodename(struct device *dev,
-				    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev,
-				   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
@@ -667,6 +697,7 @@ static int xenbus_probe_frontend(const c
 	return err;
 }
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<typename>/<frontend-uuid>/<name> */
 static int xenbus_probe_backend_unit(const char *dir,
 				     const char *type,
@@ -715,6 +746,7 @@ static int xenbus_probe_backend(const ch
 	kfree(nodename);
 	return err;
 }
+#endif
 
 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
 {
@@ -823,6 +855,7 @@ static void frontend_changed(struct xenb
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
 }
 
+#ifdef CONFIG_XEN_BACKEND
 static void backend_changed(struct xenbus_watch *watch,
 			    const char **vec, unsigned int len)
 {
@@ -830,6 +863,7 @@ static void backend_changed(struct xenbu
 
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
+#endif
 
 /* We watch for devices appearing and vanishing. */
 static struct xenbus_watch fe_watch = {
@@ -837,10 +871,12 @@ static struct xenbus_watch fe_watch = {
 	.callback = frontend_changed,
 };
 
+#ifdef CONFIG_XEN_BACKEND
 static struct xenbus_watch be_watch = {
 	.node = "backend",
 	.callback = backend_changed,
 };
+#endif
 
 static int suspend_dev(struct device *dev, void *data)
 {
@@ -912,7 +948,9 @@ void xenbus_suspend(void)
 	DPRINTK("");
 
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
+#endif
 	xs_suspend();
 }
 EXPORT_SYMBOL_GPL(xenbus_suspend);
@@ -922,7 +960,9 @@ void xenbus_resume(void)
 	xb_init_comms();
 	xs_resume();
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
+#endif
 }
 EXPORT_SYMBOL_GPL(xenbus_resume);
 
@@ -957,11 +997,15 @@ void xenbus_probe(void *unused)
 
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices(&xenbus_frontend);
+#ifdef CONFIG_XEN_BACKEND
 	xenbus_probe_devices(&xenbus_backend);
+#endif
 
 	/* Watch for changes. */
 	register_xenbus_watch(&fe_watch);
+#ifdef CONFIG_XEN_BACKEND
 	register_xenbus_watch(&be_watch);
+#endif
 
 	/* Notify others that xenstore is up */
 	notifier_call_chain(&xenstore_chain, 0, NULL);
@@ -973,6 +1017,7 @@ static struct proc_dir_entry *xsd_kva_in
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	size_t size = vma->vm_end - vma->vm_start;
@@ -986,6 +1031,9 @@ static int xsd_kva_mmap(struct file *fil
 
 	return 0;
 }
+#else
+#define xsd_kva_mmap NULL
+#endif
 
 static int xsd_kva_read(char *page, char **start, off_t off,
 			int count, int *eof, void *data)
@@ -1020,7 +1068,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
+#ifdef CONFIG_XEN_BACKEND
 	bus_register(&xenbus_backend.bus);
+#endif
 
 	/*
 	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
@@ -1091,7 +1141,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel device subsystem */
 	device_register(&xenbus_frontend.dev);
+#ifdef CONFIG_XEN_BACKEND
 	device_register(&xenbus_backend.dev);
+#endif
 
 	if (!is_initial_xendomain())
 		xenbus_probe(NULL);
diff -r 8959876abbe3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Oct 05 16:01:30 2006 +0100
@@ -42,8 +42,13 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
+#include <linux/module.h>
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r 8959876abbe3 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Wed Oct 04 15:13:48 2006 +0100
@@ -8,6 +8,10 @@
  */
 
 #include <linux/config.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 #define ADDR (*(volatile long *) addr)
 
diff -r 8959876abbe3 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Thu Oct 05 14:07:57 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Oct 04 15:16:43 2006 +0100
@@ -38,10 +38,15 @@
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/init.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* Register callback to watch this node. */
 struct xenbus_watch
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk	Wed Oct 04 15:21:20 2006 +0100
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
 EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_COMPAT_H
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/evtchn.c
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Wed Oct 04 15:26:54 2006 +0100
@@ -35,6 +35,10 @@
 #include <xen/interface/hvm/ioreq.h>
 #include <xen/features.h>
 #include "platform-pci.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 void *shared_info_area;
 
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Oct 05 10:52:37 2006 +0100
@@ -38,6 +38,10 @@
 
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define DRV_NAME    "xen-platform-pci"
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Wed Oct 04 15:26:59 2006 +0100
@@ -26,6 +26,10 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
 	BUG();
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/Kbuild
--- a/unmodified_drivers/linux-2.6/xenbus/Kbuild	Thu Oct 05 14:07:57 2006 +0100
+++ b/unmodified_drivers/linux-2.6/xenbus/Kbuild	Wed Oct 04 15:30:27 2006 +0100
@@ -8,3 +8,4 @@ xenbus-objs += xenbus_dev.o
 xenbus-objs += xenbus_dev.o 
 xenbus-objs += xenbus_client.o 
 xenbus-objs += xen_proc.o
+xenbus-objs += compat.o
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/blkfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile	Wed Oct 04 15:25:10 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h	Wed Oct 04 14:32:22 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPMD_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Wed Oct 04 14:30:35 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPUD_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/compat.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/compat.h	Thu Oct 05 16:16:03 2006 +0100
@@ -0,0 +1,49 @@
+#ifndef COMPAT_INCLUDE_COMPAT_H
+#define COMPAT_INCLUDE_COMPAT_H
+
+#include <linux/version.h>
+
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) /* TODO: confirm version */
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kzalloc(size_t size, int flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
+#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
+#endif
+
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+struct page *vmalloc_to_page(void *addr);
+unsigned long vmalloc_to_pfn(void *addr);
+#endif
+
+#endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/linux/io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h	Wed Oct 04 15:27:26 2006 +0100
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) /* TODO: check version */
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h	Wed Oct 04 14:44:32 2006 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so        *
+ * it is negated to the down_trylock() return values! Be careful  */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile	Wed Oct 04 15:25:01 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/platform-pci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile	Wed Oct 04 11:59:14 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile	Wed Oct 04 15:31:51 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r 8959876abbe3 unmodified_drivers/linux-2.6/xenbus/compat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/compat.c	Thu Oct 05 10:52:33 2006 +0100
@@ -0,0 +1,54 @@
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+/*
+ * Map a vmalloc()-space virtual address to the physical page.
+ */
+struct page * vmalloc_to_page(void * vmalloc_addr)
+{
+        unsigned long addr = (unsigned long) vmalloc_addr;
+        struct page *page = NULL;
+        pgd_t *pgd = pgd_offset_k(addr);
+        pud_t *pud;
+        pmd_t *pmd;
+        pte_t *ptep, pte;
+
+        if (!pgd_none(*pgd)) {
+                pud = pud_offset(pgd, addr);
+                if (!pud_none(*pud)) {
+                        pmd = pmd_offset(pud, addr);
+                        if (!pmd_none(*pmd)) {
+                                ptep = pte_offset_map(pmd, addr);
+                                pte = *ptep;
+                                if (pte_present(pte))
+                                        page = pte_page(pte);
+                                pte_unmap(ptep);
+                        }
+                }
+        }
+        return page;
+}
+
+EXPORT_SYMBOL(vmalloc_to_page);
+
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+        return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+
+EXPORT_SYMBOL(vmalloc_to_pfn);
+#endif

[-- 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] 22+ messages in thread

* Re: PV drivers for HVM guests
  2006-10-05 15:21 ` Ian Campbell
@ 2006-10-05 16:47   ` Ky Srinivasan
  2006-10-10  8:00   ` DOI Tsunehisa
  1 sibling, 0 replies; 22+ messages in thread
From: Ky Srinivasan @ 2006-10-05 16:47 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Thanks Ian. I am currently testing my implementation on sles9. I will certainly look at how I can leverage your work.

Regards,

K. Y

>>> On Thu, Oct 5, 2006 at 11:21 AM, in message
<1160061687.3755.101.camel@localhost.localdomain>, Ian Campbell
<Ian.Campbell@XenSource.com> wrote: 
> On Tue, 2006- 10- 03 at 16:31 - 0400, Ky Srinivasan wrote:
>> 2)  Introduce  a compatibility component that bridges the gap between
>> the current PV code and a given Linux target and leave much of the PV
>> driver  code untouched.
>> 
>> I have implemented both these schemes for the sles9 kernel 
> 
> FWIW I have a half complete implementation (compile tested only) of such
> a scheme which I've attached, perhaps you can crib something useful from
> it ;- ).
> 
> Basically it adds a compat- include directory to the end of the include
> search path which contains compatibility versions of headers which may
> not present in older kernels and adds compat.h which defines other
> missing bits where necessary.
> 
> It covers most of the issues compiling against a RHEL4 (2.6.9) or SLES9
> (2.6.5) kernel, although compatibility shims for
> schedule_timeout_interruptible() and nonseekable_open() are still
> missing and the versions used for triggering compatibility code are
> certainly totally wrong (just right for RHEL4 and SLES9 though ;- )).
> 
> I'm fairly unhappy about the number of ifdef's in xenbus_probe.c. I
> reckon some function reordering could coalesce a lot of them. Perhaps
> they are candidates for splitting into a separate file.
> 
> This work will also be useful for the fully PV vendor kernel ports which
> is why I'm interested.
> 
> Ian.

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

* Re: PV drivers for HVM guests
  2006-10-05 15:21 ` Ian Campbell
  2006-10-05 16:47   ` Ky Srinivasan
@ 2006-10-10  8:00   ` DOI Tsunehisa
  2006-10-11 10:46     ` DOI Tsunehisa
  1 sibling, 1 reply; 22+ messages in thread
From: DOI Tsunehisa @ 2006-10-10  8:00 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Ky Srinivasan, xen-devel

[-- Attachment #1: Type: text/plain, Size: 681 bytes --]

Hi,

Ian Campbell wrote:
> On Tue, 2006-10-03 at 16:31 -0400, Ky Srinivasan wrote:
>> 2)  Introduce  a compatibility component that bridges the gap between
>> the current PV code and a given Linux target and leave much of the PV
>> driver  code untouched.
>>
>> I have implemented both these schemes for the sles9 kernel 
> 
> FWIW I have a half complete implementation (compile tested only) of such
> a scheme which I've attached, perhaps you can crib something useful from
> it ;-).

  I modified Ian's patch for RHEL4.

  We've tested compiling and attaching them on RHEL4. In our simple
test, PV-on-HVM VBD/VNIF drivers work on RHEL4 original kernel.

Thanks,
- Tsunehisa Doi


[-- Attachment #2: pv-backport.patch --]
[-- Type: text/plain, Size: 24457 bytes --]

# HG changeset patch
# User Doi.Tsunehisa@jp.fujitsu.com
# Node ID 605297fb8618ffab4dc5bf14887700ccf3e98b78
# Parent  ab85c20d33e50fb29b451580ce03f7697a0fc3b5
Backport PV-on-HVM for pre linux-2.6.16

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>

diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Oct 10 14:29:36 2006 +0900
@@ -48,6 +48,10 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
@@ -468,6 +472,27 @@ int blkif_ioctl(struct inode *inode, str
 		      command, (long)argument, inode->i_rdev);
 
 	switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	case HDIO_GETGEO: {
+		struct block_device *bd = inode->i_bdev;
+		struct hd_geometry geo;
+		int ret;
+
+                if (!argument)
+                        return -EINVAL;
+
+		geo.start = get_start_sect(bd);
+		ret = blkif_getgeo(bd, &geo);
+		if (ret)
+			return ret;
+
+		if (copy_to_user((struct hd_geometry __user *)argument, &geo,
+				 sizeof(geo)))
+                        return -EFAULT;
+
+                return 0;
+	}
+#endif
 	case CDROMMULTISESSION:
 		DPRINTK("FIXME: support multisession CDs later\n");
 		for (i = 0; i < sizeof(struct cdrom_multisession); i++)
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Tue Oct 10 14:29:36 2006 +0900
@@ -36,6 +36,10 @@
 #include <linux/blkdev.h>
 #include <linux/list.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -91,7 +95,9 @@ static struct block_device_operations xl
 	.open = blkif_open,
 	.release = blkif_release,
 	.ioctl  = blkif_ioctl,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) /* TODO: check version */
 	.getgeo = blkif_getgeo
+#endif
 };
 
 DEFINE_SPINLOCK(blkif_io_lock);
@@ -186,7 +192,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
 	if (rq == NULL)
 		return -1;
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	elevator_init(rq, "noop");
+#else
+	elevator_init(rq, &elevator_noop);
+#endif
 
 	/* Hard sector size and max sectors impersonate the equiv. hardware. */
 	blk_queue_hardsect_size(rq, sector_size);
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/core/features.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Tue Oct 10 14:29:36 2006 +0900
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Oct 10 14:29:36 2006 +0900
@@ -44,6 +44,10 @@
 #include <asm/io.h>
 #include <xen/interface/memory.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
 
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Oct 10 14:29:36 2006 +0900
@@ -64,6 +64,10 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Tue Oct 10 14:29:36 2006 +0900
@@ -34,6 +34,10 @@
 #include <xen/gnttab.h>
 #include <xen/xenbus.h>
 #include <xen/driver_util.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Tue Oct 10 14:29:36 2006 +0900
@@ -39,6 +39,10 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Oct 10 14:29:36 2006 +0900
@@ -56,6 +56,10 @@
 
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 int xen_store_evtchn;
 struct xenstore_domain_interface *xen_store_interface;
 static unsigned long xen_store_mfn;
@@ -67,13 +71,17 @@ static void wait_for_devices(struct xenb
 static void wait_for_devices(struct xenbus_driver *xendrv);
 
 static int xenbus_probe_frontend(const char *type, const char *name);
+#ifdef CONFIG_XEN_BACKEND
 static int xenbus_uevent_backend(struct device *dev, char **envp,
 				 int num_envp, char *buffer, int buffer_size);
 static int xenbus_probe_backend(const char *type, const char *domid);
+#endif
 
 static int xenbus_dev_probe(struct device *_dev);
 static int xenbus_dev_remove(struct device *_dev);
+#ifdef CONFIG_XEN_BACKEND
 static void xenbus_dev_shutdown(struct device *_dev);
+#endif
 
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
@@ -176,10 +184,12 @@ static int read_backend_details(struct x
 }
 
 
+#ifdef CONFIG_XEN_BACKEND
 static int read_frontend_details(struct xenbus_device *xendev)
 {
 	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
+#endif
 
 
 /* Bus type for frontend drivers. */
@@ -191,15 +201,18 @@ static struct xen_bus_type xenbus_fronte
 	.bus = {
 		.name     = "xen",
 		.match    = xenbus_match,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 		.probe    = xenbus_dev_probe,
 		.remove   = xenbus_dev_remove,
 		.shutdown = xenbus_dev_shutdown,
+#endif
 	},
 	.dev = {
 		.bus_id = "xen",
 	},
 };
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
@@ -299,6 +312,7 @@ static int xenbus_uevent_backend(struct 
 
 	return 0;
 }
+#endif
 
 static void otherend_changed(struct xenbus_watch *watch,
 			     const char **vec, unsigned int len)
@@ -423,6 +437,7 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 static void xenbus_dev_shutdown(struct device *_dev)
 {
 	struct xenbus_device *dev = to_xenbus_device(_dev);
@@ -443,6 +458,7 @@ static void xenbus_dev_shutdown(struct d
  out:
 	put_device(&dev->dev);
 }
+#endif
 
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
@@ -451,7 +467,13 @@ static int xenbus_register_driver_common
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
 	drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
+#endif
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -476,6 +498,7 @@ int xenbus_register_frontend(struct xenb
 }
 EXPORT_SYMBOL_GPL(xenbus_register_frontend);
 
+#ifdef CONFIG_XEN_BACKEND
 int xenbus_register_backend(struct xenbus_driver *drv)
 {
 	drv->read_otherend_details = read_frontend_details;
@@ -483,6 +506,7 @@ int xenbus_register_backend(struct xenbu
 	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL_GPL(xenbus_register_backend);
+#endif
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
@@ -581,14 +605,20 @@ char *kasprintf(const char *fmt, ...)
 }
 
 static ssize_t xendev_show_nodename(struct device *dev,
-				    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev,
-				   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* TODO: confirm version */
+				   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
@@ -667,6 +697,7 @@ static int xenbus_probe_frontend(const c
 	return err;
 }
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<typename>/<frontend-uuid>/<name> */
 static int xenbus_probe_backend_unit(const char *dir,
 				     const char *type,
@@ -715,6 +746,7 @@ static int xenbus_probe_backend(const ch
 	kfree(nodename);
 	return err;
 }
+#endif
 
 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
 {
@@ -823,6 +855,7 @@ static void frontend_changed(struct xenb
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
 }
 
+#ifdef CONFIG_XEN_BACKEND
 static void backend_changed(struct xenbus_watch *watch,
 			    const char **vec, unsigned int len)
 {
@@ -830,6 +863,7 @@ static void backend_changed(struct xenbu
 
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
+#endif
 
 /* We watch for devices appearing and vanishing. */
 static struct xenbus_watch fe_watch = {
@@ -837,10 +871,12 @@ static struct xenbus_watch fe_watch = {
 	.callback = frontend_changed,
 };
 
+#ifdef CONFIG_XEN_BACKEND
 static struct xenbus_watch be_watch = {
 	.node = "backend",
 	.callback = backend_changed,
 };
+#endif
 
 static int suspend_dev(struct device *dev, void *data)
 {
@@ -912,7 +948,9 @@ void xenbus_suspend(void)
 	DPRINTK("");
 
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
+#endif
 	xs_suspend();
 }
 EXPORT_SYMBOL_GPL(xenbus_suspend);
@@ -922,7 +960,9 @@ void xenbus_resume(void)
 	xb_init_comms();
 	xs_resume();
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
+#endif
 }
 EXPORT_SYMBOL_GPL(xenbus_resume);
 
@@ -957,11 +997,15 @@ void xenbus_probe(void *unused)
 
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices(&xenbus_frontend);
+#ifdef CONFIG_XEN_BACKEND
 	xenbus_probe_devices(&xenbus_backend);
+#endif
 
 	/* Watch for changes. */
 	register_xenbus_watch(&fe_watch);
+#ifdef CONFIG_XEN_BACKEND
 	register_xenbus_watch(&be_watch);
+#endif
 
 	/* Notify others that xenstore is up */
 	notifier_call_chain(&xenstore_chain, 0, NULL);
@@ -973,6 +1017,7 @@ static struct proc_dir_entry *xsd_kva_in
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	size_t size = vma->vm_end - vma->vm_start;
@@ -986,6 +1031,9 @@ static int xsd_kva_mmap(struct file *fil
 
 	return 0;
 }
+#else
+#define xsd_kva_mmap NULL
+#endif
 
 static int xsd_kva_read(char *page, char **start, off_t off,
 			int count, int *eof, void *data)
@@ -1020,7 +1068,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
+#ifdef CONFIG_XEN_BACKEND
 	bus_register(&xenbus_backend.bus);
+#endif
 
 	/*
 	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
@@ -1091,7 +1141,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel device subsystem */
 	device_register(&xenbus_frontend.dev);
+#ifdef CONFIG_XEN_BACKEND
 	device_register(&xenbus_backend.dev);
+#endif
 
 	if (!is_initial_xendomain())
 		xenbus_probe(NULL);
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Tue Oct 10 14:29:36 2006 +0900
@@ -42,8 +42,13 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
+#include <linux/module.h>
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Tue Oct 10 14:29:36 2006 +0900
@@ -8,6 +8,10 @@
  */
 
 #include <linux/config.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 #define ADDR (*(volatile long *) addr)
 
diff -r ab85c20d33e5 -r 605297fb8618 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Mon Oct 09 23:34:00 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Tue Oct 10 14:29:36 2006 +0900
@@ -38,10 +38,15 @@
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/init.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* Register callback to watch this node. */
 struct xenbus_watch
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk	Mon Oct 09 23:34:00 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk	Tue Oct 10 14:29:36 2006 +0900
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
 EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_COMPAT_H
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/Kbuild
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Mon Oct 09 23:34:00 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Tue Oct 10 14:29:36 2006 +0900
@@ -4,4 +4,10 @@ obj-m := xen-platform-pci.o
 
 EXTRA_CFLAGS += -I$(M)/platform-pci
 
-xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
+xen-platform-pci-objs :=
+xen-platform-pci-objs += platform-pci.o
+xen-platform-pci-objs += features.o
+xen-platform-pci-objs += evtchn.o
+xen-platform-pci-objs += gnttab.o
+xen-platform-pci-objs += xen_support.o
+xen-platform-pci-objs += compat.o
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/evtchn.c
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Tue Oct 10 14:29:36 2006 +0900
@@ -35,6 +35,10 @@
 #include <xen/interface/hvm/ioreq.h>
 #include <xen/features.h>
 #include "platform-pci.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 void *shared_info_area;
 
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Tue Oct 10 14:29:36 2006 +0900
@@ -38,6 +38,10 @@
 
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define DRV_NAME    "xen-platform-pci"
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Mon Oct 09 23:34:00 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Tue Oct 10 14:29:36 2006 +0900
@@ -26,6 +26,10 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
 	BUG();
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/blkfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPMD_H */
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPUD_H */
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/compat-include/compat.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/compat.h	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,52 @@
+#ifndef COMPAT_INCLUDE_COMPAT_H
+#define COMPAT_INCLUDE_COMPAT_H
+
+#include <linux/version.h>
+
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kzalloc(size_t size, int flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
+#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+unsigned long vmalloc_to_pfn(void *addr);
+#endif
+
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+signed long __sched schedule_timeout_interruptible(signed long timeout);
+#endif
+
+#endif /* !COMPAT_INCLUDE_COMPAT_H */
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/compat-include/linux/io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so        *
+ * it is negated to the down_trylock() return values! Be careful  */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/platform-pci/compat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/compat.c	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,48 @@
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+	return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+
+EXPORT_SYMBOL(vmalloc_to_pfn);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+/*
+    fake do_exit using complete_and_exit
+ */
+asmlinkage NORET_TYPE void do_exit(long code)
+{
+    complete_and_exit(NULL, code);
+}
+EXPORT_SYMBOL(do_exit);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/*
+ * We can use __set_current_state() here because schedule_timeout() calls
+ * schedule() unconditionally.
+ */
+signed long __sched schedule_timeout_interruptible(signed long timeout)
+{
+	__set_current_state(TASK_INTERRUPTIBLE);
+	return schedule_timeout(timeout);
+}
+EXPORT_SYMBOL(schedule_timeout_interruptible);
+#endif
diff -r ab85c20d33e5 -r 605297fb8618 unmodified_drivers/linux-2.6/xenbus/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile	Tue Oct 10 14:29:36 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif

[-- 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] 22+ messages in thread

* Re: PV drivers for HVM guests
  2006-10-10  8:00   ` DOI Tsunehisa
@ 2006-10-11 10:46     ` DOI Tsunehisa
  2006-10-13  2:00       ` DOI Tsunehisa
  0 siblings, 1 reply; 22+ messages in thread
From: DOI Tsunehisa @ 2006-10-11 10:46 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Ky Srinivasan, xen-devel

[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]

Hi all,

DOI Tsunehisa wrote:
>   I modified Ian's patch for RHEL4.
>
>   We've tested compiling and attaching them on RHEL4. In our simple
> test, PV-on-HVM VBD/VNIF drivers work on RHEL4 original kernel.

  I checked several version of kernel source, and modified the patch.

  This patch is modified from Ian's patch:

  + move compat.c from xenbus to platform-pci
    - platform-pci needs vmalloc_to_pfn() realized in compat.c
      * platform-pci is inserted before xenbus insertion.
  + append schedule_timeout_interruptible() to compat.c
    - the code was copied from linux/kernel/timer.c
  + append do_exit() faker to compat.c
    - the faker was implemented using complete_and_exit()
  + delete vmalloc_to_page() from compat.c
    - vmalloc_to_page() already exists in linux-2.6.0 kernel.
  + conferm version for several features
    - do conferm version about "TODO: conferm version"

  We've tested compiling and attaching them on RHEL4. And they
work on RHEL4 in same test.

Thanks,
- Doi Tsunehisa


[-- Attachment #2: pv-backport2.patch --]
[-- Type: text/plain, Size: 24265 bytes --]

# HG changeset patch
# User Doi.Tsunehisa@jp.fujitsu.com
# Node ID 50d32ae2e0f45bdd06d6f14cc1c851cf3f130adf
# Parent  f7d65fb7299b95b8b6d3a44134a9f2af211393c6
Backport PV-on-HVM drivers for pre-linux-2.6.16

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>

diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Oct 11 16:58:28 2006 +0900
@@ -48,6 +48,10 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
@@ -468,6 +472,27 @@ int blkif_ioctl(struct inode *inode, str
 		      command, (long)argument, inode->i_rdev);
 
 	switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+	case HDIO_GETGEO: {
+		struct block_device *bd = inode->i_bdev;
+		struct hd_geometry geo;
+		int ret;
+
+                if (!argument)
+                        return -EINVAL;
+
+		geo.start = get_start_sect(bd);
+		ret = blkif_getgeo(bd, &geo);
+		if (ret)
+			return ret;
+
+		if (copy_to_user((struct hd_geometry __user *)argument, &geo,
+				 sizeof(geo)))
+                        return -EFAULT;
+
+                return 0;
+	}
+#endif
 	case CDROMMULTISESSION:
 		DPRINTK("FIXME: support multisession CDs later\n");
 		for (i = 0; i < sizeof(struct cdrom_multisession); i++)
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Wed Oct 11 16:58:28 2006 +0900
@@ -36,6 +36,10 @@
 #include <linux/blkdev.h>
 #include <linux/list.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -91,7 +95,9 @@ static struct block_device_operations xl
 	.open = blkif_open,
 	.release = blkif_release,
 	.ioctl  = blkif_ioctl,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 	.getgeo = blkif_getgeo
+#endif
 };
 
 DEFINE_SPINLOCK(blkif_io_lock);
@@ -186,7 +192,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
 	if (rq == NULL)
 		return -1;
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	elevator_init(rq, "noop");
+#else
+	elevator_init(rq, &elevator_noop);
+#endif
 
 	/* Hard sector size and max sectors impersonate the equiv. hardware. */
 	blk_queue_hardsect_size(rq, sector_size);
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/core/features.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Wed Oct 11 16:58:28 2006 +0900
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Oct 11 16:58:28 2006 +0900
@@ -44,6 +44,10 @@
 #include <asm/io.h>
 #include <xen/interface/memory.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
 
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Oct 11 16:58:28 2006 +0900
@@ -64,6 +64,10 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Oct 11 16:58:28 2006 +0900
@@ -34,6 +34,10 @@
 #include <xen/gnttab.h>
 #include <xen/xenbus.h>
 #include <xen/driver_util.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Oct 11 16:58:28 2006 +0900
@@ -39,6 +39,10 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Oct 11 16:58:28 2006 +0900
@@ -56,6 +56,10 @@
 
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 int xen_store_evtchn;
 struct xenstore_domain_interface *xen_store_interface;
 static unsigned long xen_store_mfn;
@@ -67,13 +71,17 @@ static void wait_for_devices(struct xenb
 static void wait_for_devices(struct xenbus_driver *xendrv);
 
 static int xenbus_probe_frontend(const char *type, const char *name);
+#ifdef CONFIG_XEN_BACKEND
 static int xenbus_uevent_backend(struct device *dev, char **envp,
 				 int num_envp, char *buffer, int buffer_size);
 static int xenbus_probe_backend(const char *type, const char *domid);
+#endif
 
 static int xenbus_dev_probe(struct device *_dev);
 static int xenbus_dev_remove(struct device *_dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 static void xenbus_dev_shutdown(struct device *_dev);
+#endif
 
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
@@ -176,10 +184,12 @@ static int read_backend_details(struct x
 }
 
 
+#ifdef CONFIG_XEN_BACKEND
 static int read_frontend_details(struct xenbus_device *xendev)
 {
 	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
+#endif
 
 
 /* Bus type for frontend drivers. */
@@ -191,15 +201,18 @@ static struct xen_bus_type xenbus_fronte
 	.bus = {
 		.name     = "xen",
 		.match    = xenbus_match,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 		.probe    = xenbus_dev_probe,
 		.remove   = xenbus_dev_remove,
 		.shutdown = xenbus_dev_shutdown,
+#endif
 	},
 	.dev = {
 		.bus_id = "xen",
 	},
 };
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
@@ -299,6 +312,7 @@ static int xenbus_uevent_backend(struct 
 
 	return 0;
 }
+#endif
 
 static void otherend_changed(struct xenbus_watch *watch,
 			     const char **vec, unsigned int len)
@@ -423,6 +437,7 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 static void xenbus_dev_shutdown(struct device *_dev)
 {
 	struct xenbus_device *dev = to_xenbus_device(_dev);
@@ -443,6 +458,7 @@ static void xenbus_dev_shutdown(struct d
  out:
 	put_device(&dev->dev);
 }
+#endif
 
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
@@ -451,7 +467,13 @@ static int xenbus_register_driver_common
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
+#endif
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -476,6 +498,7 @@ int xenbus_register_frontend(struct xenb
 }
 EXPORT_SYMBOL_GPL(xenbus_register_frontend);
 
+#ifdef CONFIG_XEN_BACKEND
 int xenbus_register_backend(struct xenbus_driver *drv)
 {
 	drv->read_otherend_details = read_frontend_details;
@@ -483,6 +506,7 @@ int xenbus_register_backend(struct xenbu
 	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL_GPL(xenbus_register_backend);
+#endif
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
@@ -581,14 +605,20 @@ char *kasprintf(const char *fmt, ...)
 }
 
 static ssize_t xendev_show_nodename(struct device *dev,
-				    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+				    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev,
-				   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+				   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
@@ -667,6 +697,7 @@ static int xenbus_probe_frontend(const c
 	return err;
 }
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<typename>/<frontend-uuid>/<name> */
 static int xenbus_probe_backend_unit(const char *dir,
 				     const char *type,
@@ -715,6 +746,7 @@ static int xenbus_probe_backend(const ch
 	kfree(nodename);
 	return err;
 }
+#endif
 
 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
 {
@@ -823,6 +855,7 @@ static void frontend_changed(struct xenb
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
 }
 
+#ifdef CONFIG_XEN_BACKEND
 static void backend_changed(struct xenbus_watch *watch,
 			    const char **vec, unsigned int len)
 {
@@ -830,6 +863,7 @@ static void backend_changed(struct xenbu
 
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
+#endif
 
 /* We watch for devices appearing and vanishing. */
 static struct xenbus_watch fe_watch = {
@@ -837,10 +871,12 @@ static struct xenbus_watch fe_watch = {
 	.callback = frontend_changed,
 };
 
+#ifdef CONFIG_XEN_BACKEND
 static struct xenbus_watch be_watch = {
 	.node = "backend",
 	.callback = backend_changed,
 };
+#endif
 
 static int suspend_dev(struct device *dev, void *data)
 {
@@ -912,7 +948,9 @@ void xenbus_suspend(void)
 	DPRINTK("");
 
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
+#endif
 	xs_suspend();
 }
 EXPORT_SYMBOL_GPL(xenbus_suspend);
@@ -922,7 +960,9 @@ void xenbus_resume(void)
 	xb_init_comms();
 	xs_resume();
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
+#endif
 }
 EXPORT_SYMBOL_GPL(xenbus_resume);
 
@@ -957,11 +997,15 @@ void xenbus_probe(void *unused)
 
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices(&xenbus_frontend);
+#ifdef CONFIG_XEN_BACKEND
 	xenbus_probe_devices(&xenbus_backend);
+#endif
 
 	/* Watch for changes. */
 	register_xenbus_watch(&fe_watch);
+#ifdef CONFIG_XEN_BACKEND
 	register_xenbus_watch(&be_watch);
+#endif
 
 	/* Notify others that xenstore is up */
 	notifier_call_chain(&xenstore_chain, 0, NULL);
@@ -973,6 +1017,7 @@ static struct proc_dir_entry *xsd_kva_in
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	size_t size = vma->vm_end - vma->vm_start;
@@ -986,6 +1031,9 @@ static int xsd_kva_mmap(struct file *fil
 
 	return 0;
 }
+#else
+#define xsd_kva_mmap NULL
+#endif
 
 static int xsd_kva_read(char *page, char **start, off_t off,
 			int count, int *eof, void *data)
@@ -1020,7 +1068,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
+#ifdef CONFIG_XEN_BACKEND
 	bus_register(&xenbus_backend.bus);
+#endif
 
 	/*
 	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
@@ -1091,7 +1141,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel device subsystem */
 	device_register(&xenbus_frontend.dev);
+#ifdef CONFIG_XEN_BACKEND
 	device_register(&xenbus_backend.dev);
+#endif
 
 	if (!is_initial_xendomain())
 		xenbus_probe(NULL);
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Wed Oct 11 16:58:28 2006 +0900
@@ -42,8 +42,13 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
+#include <linux/module.h>
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Wed Oct 11 16:58:28 2006 +0900
@@ -8,6 +8,10 @@
  */
 
 #include <linux/config.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 #define ADDR (*(volatile long *) addr)
 
diff -r f7d65fb7299b -r 50d32ae2e0f4 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Tue Oct 10 22:04:01 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Oct 11 16:58:28 2006 +0900
@@ -38,10 +38,15 @@
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/init.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* Register callback to watch this node. */
 struct xenbus_watch
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk	Tue Oct 10 22:04:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk	Wed Oct 11 16:58:28 2006 +0900
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
 EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_COMPAT_H
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/Kbuild
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Tue Oct 10 22:04:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Wed Oct 11 16:58:28 2006 +0900
@@ -4,4 +4,10 @@ obj-m := xen-platform-pci.o
 
 EXTRA_CFLAGS += -I$(M)/platform-pci
 
-xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
+xen-platform-pci-objs :=
+xen-platform-pci-objs += platform-pci.o
+xen-platform-pci-objs += features.o
+xen-platform-pci-objs += evtchn.o
+xen-platform-pci-objs += gnttab.o
+xen-platform-pci-objs += xen_support.o
+xen-platform-pci-objs += compat.o
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/evtchn.c
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Wed Oct 11 16:58:28 2006 +0900
@@ -35,6 +35,10 @@
 #include <xen/interface/hvm/ioreq.h>
 #include <xen/features.h>
 #include "platform-pci.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 void *shared_info_area;
 
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Wed Oct 11 16:58:28 2006 +0900
@@ -38,6 +38,10 @@
 
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define DRV_NAME    "xen-platform-pci"
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Tue Oct 10 22:04:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Wed Oct 11 16:58:28 2006 +0900
@@ -26,6 +26,10 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
 	BUG();
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/blkfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPMD_H */
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPUD_H */
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/compat-include/compat.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/compat.h	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,52 @@
+#ifndef COMPAT_INCLUDE_COMPAT_H
+#define COMPAT_INCLUDE_COMPAT_H
+
+#include <linux/version.h>
+
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kzalloc(size_t size, int flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
+#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+unsigned long vmalloc_to_pfn(void *addr);
+#endif
+
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+signed long __sched schedule_timeout_interruptible(signed long timeout);
+#endif
+
+#endif /* !COMPAT_INCLUDE_COMPAT_H */
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/compat-include/linux/io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so        *
+ * it is negated to the down_trylock() return values! Be careful  */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/platform-pci/compat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/compat.c	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,48 @@
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+	return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+
+EXPORT_SYMBOL(vmalloc_to_pfn);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+/*
+    fake do_exit using complete_and_exit
+ */
+asmlinkage NORET_TYPE void do_exit(long code)
+{
+    complete_and_exit(NULL, code);
+}
+EXPORT_SYMBOL(do_exit);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/*
+ * We can use __set_current_state() here because schedule_timeout() calls
+ * schedule() unconditionally.
+ */
+signed long __sched schedule_timeout_interruptible(signed long timeout)
+{
+	__set_current_state(TASK_INTERRUPTIBLE);
+	return schedule_timeout(timeout);
+}
+EXPORT_SYMBOL(schedule_timeout_interruptible);
+#endif
diff -r f7d65fb7299b -r 50d32ae2e0f4 unmodified_drivers/linux-2.6/xenbus/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile	Wed Oct 11 16:58:28 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif

[-- 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] 22+ messages in thread

* Re: PV drivers for HVM guests
  2006-10-11 10:46     ` DOI Tsunehisa
@ 2006-10-13  2:00       ` DOI Tsunehisa
  2006-10-13  6:55         ` Ian Campbell
  0 siblings, 1 reply; 22+ messages in thread
From: DOI Tsunehisa @ 2006-10-13  2:00 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Ky Srinivasan, xen-devel

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

Hi all,

  I found some issue with my old patch.

  + Fix do_exit() faker type
    - can't compile on linux-2.6.10 and 2.6.11
    - do_exit() faker is mismatched with original header.
    - do_exit type changed after linux-2.6.10
      <  asmlinkage NORET_TYPE void do_exit(long code);
      >  fastcall NORET_TYPE void do_exit(long code);
  + Fix compat-include/linun/mutex.h about version checker
    - change reference version from 2.6.16 to 2.6.15

DOI Tsunehisa wrote:
> Hi all,
> 
> DOI Tsunehisa wrote:
>>   I modified Ian's patch for RHEL4.
>>
>>   We've tested compiling and attaching them on RHEL4. In our simple
>> test, PV-on-HVM VBD/VNIF drivers work on RHEL4 original kernel.
> 
>   I checked several version of kernel source, and modified the patch.
> 
>   This patch is modified from Ian's patch:
> 
>   + move compat.c from xenbus to platform-pci
>     - platform-pci needs vmalloc_to_pfn() realized in compat.c
>       * platform-pci is inserted before xenbus insertion.
>   + append schedule_timeout_interruptible() to compat.c
>     - the code was copied from linux/kernel/timer.c
>   + append do_exit() faker to compat.c
>     - the faker was implemented using complete_and_exit()
>   + delete vmalloc_to_page() from compat.c
>     - vmalloc_to_page() already exists in linux-2.6.0 kernel.
>   + conferm version for several features
>     - do conferm version about "TODO: conferm version"
> 
>   We've tested compiling and attaching them on RHEL4. And they
> work on RHEL4 in same test.
> 
> Thanks,
> - Doi Tsunehisa

[-- Attachment #2: pv-backport3.patch --]
[-- Type: text/plain, Size: 24367 bytes --]

# HG changeset patch
# User Doi.Tsunehisa@jp.fujitsu.com
# Node ID 6e075156ea4603c81d1ebd37bdb2fea00eb9f026
# Parent  f14a67a35becfb8fb9b455a219fd1a7c942bc21d
Modify for backporting PV-on-HVM drivers

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>

diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Oct 13 09:06:45 2006 +0900
@@ -48,6 +48,10 @@
 #include <asm/hypervisor.h>
 #include <asm/maddr.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
@@ -468,6 +472,27 @@ int blkif_ioctl(struct inode *inode, str
 		      command, (long)argument, inode->i_rdev);
 
 	switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+	case HDIO_GETGEO: {
+		struct block_device *bd = inode->i_bdev;
+		struct hd_geometry geo;
+		int ret;
+
+                if (!argument)
+                        return -EINVAL;
+
+		geo.start = get_start_sect(bd);
+		ret = blkif_getgeo(bd, &geo);
+		if (ret)
+			return ret;
+
+		if (copy_to_user((struct hd_geometry __user *)argument, &geo,
+				 sizeof(geo)))
+                        return -EFAULT;
+
+                return 0;
+	}
+#endif
 	case CDROMMULTISESSION:
 		DPRINTK("FIXME: support multisession CDs later\n");
 		for (i = 0; i < sizeof(struct cdrom_multisession); i++)
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Oct 13 09:06:45 2006 +0900
@@ -36,6 +36,10 @@
 #include <linux/blkdev.h>
 #include <linux/list.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -91,7 +95,9 @@ static struct block_device_operations xl
 	.open = blkif_open,
 	.release = blkif_release,
 	.ioctl  = blkif_ioctl,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 	.getgeo = blkif_getgeo
+#endif
 };
 
 DEFINE_SPINLOCK(blkif_io_lock);
@@ -186,7 +192,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
 	if (rq == NULL)
 		return -1;
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	elevator_init(rq, "noop");
+#else
+	elevator_init(rq, &elevator_noop);
+#endif
 
 	/* Hard sector size and max sectors impersonate the equiv. hardware. */
 	blk_queue_hardsect_size(rq, sector_size);
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/core/features.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Fri Oct 13 09:06:45 2006 +0900
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <asm/hypervisor.h>
 #include <xen/features.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri Oct 13 09:06:45 2006 +0900
@@ -44,6 +44,10 @@
 #include <asm/io.h>
 #include <xen/interface/memory.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
 
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Oct 13 09:06:45 2006 +0900
@@ -64,6 +64,10 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Fri Oct 13 09:06:45 2006 +0900
@@ -34,6 +34,10 @@
 #include <xen/gnttab.h>
 #include <xen/xenbus.h>
 #include <xen/driver_util.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Oct 13 09:06:45 2006 +0900
@@ -39,6 +39,10 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Oct 13 09:06:45 2006 +0900
@@ -56,6 +56,10 @@
 
 #include "xenbus_comms.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 int xen_store_evtchn;
 struct xenstore_domain_interface *xen_store_interface;
 static unsigned long xen_store_mfn;
@@ -67,13 +71,17 @@ static void wait_for_devices(struct xenb
 static void wait_for_devices(struct xenbus_driver *xendrv);
 
 static int xenbus_probe_frontend(const char *type, const char *name);
+#ifdef CONFIG_XEN_BACKEND
 static int xenbus_uevent_backend(struct device *dev, char **envp,
 				 int num_envp, char *buffer, int buffer_size);
 static int xenbus_probe_backend(const char *type, const char *domid);
+#endif
 
 static int xenbus_dev_probe(struct device *_dev);
 static int xenbus_dev_remove(struct device *_dev);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 static void xenbus_dev_shutdown(struct device *_dev);
+#endif
 
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
@@ -176,10 +184,12 @@ static int read_backend_details(struct x
 }
 
 
+#ifdef CONFIG_XEN_BACKEND
 static int read_frontend_details(struct xenbus_device *xendev)
 {
 	return read_otherend_details(xendev, "frontend-id", "frontend");
 }
+#endif
 
 
 /* Bus type for frontend drivers. */
@@ -191,15 +201,18 @@ static struct xen_bus_type xenbus_fronte
 	.bus = {
 		.name     = "xen",
 		.match    = xenbus_match,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 		.probe    = xenbus_dev_probe,
 		.remove   = xenbus_dev_remove,
 		.shutdown = xenbus_dev_shutdown,
+#endif
 	},
 	.dev = {
 		.bus_id = "xen",
 	},
 };
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
 {
@@ -299,6 +312,7 @@ static int xenbus_uevent_backend(struct 
 
 	return 0;
 }
+#endif
 
 static void otherend_changed(struct xenbus_watch *watch,
 			     const char **vec, unsigned int len)
@@ -423,6 +437,7 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
 static void xenbus_dev_shutdown(struct device *_dev)
 {
 	struct xenbus_device *dev = to_xenbus_device(_dev);
@@ -443,6 +458,7 @@ static void xenbus_dev_shutdown(struct d
  out:
 	put_device(&dev->dev);
 }
+#endif
 
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
@@ -451,7 +467,13 @@ static int xenbus_register_driver_common
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
 	drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+	drv->driver.probe = xenbus_dev_probe;
+	drv->driver.remove = xenbus_dev_remove;
+#endif
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -476,6 +498,7 @@ int xenbus_register_frontend(struct xenb
 }
 EXPORT_SYMBOL_GPL(xenbus_register_frontend);
 
+#ifdef CONFIG_XEN_BACKEND
 int xenbus_register_backend(struct xenbus_driver *drv)
 {
 	drv->read_otherend_details = read_frontend_details;
@@ -483,6 +506,7 @@ int xenbus_register_backend(struct xenbu
 	return xenbus_register_driver_common(drv, &xenbus_backend);
 }
 EXPORT_SYMBOL_GPL(xenbus_register_backend);
+#endif
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
@@ -581,14 +605,20 @@ char *kasprintf(const char *fmt, ...)
 }
 
 static ssize_t xendev_show_nodename(struct device *dev,
-				    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+				    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
 }
 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 
 static ssize_t xendev_show_devtype(struct device *dev,
-				   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+				   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
 }
@@ -667,6 +697,7 @@ static int xenbus_probe_frontend(const c
 	return err;
 }
 
+#ifdef CONFIG_XEN_BACKEND
 /* backend/<typename>/<frontend-uuid>/<name> */
 static int xenbus_probe_backend_unit(const char *dir,
 				     const char *type,
@@ -715,6 +746,7 @@ static int xenbus_probe_backend(const ch
 	kfree(nodename);
 	return err;
 }
+#endif
 
 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
 {
@@ -823,6 +855,7 @@ static void frontend_changed(struct xenb
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
 }
 
+#ifdef CONFIG_XEN_BACKEND
 static void backend_changed(struct xenbus_watch *watch,
 			    const char **vec, unsigned int len)
 {
@@ -830,6 +863,7 @@ static void backend_changed(struct xenbu
 
 	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
+#endif
 
 /* We watch for devices appearing and vanishing. */
 static struct xenbus_watch fe_watch = {
@@ -837,10 +871,12 @@ static struct xenbus_watch fe_watch = {
 	.callback = frontend_changed,
 };
 
+#ifdef CONFIG_XEN_BACKEND
 static struct xenbus_watch be_watch = {
 	.node = "backend",
 	.callback = backend_changed,
 };
+#endif
 
 static int suspend_dev(struct device *dev, void *data)
 {
@@ -912,7 +948,9 @@ void xenbus_suspend(void)
 	DPRINTK("");
 
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
+#endif
 	xs_suspend();
 }
 EXPORT_SYMBOL_GPL(xenbus_suspend);
@@ -922,7 +960,9 @@ void xenbus_resume(void)
 	xb_init_comms();
 	xs_resume();
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+#ifdef CONFIG_XEN_BACKEND
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
+#endif
 }
 EXPORT_SYMBOL_GPL(xenbus_resume);
 
@@ -957,11 +997,15 @@ void xenbus_probe(void *unused)
 
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices(&xenbus_frontend);
+#ifdef CONFIG_XEN_BACKEND
 	xenbus_probe_devices(&xenbus_backend);
+#endif
 
 	/* Watch for changes. */
 	register_xenbus_watch(&fe_watch);
+#ifdef CONFIG_XEN_BACKEND
 	register_xenbus_watch(&be_watch);
+#endif
 
 	/* Notify others that xenstore is up */
 	notifier_call_chain(&xenstore_chain, 0, NULL);
@@ -973,6 +1017,7 @@ static struct proc_dir_entry *xsd_kva_in
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	size_t size = vma->vm_end - vma->vm_start;
@@ -986,6 +1031,9 @@ static int xsd_kva_mmap(struct file *fil
 
 	return 0;
 }
+#else
+#define xsd_kva_mmap NULL
+#endif
 
 static int xsd_kva_read(char *page, char **start, off_t off,
 			int count, int *eof, void *data)
@@ -1020,7 +1068,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
+#ifdef CONFIG_XEN_BACKEND
 	bus_register(&xenbus_backend.bus);
+#endif
 
 	/*
 	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
@@ -1091,7 +1141,9 @@ static int __init xenbus_probe_init(void
 
 	/* Register ourselves with the kernel device subsystem */
 	device_register(&xenbus_frontend.dev);
+#ifdef CONFIG_XEN_BACKEND
 	device_register(&xenbus_backend.dev);
+#endif
 
 	if (!is_initial_xendomain())
 		xenbus_probe(NULL);
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Oct 13 09:06:45 2006 +0900
@@ -42,8 +42,13 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
+#include <linux/module.h>
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* xenbus_probe.c */
 extern char *kasprintf(const char *fmt, ...);
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Fri Oct 13 09:06:45 2006 +0900
@@ -8,6 +8,10 @@
  */
 
 #include <linux/config.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 #define ADDR (*(volatile long *) addr)
 
diff -r f14a67a35bec -r 6e075156ea46 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Thu Oct 12 17:53:51 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Fri Oct 13 09:06:45 2006 +0900
@@ -38,10 +38,15 @@
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/init.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 /* Register callback to watch this node. */
 struct xenbus_watch
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk	Thu Oct 12 17:53:51 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk	Fri Oct 13 09:06:45 2006 +0900
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
 EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_COMPAT_H
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/Kbuild
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Thu Oct 12 17:53:51 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Fri Oct 13 09:06:45 2006 +0900
@@ -4,4 +4,10 @@ obj-m := xen-platform-pci.o
 
 EXTRA_CFLAGS += -I$(M)/platform-pci
 
-xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
+xen-platform-pci-objs :=
+xen-platform-pci-objs += platform-pci.o
+xen-platform-pci-objs += features.o
+xen-platform-pci-objs += evtchn.o
+xen-platform-pci-objs += gnttab.o
+xen-platform-pci-objs += xen_support.o
+xen-platform-pci-objs += compat.o
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/evtchn.c
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c	Fri Oct 13 09:06:45 2006 +0900
@@ -35,6 +35,10 @@
 #include <xen/interface/hvm/ioreq.h>
 #include <xen/features.h>
 #include "platform-pci.h"
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
 
 void *shared_info_area;
 
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Fri Oct 13 09:06:45 2006 +0900
@@ -38,6 +38,10 @@
 
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 #define DRV_NAME    "xen-platform-pci"
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Thu Oct 12 17:53:51 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Fri Oct 13 09:06:45 2006 +0900
@@ -26,6 +26,10 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
 	BUG();
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/blkfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPMD_H */
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud)           0
+#define pud_present(pud)        1
+#define PTRS_PER_PUD            1
+
+#endif /* _PGTABLE_NOPUD_H */
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/compat-include/compat.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/compat.h	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,52 @@
+#ifndef COMPAT_INCLUDE_COMPAT_H
+#define COMPAT_INCLUDE_COMPAT_H
+
+#include <linux/version.h>
+
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kzalloc(size_t size, int flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
+#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+unsigned long vmalloc_to_pfn(void *addr);
+#endif
+
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+signed long __sched schedule_timeout_interruptible(signed long timeout);
+#endif
+
+#endif /* !COMPAT_INCLUDE_COMPAT_H */
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/compat-include/linux/io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so        *
+ * it is negated to the down_trylock() return values! Be careful  */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/platform-pci/compat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/compat.c	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,52 @@
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/highmem.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+
+#ifdef HAVE_COMPAT_H
+#include <compat.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+	return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+
+EXPORT_SYMBOL(vmalloc_to_pfn);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+/*
+    fake do_exit using complete_and_exit
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+asmlinkage NORET_TYPE void do_exit(long code)
+#else
+fastcall NORET_TYPE void do_exit(long code)
+#endif
+{
+    complete_and_exit(NULL, code);
+}
+EXPORT_SYMBOL(do_exit);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/*
+ * We can use __set_current_state() here because schedule_timeout() calls
+ * schedule() unconditionally.
+ */
+signed long __sched schedule_timeout_interruptible(signed long timeout)
+{
+	__set_current_state(TASK_INTERRUPTIBLE);
+	return schedule_timeout(timeout);
+}
+EXPORT_SYMBOL(schedule_timeout_interruptible);
+#endif
diff -r f14a67a35bec -r 6e075156ea46 unmodified_drivers/linux-2.6/xenbus/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile	Fri Oct 13 09:06:45 2006 +0900
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif

[-- 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] 22+ messages in thread

* Re: PV drivers for HVM guests
  2006-10-13  2:00       ` DOI Tsunehisa
@ 2006-10-13  6:55         ` Ian Campbell
  0 siblings, 0 replies; 22+ messages in thread
From: Ian Campbell @ 2006-10-13  6:55 UTC (permalink / raw)
  To: DOI Tsunehisa; +Cc: Ky Srinivasan, xen-devel

On Fri, 2006-10-13 at 11:00 +0900, DOI Tsunehisa wrote:
>   I found some issue with my old patch.

Thanks for these. I'll look at them properly once the 3.0.3 release is
out and the unstable tree has opened again.

Cheers,
Ian.

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

end of thread, other threads:[~2006-10-13  6:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-04 18:42 PV drivers for HVM guests Ky Srinivasan
2006-10-05 14:59 ` Andrew D. Ball
2006-10-05 15:13   ` Ky Srinivasan
  -- strict thread matches above, loose matches on Subject: below --
2006-10-04 18:50 Ky Srinivasan
2006-10-04 18:47 Ky Srinivasan
2006-10-04 18:45 Ky Srinivasan
2006-10-04 18:40 Ky Srinivasan
2006-10-03 20:31 Ky Srinivasan
2006-10-03 22:19 ` Andrew D. Ball
2006-10-03 22:31 ` Steve Ofsthun
2006-10-04  7:56 ` Keir Fraser
2006-10-04  8:15   ` Muli Ben-Yehuda
2006-10-04  8:17     ` Keir Fraser
2006-10-04 11:02     ` Gerd Hoffmann
2006-10-04 15:54       ` Andi Kleen
2006-10-04 10:24 ` Steven Smith
2006-10-05 15:21 ` Ian Campbell
2006-10-05 16:47   ` Ky Srinivasan
2006-10-10  8:00   ` DOI Tsunehisa
2006-10-11 10:46     ` DOI Tsunehisa
2006-10-13  2:00       ` DOI Tsunehisa
2006-10-13  6:55         ` Ian Campbell

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.