diff mbox

[Xen-devel,30/34] xen: Add missing includes on different files

Message ID 1395766541-23979-31-git-send-email-julien.grall@linaro.org
State Deferred, archived
Headers show

Commit Message

Julien Grall March 25, 2014, 4:55 p.m. UTC
There is a bunch of functions in xen code which are declared without the
prototypes defined before. This may lead to runtime issue if the propotype
doesn't match the declaration.

Add missing includes where the prototype of theses functions are defined.

This was spotted by -Wmissing-prototypes, which we can't enable because there
is exported function for assembly. I'm not sure if we need to add a prototype
for them.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@citrix.com>
Cc: Tim Deegan <tim@xen.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---
 xen/arch/arm/hvm.c             |    1 +
 xen/arch/arm/mm.c              |    1 +
 xen/arch/arm/shutdown.c        |    1 +
 xen/arch/arm/smp.c             |    1 +
 xen/arch/arm/time.c            |    1 +
 xen/arch/arm/vtimer.c          |    1 +
 xen/common/event_channel.c     |    1 +
 xen/common/grant_table.c       |    1 +
 xen/common/multicall.c         |    3 +++
 xen/common/sort.c              |    1 +
 xen/common/tmem.c              |    1 +
 xen/drivers/video/arm_hdlcd.c  |    1 +
 xen/xsm/flask/ss/conditional.h |    1 +
 13 files changed, 15 insertions(+)

Comments

Daniel De Graaf March 25, 2014, 5:38 p.m. UTC | #1
On 03/25/2014 12:55 PM, Julien Grall wrote:
> There is a bunch of functions in xen code which are declared without the
> prototypes defined before. This may lead to runtime issue if the propotype
> doesn't match the declaration.
>
> Add missing includes where the prototype of theses functions are defined.
>
> This was spotted by -Wmissing-prototypes, which we can't enable because there
> is exported function for assembly. I'm not sure if we need to add a prototype
> for them.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@citrix.com>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>

Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

> ---
>   xen/arch/arm/hvm.c             |    1 +
>   xen/arch/arm/mm.c              |    1 +
>   xen/arch/arm/shutdown.c        |    1 +
>   xen/arch/arm/smp.c             |    1 +
>   xen/arch/arm/time.c            |    1 +
>   xen/arch/arm/vtimer.c          |    1 +
>   xen/common/event_channel.c     |    1 +
>   xen/common/grant_table.c       |    1 +
>   xen/common/multicall.c         |    3 +++
>   xen/common/sort.c              |    1 +
>   xen/common/tmem.c              |    1 +
>   xen/drivers/video/arm_hdlcd.c  |    1 +
>   xen/xsm/flask/ss/conditional.h |    1 +
>   13 files changed, 15 insertions(+)
>
> diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
> index 471c4cd..b695b26 100644
> --- a/xen/arch/arm/hvm.c
> +++ b/xen/arch/arm/hvm.c
> @@ -4,6 +4,7 @@
>   #include <xen/errno.h>
>   #include <xen/guest_access.h>
>   #include <xen/sched.h>
> +#include <xen/hypercall.h>
>
>   #include <xsm/xsm.h>
>
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index fc58fc6..84b6ccc 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -39,6 +39,7 @@
>   #include <xen/vmap.h>
>   #include <xsm/xsm.h>
>   #include <xen/pfn.h>
> +#include <asm/setup.h>
>
>   struct domain *dom_xen, *dom_io, *dom_cow;
>
> diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c
> index adc0529..43eaf47 100644
> --- a/xen/arch/arm/shutdown.c
> +++ b/xen/arch/arm/shutdown.c
> @@ -4,6 +4,7 @@
>   #include <xen/delay.h>
>   #include <xen/lib.h>
>   #include <xen/smp.h>
> +#include <xen/shutdown.h>
>   #include <asm/platform.h>
>
>   static void raw_machine_reset(void)
> diff --git a/xen/arch/arm/smp.c b/xen/arch/arm/smp.c
> index 30203b8..7bb602d 100644
> --- a/xen/arch/arm/smp.c
> +++ b/xen/arch/arm/smp.c
> @@ -1,4 +1,5 @@
>   #include <xen/config.h>
> +#include <xen/smp.h>
>   #include <asm/system.h>
>   #include <asm/smp.h>
>   #include <asm/cpregs.h>
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 7f4f2b4..3b0feec 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -29,6 +29,7 @@
>   #include <xen/time.h>
>   #include <xen/sched.h>
>   #include <xen/event.h>
> +#include <xen/delay.h>
>   #include <asm/system.h>
>   #include <asm/time.h>
>   #include <asm/gic.h>
> diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
> index 83f4c0f..6aeae5d 100644
> --- a/xen/arch/arm/vtimer.c
> +++ b/xen/arch/arm/vtimer.c
> @@ -25,6 +25,7 @@
>   #include <asm/time.h>
>   #include <asm/gic.h>
>   #include <asm/regs.h>
> +#include "vtimer.h"
>
>   static void phys_timer_expired(void *data)
>   {
> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
> index db952af..e94e37e 100644
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -28,6 +28,7 @@
>   #include <xen/keyhandler.h>
>   #include <xen/event_fifo.h>
>   #include <asm/current.h>
> +#include <xen/hypercall.h>
>
>   #include <public/xen.h>
>   #include <public/event_channel.h>
> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> index 107b000..386cdff 100644
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -37,6 +37,7 @@
>   #include <xen/iommu.h>
>   #include <xen/paging.h>
>   #include <xen/keyhandler.h>
> +#include <xen/hypercall.h>
>   #include <xsm/xsm.h>
>   #include <asm/flushtlb.h>
>
> diff --git a/xen/common/multicall.c b/xen/common/multicall.c
> index e66c798..bb7550b 100644
> --- a/xen/common/multicall.c
> +++ b/xen/common/multicall.c
> @@ -6,6 +6,9 @@
>   #include <xen/types.h>
>   #include <xen/lib.h>
>   #include <xen/mm.h>
> +#ifndef COMPAT
> +#include <xen/hypercall.h>
> +#endif
>   #include <xen/sched.h>
>   #include <xen/event.h>
>   #include <xen/multicall.h>
> diff --git a/xen/common/sort.c b/xen/common/sort.c
> index d96fc2a..7069888 100644
> --- a/xen/common/sort.c
> +++ b/xen/common/sort.c
> @@ -5,6 +5,7 @@
>    */
>
>   #include <xen/types.h>
> +#include <xen/sort.h>
>
>   static void u32_swap(void *a, void *b, int size)
>   {
> diff --git a/xen/common/tmem.c b/xen/common/tmem.c
> index 5155114..865d154 100644
> --- a/xen/common/tmem.c
> +++ b/xen/common/tmem.c
> @@ -23,6 +23,7 @@
>   #include <xen/radix-tree.h>
>   #include <xen/list.h>
>   #include <xen/init.h>
> +#include <xen/hypercall.h>
>
>   #define TMEM_SPEC_VERSION 1
>
> diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c
> index 841d0d0..04a3091 100644
> --- a/xen/drivers/video/arm_hdlcd.c
> +++ b/xen/drivers/video/arm_hdlcd.c
> @@ -25,6 +25,7 @@
>   #include <xen/libfdt/libfdt.h>
>   #include <xen/init.h>
>   #include <xen/mm.h>
> +#include <xen/video.h>
>   #include "font.h"
>   #include "lfb.h"
>   #include "modelines.h"
> diff --git a/xen/xsm/flask/ss/conditional.h b/xen/xsm/flask/ss/conditional.h
> index d389ecf..65af76b 100644
> --- a/xen/xsm/flask/ss/conditional.h
> +++ b/xen/xsm/flask/ss/conditional.h
> @@ -13,6 +13,7 @@
>   #include "avtab.h"
>   #include "symtab.h"
>   #include "policydb.h"
> +#include "../include/conditional.h"
>
>   #define COND_EXPR_MAXDEPTH 10
>
>
Jan Beulich March 26, 2014, 12:57 p.m. UTC | #2
>>> On 25.03.14 at 17:55, <julien.grall@linaro.org> wrote:
> --- a/xen/common/multicall.c
> +++ b/xen/common/multicall.c
> @@ -6,6 +6,9 @@
>  #include <xen/types.h>
>  #include <xen/lib.h>
>  #include <xen/mm.h>
> +#ifndef COMPAT
> +#include <xen/hypercall.h>
> +#endif

Is there anything wrong with adding this without the seemingly
unmotivated #ifndef?

Jan
Julien Grall March 26, 2014, 5:41 p.m. UTC | #3
On 03/26/2014 12:57 PM, Jan Beulich wrote:
>>>> On 25.03.14 at 17:55, <julien.grall@linaro.org> wrote:
>> --- a/xen/common/multicall.c
>> +++ b/xen/common/multicall.c
>> @@ -6,6 +6,9 @@
>>  #include <xen/types.h>
>>  #include <xen/lib.h>
>>  #include <xen/mm.h>
>> +#ifndef COMPAT
>> +#include <xen/hypercall.h>
>> +#endif
> 
> Is there anything wrong with adding this without the seemingly
> unmotivated #ifndef?

The prototype in hypercall.h return directly long, but the definition
returns ret_t (which is replaced by int if COMPAT is defined).

This will result to a compilation failure:

In file included from multicall.c:41:0:
../multicall.c:38:1: error: conflicting types for ‘compat_multicall’
In file included from ../multicall.c:9:0,
                 from multicall.c:41:
Jan Beulich March 27, 2014, 7:57 a.m. UTC | #4
>>> On 26.03.14 at 18:41, <julien.grall@linaro.org> wrote:
> On 03/26/2014 12:57 PM, Jan Beulich wrote:
>>>>> On 25.03.14 at 17:55, <julien.grall@linaro.org> wrote:
>>> --- a/xen/common/multicall.c
>>> +++ b/xen/common/multicall.c
>>> @@ -6,6 +6,9 @@
>>>  #include <xen/types.h>
>>>  #include <xen/lib.h>
>>>  #include <xen/mm.h>
>>> +#ifndef COMPAT
>>> +#include <xen/hypercall.h>
>>> +#endif
>> 
>> Is there anything wrong with adding this without the seemingly
>> unmotivated #ifndef?
> 
> The prototype in hypercall.h return directly long, but the definition
> returns ret_t (which is replaced by int if COMPAT is defined).
> 
> This will result to a compilation failure:
> 
> In file included from multicall.c:41:0:
> ../multicall.c:38:1: error: conflicting types for ‘compat_multicall’
> In file included from ../multicall.c:9:0,
>                  from multicall.c:41:

Meaning this needs to be dealt with differently: Include the header in
both files _and_ add a declaration of compat_multicall() to it (alongside
the other compat_ ones already there).

Jan
Ian Campbell March 27, 2014, 5:11 p.m. UTC | #5
On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
> This was spotted by -Wmissing-prototypes, which we can't enable because there
> is exported function for assembly. I'm not sure if we need to add a prototype
> for them.

What exactly is the issue here?

Ian.
Julien Grall March 27, 2014, 5:30 p.m. UTC | #6
On 03/27/2014 05:11 PM, Ian Campbell wrote:
> On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
>> This was spotted by -Wmissing-prototypes, which we can't enable because there
>> is exported function for assembly. I'm not sure if we need to add a prototype
>> for them.
> 
> What exactly is the issue here?

There a bunch of functions (see below for ARM) where the prototype is
not defined before. Mainly because theses functions are used by the
assembly code so we don't need to give a prototype.

do_trap_*
start_xen
start_secondary
leave_hypervisor_tail

Regards,
Ian Campbell March 27, 2014, 5:39 p.m. UTC | #7
On Thu, 2014-03-27 at 17:30 +0000, Julien Grall wrote:
> On 03/27/2014 05:11 PM, Ian Campbell wrote:
> > On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
> >> This was spotted by -Wmissing-prototypes, which we can't enable because there
> >> is exported function for assembly. I'm not sure if we need to add a prototype
> >> for them.
> > 
> > What exactly is the issue here?
> 
> There a bunch of functions (see below for ARM) where the prototype is
> not defined before. Mainly because theses functions are used by the
> assembly code so we don't need to give a prototype.
> 
> do_trap_*
> start_xen
> start_secondary
> leave_hypervisor_tail

Is that all of them? Although their prototypes are useless there are few
enough of them that the benefit of being able to turn on
Wmissing-prototypes might make it worth it.

Unless there is some attribute we can apply which marks these as not
requiring a prototype? Even better if as a side effect the compiler will
warn about calls not from assembly...

Ian.
Julien Grall March 27, 2014, 5:47 p.m. UTC | #8
On 03/27/2014 05:39 PM, Ian Campbell wrote:
> On Thu, 2014-03-27 at 17:30 +0000, Julien Grall wrote:
>> On 03/27/2014 05:11 PM, Ian Campbell wrote:
>>> On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
>>>> This was spotted by -Wmissing-prototypes, which we can't enable because there
>>>> is exported function for assembly. I'm not sure if we need to add a prototype
>>>> for them.
>>>
>>> What exactly is the issue here?
>>
>> There a bunch of functions (see below for ARM) where the prototype is
>> not defined before. Mainly because theses functions are used by the
>> assembly code so we don't need to give a prototype.
>>
>> do_trap_*
>> start_xen
>> start_secondary
>> leave_hypervisor_tail
> 
> Is that all of them? Although their prototypes are useless there are few
> enough of them that the benefit of being able to turn on
> Wmissing-prototypes might make it worth it.

From the common code there is 7 others:

core_parking_helper and get_cur_idle_nums (both of them are used on C
code but never defined in an header. I was lazy and I didn't write a patch).

__qdivrem
__divdi3
__umoddi3
__moddi3
__ldivmod_helper

For x86, I didn't yet try to compiled it with -Wmissing-prototypes.

> 
> Unless there is some attribute we can apply which marks these as not
> requiring a prototype?

I will look at it.

> Even better if as a side effect the compiler will
> warn about calls not from assembly...

I would love to see this feature, but I don't think the linker is able
to differentiate call from C and from assembly :).

Regards,
Ian Campbell March 28, 2014, 9:59 a.m. UTC | #9
On Thu, 2014-03-27 at 17:47 +0000, Julien Grall wrote:
> On 03/27/2014 05:39 PM, Ian Campbell wrote:
> > On Thu, 2014-03-27 at 17:30 +0000, Julien Grall wrote:
> >> On 03/27/2014 05:11 PM, Ian Campbell wrote:
> >>> On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
> >>>> This was spotted by -Wmissing-prototypes, which we can't enable because there
> >>>> is exported function for assembly. I'm not sure if we need to add a prototype
> >>>> for them.
> >>>
> >>> What exactly is the issue here?
> >>
> >> There a bunch of functions (see below for ARM) where the prototype is
> >> not defined before. Mainly because theses functions are used by the
> >> assembly code so we don't need to give a prototype.
> >>
> >> do_trap_*
> >> start_xen
> >> start_secondary
> >> leave_hypervisor_tail
> > 
> > Is that all of them? Although their prototypes are useless there are few
> > enough of them that the benefit of being able to turn on
> > Wmissing-prototypes might make it worth it.
> 
> From the common code there is 7 others:
> 
> core_parking_helper and get_cur_idle_nums (both of them are used on C
> code but never defined in an header. I was lazy and I didn't write a patch).
> 
> __qdivrem
> __divdi3
> __umoddi3
> __moddi3
> __ldivmod_helper

Still not awful I guess.

Several of these are essentially library functions provided for the
compiler to emit calls to, I wonder if there is some compiler header
which we should be including which would prototype them. Probably not,
worth a look though.

> 
> For x86, I didn't yet try to compiled it with -Wmissing-prototypes.
> 
> > 
> > Unless there is some attribute we can apply which marks these as not
> > requiring a prototype?
> 
> I will look at it.

Thanks.

> > Even better if as a side effect the compiler will
> > warn about calls not from assembly...
> 
> I would love to see this feature, but I don't think the linker is able
> to differentiate call from C and from assembly :).

The compiler could see a call from C code to a function whose prototype
was marked with "called_from_asm_only".

Ian.
Julien Grall April 1, 2014, 5:58 p.m. UTC | #10
On 03/28/2014 09:59 AM, Ian Campbell wrote:
> On Thu, 2014-03-27 at 17:47 +0000, Julien Grall wrote:
>> On 03/27/2014 05:39 PM, Ian Campbell wrote:
>>> On Thu, 2014-03-27 at 17:30 +0000, Julien Grall wrote:
>>>> On 03/27/2014 05:11 PM, Ian Campbell wrote:
>>>>> On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
>>>>>> This was spotted by -Wmissing-prototypes, which we can't enable because there
>>>>>> is exported function for assembly. I'm not sure if we need to add a prototype
>>>>>> for them.
>>>>>
>>>>> What exactly is the issue here?
>>>>
>>>> There a bunch of functions (see below for ARM) where the prototype is
>>>> not defined before. Mainly because theses functions are used by the
>>>> assembly code so we don't need to give a prototype.
>>>>
>>>> do_trap_*
>>>> start_xen
>>>> start_secondary
>>>> leave_hypervisor_tail
>>>
>>> Is that all of them? Although their prototypes are useless there are few
>>> enough of them that the benefit of being able to turn on
>>> Wmissing-prototypes might make it worth it.
>>
>> From the common code there is 7 others:
>>
>> core_parking_helper and get_cur_idle_nums (both of them are used on C
>> code but never defined in an header. I was lazy and I didn't write a patch).
>>
>> __qdivrem
>> __divdi3
>> __umoddi3
>> __moddi3
>> __ldivmod_helper
> 
> Still not awful I guess.
> 
> Several of these are essentially library functions provided for the
> compiler to emit calls to, I wonder if there is some compiler header
> which we should be including which would prototype them. Probably not,
> worth a look though.

These functions are not used by x86 (because of the if BITS_PER_LONG ==
32), and on ARM we provide eabi_* helpers.

>>
>> For x86, I didn't yet try to compiled it with -Wmissing-prototypes.
>>
>>>
>>> Unless there is some attribute we can apply which marks these as not
>>> requiring a prototype?
>>
>> I will look at it.
> 
> Thanks.
> 
>>> Even better if as a side effect the compiler will
>>> warn about calls not from assembly...
>>
>> I would love to see this feature, but I don't think the linker is able
>> to differentiate call from C and from assembly :).
> 
> The compiler could see a call from C code to a function whose prototype
> was marked with "called_from_asm_only".

I'm afraid there is no __attribute__ feature for a such thing. One
solution could be introduce mismatch section as Linux (e.g: functions
called from assembly are in a specific section).

Regards,
Ian Campbell April 2, 2014, 8:45 a.m. UTC | #11
On Tue, 2014-04-01 at 18:58 +0100, Julien Grall wrote:
> On 03/28/2014 09:59 AM, Ian Campbell wrote:
> > On Thu, 2014-03-27 at 17:47 +0000, Julien Grall wrote:
> >> On 03/27/2014 05:39 PM, Ian Campbell wrote:
> >>> On Thu, 2014-03-27 at 17:30 +0000, Julien Grall wrote:
> >>>> On 03/27/2014 05:11 PM, Ian Campbell wrote:
> >>>>> On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
> >>>>>> This was spotted by -Wmissing-prototypes, which we can't enable because there
> >>>>>> is exported function for assembly. I'm not sure if we need to add a prototype
> >>>>>> for them.
> >>>>>
> >>>>> What exactly is the issue here?
> >>>>
> >>>> There a bunch of functions (see below for ARM) where the prototype is
> >>>> not defined before. Mainly because theses functions are used by the
> >>>> assembly code so we don't need to give a prototype.
> >>>>
> >>>> do_trap_*
> >>>> start_xen
> >>>> start_secondary
> >>>> leave_hypervisor_tail
> >>>
> >>> Is that all of them? Although their prototypes are useless there are few
> >>> enough of them that the benefit of being able to turn on
> >>> Wmissing-prototypes might make it worth it.
> >>
> >> From the common code there is 7 others:
> >>
> >> core_parking_helper and get_cur_idle_nums (both of them are used on C
> >> code but never defined in an header. I was lazy and I didn't write a patch).
> >>
> >> __qdivrem
> >> __divdi3
> >> __umoddi3
> >> __moddi3
> >> __ldivmod_helper
> > 
> > Still not awful I guess.
> > 
> > Several of these are essentially library functions provided for the
> > compiler to emit calls to, I wonder if there is some compiler header
> > which we should be including which would prototype them. Probably not,
> > worth a look though.
> 
> These functions are not used by x86 (because of the if BITS_PER_LONG ==
> 32), and on ARM we provide eabi_* helpers.

Not sure I follow, what are you concluding there?

> > The compiler could see a call from C code to a function whose prototype
> > was marked with "called_from_asm_only".
> 
> I'm afraid there is no __attribute__ feature for a such thing. One
> solution could be introduce mismatch section as Linux (e.g: functions
> called from assembly are in a specific section).
Julien Grall April 9, 2014, 4:06 p.m. UTC | #12
Hi Jan,

Sorry for the late answer.

On 03/27/2014 07:57 AM, Jan Beulich wrote:
>>>> On 26.03.14 at 18:41, <julien.grall@linaro.org> wrote:
>> On 03/26/2014 12:57 PM, Jan Beulich wrote:
>>>>>> On 25.03.14 at 17:55, <julien.grall@linaro.org> wrote:
>>>> --- a/xen/common/multicall.c
>>>> +++ b/xen/common/multicall.c
>>>> @@ -6,6 +6,9 @@
>>>>  #include <xen/types.h>
>>>>  #include <xen/lib.h>
>>>>  #include <xen/mm.h>
>>>> +#ifndef COMPAT
>>>> +#include <xen/hypercall.h>
>>>> +#endif
>>>
>>> Is there anything wrong with adding this without the seemingly
>>> unmotivated #ifndef?
>>
>> The prototype in hypercall.h return directly long, but the definition
>> returns ret_t (which is replaced by int if COMPAT is defined).
>>
>> This will result to a compilation failure:
>>
>> In file included from multicall.c:41:0:
>> ../multicall.c:38:1: error: conflicting types for ‘compat_multicall’
>> In file included from ../multicall.c:9:0,
>>                  from multicall.c:41:
> 
> Meaning this needs to be dealt with differently: Include the header in
> both files _and_ add a declaration of compat_multicall() to it (alongside
> the other compat_ ones already there).

I gave a look to this solution. It won't works because do_multicall is
replaced by the define in compat/multicall.c:26. It will end up to
multiple definition of compat_multcall.

I'm not sure how to handle it because, AFAIU, compat/multicall.c is
defining some macro to redefine the behavior of multicall.c

Regards,
Jan Beulich April 9, 2014, 4:17 p.m. UTC | #13
>>> On 09.04.14 at 18:06, <julien.grall@linaro.org> wrote:
> On 03/27/2014 07:57 AM, Jan Beulich wrote:
>>>>> On 26.03.14 at 18:41, <julien.grall@linaro.org> wrote:
>>> In file included from multicall.c:41:0:
>>> ../multicall.c:38:1: error: conflicting types for ‘compat_multicall’
>>> In file included from ../multicall.c:9:0,
>>>                  from multicall.c:41:
>> 
>> Meaning this needs to be dealt with differently: Include the header in
>> both files _and_ add a declaration of compat_multicall() to it (alongside
>> the other compat_ ones already there).
> 
> I gave a look to this solution. It won't works because do_multicall is
> replaced by the define in compat/multicall.c:26. It will end up to
> multiple definition of compat_multcall.
> 
> I'm not sure how to handle it because, AFAIU, compat/multicall.c is
> defining some macro to redefine the behavior of multicall.c

Right, but that doesn't prevent the suggested model afaict:

- compat/multicall.c includes xen/hypercall.h, obtaining proper
  prototypes for both do_multicall() and compat_multicall()
- compat/multicall.c re-defines do_multicall (which doesn't affect
  the prototypes already seen)
- compat/multicall.c includes multicall.c
- multicall.c's inclusion of xen/hypercall.h does nothing (thanks
  to the header guard)

Did you indeed try this and it didn't work?

Jan
diff mbox

Patch

diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 471c4cd..b695b26 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -4,6 +4,7 @@ 
 #include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <xen/sched.h>
+#include <xen/hypercall.h>
 
 #include <xsm/xsm.h>
 
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index fc58fc6..84b6ccc 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -39,6 +39,7 @@ 
 #include <xen/vmap.h>
 #include <xsm/xsm.h>
 #include <xen/pfn.h>
+#include <asm/setup.h>
 
 struct domain *dom_xen, *dom_io, *dom_cow;
 
diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c
index adc0529..43eaf47 100644
--- a/xen/arch/arm/shutdown.c
+++ b/xen/arch/arm/shutdown.c
@@ -4,6 +4,7 @@ 
 #include <xen/delay.h>
 #include <xen/lib.h>
 #include <xen/smp.h>
+#include <xen/shutdown.h>
 #include <asm/platform.h>
 
 static void raw_machine_reset(void)
diff --git a/xen/arch/arm/smp.c b/xen/arch/arm/smp.c
index 30203b8..7bb602d 100644
--- a/xen/arch/arm/smp.c
+++ b/xen/arch/arm/smp.c
@@ -1,4 +1,5 @@ 
 #include <xen/config.h>
+#include <xen/smp.h>
 #include <asm/system.h>
 #include <asm/smp.h>
 #include <asm/cpregs.h>
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 7f4f2b4..3b0feec 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -29,6 +29,7 @@ 
 #include <xen/time.h>
 #include <xen/sched.h>
 #include <xen/event.h>
+#include <xen/delay.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/gic.h>
diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
index 83f4c0f..6aeae5d 100644
--- a/xen/arch/arm/vtimer.c
+++ b/xen/arch/arm/vtimer.c
@@ -25,6 +25,7 @@ 
 #include <asm/time.h>
 #include <asm/gic.h>
 #include <asm/regs.h>
+#include "vtimer.h"
 
 static void phys_timer_expired(void *data)
 {
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index db952af..e94e37e 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -28,6 +28,7 @@ 
 #include <xen/keyhandler.h>
 #include <xen/event_fifo.h>
 #include <asm/current.h>
+#include <xen/hypercall.h>
 
 #include <public/xen.h>
 #include <public/event_channel.h>
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 107b000..386cdff 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -37,6 +37,7 @@ 
 #include <xen/iommu.h>
 #include <xen/paging.h>
 #include <xen/keyhandler.h>
+#include <xen/hypercall.h>
 #include <xsm/xsm.h>
 #include <asm/flushtlb.h>
 
diff --git a/xen/common/multicall.c b/xen/common/multicall.c
index e66c798..bb7550b 100644
--- a/xen/common/multicall.c
+++ b/xen/common/multicall.c
@@ -6,6 +6,9 @@ 
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#ifndef COMPAT
+#include <xen/hypercall.h>
+#endif
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <xen/multicall.h>
diff --git a/xen/common/sort.c b/xen/common/sort.c
index d96fc2a..7069888 100644
--- a/xen/common/sort.c
+++ b/xen/common/sort.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <xen/types.h>
+#include <xen/sort.h>
 
 static void u32_swap(void *a, void *b, int size)
 {
diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index 5155114..865d154 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -23,6 +23,7 @@ 
 #include <xen/radix-tree.h>
 #include <xen/list.h>
 #include <xen/init.h>
+#include <xen/hypercall.h>
 
 #define TMEM_SPEC_VERSION 1
 
diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c
index 841d0d0..04a3091 100644
--- a/xen/drivers/video/arm_hdlcd.c
+++ b/xen/drivers/video/arm_hdlcd.c
@@ -25,6 +25,7 @@ 
 #include <xen/libfdt/libfdt.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/video.h>
 #include "font.h"
 #include "lfb.h"
 #include "modelines.h"
diff --git a/xen/xsm/flask/ss/conditional.h b/xen/xsm/flask/ss/conditional.h
index d389ecf..65af76b 100644
--- a/xen/xsm/flask/ss/conditional.h
+++ b/xen/xsm/flask/ss/conditional.h
@@ -13,6 +13,7 @@ 
 #include "avtab.h"
 #include "symtab.h"
 #include "policydb.h"
+#include "../include/conditional.h"
 
 #define COND_EXPR_MAXDEPTH 10