Re: [Xenomai] Writing to UDD driver through mapped memory cause secondary mode switch

2018-01-26 Thread Greg Gallagher
Sorry to bring back an old thread but I just noticed this.  Did you
solve your issue?  Did you use the documentation in this file for
help? 
https://git.xenomai.org/xenomai-3.git/tree/include/cobalt/kernel/rtdm/udd.h?id=f4a54b173db71a182d9826852a94b20f6095b411

-Greg

On Thu, Dec 14, 2017 at 6:23 AM, MINIER Bertrand
 wrote:
> Hi,
>
> I implemented an UDD driver for a SOC IP on my Xilinx Ultrascale ZCU102 board.
> The arch is arm64 so I'm using Xenomai from the next branch.
>
> When I try to write to the memory mapped from the user space side, Xenomai 
> switches to secondary mode.
>
> I activated the SIGDEBUG and attached an handler to point the origin and the 
> reason of this secondary mode switch.
> The result of sigdebug_reason(siginfo) is SIGDEBUG_MIGRATE_FAULT.
>
> I'm using mmap with the following attributes:
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fpgaMemfd, 0);
>
> The file descriptor is opened with O_RDWR flag.
>
> What is strange is that memory write effectively works but the 
> SIGDEBUG_MIGRATE_FAULT is triggered. Reading the physical driver memory with 
> devmem returns the written value.
>
> Does anyone would have any idea about the origin of the issue ?
>
> Thanks,
>
> Bertrand Minier
>
>
> This e-mail and any accompanying attachments are confidential. If you are not 
> the intended recipient, you must not review, disclose, copy, distribute or 
> use this e-mail; please delete it from your system and notify the sender 
> immediately.
> ___
> Xenomai mailing list
> Xenomai@xenomai.org
> https://xenomai.org/mailman/listinfo/xenomai

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Auel, Kendall
I've been lurking on this list for a while, and looking forward to seeing some 
of you face-to-face. I'm a Portland native, so feel free to use me as a 
resource when planning your visit.

> -Original Message-
> From: Xenomai [mailto:xenomai-boun...@xenomai.org] On Behalf Of Greg
> Gallagher
> Sent: Friday, January 26, 2018 11:02 AM
> To: Jan Kiszka 
> Cc: Steven Seeger ; Xenomai@xenomai.org
> Subject: Re: [Xenomai] [RFC] FOSDEM meeting agenda
> 
> That would be great,  I booked my flights and hotel this morning.
> Definitely attending the Xenomai talk and there was another talk on a 3D
> printer that is using Xenomai
> (https://elciotna18.sched.com/event/DXmw/3d-printing-with-linux-and-xenomai-kendall-auel-3d-systems-corp)
> that sounds like it will be interesting.  I'm up for anything Xenomai, I'll be
> getting there late Sunday and leaving around 6pm Wednesday.
> 
> -Greg
> 
> On Fri, Jan 26, 2018 at 1:57 PM, Jan Kiszka  wrote:
> > On 2018-01-26 19:51, Greg Gallagher wrote:
> >> We can add an ELC meeting ;)
> >>
> >
> > Sure! Will you attend?
> >
> > Our Xenomai talk was accepted [1], and I'll hang around in Portland
> > for the whole ELC. We can do some hallway tracks or more if there is
> interest.
> >
> > Jan
> >
> > [1]
> > https://elciotna18.sched.com/event/DXnN/steering-xenomai-into-the-
> real
> > -time-linux-future-jan-kiszka-siemens-ag
> >
> >> On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka 
> wrote:
> >>> On 2018-01-25 18:40, Philippe Gerum wrote:
> 
>  Here are some points I would like to discuss during this meeting.
>  Please feel free to comment:
> 
>  1. Release management
> 
>    * Currently, the person who contributes most of the code is
>  also the release manager, which is clearly not optimal. Both
>  activities should be decoupled for efficiency (esp. hindsight) and
>  practical reasons. At some point, I will stop acting as the release
>  manager, so the project will need a different organization in this
> respect. Which one?
> 
>    * As a corollary, the current release process is broken: no
>  explicit release plan or schedule, limited testing, barely any user
>  feedback about the development version in general. Practical steps
>  to improve this should be discussed.
> 
>    * My understanding is that v3.1 is almost there feature-wise,
>  with a working arm64 port Dmitriy is polishing, a bunch of rtnet
>  fixes actually enabling RTnet with SMAP/x86 (which still need some
>  feedback btw), and support for recent kernels up to 4.14 (arm,
>  arm64, powerpc). x86 is still lagging behind with kernel 4.9
>  though. I'm about to queue a couple of ABI changes more, with the
>  implementation of sendmmsg() and
>  recvmmsg() for RTDM sockets.
> 
>  This raises the following questions: 1) may we freeze the v3.1 ABI,
>  2) should we wait for supporting 4.14/x86 before releasing v3.1, 3)
>  how much use/testing do we currently have of the -next branch, on
>  which CPU architecture(s)?
> 
>  2. Documentation
> 
>    * The existing documentation has several weaknesses; from the
>  traffic on the mailing list, the main one may be that it leaves
>  newcomers with a steep learning curve, in some occasions, even when
>  the information is published on the website and/or present in the
>  inline documentation. How to improve the situation, how to better
>  organize the existing doc so that people do find what they are looking
> for?
> 
>    * Doxygen may not be the best option anymore for inline
>  documentation; Chasing glitches with using the markup has been a
>  real pain over the years, getting properly structured output has
>  never been obvious. Could we do better with Doxygen in a reasonably
>  simple fashion, or should reStructuredText and Sphinx be considered
>  as a replacement, so that we can converge toward the kernel
> documentation system?
> 
>  3. Pipeline maintenance
> 
>    * We now have a dedicated I-pipe maintainer per CPU
>  architecture, which is a great relief to me. Now I'd like we
>  discuss the maintenance process, 1) how to organize the
>  upstream/downstream flow of the generic pipeline bits I still
>  maintain currently, between other maintainers and me? 2) how to best
> disseminate knowledge about the I-pipe implementation?
> 
>    * mainline vs CIP kernel, LTS maintenance policy
> 
>  4. Misc
> 
>    * formalizing the decision about dropping the blackfin and
>  powerpc64 port, since we had zero feedback from users so far, so
>  everyone must be fine with this.
> 
>  Thanks,
> 
> >>>
> >>> Thanks for preparing this. Sounds good to me.
> >>>
> >>> Adding from Greg's points as well, we 

Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Greg Gallagher
Sounds good to me, I can send out a reminder to the list the week
before the conference.

On Fri, Jan 26, 2018 at 2:34 PM, Jan Kiszka  wrote:
> On 2018-01-26 20:02, Greg Gallagher wrote:
>> That would be great,  I booked my flights and hotel this morning.
>> Definitely attending the Xenomai talk and there was another talk on a
>> 3D printer that is using Xenomai
>> (https://elciotna18.sched.com/event/DXmw/3d-printing-with-linux-and-xenomai-kendall-auel-3d-systems-corp)
>
> Cool! Didn't check the agenda yet.
>
>> that sounds like it will be interesting.  I'm up for anything Xenomai,
>> I'll be getting there late Sunday and leaving around 6pm Wednesday.
>
> I'll have a couple of appointments, I suppose, but we could do a Xenomai
> lunch. Maybe right away on Monday (Tuesdays would be before my talk, I
> will likely need that time ;)).
>
> Jan
>
>>
>> -Greg
>>
>> On Fri, Jan 26, 2018 at 1:57 PM, Jan Kiszka  wrote:
>>> On 2018-01-26 19:51, Greg Gallagher wrote:
 We can add an ELC meeting ;)

>>>
>>> Sure! Will you attend?
>>>
>>> Our Xenomai talk was accepted [1], and I'll hang around in Portland for
>>> the whole ELC. We can do some hallway tracks or more if there is interest.
>>>
>>> Jan
>>>
>>> [1]
>>> https://elciotna18.sched.com/event/DXnN/steering-xenomai-into-the-real-time-linux-future-jan-kiszka-siemens-ag
>>>
 On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka  wrote:
> On 2018-01-25 18:40, Philippe Gerum wrote:
>>
>> Here are some points I would like to discuss during this meeting. Please
>> feel free to comment:
>>
>> 1. Release management
>>
>>   * Currently, the person who contributes most of the code is also 
>> the
>> release manager, which is clearly not optimal. Both activities should be
>> decoupled for efficiency (esp. hindsight) and practical reasons. At some
>> point, I will stop acting as the release manager, so the project will
>> need a different organization in this respect. Which one?
>>
>>   * As a corollary, the current release process is broken: no 
>> explicit
>> release plan or schedule, limited testing, barely any user feedback
>> about the development version in general. Practical steps to improve
>> this should be discussed.
>>
>>   * My understanding is that v3.1 is almost there feature-wise, with 
>> a
>> working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
>> enabling RTnet with SMAP/x86 (which still need some feedback btw), and
>> support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
>> still lagging behind with kernel 4.9 though. I'm about to queue a couple
>> of ABI changes more, with the implementation of sendmmsg() and
>> recvmmsg() for RTDM sockets.
>>
>> This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
>> should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
>> much use/testing do we currently have of the -next branch, on which CPU
>> architecture(s)?
>>
>> 2. Documentation
>>
>>   * The existing documentation has several weaknesses; from the 
>> traffic
>> on the mailing list, the main one may be that it leaves newcomers with a
>> steep learning curve, in some occasions, even when the information is
>> published on the website and/or present in the inline documentation. How
>> to improve the situation, how to better organize the existing doc so
>> that people do find what they are looking for?
>>
>>   * Doxygen may not be the best option anymore for inline 
>> documentation;
>> Chasing glitches with using the markup has been a real pain over the
>> years, getting properly structured output has never been obvious. Could
>> we do better with Doxygen in a reasonably simple fashion, or should
>> reStructuredText and Sphinx be considered as a replacement, so that we
>> can converge toward the kernel documentation system?
>>
>> 3. Pipeline maintenance
>>
>>   * We now have a dedicated I-pipe maintainer per CPU architecture, 
>> which
>> is a great relief to me. Now I'd like we discuss the maintenance
>> process, 1) how to organize the upstream/downstream flow of the generic
>> pipeline bits I still maintain currently, between other maintainers and
>> me? 2) how to best disseminate knowledge about the I-pipe implementation?
>>
>>   * mainline vs CIP kernel, LTS maintenance policy
>>
>> 4. Misc
>>
>>   * formalizing the decision about dropping the blackfin and 
>> powerpc64
>> port, since we had zero feedback from users so far, so everyone must be
>> fine with this.
>>
>> Thanks,
>>
>
> Thanks for preparing this. Sounds good to me.
>
> Adding from Greg's points as well, we probably need to bring up 

Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Jan Kiszka
On 2018-01-26 20:02, Greg Gallagher wrote:
> That would be great,  I booked my flights and hotel this morning.
> Definitely attending the Xenomai talk and there was another talk on a
> 3D printer that is using Xenomai
> (https://elciotna18.sched.com/event/DXmw/3d-printing-with-linux-and-xenomai-kendall-auel-3d-systems-corp)

Cool! Didn't check the agenda yet.

> that sounds like it will be interesting.  I'm up for anything Xenomai,
> I'll be getting there late Sunday and leaving around 6pm Wednesday.

I'll have a couple of appointments, I suppose, but we could do a Xenomai
lunch. Maybe right away on Monday (Tuesdays would be before my talk, I
will likely need that time ;)).

Jan

> 
> -Greg
> 
> On Fri, Jan 26, 2018 at 1:57 PM, Jan Kiszka  wrote:
>> On 2018-01-26 19:51, Greg Gallagher wrote:
>>> We can add an ELC meeting ;)
>>>
>>
>> Sure! Will you attend?
>>
>> Our Xenomai talk was accepted [1], and I'll hang around in Portland for
>> the whole ELC. We can do some hallway tracks or more if there is interest.
>>
>> Jan
>>
>> [1]
>> https://elciotna18.sched.com/event/DXnN/steering-xenomai-into-the-real-time-linux-future-jan-kiszka-siemens-ag
>>
>>> On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka  wrote:
 On 2018-01-25 18:40, Philippe Gerum wrote:
>
> Here are some points I would like to discuss during this meeting. Please
> feel free to comment:
>
> 1. Release management
>
>   * Currently, the person who contributes most of the code is also the
> release manager, which is clearly not optimal. Both activities should be
> decoupled for efficiency (esp. hindsight) and practical reasons. At some
> point, I will stop acting as the release manager, so the project will
> need a different organization in this respect. Which one?
>
>   * As a corollary, the current release process is broken: no explicit
> release plan or schedule, limited testing, barely any user feedback
> about the development version in general. Practical steps to improve
> this should be discussed.
>
>   * My understanding is that v3.1 is almost there feature-wise, with a
> working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
> enabling RTnet with SMAP/x86 (which still need some feedback btw), and
> support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
> still lagging behind with kernel 4.9 though. I'm about to queue a couple
> of ABI changes more, with the implementation of sendmmsg() and
> recvmmsg() for RTDM sockets.
>
> This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
> should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
> much use/testing do we currently have of the -next branch, on which CPU
> architecture(s)?
>
> 2. Documentation
>
>   * The existing documentation has several weaknesses; from the 
> traffic
> on the mailing list, the main one may be that it leaves newcomers with a
> steep learning curve, in some occasions, even when the information is
> published on the website and/or present in the inline documentation. How
> to improve the situation, how to better organize the existing doc so
> that people do find what they are looking for?
>
>   * Doxygen may not be the best option anymore for inline 
> documentation;
> Chasing glitches with using the markup has been a real pain over the
> years, getting properly structured output has never been obvious. Could
> we do better with Doxygen in a reasonably simple fashion, or should
> reStructuredText and Sphinx be considered as a replacement, so that we
> can converge toward the kernel documentation system?
>
> 3. Pipeline maintenance
>
>   * We now have a dedicated I-pipe maintainer per CPU architecture, 
> which
> is a great relief to me. Now I'd like we discuss the maintenance
> process, 1) how to organize the upstream/downstream flow of the generic
> pipeline bits I still maintain currently, between other maintainers and
> me? 2) how to best disseminate knowledge about the I-pipe implementation?
>
>   * mainline vs CIP kernel, LTS maintenance policy
>
> 4. Misc
>
>   * formalizing the decision about dropping the blackfin and powerpc64
> port, since we had zero feedback from users so far, so everyone must be
> fine with this.
>
> Thanks,
>

 Thanks for preparing this. Sounds good to me.

 Adding from Greg's points as well, we probably need to bring up bug
 tracking together with the bigger topic workflow and related tooling.
 This may easily make us run out of time, but a survey of opinions and
 ideas in that round would be good to follow up on the list afterwards.

 Then testing. I would also not go into too much details, but it would 

Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Greg Gallagher
That would be great,  I booked my flights and hotel this morning.
Definitely attending the Xenomai talk and there was another talk on a
3D printer that is using Xenomai
(https://elciotna18.sched.com/event/DXmw/3d-printing-with-linux-and-xenomai-kendall-auel-3d-systems-corp)
that sounds like it will be interesting.  I'm up for anything Xenomai,
I'll be getting there late Sunday and leaving around 6pm Wednesday.

-Greg

On Fri, Jan 26, 2018 at 1:57 PM, Jan Kiszka  wrote:
> On 2018-01-26 19:51, Greg Gallagher wrote:
>> We can add an ELC meeting ;)
>>
>
> Sure! Will you attend?
>
> Our Xenomai talk was accepted [1], and I'll hang around in Portland for
> the whole ELC. We can do some hallway tracks or more if there is interest.
>
> Jan
>
> [1]
> https://elciotna18.sched.com/event/DXnN/steering-xenomai-into-the-real-time-linux-future-jan-kiszka-siemens-ag
>
>> On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka  wrote:
>>> On 2018-01-25 18:40, Philippe Gerum wrote:

 Here are some points I would like to discuss during this meeting. Please
 feel free to comment:

 1. Release management

   * Currently, the person who contributes most of the code is also the
 release manager, which is clearly not optimal. Both activities should be
 decoupled for efficiency (esp. hindsight) and practical reasons. At some
 point, I will stop acting as the release manager, so the project will
 need a different organization in this respect. Which one?

   * As a corollary, the current release process is broken: no explicit
 release plan or schedule, limited testing, barely any user feedback
 about the development version in general. Practical steps to improve
 this should be discussed.

   * My understanding is that v3.1 is almost there feature-wise, with a
 working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
 enabling RTnet with SMAP/x86 (which still need some feedback btw), and
 support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
 still lagging behind with kernel 4.9 though. I'm about to queue a couple
 of ABI changes more, with the implementation of sendmmsg() and
 recvmmsg() for RTDM sockets.

 This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
 should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
 much use/testing do we currently have of the -next branch, on which CPU
 architecture(s)?

 2. Documentation

   * The existing documentation has several weaknesses; from the traffic
 on the mailing list, the main one may be that it leaves newcomers with a
 steep learning curve, in some occasions, even when the information is
 published on the website and/or present in the inline documentation. How
 to improve the situation, how to better organize the existing doc so
 that people do find what they are looking for?

   * Doxygen may not be the best option anymore for inline 
 documentation;
 Chasing glitches with using the markup has been a real pain over the
 years, getting properly structured output has never been obvious. Could
 we do better with Doxygen in a reasonably simple fashion, or should
 reStructuredText and Sphinx be considered as a replacement, so that we
 can converge toward the kernel documentation system?

 3. Pipeline maintenance

   * We now have a dedicated I-pipe maintainer per CPU architecture, 
 which
 is a great relief to me. Now I'd like we discuss the maintenance
 process, 1) how to organize the upstream/downstream flow of the generic
 pipeline bits I still maintain currently, between other maintainers and
 me? 2) how to best disseminate knowledge about the I-pipe implementation?

   * mainline vs CIP kernel, LTS maintenance policy

 4. Misc

   * formalizing the decision about dropping the blackfin and powerpc64
 port, since we had zero feedback from users so far, so everyone must be
 fine with this.

 Thanks,

>>>
>>> Thanks for preparing this. Sounds good to me.
>>>
>>> Adding from Greg's points as well, we probably need to bring up bug
>>> tracking together with the bigger topic workflow and related tooling.
>>> This may easily make us run out of time, but a survey of opinions and
>>> ideas in that round would be good to follow up on the list afterwards.
>>>
>>> Then testing. I would also not go into too much details, but it would be
>>> good to understand what exist(ed) and what could be done easily to
>>> improve it. Overlaps also with release management and with the good
>>> proposal to define reference boards.
>>>
>>> How many days will our meeting have? ;)
>>>
>>> Jan
>>>
>>> --
>>> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
>>> Corporate Competence Center Embedded Linux
>


Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Jan Kiszka
On 2018-01-26 19:51, Greg Gallagher wrote:
> We can add an ELC meeting ;)
> 

Sure! Will you attend?

Our Xenomai talk was accepted [1], and I'll hang around in Portland for
the whole ELC. We can do some hallway tracks or more if there is interest.

Jan

[1]
https://elciotna18.sched.com/event/DXnN/steering-xenomai-into-the-real-time-linux-future-jan-kiszka-siemens-ag

> On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka  wrote:
>> On 2018-01-25 18:40, Philippe Gerum wrote:
>>>
>>> Here are some points I would like to discuss during this meeting. Please
>>> feel free to comment:
>>>
>>> 1. Release management
>>>
>>>   * Currently, the person who contributes most of the code is also the
>>> release manager, which is clearly not optimal. Both activities should be
>>> decoupled for efficiency (esp. hindsight) and practical reasons. At some
>>> point, I will stop acting as the release manager, so the project will
>>> need a different organization in this respect. Which one?
>>>
>>>   * As a corollary, the current release process is broken: no explicit
>>> release plan or schedule, limited testing, barely any user feedback
>>> about the development version in general. Practical steps to improve
>>> this should be discussed.
>>>
>>>   * My understanding is that v3.1 is almost there feature-wise, with a
>>> working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
>>> enabling RTnet with SMAP/x86 (which still need some feedback btw), and
>>> support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
>>> still lagging behind with kernel 4.9 though. I'm about to queue a couple
>>> of ABI changes more, with the implementation of sendmmsg() and
>>> recvmmsg() for RTDM sockets.
>>>
>>> This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
>>> should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
>>> much use/testing do we currently have of the -next branch, on which CPU
>>> architecture(s)?
>>>
>>> 2. Documentation
>>>
>>>   * The existing documentation has several weaknesses; from the traffic
>>> on the mailing list, the main one may be that it leaves newcomers with a
>>> steep learning curve, in some occasions, even when the information is
>>> published on the website and/or present in the inline documentation. How
>>> to improve the situation, how to better organize the existing doc so
>>> that people do find what they are looking for?
>>>
>>>   * Doxygen may not be the best option anymore for inline documentation;
>>> Chasing glitches with using the markup has been a real pain over the
>>> years, getting properly structured output has never been obvious. Could
>>> we do better with Doxygen in a reasonably simple fashion, or should
>>> reStructuredText and Sphinx be considered as a replacement, so that we
>>> can converge toward the kernel documentation system?
>>>
>>> 3. Pipeline maintenance
>>>
>>>   * We now have a dedicated I-pipe maintainer per CPU architecture, 
>>> which
>>> is a great relief to me. Now I'd like we discuss the maintenance
>>> process, 1) how to organize the upstream/downstream flow of the generic
>>> pipeline bits I still maintain currently, between other maintainers and
>>> me? 2) how to best disseminate knowledge about the I-pipe implementation?
>>>
>>>   * mainline vs CIP kernel, LTS maintenance policy
>>>
>>> 4. Misc
>>>
>>>   * formalizing the decision about dropping the blackfin and powerpc64
>>> port, since we had zero feedback from users so far, so everyone must be
>>> fine with this.
>>>
>>> Thanks,
>>>
>>
>> Thanks for preparing this. Sounds good to me.
>>
>> Adding from Greg's points as well, we probably need to bring up bug
>> tracking together with the bigger topic workflow and related tooling.
>> This may easily make us run out of time, but a survey of opinions and
>> ideas in that round would be good to follow up on the list afterwards.
>>
>> Then testing. I would also not go into too much details, but it would be
>> good to understand what exist(ed) and what could be done easily to
>> improve it. Overlaps also with release management and with the good
>> proposal to define reference boards.
>>
>> How many days will our meeting have? ;)
>>
>> Jan
>>
>> --
>> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
>> Corporate Competence Center Embedded Linux


___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Greg Gallagher
We can add an ELC meeting ;)

On Fri, Jan 26, 2018 at 1:49 PM, Jan Kiszka  wrote:
> On 2018-01-25 18:40, Philippe Gerum wrote:
>>
>> Here are some points I would like to discuss during this meeting. Please
>> feel free to comment:
>>
>> 1. Release management
>>
>>   * Currently, the person who contributes most of the code is also the
>> release manager, which is clearly not optimal. Both activities should be
>> decoupled for efficiency (esp. hindsight) and practical reasons. At some
>> point, I will stop acting as the release manager, so the project will
>> need a different organization in this respect. Which one?
>>
>>   * As a corollary, the current release process is broken: no explicit
>> release plan or schedule, limited testing, barely any user feedback
>> about the development version in general. Practical steps to improve
>> this should be discussed.
>>
>>   * My understanding is that v3.1 is almost there feature-wise, with a
>> working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
>> enabling RTnet with SMAP/x86 (which still need some feedback btw), and
>> support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
>> still lagging behind with kernel 4.9 though. I'm about to queue a couple
>> of ABI changes more, with the implementation of sendmmsg() and
>> recvmmsg() for RTDM sockets.
>>
>> This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
>> should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
>> much use/testing do we currently have of the -next branch, on which CPU
>> architecture(s)?
>>
>> 2. Documentation
>>
>>   * The existing documentation has several weaknesses; from the traffic
>> on the mailing list, the main one may be that it leaves newcomers with a
>> steep learning curve, in some occasions, even when the information is
>> published on the website and/or present in the inline documentation. How
>> to improve the situation, how to better organize the existing doc so
>> that people do find what they are looking for?
>>
>>   * Doxygen may not be the best option anymore for inline documentation;
>> Chasing glitches with using the markup has been a real pain over the
>> years, getting properly structured output has never been obvious. Could
>> we do better with Doxygen in a reasonably simple fashion, or should
>> reStructuredText and Sphinx be considered as a replacement, so that we
>> can converge toward the kernel documentation system?
>>
>> 3. Pipeline maintenance
>>
>>   * We now have a dedicated I-pipe maintainer per CPU architecture, which
>> is a great relief to me. Now I'd like we discuss the maintenance
>> process, 1) how to organize the upstream/downstream flow of the generic
>> pipeline bits I still maintain currently, between other maintainers and
>> me? 2) how to best disseminate knowledge about the I-pipe implementation?
>>
>>   * mainline vs CIP kernel, LTS maintenance policy
>>
>> 4. Misc
>>
>>   * formalizing the decision about dropping the blackfin and powerpc64
>> port, since we had zero feedback from users so far, so everyone must be
>> fine with this.
>>
>> Thanks,
>>
>
> Thanks for preparing this. Sounds good to me.
>
> Adding from Greg's points as well, we probably need to bring up bug
> tracking together with the bigger topic workflow and related tooling.
> This may easily make us run out of time, but a survey of opinions and
> ideas in that round would be good to follow up on the list afterwards.
>
> Then testing. I would also not go into too much details, but it would be
> good to understand what exist(ed) and what could be done easily to
> improve it. Overlaps also with release management and with the good
> proposal to define reference boards.
>
> How many days will our meeting have? ;)
>
> Jan
>
> --
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


Re: [Xenomai] [RFC] FOSDEM meeting agenda

2018-01-26 Thread Jan Kiszka
On 2018-01-25 18:40, Philippe Gerum wrote:
> 
> Here are some points I would like to discuss during this meeting. Please
> feel free to comment:
> 
> 1. Release management
> 
>   * Currently, the person who contributes most of the code is also the
> release manager, which is clearly not optimal. Both activities should be
> decoupled for efficiency (esp. hindsight) and practical reasons. At some
> point, I will stop acting as the release manager, so the project will
> need a different organization in this respect. Which one?
> 
>   * As a corollary, the current release process is broken: no explicit
> release plan or schedule, limited testing, barely any user feedback
> about the development version in general. Practical steps to improve
> this should be discussed.
> 
>   * My understanding is that v3.1 is almost there feature-wise, with a
> working arm64 port Dmitriy is polishing, a bunch of rtnet fixes actually
> enabling RTnet with SMAP/x86 (which still need some feedback btw), and
> support for recent kernels up to 4.14 (arm, arm64, powerpc). x86 is
> still lagging behind with kernel 4.9 though. I'm about to queue a couple
> of ABI changes more, with the implementation of sendmmsg() and
> recvmmsg() for RTDM sockets.
> 
> This raises the following questions: 1) may we freeze the v3.1 ABI, 2)
> should we wait for supporting 4.14/x86 before releasing v3.1, 3) how
> much use/testing do we currently have of the -next branch, on which CPU
> architecture(s)?
> 
> 2. Documentation
> 
>   * The existing documentation has several weaknesses; from the traffic
> on the mailing list, the main one may be that it leaves newcomers with a
> steep learning curve, in some occasions, even when the information is
> published on the website and/or present in the inline documentation. How
> to improve the situation, how to better organize the existing doc so
> that people do find what they are looking for?
> 
>   * Doxygen may not be the best option anymore for inline documentation;
> Chasing glitches with using the markup has been a real pain over the
> years, getting properly structured output has never been obvious. Could
> we do better with Doxygen in a reasonably simple fashion, or should
> reStructuredText and Sphinx be considered as a replacement, so that we
> can converge toward the kernel documentation system?
> 
> 3. Pipeline maintenance
> 
>   * We now have a dedicated I-pipe maintainer per CPU architecture, which
> is a great relief to me. Now I'd like we discuss the maintenance
> process, 1) how to organize the upstream/downstream flow of the generic
> pipeline bits I still maintain currently, between other maintainers and
> me? 2) how to best disseminate knowledge about the I-pipe implementation?
> 
>   * mainline vs CIP kernel, LTS maintenance policy
> 
> 4. Misc
> 
>   * formalizing the decision about dropping the blackfin and powerpc64
> port, since we had zero feedback from users so far, so everyone must be
> fine with this.
> 
> Thanks,
> 

Thanks for preparing this. Sounds good to me.

Adding from Greg's points as well, we probably need to bring up bug
tracking together with the bigger topic workflow and related tooling.
This may easily make us run out of time, but a survey of opinions and
ideas in that round would be good to follow up on the list afterwards.

Then testing. I would also not go into too much details, but it would be
good to understand what exist(ed) and what could be done easily to
improve it. Overlaps also with release management and with the good
proposal to define reference boards.

How many days will our meeting have? ;)

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


[Xenomai] [PATCH] cobalt/intr: Move IRQ exit trace point

2018-01-26 Thread Jan Kiszka
It can be confusing for people reading a trace when a context switch due
to a wake up in the IRQ handler comes before the handler was left. Move
the exit instrumentation before the schedule, just like we already do in
the clock handler.

Signed-off-by: Jan Kiszka 
---
 kernel/cobalt/intr.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c
index 14dc0b35e..fb27a3295 100644
--- a/kernel/cobalt/intr.c
+++ b/kernel/cobalt/intr.c
@@ -355,12 +355,12 @@ static void xnintr_vec_handler(unsigned int irq, void 
*cookie)
 out:
xnstat_exectime_switch(sched, prev);
 
+   trace_cobalt_irq_exit(irq);
+
if (--sched->inesting == 0) {
sched->lflags &= ~XNINIRQ;
xnsched_run();
}
-
-   trace_cobalt_irq_exit(irq);
 }
 
 /*
@@ -441,12 +441,12 @@ static void xnintr_edge_vec_handler(unsigned int irq, 
void *cookie)
 out:
xnstat_exectime_switch(sched, prev);
 
+   trace_cobalt_irq_exit(irq);
+
if (--sched->inesting == 0) {
sched->lflags &= ~XNINIRQ;
xnsched_run();
}
-
-   trace_cobalt_irq_exit(irq);
 }
 
 static inline int xnintr_irq_attach(struct xnintr *intr)
-- 
2.13.6

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


Re: [Xenomai] Stack Overflow when changing Affinity

2018-01-26 Thread Philippe Gerum
On 01/09/2018 11:35 PM, Henry Bausley wrote:
> We have an application that gets run repeatedly that causes a stack overflow. 
>  The source is at the end of this mail.
> We have tracked it down to changing the affinity.
> 
> We have used xenomai 2.6.5 and 2.6.4 and kernels 3.14.28 and 4.1.18 and seen 
> identical results.  Our platform is an LS1021A NXP/Freescale ARM processor.  
> Is this a bug or are we incorrectly using affinity
> 
> 

Most likely a Xenomai bug, the issue does not even happen when changing
the affinity, but when binding a new process to the real-time core. I'd
say that such core is doing something wrong after noticing the affinity
change, which corrupts the kernel state/memory in some obscure ways.

-- 
Philippe.

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai


[Xenomai-git] Philippe Gerum : net/socket: align rtdev do_ioctl handler on the regular ndo_do_ioctl

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 09b2466e92b93d5cdd411136f3995d947f556035
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=09b2466e92b93d5cdd411136f3995d947f556035

Author: Philippe Gerum 
Date:   Tue Jan 23 12:03:51 2018 +0100

net/socket: align rtdev do_ioctl handler on the regular ndo_do_ioctl

Align on the signature of the regular ndo_do_ioctl() handler for
interface-directed ioctl requests, since an ifr block must have been
provided by the caller to determine the device to hand over the
request to anyway.

---

 kernel/drivers/net/drivers/8139too.c |7 +++
 .../net/drivers/experimental/rt2500/rt2x00core.c |6 +++---
 kernel/drivers/net/drivers/igb/igb_main.c|7 +++
 kernel/drivers/net/stack/include/rtdev.h |2 +-
 kernel/drivers/net/stack/rtwlan.c|   18 ++
 kernel/drivers/net/stack/socket.c|4 ++--
 6 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/kernel/drivers/net/drivers/8139too.c 
b/kernel/drivers/net/drivers/8139too.c
index 8b1a7df..d49d779 100644
--- a/kernel/drivers/net/drivers/8139too.c
+++ b/kernel/drivers/net/drivers/8139too.c
@@ -519,7 +519,7 @@ static int rtl8139_close (struct rtnet_device *rtdev);
 static int rtl8139_interrupt (rtdm_irq_t *irq_handle);
 static int rtl8139_start_xmit (struct rtskb *skb, struct rtnet_device *rtdev);
 
-static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, 
void *cmd);
+static int rtl8139_ioctl(struct rtnet_device *, struct ifreq *rq, int cmd);
 static struct net_device_stats *rtl8139_get_stats(struct rtnet_device*rtdev);
 
 static void rtl8139_init_ring (struct rtnet_device *rtdev);
@@ -1297,15 +1297,14 @@ static int rtl8139_start_xmit (struct rtskb *skb, 
struct rtnet_device *rtdev)
return 0;
 }
 
-static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, 
void *arg)
+static int rtl8139_ioctl(struct rtnet_device *rtdev, struct ifreq *ifr, int 
cmd)
 {
 struct rtl8139_private *tp = rtdev->priv;
 void *ioaddr = tp->mmio_addr;
 int nReturn = 0;
-struct ifreq *ifr = arg;
 struct ethtool_value *value;
 
-switch (request) {
+switch (cmd) {
case SIOCETHTOOL:
/* TODO: user-safe parameter access, most probably one layer higher 
*/
value = (struct ethtool_value *)ifr->ifr_data;
diff --git a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c 
b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
index c4807ef..926c7de 100644
--- a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
+++ b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
@@ -112,15 +112,15 @@ static int rt2x00_radio_off(struct _rt2x00_core * core) {
 /*
  * user space io handler
  */
-static int rt2x00_ioctl(struct rtnet_device * rtnet_dev, unsigned int request, 
void * arg) {
-
+static int rt2x00_ioctl(struct rtnet_device *rtnet_dev, struct ifreq *ifr, int 
request)
+{
 struct rtwlan_device * rtwlan_dev  = rtnetdev_priv(rtnet_dev);
 struct _rt2x00_core * core = rtwlan_priv(rtwlan_dev);
 struct rtwlan_cmd * cmd;
 u8 rate, dsss_rate, ofdm_rate;
 u32 address, value;
 
-cmd = (struct rtwlan_cmd *)arg;
+cmd = (struct rtwlan_cmd *)ifr->ifr_data;
 
 switch(request) {
 
diff --git a/kernel/drivers/net/drivers/igb/igb_main.c 
b/kernel/drivers/net/drivers/igb/igb_main.c
index fe0132b..be98d78 100644
--- a/kernel/drivers/net/drivers/igb/igb_main.c
+++ b/kernel/drivers/net/drivers/igb/igb_main.c
@@ -216,7 +216,7 @@ static int igb_msix_ring(rtdm_irq_t *irq_handle);
 static void igb_poll(struct igb_q_vector *);
 static bool igb_clean_tx_irq(struct igb_q_vector *);
 static bool igb_clean_rx_irq(struct igb_q_vector *, int);
-static int igb_ioctl(struct rtnet_device *, unsigned cmd, void *);
+static int igb_ioctl(struct rtnet_device *, struct ifreq *ifr, int cmd);
 static void igb_reset_task(struct work_struct *);
 static void igb_vlan_mode(struct rtnet_device *netdev,
  netdev_features_t features);
@@ -5063,15 +5063,14 @@ static int igb_mii_ioctl(struct rtnet_device *netdev, 
struct ifreq *ifr, int cmd
  * @ifreq:
  * @cmd:
  **/
-static int igb_ioctl(struct rtnet_device *netdev, unsigned cmd, void *rq)
+static int igb_ioctl(struct rtnet_device *netdev, struct ifreq *ifr, int cmd)
 {
-   struct ifreq *ifr = rq;
-
switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
return igb_mii_ioctl(netdev, ifr, cmd);
+
default:
return -EOPNOTSUPP;
}
diff --git a/kernel/drivers/net/stack/include/rtdev.h 
b/kernel/drivers/net/stack/include/rtdev.h
index c1c0b4e..a3ac7dd 100644
--- a/kernel/drivers/net/stack/include/rtdev.h
+++ b/kernel/drivers/net/stack/include/rtdev.h
@@ -152,7 +152,7 @@ struct rtnet_device {
   unsigned int 

[Xenomai-git] Philippe Gerum : net: convert to rtdm_get_iov_flatlen()

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9dfdd32d30442366e6ec48f88679dfdc5e091405
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9dfdd32d30442366e6ec48f88679dfdc5e091405

Author: Philippe Gerum 
Date:   Wed Dec  6 13:40:19 2017 +0100

net: convert to rtdm_get_iov_flatlen()

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |4 ++--
 kernel/drivers/net/stack/packet/af_packet.c |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index c460e40..a3fd496 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -454,7 +454,7 @@ ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct 
user_msghdr *msg, int msg_flag
 __rtskb_pull(skb, sizeof(struct udphdr));
 
 flags = msg->msg_flags & ~MSG_TRUNC;
-len = rt_iovec_len(iov, msg->msg_iovlen);
+len = rtdm_get_iov_flatlen(iov, msg->msg_iovlen);
 
 /* iterate over all IP fragments */
 do {
@@ -605,7 +605,7 @@ ssize_t rt_udp_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int ms
 if (err)
return err;
 
-len = rt_iovec_len(iov, msg->msg_iovlen);
+len = rtdm_get_iov_flatlen(iov, msg->msg_iovlen);
 if ((len < 0) || (len > 0x-sizeof(struct iphdr)-sizeof(struct 
udphdr))) {
err = -EMSGSIZE;
goto out;
diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index 046f380..4fbf523 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -364,7 +364,7 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
 
 /* The data must not be longer than the available buffer size */
 copy_len = rtskb->len;
-len = rt_iovec_len(iov, msg->msg_iovlen);
+len = rtdm_get_iov_flatlen(iov, msg->msg_iovlen);
 if (len < 0) {
copy_len = len;
goto out;
@@ -467,7 +467,7 @@ rt_packet_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int msg_fla
goto abort;
 }
 
-len = rt_iovec_len(iov, msg->msg_iovlen);
+len = rtdm_get_iov_flatlen(iov, msg->msg_iovlen);
 rtskb = alloc_rtskb(rtdev->hard_header_len + len, >skb_pool);
 if (rtskb == NULL) {
ret = -ENOBUFS;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/socket: forward private ioctl requests to NIC driver

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1c6ca30eb2d8fa2d22abc4854014e7ede377c30e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c6ca30eb2d8fa2d22abc4854014e7ede377c30e

Author: Philippe Gerum 
Date:   Thu Jan 18 10:49:19 2018 +0100

net/socket: forward private ioctl requests to NIC driver

This allows RTnet to define requests in the SIOCPROTOPRIVATE range for
identifying device-specific features added to the converted NIC
driver.

Therefore, no excution mode is enforced by the base handler, the
callee should check for the current mode, returning -ENOSYS to trigger
the adaptive switch if required.

---

 kernel/drivers/net/stack/socket.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/kernel/drivers/net/stack/socket.c 
b/kernel/drivers/net/stack/socket.c
index c139d95..f2622d3 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -348,6 +348,13 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
ret = -EOPNOTSUPP;
break;
 
+   case SIOCPROTOPRIVATE ... SIOCPROTOPRIVATE + 15:
+   if (rtdev->do_ioctl != NULL)
+   ret = rtdev->do_ioctl(rtdev, ifr, request);
+   else
+   ret = -EOPNOTSUPP;
+   break;
+
 default:
ret = -EOPNOTSUPP;
break;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/socket: enforce secondary mode for SIOCETHTOOL

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c2ddeffb7bdef8dc6667a79becb56f908b480efe
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c2ddeffb7bdef8dc6667a79becb56f908b480efe

Author: Philippe Gerum 
Date:   Thu Jan 18 10:37:01 2018 +0100

net/socket: enforce secondary mode for SIOCETHTOOL

Assume this feature was originally provided by the regular driver
converted to RTNet, which we may want to support thoroughly, including
when tapping into the common PHY layer is required.

To this end, we need to enter the ioctl handler from secondary mode
only, which is not supposed to be an issue since there is no point is
expecting ethertool requests to be part of the time-critical code
anyway.

---

 kernel/drivers/net/stack/socket.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/net/stack/socket.c 
b/kernel/drivers/net/stack/socket.c
index d7d36d5..1eb1856 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -340,10 +340,12 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
break;
 
case SIOCETHTOOL:
-   if (rtdev->do_ioctl != NULL)
-   ret = rtdev->do_ioctl(rtdev, request, arg);
-   else
-   ret = -EOPNOTSUPP;
+   if (rtdev->do_ioctl != NULL) {
+   if (rtdm_in_rt_context())
+   return -ENOSYS;
+   ret = rtdev->do_ioctl(rtdev, request, arg);
+   } else
+   ret = -EOPNOTSUPP;
break;
 
default:


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/packet: recvmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9a86936951e94ad67a49b9fd170ba77208b6e411
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9a86936951e94ad67a49b9fd170ba77208b6e411

Author: Philippe Gerum 
Date:   Tue Dec  5 10:31:32 2017 +0100

net/packet: recvmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/packet/af_packet.c |   84 +++
 1 file changed, 59 insertions(+), 25 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index f6638a7..ff3ef33 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -292,14 +292,29 @@ static ssize_t
 rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr *msg, int msg_flags)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
-size_t  len   = rt_iovec_len(msg->msg_iov, msg->msg_iovlen);
+ssize_t len;
 size_t  copy_len;
-size_t  real_len;
 struct rtskb*rtskb;
-struct sockaddr_ll  *sll;
-int ret;
+struct sockaddr_ll  sll;
+intret, flags;
 nanosecs_rel_t  timeout = sock->timeout;
+struct user_msghdr _msg;
+socklen_t namelen;
+struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
+
+msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+if (IS_ERR(msg))
+   return PTR_ERR(msg);
+   
+if (msg->msg_iovlen < 0)
+   return -EINVAL;
 
+if (msg->msg_iovlen == 0)
+   return 0;
+
+ret = rtdm_get_iovec(fd, , msg, iov_fast);
+if (ret)
+   return ret;
 
 /* non-blocking receive? */
 if (msg_flags & MSG_DONTWAIT)
@@ -308,50 +323,64 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
 ret = rtdm_sem_timeddown(>pending_sem, timeout, NULL);
 if (unlikely(ret < 0))
switch (ret) {
+   default:
+   ret = -EBADF;   /* socket has been closed */
case -EWOULDBLOCK:
case -ETIMEDOUT:
case -EINTR:
+   rtdm_drop_iovec(iov, iov_fast);
return ret;
-
-   default:
-   return -EBADF;   /* socket has been closed */
}
 
 rtskb = rtskb_dequeue_chain(>incoming);
 RTNET_ASSERT(rtskb != NULL, return -EFAULT;);
 
-sll = msg->msg_name;
-
 /* copy the address */
-msg->msg_namelen = sizeof(*sll);
-if (sll != NULL) {
-   struct rtnet_device *rtdev = rtskb->rtdev;
+namelen = sizeof(sll);
+ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
+if (ret)
+   goto fail;
 
-   sll->sll_family   = AF_PACKET;
-   sll->sll_hatype   = rtdev->type;
-   sll->sll_protocol = rtskb->protocol;
-   sll->sll_pkttype  = rtskb->pkt_type;
-   sll->sll_ifindex  = rtdev->ifindex;
+/* copy the address if required. */
+if (msg->msg_name) {
+   struct rtnet_device *rtdev = rtskb->rtdev;
+   memset(, 0, sizeof(sll));
+   sll.sll_family   = AF_PACKET;
+   sll.sll_hatype   = rtdev->type;
+   sll.sll_protocol = rtskb->protocol;
+   sll.sll_pkttype  = rtskb->pkt_type;
+   sll.sll_ifindex  = rtdev->ifindex;
 
/* Ethernet specific - we rather need some parse handler here */
-   memcpy(sll->sll_addr, rtskb->mac.ethernet->h_source, ETH_ALEN);
-   sll->sll_halen = ETH_ALEN;
+   memcpy(sll.sll_addr, rtskb->mac.ethernet->h_source, ETH_ALEN);
+   sll.sll_halen = ETH_ALEN;
+   ret = rtnet_put_arg(fd, >msg_name, , sizeof(sll));
+   if (ret)
+   goto fail;
 }
 
 /* Include the header in raw delivery */
 if (rtdm_fd_to_context(fd)->device->driver->socket_type != SOCK_DGRAM)
rtskb_push(rtskb, rtskb->data - rtskb->mac.raw);
 
-copy_len = real_len = rtskb->len;
-
 /* The data must not be longer than the available buffer size */
+copy_len = rtskb->len;
+len = rt_iovec_len(iov, msg->msg_iovlen);
+if (len < 0) {
+   copy_len = len;
+   goto out;
+}
+
 if (copy_len > len) {
copy_len = len;
-   msg->msg_flags |= MSG_TRUNC;
+   flags = msg->msg_flags | MSG_TRUNC;
+   ret = rtnet_put_arg(fd, >msg_flags, , sizeof(flags));
+   if (ret)
+   goto fail;
 }
 
-rt_memcpy_tokerneliovec(msg->msg_iov, rtskb->data, copy_len);
-
+copy_len = rtnet_write_to_iov(fd, iov, msg->msg_iovlen, rtskb->data, 
copy_len);
+out:
 if ((msg_flags & MSG_PEEK) == 0) {
kfree_rtskb(rtskb);
 } else {
@@ -359,7 +388,12 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
rtdm_sem_up(>pending_sem);
 }
 
-return real_len;
+rtdm_drop_iovec(iov, iov_fast);
+
+return copy_len;
+fail:
+copy_len = ret;
+goto out;
 }
 
 


___
Xenomai-git mailing list

[Xenomai-git] Philippe Gerum : net/socket: ioctl: remove direct references to user memory (2)

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2ab13f22ccc28266402993d70daa64953f31803c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2ab13f22ccc28266402993d70daa64953f31803c

Author: Philippe Gerum 
Date:   Sun Jan  7 18:26:48 2018 +0100

net/socket: ioctl: remove direct references to user memory (2)

---

 kernel/drivers/net/stack/socket.c |   47 -
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/kernel/drivers/net/stack/socket.c 
b/kernel/drivers/net/stack/socket.c
index 5b2..d7d36d5 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -243,25 +243,20 @@ EXPORT_SYMBOL_GPL(rt_socket_common_ioctl);
 int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void __user *arg)
 {
 struct rtnet_device *rtdev;
-const struct ifreq  *ifr;
-struct ifreq_ifr, *ifrw;
+struct ifreq _ifr, *ifr, *u_ifr;
 struct sockaddr_in  _sin;
-const struct ifconf *ifc;
-struct ifconf _ifc, *ifcw;
+struct ifconf _ifc, *ifc, *u_ifc;
 int ret = 0, size = 0, i;
 short flags;
 
 
 if (request == SIOCGIFCONF) {
-   ifc = rtnet_get_arg(fd, &_ifc, arg, sizeof(_ifc));
+   u_ifc = arg;
+   ifc = rtnet_get_arg(fd, &_ifc, u_ifc, sizeof(_ifc));
if (IS_ERR(ifc))
return PTR_ERR(ifc);
 
-   for (ifrw = ifc->ifc_req, i = 1; i <= MAX_RT_DEVICES; i++) {
-   ifrw = (struct ifreq *)rtnet_get_arg(fd, &_ifr, ifrw, 
sizeof(_ifr));
-   if (IS_ERR(ifrw))
-   return PTR_ERR(ifrw);
-
+   for (u_ifr = ifc->ifc_req, i = 1; i <= MAX_RT_DEVICES; i++, u_ifr++) {
rtdev = rtdev_get_by_index(i);
if (rtdev == NULL)
continue;
@@ -278,26 +273,24 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
break;
}
 
-   ret = rtnet_put_arg(fd, ifrw->ifr_name, rtdev->name, IFNAMSIZ);
+   ret = rtnet_put_arg(fd, u_ifr->ifr_name, rtdev->name, IFNAMSIZ);
if (ret == 0) {
memset(&_sin, 0, sizeof(_sin));
_sin.sin_family  = AF_INET;
_sin.sin_addr.s_addr = rtdev->local_ip;
-   ret = rtnet_put_arg(fd, >ifr_addr, &_sin, 
sizeof(ifrw->ifr_addr));
+   ret = rtnet_put_arg(fd, _ifr->ifr_addr, &_sin, 
sizeof(_sin));
}

rtdev_dereference(rtdev);
if (ret)
return ret;
-   ifrw++;
}
 
-   ifcw = arg;
-   return rtnet_put_arg(fd, >ifc_len, , sizeof(size));
+   return rtnet_put_arg(fd, _ifc->ifc_len, , sizeof(size));
 }
 
-ifrw = arg;
-ifr = rtnet_get_arg(fd, &_ifr, arg, sizeof(_ifr));
+u_ifr = arg;
+ifr = rtnet_get_arg(fd, &_ifr, u_ifr, sizeof(_ifr));
 if (IS_ERR(ifr))
return PTR_ERR(ifr);
 
@@ -305,7 +298,7 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
 rtdev = rtdev_get_by_index(ifr->ifr_ifindex);
 if (rtdev == NULL)
 return -ENODEV;
-   ret = rtnet_put_arg(fd, ifrw->ifr_name, rtdev->name, IFNAMSIZ);
+   ret = rtnet_put_arg(fd, u_ifr->ifr_name, rtdev->name, IFNAMSIZ);
goto out;
 }
 
@@ -315,8 +308,8 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
 
 switch (request) {
case SIOCGIFINDEX:
-   ret = rtnet_put_arg(fd, >ifr_ifindex, >ifindex,
-   sizeof(ifrw->ifr_ifindex));
+   ret = rtnet_put_arg(fd, _ifr->ifr_ifindex, >ifindex,
+   sizeof(u_ifr->ifr_ifindex));
break;
 
case SIOCGIFFLAGS:
@@ -327,23 +320,23 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
   | RTNET_LINK_STATE_NOCARRIER))
 == RTNET_LINK_STATE_PRESENT)
flags |= IFF_RUNNING;
-   ret = rtnet_put_arg(fd, >ifr_flags, ,
-   sizeof(ifrw->ifr_flags));
+   ret = rtnet_put_arg(fd, _ifr->ifr_flags, ,
+   sizeof(u_ifr->ifr_flags));
break;
 
case SIOCGIFHWADDR:
-   ret = rtnet_put_arg(fd, >ifr_hwaddr.sa_data, 
rtdev->dev_addr,
-   rtdev->addr_len);
+   ret = rtnet_put_arg(fd, _ifr->ifr_hwaddr.sa_data,
+   rtdev->dev_addr, rtdev->addr_len);
if (!ret)
-   ret = rtnet_put_arg(fd, >ifr_hwaddr.sa_family, 
>type,
-   sizeof(ifrw->ifr_hwaddr.sa_family));
+   ret = rtnet_put_arg(fd, _ifr->ifr_hwaddr.sa_family,
+   >type, 

[Xenomai-git] Philippe Gerum : net/udp: ioctl: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b078ab3efe5cf3ef1b3df5905ce4e8004de5179d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b078ab3efe5cf3ef1b3df5905ce4e8004de5179d

Author: Philippe Gerum 
Date:   Mon Dec  4 19:21:23 2017 +0100

net/udp: ioctl: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |   31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index 01c9d8d..f8eeadd 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -345,26 +346,30 @@ void rt_udp_close(struct rtdm_fd *fd)
 
 
 
-int rt_udp_ioctl(struct rtdm_fd *fd, unsigned int request, void *arg)
+int rt_udp_ioctl(struct rtdm_fd *fd, unsigned int request, void __user *arg)
 {
-struct rtsocket *sock = rtdm_fd_to_private(fd);
-struct _rtdm_setsockaddr_args *setaddr = arg;
-
+   struct rtsocket *sock = rtdm_fd_to_private(fd);
+   const struct _rtdm_setsockaddr_args *setaddr;
+   struct _rtdm_setsockaddr_args *_setaddr;
 
-/* fast path for common socket IOCTLs */
-if (_IOC_TYPE(request) == RTIOC_TYPE_NETWORK)
-return rt_socket_common_ioctl(fd, request, arg);
+   /* fast path for common socket IOCTLs */
+   if (_IOC_TYPE(request) == RTIOC_TYPE_NETWORK)
+   return rt_socket_common_ioctl(fd, request, arg);
 
-switch (request) {
+   switch (request) {
 case _RTIOC_BIND:
-return rt_udp_bind(sock, setaddr->addr, setaddr->addrlen);
-
 case _RTIOC_CONNECT:
-return rt_udp_connect(sock, setaddr->addr, setaddr->addrlen);
+   setaddr = rtnet_get_arg(fd, &_setaddr, arg, sizeof(_setaddr));
+   if (IS_ERR(setaddr))
+   return PTR_ERR(setaddr);
+   if (request == _RTIOC_BIND)
+   return rt_udp_bind(sock, setaddr->addr, 
setaddr->addrlen);
+
+   return rt_udp_connect(sock, setaddr->addr, setaddr->addrlen);
 
 default:
-return rt_ip_ioctl(fd, request, arg);
-}
+   return rt_ip_ioctl(fd, request, arg);
+   }
 }
 
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/iovec: drop useless kernel<-> iovec[] copy helpers

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 26a55e77abd2b35f096ac8f9aec76f98f5d49520
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=26a55e77abd2b35f096ac8f9aec76f98f5d49520

Author: Philippe Gerum 
Date:   Wed Dec  6 13:41:06 2017 +0100

net/iovec: drop useless kernel<-> iovec[] copy helpers

No more in-tree users for those, in the wake of dropping the broken
direct references from the kernel to user-space memory.

---

 kernel/drivers/net/stack/include/rtnet_iovec.h |   18 --
 kernel/drivers/net/stack/iovec.c   |   46 
 2 files changed, 64 deletions(-)

diff --git a/kernel/drivers/net/stack/include/rtnet_iovec.h 
b/kernel/drivers/net/stack/include/rtnet_iovec.h
index 09e86d1..69113f4 100644
--- a/kernel/drivers/net/stack/include/rtnet_iovec.h
+++ b/kernel/drivers/net/stack/include/rtnet_iovec.h
@@ -28,24 +28,6 @@
 struct user_msghdr;
 struct rtdm_fd;
 
-/***
- *  rt_iovec_len
- */
-static inline size_t rt_iovec_len(const struct iovec *iov, int iovlen)
-{
-int i;
-size_t len = 0;
-
-for (i = 0; i < iovlen; i++)
-len += iov[i].iov_len;
-
-return len;
-}
-
-
-extern void rt_memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, 
int len);
-extern void rt_memcpy_fromkerneliovec(unsigned char *kdata, struct iovec *iov, 
int len);
-
 ssize_t rtnet_write_to_iov(struct rtdm_fd *fd,
   struct iovec *iov, int iovlen,
   const void *data, size_t len);
diff --git a/kernel/drivers/net/stack/iovec.c b/kernel/drivers/net/stack/iovec.c
index 3164d28..ac7501c 100644
--- a/kernel/drivers/net/stack/iovec.c
+++ b/kernel/drivers/net/stack/iovec.c
@@ -29,52 +29,6 @@
 #include 
 #include 
 
-
-/***
- *  rt_memcpy_tokerneliovec
- */
-void rt_memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len)
-{
-while (len > 0)
-{
-if (iov->iov_len)
-{
-int copy = min_t(unsigned int, iov->iov_len, len);
-
-memcpy(iov->iov_base, kdata, copy);
-kdata+=copy;
-len-=copy;
-iov->iov_len-=copy;
-iov->iov_base+=copy;
-}
-iov++;
-}
-}
-EXPORT_SYMBOL_GPL(rt_memcpy_tokerneliovec);
-
-
-/***
- *  rt_memcpy_fromkerneliovec
- */
-void rt_memcpy_fromkerneliovec(unsigned char *kdata, struct iovec *iov,int len)
-{
-while (len > 0)
-{
-if (iov->iov_len)
-{
-int copy=min_t(unsigned int, len, iov->iov_len);
-
-memcpy(kdata, iov->iov_base, copy);
-len-=copy;
-kdata+=copy;
-iov->iov_base+=copy;
-iov->iov_len-=copy;
-}
-iov++;
-}
-}
-EXPORT_SYMBOL_GPL(rt_memcpy_fromkerneliovec);
-
 ssize_t rtnet_write_to_iov(struct rtdm_fd *fd,
   struct iovec *iov, int iovlen,
   const void *data, size_t len)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/iovec: add copy iterators for iovec[]

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6ec32eed8f0d3fc87bc8082f20f2c768130ba34d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6ec32eed8f0d3fc87bc8082f20f2c768130ba34d

Author: Philippe Gerum 
Date:   Tue Dec  5 15:34:17 2017 +0100

net/iovec: add copy iterators for iovec[]

---

 kernel/drivers/net/stack/include/rtnet_iovec.h |8 +++
 kernel/drivers/net/stack/iovec.c   |   79 +++-
 2 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/net/stack/include/rtnet_iovec.h 
b/kernel/drivers/net/stack/include/rtnet_iovec.h
index 2b81893..09e86d1 100644
--- a/kernel/drivers/net/stack/include/rtnet_iovec.h
+++ b/kernel/drivers/net/stack/include/rtnet_iovec.h
@@ -25,6 +25,8 @@
 
 #include 
 
+struct user_msghdr;
+struct rtdm_fd;
 
 /***
  *  rt_iovec_len
@@ -44,7 +46,13 @@ static inline size_t rt_iovec_len(const struct iovec *iov, 
int iovlen)
 extern void rt_memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, 
int len);
 extern void rt_memcpy_fromkerneliovec(unsigned char *kdata, struct iovec *iov, 
int len);
 
+ssize_t rtnet_write_to_iov(struct rtdm_fd *fd,
+  struct iovec *iov, int iovlen,
+  const void *data, size_t len);
 
+ssize_t rtnet_read_from_iov(struct rtdm_fd *fd,
+   struct iovec *iov, int iovlen,
+   void *data, size_t len);
 #endif  /* __KERNEL__ */
 
 #endif  /* __RTNET_IOVEC_H_ */
diff --git a/kernel/drivers/net/stack/iovec.c b/kernel/drivers/net/stack/iovec.c
index 24efa87..3164d28 100644
--- a/kernel/drivers/net/stack/iovec.c
+++ b/kernel/drivers/net/stack/iovec.c
@@ -25,8 +25,9 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
+#include 
 
 
 /***
@@ -49,6 +50,7 @@ void rt_memcpy_tokerneliovec(struct iovec *iov, unsigned char 
*kdata, int len)
 iov++;
 }
 }
+EXPORT_SYMBOL_GPL(rt_memcpy_tokerneliovec);
 
 
 /***
@@ -71,7 +73,78 @@ void rt_memcpy_fromkerneliovec(unsigned char *kdata, struct 
iovec *iov,int len)
 iov++;
 }
 }
+EXPORT_SYMBOL_GPL(rt_memcpy_fromkerneliovec);
 
+ssize_t rtnet_write_to_iov(struct rtdm_fd *fd,
+  struct iovec *iov, int iovlen,
+  const void *data, size_t len)
+{
+   ssize_t ret = 0;
+   size_t nbytes;
+   int n;
 
-EXPORT_SYMBOL_GPL(rt_memcpy_tokerneliovec);
-EXPORT_SYMBOL_GPL(rt_memcpy_fromkerneliovec);
+   for (n = 0; len > 0 && n < iovlen; n++, iov++) {
+   if (iov->iov_len == 0)
+   continue;
+
+   nbytes = iov->iov_len;
+   if (nbytes > len)
+   nbytes = len;
+
+   ret = rtnet_put_arg(fd, iov->iov_base, data, nbytes);
+   if (ret)
+   break;
+   
+   len -= nbytes;
+   data += nbytes;
+   iov->iov_len -= nbytes;
+   iov->iov_base += nbytes;
+   ret += nbytes;
+   if (ret < 0) {
+   ret = -EINVAL;
+   break;
+   }
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(rtnet_write_to_iov);
+
+ssize_t rtnet_read_from_iov(struct rtdm_fd *fd,
+   struct iovec *iov, int iovlen,
+   void *data, size_t len)
+{
+   ssize_t ret = 0;
+   size_t nbytes;
+   int n;
+
+   for (n = 0; len > 0 && n < iovlen; n++, iov++) {
+   if (iov->iov_len == 0)
+   continue;
+
+   nbytes = iov->iov_len;
+   if (nbytes > len)
+   nbytes = len;
+
+   if (!rtdm_fd_is_user(fd))
+   memcpy(data, iov->iov_base, nbytes);
+   else {
+   ret = rtdm_copy_from_user(fd, data, iov->iov_base, 
nbytes);
+   if (ret)
+   break;
+   }
+   
+   len -= nbytes;
+   data += nbytes;
+   iov->iov_len -= nbytes;
+   iov->iov_base += nbytes;
+   ret += nbytes;
+   if (ret < 0) {
+   ret = -EINVAL;
+   break;
+   }
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(rtnet_read_from_iov);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/packet: ioctl: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: eccda56df5440d4e0a30d6aeda3f83313e8ba713
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=eccda56df5440d4e0a30d6aeda3f83313e8ba713

Author: Philippe Gerum 
Date:   Mon Dec  4 19:40:34 2017 +0100

net/packet: ioctl: remove direct references to user memory

---

 kernel/drivers/net/stack/packet/af_packet.c |   36 ---
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index 1e4c2be..f6638a7 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -24,6 +24,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -251,28 +252,35 @@ static void rt_packet_close(struct rtdm_fd *fd)
 /***
  *  rt_packet_ioctl
  */
-static int rt_packet_ioctl(struct rtdm_fd *fd, unsigned int request, void *arg)
+static int rt_packet_ioctl(struct rtdm_fd *fd, unsigned int request, void 
__user *arg)
 {
-struct rtsocket *sock = rtdm_fd_to_private(fd);
-struct _rtdm_setsockaddr_args *setaddr = arg;
-struct _rtdm_getsockaddr_args *getaddr = arg;
-
+   struct rtsocket *sock = rtdm_fd_to_private(fd);
+   const struct _rtdm_setsockaddr_args *setaddr;
+   struct _rtdm_setsockaddr_args _setaddr;
+   const struct _rtdm_getsockaddr_args *getaddr;
+   struct _rtdm_getsockaddr_args _getaddr;
 
-/* fast path for common socket IOCTLs */
-if (_IOC_TYPE(request) == RTIOC_TYPE_NETWORK)
-   return rt_socket_common_ioctl(fd, request, arg);
+   /* fast path for common socket IOCTLs */
+   if (_IOC_TYPE(request) == RTIOC_TYPE_NETWORK)
+   return rt_socket_common_ioctl(fd, request, arg);
 
-switch (request) {
+   switch (request) {
case _RTIOC_BIND:
-   return rt_packet_bind(sock, setaddr->addr, setaddr->addrlen);
+   setaddr = rtnet_get_arg(fd, &_setaddr, arg, sizeof(_setaddr));
+   if (IS_ERR(setaddr))
+   return PTR_ERR(setaddr);
+   return rt_packet_bind(sock, setaddr->addr, setaddr->addrlen);
 
case _RTIOC_GETSOCKNAME:
-   return rt_packet_getsockname(sock, getaddr->addr,
-getaddr->addrlen);
+   getaddr = rtnet_get_arg(fd, &_getaddr, arg, sizeof(_getaddr));
+   if (IS_ERR(getaddr))
+   return PTR_ERR(getaddr);
+   return rt_packet_getsockname(sock, getaddr->addr,
+getaddr->addrlen);
 
default:
-   return rt_socket_if_ioctl(fd, request, arg);
-}
+   return rt_socket_if_ioctl(fd, request, arg);
+   }
 }
 
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/udp: recvmsg, ioctl: remove direct references to user memory (2)

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 897c27e4de9312dd8e3ccd123a2b50c0f1e56bc8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=897c27e4de9312dd8e3ccd123a2b50c0f1e56bc8

Author: Philippe Gerum 
Date:   Sun Jan  7 18:23:57 2018 +0100

net/udp: recvmsg, ioctl: remove direct references to user memory (2)

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |  137 ++-
 1 file changed, 78 insertions(+), 59 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index 4368303..8e80d3e 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -154,18 +154,24 @@ static inline struct rtsocket *rt_udp_v4_lookup(u32 
daddr, u16 dport)
  *  @s: socket
  *  @addr:  local address
  */
-int rt_udp_bind(struct rtsocket *sock, const struct sockaddr *addr,
-socklen_t addrlen)
+int rt_udp_bind(struct rtdm_fd *fd, struct rtsocket *sock,
+   const struct sockaddr __user *addr, socklen_t addrlen)
 {
-struct sockaddr_in  *usin = (struct sockaddr_in *)addr;
+struct sockaddr_in  _sin, *sin;
 rtdm_lockctx_t  context;
 int index;
 int err = 0;
 
 
-if ((addrlen < (int)sizeof(struct sockaddr_in)) ||
-((usin->sin_port & auto_port_mask) == auto_port_start))
-return -EINVAL;
+if (addrlen < sizeof(struct sockaddr_in))
+   return -EINVAL;
+
+sin = rtnet_get_arg(fd, &_sin, addr, sizeof(_sin));
+if (IS_ERR(sin))
+   return PTR_ERR(sin);
+
+if ((sin->sin_port & auto_port_mask) == auto_port_start)
+   return -EINVAL;
 
 rtdm_lock_get_irqsave(_socket_base_lock, context);
 
@@ -181,8 +187,8 @@ int rt_udp_bind(struct rtsocket *sock, const struct 
sockaddr *addr,
 
 port_hash_del(_registry[index]);
 if (port_hash_insert(_registry[index],
- usin->sin_addr.s_addr,
- usin->sin_port ?: index + auto_port_start)) {
+ sin->sin_addr.s_addr,
+ sin->sin_port ?: index + auto_port_start)) {
 port_hash_insert(_registry[index],
  port_registry[index].saddr,
  port_registry[index].sport);
@@ -207,51 +213,64 @@ int rt_udp_bind(struct rtsocket *sock, const struct 
sockaddr *addr,
 /***
  *  rt_udp_connect
  */
-int rt_udp_connect(struct rtsocket *sock, const struct sockaddr *serv_addr,
-   socklen_t addrlen)
+int rt_udp_connect(struct rtdm_fd *fd, struct rtsocket *sock,
+  const struct sockaddr __user *serv_addr, socklen_t addrlen)
 {
-struct sockaddr_in  *usin = (struct sockaddr_in *) serv_addr;
-rtdm_lockctx_t  context;
-int index;
-
-
-if (usin->sin_family == AF_UNSPEC) {
-if ((index = sock->prot.inet.reg_index) < 0)
-/* socket is being closed */
-return -EBADF;
-
-rtdm_lock_get_irqsave(_socket_base_lock, context);
-
-sock->prot.inet.saddr = INADDR_ANY;
-/* Note: The following line differs from standard stacks, and we also
- don't remove the socket from the port list. Might get fixed in
- the future... */
-sock->prot.inet.sport = index + auto_port_start;
-sock->prot.inet.daddr = INADDR_ANY;
-sock->prot.inet.dport = 0;
-sock->prot.inet.state = TCP_CLOSE;
-
-rtdm_lock_put_irqrestore(_socket_base_lock, context);
-} else {
-if ((addrlen < (int)sizeof(struct sockaddr_in)) ||
-(usin->sin_family != AF_INET))
-return -EINVAL;
-
-rtdm_lock_get_irqsave(_socket_base_lock, context);
-
-if (sock->prot.inet.state != TCP_CLOSE) {
-rtdm_lock_put_irqrestore(_socket_base_lock, context);
-return -EINVAL;
-}
-
-sock->prot.inet.state = TCP_ESTABLISHED;
-sock->prot.inet.daddr = usin->sin_addr.s_addr;
-sock->prot.inet.dport = usin->sin_port;
-
-rtdm_lock_put_irqrestore(_socket_base_lock, context);
-}
+   struct sockaddr _sa, *sa;
+   struct sockaddr_in _sin, *sin;
+   rtdm_lockctx_t  context;
+   int index;
+
+   if (addrlen < sizeof(struct sockaddr))
+   return -EINVAL;
+   
+   sa = rtnet_get_arg(fd, &_sa, serv_addr, sizeof(_sa));
+   if (IS_ERR(sa))
+   return PTR_ERR(sa);
+
+   if (sa->sa_family == AF_UNSPEC) {
+   if ((index = sock->prot.inet.reg_index) < 0)
+   /* socket is being closed */
+   return -EBADF;
+
+   rtdm_lock_get_irqsave(_socket_base_lock, context);
+
+   sock->prot.inet.saddr = INADDR_ANY;
+   /* Note: The following line differs from standard
+  stacks, and we also don't remove the socket from
+   

[Xenomai-git] Philippe Gerum : net: wire up corectl interface

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fd6d1ef285e7f6eb81d70a3a2c65612e4b98dcb6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fd6d1ef285e7f6eb81d70a3a2c65612e4b98dcb6

Author: Philippe Gerum 
Date:   Mon Dec  4 16:52:24 2017 +0100

net: wire up corectl interface

A bug in some Makefile rule caused the corectl support to be wrongly
omitted from the object list for building rtnet.ko. As a consequence
of this, there is no way the smokey-based RTnet testsuite could have
ever worked.

Wire up the corectl handler to the Cobalt core as expected.

---

 kernel/drivers/net/stack/Makefile   |3 +--
 kernel/drivers/net/stack/corectl.c  |9 ++---
 kernel/drivers/net/stack/rtnet_module.c |6 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/net/stack/Makefile 
b/kernel/drivers/net/stack/Makefile
index 508d487..d055dc2 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,7 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
 
-obj-y += corectl.o
-
 obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
 
 obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
@@ -13,6 +11,7 @@ obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
 
 rtnet-y :=  \
+   corectl.o \
iovec.o \
rtdev.o \
rtdev_mgr.o \
diff --git a/kernel/drivers/net/stack/corectl.c 
b/kernel/drivers/net/stack/corectl.c
index 2f6f179..c8a9a12 100644
--- a/kernel/drivers/net/stack/corectl.c
+++ b/kernel/drivers/net/stack/corectl.c
@@ -66,9 +66,12 @@ static struct notifier_block rtnet_corectl_notifier = {
.notifier_call = rtnet_corectl_call,
 };
 
-static int rtnet_corectl_register(void)
+void rtnet_corectl_register(void)
 {
cobalt_add_config_chain(_corectl_notifier);
-   return 0;
 }
-device_initcall(rtnet_corectl_register);
+
+void rtnet_corectl_unregister(void)
+{
+   cobalt_remove_config_chain(_corectl_notifier);
+}
diff --git a/kernel/drivers/net/stack/rtnet_module.c 
b/kernel/drivers/net/stack/rtnet_module.c
index 1e42558..63ad558 100644
--- a/kernel/drivers/net/stack/rtnet_module.c
+++ b/kernel/drivers/net/stack/rtnet_module.c
@@ -50,6 +50,8 @@ const char rtnet_rtdm_provider_name[] =
 
 EXPORT_SYMBOL_GPL(rtnet_rtdm_provider_name);
 
+void rtnet_corectl_register(void);
+void rtnet_corectl_unregister(void);
 
 #ifdef CONFIG_XENO_OPT_VFILE
 /***
@@ -345,6 +347,8 @@ int __init rtnet_init(void)
 if ((err = rtpc_init()) != 0)
goto err_out6;
 
+rtnet_corectl_register();
+
 return 0;
 
 
@@ -376,6 +380,8 @@ err_out1:
  */
 void __exit rtnet_release(void)
 {
+rtnet_corectl_unregister();
+
 rtpc_cleanup();
 
 rtwlan_exit();


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/udp: sendmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d1043c5923bc6fa077c001b110163ed6e72de504
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d1043c5923bc6fa077c001b110163ed6e72de504

Author: Philippe Gerum 
Date:   Wed Dec  6 12:45:58 2017 +0100

net/udp: sendmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |  126 +++
 1 file changed, 79 insertions(+), 47 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index 4ec5ab3..c460e40 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -515,6 +515,7 @@ struct udpfakehdr
 struct udphdr uh;
 u32 daddr;
 u32 saddr;
+struct rtdm_fd *fd;
 struct iovec *iov;
 int iovlen;
 u32 wcheck;
@@ -529,35 +530,36 @@ static int rt_udp_getfrag(const void *p, unsigned char 
*to,
   unsigned int offset, unsigned int fraglen)
 {
 struct udpfakehdr *ufh = (struct udpfakehdr *)p;
-int i;
+int i, ret;
 
 
 // We should optimize this function a bit (copy+csum...)!
-if (offset==0) {
-/* Checksum of the complete data part of the UDP message: */
-for (i = 0; i < ufh->iovlen; i++) {
+if (offset)
+   return rtnet_read_from_iov(ufh->fd, ufh->iov, ufh->iovlen, to, 
fraglen);
+
+/* Checksum of the complete data part of the UDP message: */
+for (i = 0; i < ufh->iovlen; i++) {
 ufh->wcheck = csum_partial(ufh->iov[i].iov_base, 
ufh->iov[i].iov_len,
ufh->wcheck);
-}
-
-rt_memcpy_fromkerneliovec(to + sizeof(struct udphdr), ufh->iov,
-  fraglen - sizeof(struct udphdr));
+}
 
-/* Checksum of the udp header: */
-ufh->wcheck = csum_partial((unsigned char *)ufh,
-   sizeof(struct udphdr), ufh->wcheck);
+ret = rtnet_read_from_iov(ufh->fd, ufh->iov, ufh->iovlen,
+ to + sizeof(struct udphdr),
+ fraglen - sizeof(struct udphdr));
+if (ret)
+   return ret;
 
-ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr, 
ntohs(ufh->uh.len),
-  IPPROTO_UDP, ufh->wcheck);
+/* Checksum of the udp header: */
+ufh->wcheck = csum_partial((unsigned char *)ufh,
+  sizeof(struct udphdr), ufh->wcheck);
+
+ufh->uh.check = csum_tcpudp_magic(ufh->saddr, ufh->daddr, 
ntohs(ufh->uh.len),
+ IPPROTO_UDP, ufh->wcheck);
 
-if (ufh->uh.check == 0)
+if (ufh->uh.check == 0)
 ufh->uh.check = -1;
 
-memcpy(to, ufh, sizeof(struct udphdr));
-return 0;
-}
-
-rt_memcpy_fromkerneliovec(to, ufh->iov, fraglen);
+memcpy(to, ufh, sizeof(struct udphdr));
 
 return 0;
 }
@@ -570,9 +572,9 @@ static int rt_udp_getfrag(const void *p, unsigned char *to,
 ssize_t rt_udp_sendmsg(struct rtdm_fd *fd, const struct user_msghdr *msg, int 
msg_flags)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
-size_t  len   = rt_iovec_len(msg->msg_iov, msg->msg_iovlen);
-int ulen  = len + sizeof(struct udphdr);
-struct sockaddr_in  *usin;
+size_t  len;
+int ulen;
+struct sockaddr_in  _sin, *sin;
 struct udpfakehdr   ufh;
 struct dest_route   rt;
 u32 saddr;
@@ -580,10 +582,8 @@ ssize_t rt_udp_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int ms
 u16 dport;
 int err;
 rtdm_lockctx_t  context;
-
-
-if ((len < 0) || (len > 0x-sizeof(struct iphdr)-sizeof(struct udphdr)))
-return -EMSGSIZE;
+struct user_msghdr _msg;
+struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
 
 if (msg_flags & MSG_OOB)   /* Mirror BSD error message compatibility */
 return -EOPNOTSUPP;
@@ -591,39 +591,70 @@ ssize_t rt_udp_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int ms
 if (msg_flags & ~(MSG_DONTROUTE|MSG_DONTWAIT) )
 return -EINVAL;
 
-if ((msg->msg_name) && (msg->msg_namelen==sizeof(struct sockaddr_in))) {
-usin = (struct sockaddr_in*) msg->msg_name;
+msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+if (IS_ERR(msg))
+   return PTR_ERR(msg);
 
-if ((usin->sin_family != AF_INET) && (usin->sin_family != AF_UNSPEC))
-return -EINVAL;
+if (msg->msg_iovlen < 0)
+   return -EINVAL;
+
+if (msg->msg_iovlen == 0)
+   return 0;
+
+err = rtdm_get_iovec(fd, , msg, iov_fast);
+if (err)
+   return err;
 
-daddr = usin->sin_addr.s_addr;
-dport = usin->sin_port;
+len = rt_iovec_len(iov, msg->msg_iovlen);
+if ((len < 0) || (len > 0x-sizeof(struct 

[Xenomai-git] Philippe Gerum : net/udp: recvmsg: write back namelen only if name required

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a605a8e3416198d270727fa028c8825f5a871cab
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a605a8e3416198d270727fa028c8825f5a871cab

Author: Philippe Gerum 
Date:   Wed Dec  6 12:47:55 2017 +0100

net/udp: recvmsg: write back namelen only if name required

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index 8284ff7..4ec5ab3 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -432,12 +432,7 @@ ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct 
user_msghdr *msg, int msg_flag
 uh = skb->h.uh;
 first_skb = skb;
 
-namelen = sizeof(sin);
-ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
-if (ret)
-   goto fail;
-   
-/* copy the address */
+/* copy the address if required. */
 if (msg->msg_name) {
memset(, 0, sizeof(sin));
sin.sin_family  = AF_INET;
@@ -446,7 +441,12 @@ ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct 
user_msghdr *msg, int msg_flag
ret = rtnet_put_arg(fd, >msg_name, , sizeof(sin));
if (ret)
goto fail;
-}
+
+   namelen = sizeof(sin);
+   ret = rtnet_put_arg(fd, >msg_namelen, , 
sizeof(namelen));
+   if (ret)
+   goto fail;
+   }
 
 data_len = ntohs(uh->len) - sizeof(struct udphdr);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/proxy: stop updating netdev-> last_rx with kernel 4.11+

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f9440feb9284172e62d921d61a2cf8ac1e5d505e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f9440feb9284172e62d921d61a2cf8ac1e5d505e

Author: Philippe Gerum 
Date:   Fri Jan 26 11:51:42 2018 +0100

net/proxy: stop updating netdev->last_rx with kernel 4.11+

The network stack stopped using netdev->last_rx a long time ago, and
this field was removed during the 4.11 development cycle
(#4a7c972644c1).

---

 kernel/drivers/net/addons/proxy.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/drivers/net/addons/proxy.c 
b/kernel/drivers/net/addons/proxy.c
index 4887f77..5805475 100644
--- a/kernel/drivers/net/addons/proxy.c
+++ b/kernel/drivers/net/addons/proxy.c
@@ -256,7 +256,9 @@ static inline void rtnetproxy_kernel_recv(struct rtskb 
*rtskb)
 /* the rtskb stamp is useless (different clock), get new one */
 __net_timestamp(skb);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
 dev->last_rx = jiffies;
+#endif
 dev->stats.rx_bytes+=skb->len;
 dev->stats.rx_packets++;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/tcp: ioctl: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 76518343bfe5ca019fdf34cbc5321a275bb80a3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=76518343bfe5ca019fdf34cbc5321a275bb80a3e

Author: Philippe Gerum 
Date:   Mon Dec  4 19:21:18 2017 +0100

net/tcp: ioctl: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/tcp/tcp.c |   82 +--
 1 file changed, 56 insertions(+), 26 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/tcp/tcp.c 
b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
index b1d01e9..f01399d 100644
--- a/kernel/drivers/net/stack/ipv4/tcp/tcp.c
+++ b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1781,10 +1782,16 @@ static int rt_tcp_ioctl(struct rtdm_fd *fd,
unsigned int request, void __user *arg)
 {
 struct tcp_socket* ts = rtdm_fd_to_private(fd);
-struct _rtdm_setsockaddr_args *setaddr = arg;
-struct _rtdm_getsockaddr_args *getaddr = arg;
-struct _rtdm_getsockopt_args  *getopt  = arg;
-struct _rtdm_setsockopt_args  *setopt  = arg;
+const struct _rtdm_setsockaddr_args *setaddr;
+struct _rtdm_setsockaddr_args _setaddr;
+const struct _rtdm_getsockaddr_args *getaddr;
+struct _rtdm_getsockaddr_args _getaddr;
+const struct _rtdm_getsockopt_args *getopt;
+struct _rtdm_getsockopt_args _getopt;
+const struct _rtdm_setsockopt_args *setopt;
+struct _rtdm_setsockopt_args _setopt;
+const long *val;
+long _val;
 int in_rt;
 
 /* fast path for common socket IOCTLs */
@@ -1795,42 +1802,65 @@ static int rt_tcp_ioctl(struct rtdm_fd *fd,
 
 switch (request) {
case _RTIOC_BIND:
-   return rt_tcp_bind(ts, setaddr->addr, setaddr->addrlen);
-
+   setaddr = rtnet_get_arg(fd, &_setaddr, arg, sizeof(_setaddr));
+   if (IS_ERR(setaddr))
+   return PTR_ERR(setaddr);
+   return rt_tcp_bind(ts, setaddr->addr, setaddr->addrlen);
case _RTIOC_CONNECT:
-   if (!in_rt)
-   return -ENOSYS;
-   return rt_tcp_connect(ts, setaddr->addr, setaddr->addrlen);
+   if (!in_rt)
+   return -ENOSYS;
+   setaddr = rtnet_get_arg(fd, &_setaddr, arg, sizeof(_setaddr));
+   if (IS_ERR(setaddr))
+   return PTR_ERR(setaddr);
+   return rt_tcp_connect(ts, setaddr->addr, setaddr->addrlen);
 
case _RTIOC_LISTEN:
-   return rt_tcp_listen(ts, (unsigned long)arg);
+   val = rtnet_get_arg(fd, &_val, arg, sizeof(long));
+   if (IS_ERR(val))
+   return PTR_ERR(val);
+   return rt_tcp_listen(ts, *val);
 
case _RTIOC_ACCEPT:
-   if (!in_rt)
-   return -ENOSYS;
-   return rt_tcp_accept(ts, getaddr->addr, getaddr->addrlen);
+   if (!in_rt)
+   return -ENOSYS;
+   getaddr = rtnet_get_arg(fd, &_getaddr, arg, sizeof(_getaddr));
+   if (IS_ERR(getaddr))
+   return PTR_ERR(getaddr);
+   return rt_tcp_accept(ts, getaddr->addr, getaddr->addrlen);
 
case _RTIOC_SHUTDOWN:
-   return rt_tcp_shutdown(ts, (unsigned long)arg);
+   val = rtnet_get_arg(fd, &_val, arg, sizeof(long));
+   if (IS_ERR(val))
+   return PTR_ERR(val);
+   return rt_tcp_shutdown(ts, *val);
 
case _RTIOC_SETSOCKOPT:
-   if (setopt->level != SOL_SOCKET)
-   break;
+   setopt = rtnet_get_arg(fd, &_setopt, arg, sizeof(_setopt));
+   if (IS_ERR(setopt))
+   return PTR_ERR(setopt);
 
-   return rt_tcp_setsockopt(fd, ts, setopt->level,
-setopt->optname, setopt->optval,
-setopt->optlen);
+   if (setopt->level != SOL_SOCKET)
+   break;
+
+   return rt_tcp_setsockopt(fd, ts, setopt->level,
+setopt->optname, setopt->optval,
+setopt->optlen);
 
case _RTIOC_GETSOCKOPT:
-   if (getopt->level != SOL_SOCKET)
-   break;
-   return rt_tcp_getsockopt(fd, ts, getopt->level,
-getopt->optname, getopt->optval,
-getopt->optlen);
+   getopt = rtnet_get_arg(fd, &_getopt, arg, sizeof(_getopt));
+   if (IS_ERR(getopt))
+   return PTR_ERR(getopt);
 
-   default:
-   break;
+   if (getopt->level != SOL_SOCKET)
+   break;
+
+   return rt_tcp_getsockopt(fd, ts, getopt->level,
+getopt->optname, getopt->optval,

[Xenomai-git] Philippe Gerum : net/packet: sendmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 582fd9428034c9e70f38c9bde0cd3709af603eaa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=582fd9428034c9e70f38c9bde0cd3709af603eaa

Author: Philippe Gerum 
Date:   Tue Dec  5 18:56:12 2017 +0100

net/packet: sendmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/packet/af_packet.c |   67 +++
 1 file changed, 48 insertions(+), 19 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index f248239..046f380 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -404,43 +404,70 @@ static ssize_t
 rt_packet_sendmsg(struct rtdm_fd *fd, const struct user_msghdr *msg, int 
msg_flags)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
-size_t  len   = rt_iovec_len(msg->msg_iov, msg->msg_iovlen);
-struct sockaddr_ll  *sll  = (struct sockaddr_ll*)msg->msg_name;
+size_t  len;
+struct sockaddr_ll  _sll, *sll;
 struct rtnet_device *rtdev;
 struct rtskb*rtskb;
 unsigned short  proto;
 unsigned char   *addr;
 int ifindex;
-int ret = 0;
-
+ssize_t ret;
+struct user_msghdr _msg;
+struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
 
 if (msg_flags & MSG_OOB)/* Mirror BSD error message compatibility */
return -EOPNOTSUPP;
 if (msg_flags & ~MSG_DONTWAIT)
return -EINVAL;
 
-if (sll == NULL) {
+msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+if (IS_ERR(msg))
+   return PTR_ERR(msg);
+
+if (msg->msg_iovlen < 0)
+   return -EINVAL;
+
+if (msg->msg_iovlen == 0)
+   return 0;
+
+ret = rtdm_get_iovec(fd, , msg, iov_fast);
+if (ret)
+   return ret;
+
+if (msg->msg_name == NULL) {
/* Note: We do not care about races with rt_packet_bind here -
   the user has to do so. */
ifindex = sock->prot.packet.ifindex;
proto   = sock->prot.packet.packet_type.type;
addr= NULL;
+   sll = NULL;
 } else {
-   if ((msg->msg_namelen < sizeof(struct sockaddr_ll)) ||
-   (msg->msg_namelen <
-   (sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr))) ||
-   ((sll->sll_family != AF_PACKET) &&
-   (sll->sll_family != AF_UNSPEC)))
-   return -EINVAL;
-
-   ifindex = sll->sll_ifindex;
-   proto   = sll->sll_protocol;
-   addr= sll->sll_addr;
+   sll = rtnet_get_arg(fd, &_sll, msg->msg_name, sizeof(_sll));
+   if (IS_ERR(sll)) {
+   ret = PTR_ERR(sll);
+   goto abort;
+   }
+
+   if ((msg->msg_namelen < sizeof(struct sockaddr_ll)) ||
+   (msg->msg_namelen <
+(sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr))) ||
+   ((sll->sll_family != AF_PACKET) &&
+(sll->sll_family != AF_UNSPEC))) {
+   ret = -EINVAL;
+   goto abort;
+   }
+
+   ifindex = sll->sll_ifindex;
+   proto   = sll->sll_protocol;
+   addr= sll->sll_addr;
 }
 
-if ((rtdev = rtdev_get_by_index(ifindex)) == NULL)
-   return -ENODEV;
+if ((rtdev = rtdev_get_by_index(ifindex)) == NULL) {
+   ret = -ENODEV;
+   goto abort;
+}
 
+len = rt_iovec_len(iov, msg->msg_iovlen);
 rtskb = alloc_rtskb(rtdev->hard_header_len + len, >skb_pool);
 if (rtskb == NULL) {
ret = -ENOBUFS;
@@ -480,7 +507,7 @@ rt_packet_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int msg_fla
goto err;
 }
 
-rt_memcpy_fromkerneliovec(rtskb_put(rtskb, len), msg->msg_iov, len);
+ret = rtnet_read_from_iov(fd, iov, msg->msg_iovlen, rtskb_put(rtskb, len), 
len);
 
 if ((rtdev->flags & IFF_UP) != 0) {
if ((ret = rtdev_xmit(rtskb)) == 0)
@@ -492,8 +519,10 @@ rt_packet_sendmsg(struct rtdm_fd *fd, const struct 
user_msghdr *msg, int msg_fla
 
  out:
 rtdev_dereference(rtdev);
-return ret;
+ abort:
+rtdm_drop_iovec(iov, iov_fast);
 
+return ret;
  err:
 kfree_rtskb(rtskb);
 goto out;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/socket: add get_arg/put_arg helpers

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fdd716008231bc8feeb06a08f0d0a5a6d7db0e47
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fdd716008231bc8feeb06a08f0d0a5a6d7db0e47

Author: Philippe Gerum 
Date:   Mon Dec  4 19:20:48 2017 +0100

net/socket: add get_arg/put_arg helpers

---

 kernel/drivers/net/stack/include/rtnet_socket.h |   10 +-
 kernel/drivers/net/stack/socket.c   |  218 +++
 2 files changed, 150 insertions(+), 78 deletions(-)

diff --git a/kernel/drivers/net/stack/include/rtnet_socket.h 
b/kernel/drivers/net/stack/include/rtnet_socket.h
index cddf328..37f411a 100644
--- a/kernel/drivers/net/stack/include/rtnet_socket.h
+++ b/kernel/drivers/net/stack/include/rtnet_socket.h
@@ -88,6 +88,12 @@ static inline struct rtdm_fd *rt_socket_fd(struct rtsocket 
*sock)
 return rtdm_private_to_fd(sock);
 }
 
+void *rtnet_get_arg(struct rtdm_fd *fd, void *tmp,
+   const void *src, size_t len);
+
+int rtnet_put_arg(struct rtdm_fd *fd, void *dst,
+ const void *src, size_t len);
+
 #define rt_socket_reference(sock)   \
 rtdm_fd_lock(rt_socket_fd(sock))
 #define rt_socket_dereference(sock) \
@@ -99,8 +105,8 @@ int __rt_socket_init(struct rtdm_fd *fd, unsigned short 
protocol,
 __rt_socket_init(fd, proto, THIS_MODULE)
 
 void rt_socket_cleanup(struct rtdm_fd *fd);
-int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void *arg);
-int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void *arg);
+int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
+int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
 int rt_socket_select_bind(struct rtdm_fd *fd,
  rtdm_selector_t *selector,
  enum rtdm_selecttype type,
diff --git a/kernel/drivers/net/stack/socket.c 
b/kernel/drivers/net/stack/socket.c
index 7dacb25..5b2 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -141,23 +142,32 @@ EXPORT_SYMBOL_GPL(rt_socket_cleanup);
 /***
  *  rt_socket_common_ioctl
  */
-int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void *arg)
+int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void __user *arg)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
 int ret = 0;
-struct rtnet_callback   *callback = arg;
-unsigned intrtskbs;
+struct rtnet_callback   *callback;
+const unsigned int *val;
+unsigned int _val;
+const nanosecs_rel_t *timeout;
+nanosecs_rel_t _timeout;
 rtdm_lockctx_t  context;
 
 
 switch (request) {
case RTNET_RTIOC_XMITPARAMS:
-   sock->priority = *(unsigned int *)arg;
-   break;
+   val = rtnet_get_arg(fd, &_val, arg, sizeof(_val));
+   if (IS_ERR(val))
+   return PTR_ERR(val);
+   sock->priority = *val;
+   break;
 
case RTNET_RTIOC_TIMEOUT:
-   sock->timeout = *(nanosecs_rel_t *)arg;
-   break;
+   timeout = rtnet_get_arg(fd, &_timeout, arg, sizeof(_timeout));
+   if (IS_ERR(timeout))
+   return PTR_ERR(timeout);
+   sock->timeout = *timeout;
+   break;
 
case RTNET_RTIOC_CALLBACK:
if (rtdm_fd_is_user(fd))
@@ -165,6 +175,7 @@ int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, 
void *arg)
 
rtdm_lock_get_irqsave(>param_lock, context);
 
+   callback = arg;
sock->callback_func = callback->func;
sock->callback_arg  = callback->arg;
 
@@ -172,44 +183,48 @@ int rt_socket_common_ioctl(struct rtdm_fd *fd, int 
request, void *arg)
break;
 
case RTNET_RTIOC_EXTPOOL:
-   rtskbs = *(unsigned int *)arg;
+   val = rtnet_get_arg(fd, &_val, arg, sizeof(_val));
+   if (IS_ERR(val))
+   return PTR_ERR(val);
 
-   if (rtdm_in_rt_context())
-   return -ENOSYS;
+   if (rtdm_in_rt_context())
+   return -ENOSYS;
 
-   mutex_lock(>pool_nrt_lock);
+   mutex_lock(>pool_nrt_lock);
 
-   if (test_bit(SKB_POOL_CLOSED, >flags)) {
-   mutex_unlock(>pool_nrt_lock);
-   return -EBADF;
-   }
-   ret = rtskb_pool_extend(>skb_pool, rtskbs);
-   sock->pool_size += ret;
+   if (test_bit(SKB_POOL_CLOSED, >flags)) {
+   mutex_unlock(>pool_nrt_lock);
+   return -EBADF;
+   }
+   ret = rtskb_pool_extend(>skb_pool, *val);
+   sock->pool_size += ret;
 
-   mutex_unlock(>pool_nrt_lock);
+   mutex_unlock(>pool_nrt_lock);
 
-   if (ret == 0 && rtskbs > 

[Xenomai-git] Philippe Gerum : net/cap: fix panic in rtcap_signal_handler()

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 27d313f8ce2dc3dbbd0151368dead13868c05851
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=27d313f8ce2dc3dbbd0151368dead13868c05851

Author: Philippe Gerum 
Date:   Fri Jun 16 18:07:26 2017 +0200

net/cap: fix panic in rtcap_signal_handler()

---

 kernel/drivers/net/addons/cap.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/net/addons/cap.c b/kernel/drivers/net/addons/cap.c
index 7b8f4fe..78d5f56 100644
--- a/kernel/drivers/net/addons/cap.c
+++ b/kernel/drivers/net/addons/cap.c
@@ -195,11 +195,13 @@ static void rtcap_signal_handler(rtdm_nrtsig_t *nrtsig, 
void *arg)
ifindex = rtskb->rtdev->ifindex;
active  = tap_device[ifindex].present;
 
-   if ((tap_device[ifindex].tap_dev->flags & IFF_UP) == 0)
-   active &= ~TAP_DEV;
-   if (active & RTMAC_TAP_DEV &&
-   !(tap_device[ifindex].rtmac_tap_dev->flags & IFF_UP))
-   active &= ~RTMAC_TAP_DEV;
+   if (active) {
+   if ((tap_device[ifindex].tap_dev->flags & IFF_UP) == 0)
+   active &= ~TAP_DEV;
+   if (active & RTMAC_TAP_DEV &&
+   !(tap_device[ifindex].rtmac_tap_dev->flags & IFF_UP))
+   active &= ~RTMAC_TAP_DEV;
+   }
 
if (active == 0) {
tap_device[ifindex].tap_dev_stats.rx_dropped++;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/tcp: recvmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 984e0eb73b208a7cdeba4010d39bce762aca40d4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=984e0eb73b208a7cdeba4010d39bce762aca40d4

Author: Philippe Gerum 
Date:   Wed Dec  6 13:17:20 2017 +0100

net/tcp: recvmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/tcp/tcp.c |   45 +++
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/tcp/tcp.c 
b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
index f01399d..6c1f38d 100644
--- a/kernel/drivers/net/stack/ipv4/tcp/tcp.c
+++ b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
@@ -1668,7 +1668,7 @@ static int rt_tcp_accept(struct tcp_socket *ts, struct 
sockaddr *addr,
 ts->is_accepted = 1;
 rtdm_lock_put_irqrestore(>socket_lock, context);
 
-ret = rt_socket_fd(>sock)->fd;
+//ret = rt_socket_fd(>sock)->fd;
 
  err:
 /* it is not critical to leave this unlocked
@@ -2069,20 +2069,43 @@ static ssize_t rt_tcp_write(struct rtdm_fd *fd, const 
void *buf, size_t nbyte)
  */
 static ssize_t rt_tcp_recvmsg(struct rtdm_fd *fd, struct user_msghdr *msg, int 
msg_flags)
 {
-size_t len;
-void *buf;
+   struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
+   struct user_msghdr _msg;
+   ssize_t ret;
+   size_t len;
+   void *buf;
 
-if (msg_flags)
-   return -EOPNOTSUPP;
+   if (msg_flags)
+   return -EOPNOTSUPP;
 
-/* loop over all vectors to be implemented */
-if (msg->msg_iovlen != 1)
-   return -EOPNOTSUPP;
+   msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+   if (IS_ERR(msg))
+   return PTR_ERR(msg);
 
-len = msg->msg_iov[0].iov_len;
-buf = msg->msg_iov[0].iov_base;
+   /* loop over all vectors to be implemented */
+   if (msg->msg_iovlen != 1)
+   return -EOPNOTSUPP;
+
+   ret = rtdm_get_iovec(fd, , msg, iov_fast);
+   if (ret)
+   return ret;
 
-return rt_tcp_read(fd, buf, len);
+   len = iov[0].iov_len;
+   if (len > 0) {
+   buf = xnmalloc(len);
+   if (buf == NULL) {
+   ret = -ENOMEM;
+   goto out;
+   }
+   ret = rtdm_copy_from_user(fd, buf, iov[0].iov_base, len);
+   if (!ret)
+   ret = rt_tcp_read(fd, buf, len);
+   xnfree(buf);
+   }
+out:
+   rtdm_drop_iovec(iov, iov_fast);
+
+   return ret;
 }
 
 /***


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/udp: recvmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: bc0ed268adf016f79559aa53204b046b03c99837
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bc0ed268adf016f79559aa53204b046b03c99837

Author: Philippe Gerum 
Date:   Wed Dec  6 12:45:31 2017 +0100

net/udp: recvmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |   95 +--
 1 file changed, 65 insertions(+), 30 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index f8eeadd..8284ff7 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -377,20 +377,39 @@ int rt_udp_ioctl(struct rtdm_fd *fd, unsigned int 
request, void __user *arg)
 /***
  *  rt_udp_recvmsg
  */
+/***
+ *  rt_udp_recvmsg
+ */
 ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct user_msghdr *msg, int 
msg_flags)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
-size_t  len   = rt_iovec_len(msg->msg_iov, msg->msg_iovlen);
+size_t  len;
 struct rtskb*skb;
 struct rtskb*first_skb;
 size_t  copied = 0;
 size_t  block_size;
 size_t  data_len;
 struct udphdr   *uh;
-struct sockaddr_in  *sin;
+struct sockaddr_in  sin;
 nanosecs_rel_t  timeout = sock->timeout;
-int ret;
+int ret, flags;
+struct user_msghdr _msg;
+socklen_t namelen;
+struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
+
+msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+if (IS_ERR(msg))
+   return PTR_ERR(msg);
 
+if (msg->msg_iovlen < 0)
+   return -EINVAL;
+
+if (msg->msg_iovlen == 0)
+   return 0;
+
+ret = rtdm_get_iovec(fd, , msg, iov_fast);
+if (ret)
+   return ret;
 
 /* non-blocking receive? */
 if (msg_flags & MSG_DONTWAIT)
@@ -398,35 +417,44 @@ ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct 
user_msghdr *msg, int msg_flag
 
 ret = rtdm_sem_timeddown(>pending_sem, timeout, NULL);
 if (unlikely(ret < 0))
-switch (ret) {
-case -EWOULDBLOCK:
-case -ETIMEDOUT:
-case -EINTR:
-return ret;
-
-default:
-return -EBADF;   /* socket has been closed */
-}
+   switch (ret) {
+   default:
+   ret = -EBADF;   /* socket has been closed */
+   case -EWOULDBLOCK:
+   case -ETIMEDOUT:
+   case -EINTR:
+   rtdm_drop_iovec(iov, iov_fast);
+   return ret;
+   }
 
 skb = rtskb_dequeue_chain(>incoming);
 RTNET_ASSERT(skb != NULL, return -EFAULT;);
-
 uh = skb->h.uh;
-data_len = ntohs(uh->len) - sizeof(struct udphdr);
-sin = msg->msg_name;
+first_skb = skb;
 
+namelen = sizeof(sin);
+ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
+if (ret)
+   goto fail;
+   
 /* copy the address */
-msg->msg_namelen = sizeof(*sin);
-if (sin) {
-sin->sin_family  = AF_INET;
-sin->sin_port= uh->source;
-sin->sin_addr.s_addr = skb->nh.iph->saddr;
+if (msg->msg_name) {
+   memset(, 0, sizeof(sin));
+   sin.sin_family  = AF_INET;
+   sin.sin_port= uh->source;
+   sin.sin_addr.s_addr = skb->nh.iph->saddr;
+   ret = rtnet_put_arg(fd, >msg_name, , sizeof(sin));
+   if (ret)
+   goto fail;
 }
 
+data_len = ntohs(uh->len) - sizeof(struct udphdr);
+
 /* remove the UDP header */
 __rtskb_pull(skb, sizeof(struct udphdr));
 
-first_skb = skb;
+flags = msg->msg_flags & ~MSG_TRUNC;
+len = rt_iovec_len(iov, msg->msg_iovlen);
 
 /* iterate over all IP fragments */
 do {
@@ -440,25 +468,28 @@ ssize_t rt_udp_recvmsg(struct rtdm_fd *fd, struct 
user_msghdr *msg, int msg_flag
 if (copied > len) {
 block_size -= copied - len;
 copied = len;
-msg->msg_flags |= MSG_TRUNC;
-
-/* copy the data */
-rt_memcpy_tokerneliovec(msg->msg_iov, skb->data, block_size);
-
-break;
+   flags |= MSG_TRUNC;
 }
 
 /* copy the data */
-rt_memcpy_tokerneliovec(msg->msg_iov, skb->data, block_size);
+   ret = rtnet_write_to_iov(fd, iov, msg->msg_iovlen, skb->data, 
block_size);
+   if (ret)
+   goto fail;
 
 /* next fragment */
 skb = skb->next;
-} while (skb != NULL);
+} while (skb && !(flags & MSG_TRUNC));
 
 /* did we copied all bytes? */
 if (data_len > 0)
-msg->msg_flags |= MSG_TRUNC;
+   flags |= MSG_TRUNC;
 
+if (flags != msg->msg_flags) {
+   ret = rtnet_put_arg(fd, >msg_flags, , sizeof(flags));
+   if (ret)
+   goto fail;
+}
+out:
 if ((msg_flags & MSG_PEEK) 

[Xenomai-git] Philippe Gerum : net/packet: ioctl: remove direct references to user memory (3)

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c5cbef0d9e60a1bec92cc34078811c2c1ac2ddc5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c5cbef0d9e60a1bec92cc34078811c2c1ac2ddc5

Author: Philippe Gerum 
Date:   Sun Jan  7 18:24:18 2018 +0100

net/packet: ioctl: remove direct references to user memory (3)

---

 kernel/drivers/net/stack/packet/af_packet.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index 56daba8..9fa985d 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -305,7 +305,7 @@ static int rt_packet_ioctl(struct rtdm_fd *fd, unsigned int 
request, void __user
  *  rt_packet_recvmsg
  */
 static ssize_t
-rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr *msg, int msg_flags)
+rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr *u_msg, int msg_flags)
 {
 struct rtsocket *sock = rtdm_fd_to_private(fd);
 ssize_t len;
@@ -314,11 +314,11 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
 struct sockaddr_ll  sll;
 intret, flags;
 nanosecs_rel_t  timeout = sock->timeout;
-struct user_msghdr _msg;
+struct user_msghdr _msg, *msg;
 socklen_t namelen;
 struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
 
-msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+msg = rtnet_get_arg(fd, &_msg, u_msg, sizeof(_msg));
 if (IS_ERR(msg))
return PTR_ERR(msg);

@@ -364,12 +364,12 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
/* Ethernet specific - we rather need some parse handler here */
memcpy(sll.sll_addr, rtskb->mac.ethernet->h_source, ETH_ALEN);
sll.sll_halen = ETH_ALEN;
-   ret = rtnet_put_arg(fd, >msg_name, , sizeof(sll));
+   ret = rtnet_put_arg(fd, msg->msg_name, , sizeof(sll));
if (ret)
goto fail;
 
namelen = sizeof(sll);
-   ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
+   ret = rtnet_put_arg(fd, _msg->msg_namelen, , sizeof(namelen));
if (ret)
goto fail;
 }
@@ -389,7 +389,7 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
 if (copy_len > len) {
copy_len = len;
flags = msg->msg_flags | MSG_TRUNC;
-   ret = rtnet_put_arg(fd, >msg_flags, , sizeof(flags));
+   ret = rtnet_put_arg(fd, _msg->msg_flags, , sizeof(flags));
if (ret)
goto fail;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/udp: ioctl: fix temp arg buffer type

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 17a78f833aaed6f4182c8640252e28993ab22104
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=17a78f833aaed6f4182c8640252e28993ab22104

Author: Philippe Gerum 
Date:   Sun Dec 17 15:27:04 2017 +0100

net/udp: ioctl: fix temp arg buffer type

---

 kernel/drivers/net/stack/ipv4/udp/udp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index a3fd496..4368303 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -350,7 +350,7 @@ int rt_udp_ioctl(struct rtdm_fd *fd, unsigned int request, 
void __user *arg)
 {
struct rtsocket *sock = rtdm_fd_to_private(fd);
const struct _rtdm_setsockaddr_args *setaddr;
-   struct _rtdm_setsockaddr_args *_setaddr;
+   struct _rtdm_setsockaddr_args _setaddr;
 
/* fast path for common socket IOCTLs */
if (_IOC_TYPE(request) == RTIOC_TYPE_NETWORK)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/packet: ioctl: remove direct references to user memory (2)

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e9beccc371072d7d39de89dae163865a8c25ff43
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e9beccc371072d7d39de89dae163865a8c25ff43

Author: Philippe Gerum 
Date:   Wed Dec 20 11:45:16 2017 +0100

net/packet: ioctl: remove direct references to user memory (2)

---

 kernel/drivers/net/stack/packet/af_packet.c |  156 +++
 1 file changed, 86 insertions(+), 70 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index 4fbf523..56daba8 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -101,45 +101,50 @@ static void rt_packet_unlock(struct rtpacket_type *pt)
 /***
  *  rt_packet_bind
  */
-static int rt_packet_bind(struct rtsocket *sock, const struct sockaddr *addr,
- socklen_t addrlen)
+static int rt_packet_bind(struct rtdm_fd *fd, struct rtsocket *sock,
+ const struct sockaddr *addr, socklen_t addrlen)
 {
-struct sockaddr_ll  *sll = (struct sockaddr_ll *)addr;
-struct rtpacket_type*pt  = >prot.packet.packet_type;
-int new_type;
-int ret;
-rtdm_lockctx_t  context;
-
-
-if ((addrlen < (int)sizeof(struct sockaddr_ll)) ||
-   (sll->sll_family != AF_PACKET))
-   return -EINVAL;
-
-new_type = (sll->sll_protocol != 0) ? sll->sll_protocol : sock->protocol;
-
-rtdm_lock_get_irqsave(>param_lock, context);
-
-/* release existing binding */
-if (pt->type != 0)
-   rtdev_remove_pack(pt);
-
-pt->type = new_type;
-sock->prot.packet.ifindex = sll->sll_ifindex;
+   struct sockaddr_ll  _sll, *sll;
+   struct rtpacket_type*pt  = >prot.packet.packet_type;
+   int new_type;
+   int ret;
+   rtdm_lockctx_t  context;
+
+   if (addrlen < sizeof(struct sockaddr_ll))
+   return -EINVAL;
+   
+   sll = rtnet_get_arg(fd, &_sll, addr, sizeof(_sll));
+   if (IS_ERR(sll))
+   return PTR_ERR(sll);
+
+   if (sll->sll_family != AF_PACKET)
+   return -EINVAL;
+   
+   new_type = (sll->sll_protocol != 0) ? sll->sll_protocol : 
sock->protocol;
+
+   rtdm_lock_get_irqsave(>param_lock, context);
+
+   /* release existing binding */
+   if (pt->type != 0)
+   rtdev_remove_pack(pt);
+
+   pt->type = new_type;
+   sock->prot.packet.ifindex = sll->sll_ifindex;
+
+   /* if protocol is non-zero, register the packet type */
+   if (new_type != 0) {
+   pt->handler = rt_packet_rcv;
+   pt->err_handler = NULL;
+   pt->trylock = rt_packet_trylock;
+   pt->unlock  = rt_packet_unlock;
+
+   ret = rtdev_add_pack(pt);
+   } else
+   ret = 0;
+
+   rtdm_lock_put_irqrestore(>param_lock, context);
 
-/* if protocol is non-zero, register the packet type */
-if (new_type != 0) {
-   pt->handler = rt_packet_rcv;
-   pt->err_handler = NULL;
-   pt->trylock = rt_packet_trylock;
-   pt->unlock  = rt_packet_unlock;
-
-   ret = rtdev_add_pack(pt);
-} else
-   ret = 0;
-
-rtdm_lock_put_irqrestore(>param_lock, context);
-
-return ret;
+   return ret;
 }
 
 
@@ -147,41 +152,52 @@ static int rt_packet_bind(struct rtsocket *sock, const 
struct sockaddr *addr,
 /***
  *  rt_packet_getsockname
  */
-static int rt_packet_getsockname(struct rtsocket *sock, struct sockaddr *addr,
-socklen_t *addrlen)
+static int rt_packet_getsockname(struct rtdm_fd *fd, struct rtsocket *sock,
+struct sockaddr *addr, socklen_t *addrlen)
 {
-struct sockaddr_ll  *sll = (struct sockaddr_ll*)addr;
-struct rtnet_device *rtdev;
-rtdm_lockctx_t  context;
-
-
-if (*addrlen < sizeof(struct sockaddr_ll))
-   return -EINVAL;
-
-rtdm_lock_get_irqsave(>param_lock, context);
-
-sll->sll_family   = AF_PACKET;
-sll->sll_ifindex  = sock->prot.packet.ifindex;
-sll->sll_protocol = sock->protocol;
-
-rtdm_lock_put_irqrestore(>param_lock, context);
-
-rtdev = rtdev_get_by_index(sll->sll_ifindex);
-if (rtdev != NULL) {
-   sll->sll_hatype = rtdev->type;
-   sll->sll_halen  = rtdev->addr_len;
-
-   memcpy(sll->sll_addr, rtdev->dev_addr, rtdev->addr_len);
+   struct sockaddr_ll  _sll, *sll;
+   struct rtnet_device *rtdev;
+   rtdm_lockctx_t  context;
+   socklen_t _namelen, *namelen;
+   int ret;
+
+   namelen = rtnet_get_arg(fd, &_namelen, addrlen, sizeof(_namelen));
+   if (IS_ERR(namelen))
+   return PTR_ERR(namelen);
+
+   if (*namelen < sizeof(struct sockaddr_ll))
+   return -EINVAL;
+
+   sll = rtnet_get_arg(fd, &_sll, addr, 

[Xenomai-git] Philippe Gerum : net/tcp: sendmsg: remove direct references to user memory

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 15ba18d6f1db37df391a9b998c4c899e85fe76f7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=15ba18d6f1db37df391a9b998c4c899e85fe76f7

Author: Philippe Gerum 
Date:   Wed Dec  6 13:30:29 2017 +0100

net/tcp: sendmsg: remove direct references to user memory

---

 kernel/drivers/net/stack/ipv4/tcp/tcp.c |   45 +++
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/kernel/drivers/net/stack/ipv4/tcp/tcp.c 
b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
index 6c1f38d..c5e42bc 100644
--- a/kernel/drivers/net/stack/ipv4/tcp/tcp.c
+++ b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
@@ -1668,7 +1668,7 @@ static int rt_tcp_accept(struct tcp_socket *ts, struct 
sockaddr *addr,
 ts->is_accepted = 1;
 rtdm_lock_put_irqrestore(>socket_lock, context);
 
-//ret = rt_socket_fd(>sock)->fd;
+ret = rt_socket_fd(>sock)->fd;
 
  err:
 /* it is not critical to leave this unlocked
@@ -2114,20 +2114,43 @@ out:
 static ssize_t rt_tcp_sendmsg(struct rtdm_fd *fd,
  const struct user_msghdr *msg, int msg_flags)
 {
-size_t len;
-void *buf;
+   struct iovec iov_fast[RTDM_IOV_FASTMAX], *iov;
+   struct user_msghdr _msg;
+   ssize_t ret;
+   size_t len;
+   void *buf;
+
+   if (msg_flags)
+   return -EOPNOTSUPP;
 
-if (msg_flags)
-   return -EOPNOTSUPP;
+   msg = rtnet_get_arg(fd, &_msg, msg, sizeof(*msg));
+   if (IS_ERR(msg))
+   return PTR_ERR(msg);
+
+   /* loop over all vectors to be implemented */
+   if (msg->msg_iovlen != 1)
+   return -EOPNOTSUPP;
 
-/* loop over all vectors to be implemented */
-if (msg->msg_iovlen != 1)
-   return -EOPNOTSUPP;
+   ret = rtdm_get_iovec(fd, , msg, iov_fast);
+   if (ret)
+   return ret;
 
-len = msg->msg_iov[0].iov_len;
-buf = msg->msg_iov[0].iov_base;
+   len = iov[0].iov_len;
+   if (len > 0) {
+   buf = xnmalloc(len);
+   if (buf == NULL) {
+   ret = -ENOMEM;
+   goto out;
+   }
+   ret = rtdm_copy_from_user(fd, buf, iov[0].iov_base, len);
+   if (!ret)
+   ret = rt_tcp_write(fd, buf, len);
+   xnfree(buf);
+   }
+out:
+   rtdm_drop_iovec(iov, iov_fast);
 
-return rt_tcp_write(fd, (const void*)buf, len);
+   return ret;
 }
 
 /***


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/packet: recvmsg: write back namelen only if name required

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d1d3d431f5242c57862bf838209f7f8c0fc69ea6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d1d3d431f5242c57862bf838209f7f8c0fc69ea6

Author: Philippe Gerum 
Date:   Tue Dec  5 10:36:07 2017 +0100

net/packet: recvmsg: write back namelen only if name required

---

 kernel/drivers/net/stack/packet/af_packet.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/kernel/drivers/net/stack/packet/af_packet.c 
b/kernel/drivers/net/stack/packet/af_packet.c
index ff3ef33..f248239 100644
--- a/kernel/drivers/net/stack/packet/af_packet.c
+++ b/kernel/drivers/net/stack/packet/af_packet.c
@@ -335,12 +335,6 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
 rtskb = rtskb_dequeue_chain(>incoming);
 RTNET_ASSERT(rtskb != NULL, return -EFAULT;);
 
-/* copy the address */
-namelen = sizeof(sll);
-ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
-if (ret)
-   goto fail;
-
 /* copy the address if required. */
 if (msg->msg_name) {
struct rtnet_device *rtdev = rtskb->rtdev;
@@ -357,6 +351,11 @@ rt_packet_recvmsg(struct rtdm_fd *fd, struct user_msghdr 
*msg, int msg_flags)
ret = rtnet_put_arg(fd, >msg_name, , sizeof(sll));
if (ret)
goto fail;
+
+   namelen = sizeof(sll);
+   ret = rtnet_put_arg(fd, >msg_namelen, , sizeof(namelen));
+   if (ret)
+   goto fail;
 }
 
 /* Include the header in raw delivery */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/tcp: fix invalid reference in getsockopt()

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c005bf8be1dc2f98827ed76fc1f4f3f9cfc3543e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c005bf8be1dc2f98827ed76fc1f4f3f9cfc3543e

Author: Philippe Gerum 
Date:   Mon Dec  4 17:49:19 2017 +0100

net/tcp: fix invalid reference in getsockopt()

---

 kernel/drivers/net/stack/ipv4/tcp/tcp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/net/stack/ipv4/tcp/tcp.c 
b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
index 8bbb740..b1d01e9 100644
--- a/kernel/drivers/net/stack/ipv4/tcp/tcp.c
+++ b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
@@ -1822,7 +1822,7 @@ static int rt_tcp_ioctl(struct rtdm_fd *fd,
 setopt->optlen);
 
case _RTIOC_GETSOCKOPT:
-   if (setopt->level != SOL_SOCKET)
+   if (getopt->level != SOL_SOCKET)
break;
return rt_tcp_getsockopt(fd, ts, getopt->level,
 getopt->optname, getopt->optval,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/socket: forward private ioctl requests to NIC driver

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: wip/rtnet-fixes
Commit: 9a6bbc38465999d005c1bb06458fa07cbe45be05
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9a6bbc38465999d005c1bb06458fa07cbe45be05

Author: Philippe Gerum 
Date:   Thu Jan 18 10:49:19 2018 +0100

net/socket: forward private ioctl requests to NIC driver

This allows RTnet to define requests in the SIOCPROTOPRIVATE range for
identifying device-specific features added to the converted NIC
driver.

Therefore, no excution mode is enforced by the base handler, the
callee should check for the current mode, returning -ENOSYS to trigger
the adaptive switch if required.

---

 kernel/drivers/net/stack/socket.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/kernel/drivers/net/stack/socket.c 
b/kernel/drivers/net/stack/socket.c
index c139d95..f2622d3 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -348,6 +348,13 @@ int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, 
void __user *arg)
ret = -EOPNOTSUPP;
break;
 
+   case SIOCPROTOPRIVATE ... SIOCPROTOPRIVATE + 15:
+   if (rtdev->do_ioctl != NULL)
+   ret = rtdev->do_ioctl(rtdev, ifr, request);
+   else
+   ret = -EOPNOTSUPP;
+   break;
+
 default:
ret = -EOPNOTSUPP;
break;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/proxy: stop updating netdev-> last_rx with kernel 4.11+

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: wip/rtnet-fixes
Commit: 8a5c98f09a0407037832131b16aef54e480b3d74
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8a5c98f09a0407037832131b16aef54e480b3d74

Author: Philippe Gerum 
Date:   Fri Jan 26 11:51:42 2018 +0100

net/proxy: stop updating netdev->last_rx with kernel 4.11+

The network stack stopped using netdev->last_rx a long time ago, and
this field was removed during the 4.11 development cycle
(#4a7c972644c1).

---

 kernel/drivers/net/addons/proxy.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/drivers/net/addons/proxy.c 
b/kernel/drivers/net/addons/proxy.c
index 4887f77..5805475 100644
--- a/kernel/drivers/net/addons/proxy.c
+++ b/kernel/drivers/net/addons/proxy.c
@@ -256,7 +256,9 @@ static inline void rtnetproxy_kernel_recv(struct rtskb 
*rtskb)
 /* the rtskb stamp is useless (different clock), get new one */
 __net_timestamp(skb);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
 dev->last_rx = jiffies;
+#endif
 dev->stats.rx_bytes+=skb->len;
 dev->stats.rx_packets++;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : net/socket: align rtdev do_ioctl handler on the regular ndo_do_ioctl

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: wip/rtnet-fixes
Commit: b7881786889ac893158cbb43cfecaf7eb8940f94
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b7881786889ac893158cbb43cfecaf7eb8940f94

Author: Philippe Gerum 
Date:   Tue Jan 23 12:03:51 2018 +0100

net/socket: align rtdev do_ioctl handler on the regular ndo_do_ioctl

Align on the signature of the regular ndo_do_ioctl() handler for
interface-directed ioctl requests, since an ifr block must have been
provided by the caller to determine the device to hand over the
request to anyway.

---

 kernel/drivers/net/drivers/8139too.c |7 +++
 .../net/drivers/experimental/rt2500/rt2x00core.c |6 +++---
 kernel/drivers/net/drivers/igb/igb_main.c|7 +++
 kernel/drivers/net/stack/include/rtdev.h |2 +-
 kernel/drivers/net/stack/rtwlan.c|   18 ++
 kernel/drivers/net/stack/socket.c|4 ++--
 6 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/kernel/drivers/net/drivers/8139too.c 
b/kernel/drivers/net/drivers/8139too.c
index 8b1a7df..d49d779 100644
--- a/kernel/drivers/net/drivers/8139too.c
+++ b/kernel/drivers/net/drivers/8139too.c
@@ -519,7 +519,7 @@ static int rtl8139_close (struct rtnet_device *rtdev);
 static int rtl8139_interrupt (rtdm_irq_t *irq_handle);
 static int rtl8139_start_xmit (struct rtskb *skb, struct rtnet_device *rtdev);
 
-static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, 
void *cmd);
+static int rtl8139_ioctl(struct rtnet_device *, struct ifreq *rq, int cmd);
 static struct net_device_stats *rtl8139_get_stats(struct rtnet_device*rtdev);
 
 static void rtl8139_init_ring (struct rtnet_device *rtdev);
@@ -1297,15 +1297,14 @@ static int rtl8139_start_xmit (struct rtskb *skb, 
struct rtnet_device *rtdev)
return 0;
 }
 
-static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request, 
void *arg)
+static int rtl8139_ioctl(struct rtnet_device *rtdev, struct ifreq *ifr, int 
cmd)
 {
 struct rtl8139_private *tp = rtdev->priv;
 void *ioaddr = tp->mmio_addr;
 int nReturn = 0;
-struct ifreq *ifr = arg;
 struct ethtool_value *value;
 
-switch (request) {
+switch (cmd) {
case SIOCETHTOOL:
/* TODO: user-safe parameter access, most probably one layer higher 
*/
value = (struct ethtool_value *)ifr->ifr_data;
diff --git a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c 
b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
index c4807ef..926c7de 100644
--- a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
+++ b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
@@ -112,15 +112,15 @@ static int rt2x00_radio_off(struct _rt2x00_core * core) {
 /*
  * user space io handler
  */
-static int rt2x00_ioctl(struct rtnet_device * rtnet_dev, unsigned int request, 
void * arg) {
-
+static int rt2x00_ioctl(struct rtnet_device *rtnet_dev, struct ifreq *ifr, int 
request)
+{
 struct rtwlan_device * rtwlan_dev  = rtnetdev_priv(rtnet_dev);
 struct _rt2x00_core * core = rtwlan_priv(rtwlan_dev);
 struct rtwlan_cmd * cmd;
 u8 rate, dsss_rate, ofdm_rate;
 u32 address, value;
 
-cmd = (struct rtwlan_cmd *)arg;
+cmd = (struct rtwlan_cmd *)ifr->ifr_data;
 
 switch(request) {
 
diff --git a/kernel/drivers/net/drivers/igb/igb_main.c 
b/kernel/drivers/net/drivers/igb/igb_main.c
index fe0132b..be98d78 100644
--- a/kernel/drivers/net/drivers/igb/igb_main.c
+++ b/kernel/drivers/net/drivers/igb/igb_main.c
@@ -216,7 +216,7 @@ static int igb_msix_ring(rtdm_irq_t *irq_handle);
 static void igb_poll(struct igb_q_vector *);
 static bool igb_clean_tx_irq(struct igb_q_vector *);
 static bool igb_clean_rx_irq(struct igb_q_vector *, int);
-static int igb_ioctl(struct rtnet_device *, unsigned cmd, void *);
+static int igb_ioctl(struct rtnet_device *, struct ifreq *ifr, int cmd);
 static void igb_reset_task(struct work_struct *);
 static void igb_vlan_mode(struct rtnet_device *netdev,
  netdev_features_t features);
@@ -5063,15 +5063,14 @@ static int igb_mii_ioctl(struct rtnet_device *netdev, 
struct ifreq *ifr, int cmd
  * @ifreq:
  * @cmd:
  **/
-static int igb_ioctl(struct rtnet_device *netdev, unsigned cmd, void *rq)
+static int igb_ioctl(struct rtnet_device *netdev, struct ifreq *ifr, int cmd)
 {
-   struct ifreq *ifr = rq;
-
switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
return igb_mii_ioctl(netdev, ifr, cmd);
+
default:
return -EOPNOTSUPP;
}
diff --git a/kernel/drivers/net/stack/include/rtdev.h 
b/kernel/drivers/net/stack/include/rtdev.h
index c1c0b4e..a3ac7dd 100644
--- a/kernel/drivers/net/stack/include/rtdev.h
+++ b/kernel/drivers/net/stack/include/rtdev.h
@@ -152,7 +152,7 @@ struct rtnet_device {
   unsigned 

[Xenomai-git] New commits on branch next

2018-01-26 Thread git repository hosting
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fb9024b919b1c2be2c3ec7baffdfbc3647ec85f4
Author: Philippe Gerum 
Date:   Tue Jan 23 19:19:31 2018 +0100

lib/cobalt: add sendmmsg(), recvmmsg() syscalls

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=72a301e0f454dfed1bf1f6804a02edebab58a2c0
Author: Philippe Gerum 
Date:   Thu Jan 25 16:06:29 2018 +0100

cobalt/rtdm: add sendmmsg(), recvmmsg() syscalls

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50f4f6882d4d6787d373d9eeab59536c563887dc
Author: Philippe Gerum 
Date:   Tue Oct 3 12:02:36 2017 +0200

demo/gpiopwn: include required header explicitly

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2ad9de6cad536568fcd89dd0740a5f2e74d49d22
Author: Jan Kiszka 
Date:   Fri Sep 29 12:21:21 2017 +0200

cobalt/tracing: Primarily identify threads via pid

Except for the short phase between thread_init and shadow_map, a thread
is always identifiable via the pid of its Linux mate. Use this shorter
value, which also correlates with what ftrace records anyway, instead of
the pointer or the name. Report the full thread name only in prominent
cases: init, resume and switch.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6f664c086d5db9c871464c2bf3858e96f5caec7d
Author: Jan Kiszka 
Date:   Fri Sep 29 10:32:42 2017 +0200

cobalt/tracing: Don't report current thread in tracepoints

All these are synchronous, and the thread context is already recorded by
ftrace.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=06aef3cd5646abdd4d2e3216866a15605e2b94c7
Author: Jan Kiszka 
Date:   Fri Sep 29 07:36:27 2017 +0200

cobalt/tracing: Print syscalls by name

Matching numbers against syscall.h, specifically when the call is compat
or x32, is tedious work. Fortunately, ftrace allows up to automate this.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3d5c1165c16175c45a0dff69cfe481e03f62eb34
Author: Jan Kiszka 
Date:   Fri May 6 14:40:00 2016 +0200

cobalt/tracing: Trace changes of the current thread priority

Specifically useful to validate scheduling during PI or PP phases.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ae199617fd97931d96c4e189b22ae0bcd8b51614
Author: Jan Kiszka 
Date:   Thu Sep 28 20:54:24 2017 +0200

cobalt/tracing: Enhance cobalt_switch_context tracepoint

Adding PIDs and the state of the previous task will allow to track
Xenomai task switches in kernelshark (so far via out-of-tree patches,
upstream is planning for the necessary plugin concept).

Moreover, reporting the current priority on context switch helps
debugging unexpected or delayed context switches

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=56d0b7f361e6accd0d6b179ce84b08db18166bde
Author: Jan Kiszka 
Date:   Thu Sep 28 19:57:49 2017 +0200

cobalt/tracing: Convert cobalt_print_sched_params into proper function

The code of cobalt_print_sched_params is carried into the format string
in tracefs, and trace-cmd tries to make any sense out of it. While it
can process simply statements, this code is too complex and will prevent
the parsing.

Convert it into a function. That still does not resolve the parsing
issue of trace-cmd, but that can be addressed by a custom plugin which
can then interpret this tracepoint. That wouldn't be possible with the
broken format string.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a09aad81939500033666478f0732f7b32169a8e6
Author: Jan Kiszka 
Date:   Thu Sep 28 19:55:28 2017 +0200

cobalt/tracing: Do not print numerical policy in trace

__print_symbolic already ensures that unknown policies are printed
numerically.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ca29d227ccc1d6665672499f3a26e6e61de9e8c5
Author: Jan Kiszka 
Date:   Thu Aug 31 19:21:53 2017 +0200

cobalt/wrappers: Fix version level for cobalt_gpiochip_dev

That renaming only took place in 4.5.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=326df37a4a36d1da545ba521286a4dadd71dfa70
Author: Jan Kiszka 
Date:   Sun Oct 1 08:38:17 2017 +0200

   

[Xenomai-git] Philippe Gerum : cobalt/rtdm: honor O_NONBLOCK on recvmsg(), sendmsg()

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: b4153ea423873ba9acf120b9ce088bacbc20ec48
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4153ea423873ba9acf120b9ce088bacbc20ec48

Author: Philippe Gerum 
Date:   Fri Jan 26 10:46:02 2018 +0100

cobalt/rtdm: honor O_NONBLOCK on recvmsg(), sendmsg()

---

 kernel/cobalt/rtdm/fd.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index b4d3920..b97e917 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -563,6 +563,9 @@ ssize_t rtdm_fd_recvmsg(int ufd, struct user_msghdr *msg, 
int flags)
 
trace_cobalt_fd_recvmsg(current, fd, ufd, flags);
 
+   if (fd->oflags & O_NONBLOCK)
+   flags |= MSG_DONTWAIT;
+
if (ipipe_root_p)
ret = fd->ops->recvmsg_nrt(fd, msg, flags);
else
@@ -595,6 +598,9 @@ ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr 
*msg, int flags)
 
trace_cobalt_fd_sendmsg(current, fd, ufd, flags);
 
+   if (fd->oflags & O_NONBLOCK)
+   flags |= MSG_DONTWAIT;
+
if (ipipe_root_p)
ret = fd->ops->sendmsg_nrt(fd, msg, flags);
else


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/kernel: event_wait: add timeout sanity check

2018-01-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 4d4eb4098df14317d14e2b5e9063827e0e4f5fb1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4d4eb4098df14317d14e2b5e9063827e0e4f5fb1

Author: Philippe Gerum 
Date:   Wed Jan 24 11:12:36 2018 +0100

cobalt/kernel: event_wait: add timeout sanity check

---

 kernel/cobalt/posix/event.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/posix/event.c b/kernel/cobalt/posix/event.c
index 6c99ea9..407ef8d 100644
--- a/kernel/cobalt/posix/event.c
+++ b/kernel/cobalt/posix/event.c
@@ -119,6 +119,9 @@ int __cobalt_event_wait(struct cobalt_event_shadow __user 
*u_event,
handle = cobalt_get_handle_from_user(_event->handle);
 
if (ts) {
+   if ((unsigned long)ts->tv_nsec >= ONE_BILLION)
+   return -EINVAL;
+   
timeout = ts2ns(ts);
if (timeout) {
timeout++;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


Re: [Xenomai] [RFC] dropping ppc64 support

2018-01-26 Thread Jan Kiszka
On 2018-01-26 07:38, Wadepohl, Wolfram wrote:
> Hi all,
> 
> dropping the ppc64 support are bad news for me.
> 
> Watchting the xenomai project for several years, I'm now in the situation for 
> the need of a stable hard rt solution in combination with gnu/linux for a 
> project.
> So xenomai is no longer on the list, due to the missing future support for 
> ppc64.

We are happy to support anyone who is willing to take over the
maintenance. Maybe there are more parties interested so that efforts can
be shared.

> 
> Any suggestions which way to go? The PREMEPT_RT  is definitly no way to go.
> My last idea is to go for Jailhouse with GNU/Linux and RTEMS.

We do not yet have ported Jailhouse to any Power variant, and I'm still
unsure if that is going to happen due to the uncertain future of that
architecture, but also because it is a bit different compared to ARM and
x86. On the other hand, I recently heard about a safety-certified
Power64 CPU which could increase the interest again - provided the
certification material covers the virtualization extensions as well.

However, the same applies to that OSS project: contributions welcome,
and you will receive support in return.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

___
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai