Re: [PATCH 1/2] xen/hypercall: fix hypercall fallback code for veryold hypervisors

From: Konrad Rzeszutek Wilk
Date: Fri Nov 02 2012 - 12:44:02 EST


On Wed, Oct 31, 2012 at 08:55:54AM +0000, Jan Beulich wrote:
> >>> On 30.10.12 at 16:44, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> wrote:
> > On Mon, Oct 29, 2012 at 10:08:17AM -0400, Konrad Rzeszutek Wilk wrote:
> >> From: Jan Beulich <jbeulich@xxxxxxxx>
> >>
> >> While copying the argument structures in HYPERVISOR_event_channel_op()
> >> and HYPERVISOR_physdev_op() into the local variable is sufficiently
> >> safe even if the actual structure is smaller than the container one,
> >> copying back eventual output values the same way isn't: This may
> >> collide with on-stack variables (particularly "rc") which may change
> >> between the first and second memcpy() (i.e. the second memcpy() could
> >> discard that change).
> >>
> >> Move the fallback code into out-of-line functions, and handle all of
> >> the operations known by this old a hypervisor individually: Some don't
> >> require copying back anything at all, and for the rest use the
> >> individual argument structures' sizes rather than the container's.
> >>
> >> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> >> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> >> [v2: Reduce #define/#undef usage in HYPERVISOR_physdev_op_compat().]
> >> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> >
> > And it looks like I get
> >
> > ERROR: "HYPERVISOR_event_channel_op_compat" [drivers/xen/xen-evtchn.ko]
> > undefined!
> >
> > when I build xen-evtchn as module. Jan did you encounter this issue on
> > 2.6.18?
>
> No - the event channel driver there can't be built as a module, and
> for the forward ported kernels I apparently never tried to build with
> a compat setting of 3.0.2 or less (and I didn't care that much either
> because the oldest we're actually concerned about is 3.0.4 to cover
> some of those very old EC2 systems; I'll add the export at the right
> point nevertheless).

Ok, ended up with this version which I was thinking to for v3.7-rc5: