2007-09-12 15:17:01

by Paul Mackerras

[permalink] [raw]
Subject: Define termios_1 functions for powerpc, s390, avr32 and frv

Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
on all architectures. However, powerpc, s390, avr32 and frv don't
currently define those functions since their termios struct didn't
need to be changed when the arbitrary baud rate stuff was added, and
thus the kernel won't currently build on those architectures.

This adds definitions of kernel_termios_to_user_termios_1 and
user_termios_to_kernel_termios_1 to include/asm-generic/termios.h
which are identical to kernel_termios_to_user_termios and
user_termios_to_kernel_termios respectively. The definitions are the
same because the "old" termios and "new" termios are in fact the same
on these architectures (which are the same ones that use
asm-generic/termios.h).

Signed-off-by: Paul Mackerras <[email protected]>
---

Linus, this seems a bit cleaner than putting ifdefs in
drivers/char/tty_ioctl.c, and it fixes the compile error on powerpc.
Your choice whether to use this patch or Tony's.

diff --git a/include/asm-generic/termios.h b/include/asm-generic/termios.h
index 3769e6b..33dca30 100644
--- a/include/asm-generic/termios.h
+++ b/include/asm-generic/termios.h
@@ -63,6 +63,8 @@ static inline int kernel_termios_to_user_termio(struct termio __user *termio,

#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
+#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))

#endif /* __ARCH_TERMIO_GETPUT */


2007-09-12 16:10:08

by Linus Torvalds

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv



On Thu, 13 Sep 2007, Paul Mackerras wrote:
>
> Linus, this seems a bit cleaner than putting ifdefs in
> drivers/char/tty_ioctl.c, and it fixes the compile error on powerpc.
> Your choice whether to use this patch or Tony's.

Yeah, I'll take this one. I just wanted to understand why it triggered at
all.

Andrew - I'm dropping Tony's patch you forwarded, but since it will still
apply cleanly, you should drop it manually from your queues.

Linus

2007-09-13 07:05:44

by Jan Dittmer

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

Paul Mackerras wrote:
> Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
> kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
> on all architectures. However, powerpc, s390, avr32 and frv don't
> currently define those functions since their termios struct didn't
> need to be changed when the arbitrary baud rate stuff was added, and
> thus the kernel won't currently build on those architectures.

alpha, parisc, sh, sparc{64,}, xtensa are still broken with this error...

Jan

2007-09-13 07:12:54

by David Miller

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

From: Jan Dittmer <[email protected]>
Date: Thu, 13 Sep 2007 08:57:13 +0200

> Paul Mackerras wrote:
> > Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
> > kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
> > on all architectures. However, powerpc, s390, avr32 and frv don't
> > currently define those functions since their termios struct didn't
> > need to be changed when the arbitrary baud rate stuff was added, and
> > thus the kernel won't currently build on those architectures.
>
> alpha, parisc, sh, sparc{64,}, xtensa are still broken with this error...

I sent Alan a patch last week that added the Sparc bits, it would
be nice if he or someone else could merge it as I'm travelling
today :-)

2007-09-13 07:22:53

by Michael Neuling

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

> > Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
> > kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
> > on all architectures. However, powerpc, s390, avr32 and frv don't
> > currently define those functions since their termios struct didn't
> > need to be changed when the arbitrary baud rate stuff was added, and
> > thus the kernel won't currently build on those architectures.
>
> alpha, parisc, sh, sparc{64,}, xtensa are still broken with this error...

They need to include <asm-generic/termios.h> in asm-<arch>/termios.h
like in powerpc.

Alternatively tonyb's patch should fix them. Could also do that?

Mikey

2007-09-13 09:54:19

by Paul Mundt

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

On Thu, Sep 13, 2007 at 05:22:36PM +1000, Michael Neuling wrote:
> > > Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
> > > kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
> > > on all architectures. However, powerpc, s390, avr32 and frv don't
> > > currently define those functions since their termios struct didn't
> > > need to be changed when the arbitrary baud rate stuff was added, and
> > > thus the kernel won't currently build on those architectures.
> >
> > alpha, parisc, sh, sparc{64,}, xtensa are still broken with this error...
>
> They need to include <asm-generic/termios.h> in asm-<arch>/termios.h
> like in powerpc.
>
> Alternatively tonyb's patch should fix them. Could also do that?
>
Is there a consensus for this? It's a bit annoying to have this stuff
broken this late in 2.6.23. If Tony's patch gets applied, then this stuff
will work itself out. Otherwise everything has to be patched for
asm-generic/termios.h. In which case.. here's the patch to define them on
sh and sh64.

Signed-off-by: Paul Mundt <[email protected]>

--

include/asm-sh/termios.h | 34 +---------------------------------
include/asm-sh64/termios.h | 34 +---------------------------------
2 files changed, 2 insertions(+), 66 deletions(-)

diff --git a/include/asm-sh/termios.h b/include/asm-sh/termios.h
index e7c8f86..c57f74e 100644
--- a/include/asm-sh/termios.h
+++ b/include/asm-sh/termios.h
@@ -49,39 +49,7 @@ struct termio {
*/
#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"

-/*
- * Translate a "termio" structure into a "termios". Ugh.
- */
-#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
- unsigned short __tmp; \
- get_user(__tmp,&(termio)->x); \
- *(unsigned short *) &(termios)->x = __tmp; \
-}
-
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
- SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
- copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
-
-/*
- * Translate a "termios" structure into a "termio". Ugh.
- */
-#define kernel_termios_to_user_termio(termio, termios) \
-({ \
- put_user((termios)->c_iflag, &(termio)->c_iflag); \
- put_user((termios)->c_oflag, &(termio)->c_oflag); \
- put_user((termios)->c_cflag, &(termio)->c_cflag); \
- put_user((termios)->c_lflag, &(termio)->c_lflag); \
- put_user((termios)->c_line, &(termio)->c_line); \
- copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
-})
-
-#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+#include <asm-generic/termios.h>

#endif /* __KERNEL__ */

diff --git a/include/asm-sh64/termios.h b/include/asm-sh64/termios.h
index dc44e6e..b61ce95 100644
--- a/include/asm-sh64/termios.h
+++ b/include/asm-sh64/termios.h
@@ -60,39 +60,7 @@ struct termio {
*/
#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"

-/*
- * Translate a "termio" structure into a "termios". Ugh.
- */
-#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
- unsigned short __tmp; \
- get_user(__tmp,&(termio)->x); \
- *(unsigned short *) &(termios)->x = __tmp; \
-}
-
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
- SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
- SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
- copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
-
-/*
- * Translate a "termios" structure into a "termio". Ugh.
- */
-#define kernel_termios_to_user_termio(termio, termios) \
-({ \
- put_user((termios)->c_iflag, &(termio)->c_iflag); \
- put_user((termios)->c_oflag, &(termio)->c_oflag); \
- put_user((termios)->c_cflag, &(termio)->c_cflag); \
- put_user((termios)->c_lflag, &(termio)->c_lflag); \
- put_user((termios)->c_line, &(termio)->c_line); \
- copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
-})
-
-#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+#include <asm-generic/termios.h>

#endif /* __KERNEL__ */

2007-09-13 10:56:53

by Andrew Morton

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

On Thu, 13 Sep 2007 18:53:46 +0900 Paul Mundt <[email protected]> wrote:

> On Thu, Sep 13, 2007 at 05:22:36PM +1000, Michael Neuling wrote:
> > > > Commit f629307c857c030d5a3dd777fee37c8bb395e171 introduced uses of
> > > > kernel_termios_to_user_termios_1 and user_termios_to_kernel_termios_1
> > > > on all architectures. However, powerpc, s390, avr32 and frv don't
> > > > currently define those functions since their termios struct didn't
> > > > need to be changed when the arbitrary baud rate stuff was added, and
> > > > thus the kernel won't currently build on those architectures.
> > >
> > > alpha, parisc, sh, sparc{64,}, xtensa are still broken with this error...
> >
> > They need to include <asm-generic/termios.h> in asm-<arch>/termios.h
> > like in powerpc.
> >
> > Alternatively tonyb's patch should fix them. Could also do that?
> >
> Is there a consensus for this? It's a bit annoying to have this stuff
> broken this late in 2.6.23. If Tony's patch gets applied, then this stuff
> will work itself out. Otherwise everything has to be patched for
> asm-generic/termios.h. In which case.. here's the patch to define them on
> sh and sh64.

I think we need to go with Tony's patch. sparc32 and sparc64 are
presently broken too, and the patch which converts sparc to use the
new interfaces introduces a few build errors.


From: Tony Breeds <[email protected]>

Add Guards around TIOCSLCKTRMIOS and TIOCGLCKTRMIOS.

Signed-off-by: Tony Breeds <[email protected]>
Cc: Alan Cox <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: "David S. Miller" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

drivers/char/tty_ioctl.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff -puN drivers/char/tty_ioctl.c~sparc64-and-others-fix-tty_ioctlc-build drivers/char/tty_ioctl.c
--- a/drivers/char/tty_ioctl.c~sparc64-and-others-fix-tty_ioctlc-build
+++ a/drivers/char/tty_ioctl.c
@@ -795,6 +795,19 @@ int n_tty_ioctl(struct tty_struct * tty,
if (L_ICANON(tty))
retval = inq_canon(tty);
return put_user(retval, (unsigned int __user *) arg);
+#ifndef TCGETS2
+ case TIOCGLCKTRMIOS:
+ if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
+ return -EFAULT;
+ return 0;
+
+ case TIOCSLCKTRMIOS:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ if (user_termios_to_kernel_termios(real_tty->termios_locked, (struct termios __user *) arg))
+ return -EFAULT;
+ return 0;
+#else
case TIOCGLCKTRMIOS:
if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
return -EFAULT;
@@ -806,6 +819,7 @@ int n_tty_ioctl(struct tty_struct * tty,
if (user_termios_to_kernel_termios_1(real_tty->termios_locked, (struct termios __user *) arg))
return -EFAULT;
return 0;
+#endif

case TIOCPKT:
{
_

2007-09-13 16:32:37

by Alan Cox

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

On Thu, Sep 13, 2007 at 01:16:31AM +1000, Paul Mackerras wrote:
> asm-generic/termios.h).
>
> Signed-off-by: Paul Mackerras <[email protected]>

Acked-by: Alan Cox <[email protected]>

2007-09-14 18:36:38

by David Miller

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

From: Andrew Morton <[email protected]>
Date: Thu, 13 Sep 2007 03:55:06 -0700

> I think we need to go with Tony's patch. sparc32 and sparc64 are
> presently broken too, and the patch which converts sparc to use the
> new interfaces introduces a few build errors.

The problem with the asm-generic/termios.h thing is it only works
if your copying functions are just a copy_{to,from}_user() and you
can define that __ARCH_* macro.

In retrospect what that header should do is, outside of the
ARCH_* block, define the foo_1 interfaces plainly to foo.

Alternatively, here is a patch that gets sparc compiling and
working again in the current tree.

This whole termios thing hasn't been handled very well, and it's maybe
not what we should be doing so late in the -rc cycle. And yes,
this is coming from the guy who added the TCP oops'er two weeks ago
:-P

[SPARC]: Fix build due to termios changes.

Signed-off-by: David S. Miller <[email protected]>

diff --git a/include/asm-sparc/termios.h b/include/asm-sparc/termios.h
index d767f20..25e9cbb 100644
--- a/include/asm-sparc/termios.h
+++ b/include/asm-sparc/termios.h
@@ -142,6 +142,11 @@ struct winsize {
0; \
})

+#define user_termios_to_kernel_termios_1(k, u) \
+ user_termios_to_kernel_termios(k, u)
+#define kernel_termios_to_user_termios_1(u, k) \
+ kernel_termios_to_user_termios(u, k)
+
#endif /* __KERNEL__ */

#endif /* _SPARC_TERMIOS_H */
diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h
index f05d390..6fc71e6 100644
--- a/include/asm-sparc64/termios.h
+++ b/include/asm-sparc64/termios.h
@@ -145,6 +145,11 @@ struct winsize {
err; \
})

+#define user_termios_to_kernel_termios_1(k, u) \
+ user_termios_to_kernel_termios(k, u)
+#define kernel_termios_to_user_termios_1(u, k) \
+ kernel_termios_to_user_termios(u, k)
+
#endif /* __KERNEL__ */

#endif /* _SPARC64_TERMIOS_H */

2007-09-14 22:14:18

by Andrew Morton

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

On Fri, 14 Sep 2007 11:33:24 -0700 (PDT)
David Miller <[email protected]> wrote:

> From: Andrew Morton <[email protected]>
> Date: Thu, 13 Sep 2007 03:55:06 -0700
>
> > I think we need to go with Tony's patch. sparc32 and sparc64 are
> > presently broken too, and the patch which converts sparc to use the
> > new interfaces introduces a few build errors.
>
> The problem with the asm-generic/termios.h thing is it only works
> if your copying functions are just a copy_{to,from}_user() and you
> can define that __ARCH_* macro.
>
> In retrospect what that header should do is, outside of the
> ARCH_* block, define the foo_1 interfaces plainly to foo.
>
> Alternatively, here is a patch that gets sparc compiling and
> working again in the current tree.
>
> This whole termios thing hasn't been handled very well, and it's maybe
> not what we should be doing so late in the -rc cycle. And yes,
> this is coming from the guy who added the TCP oops'er two weeks ago
> :-P

tell me about it.

> [SPARC]: Fix build due to termios changes.
>
> Signed-off-by: David S. Miller <[email protected]>
>
> diff --git a/include/asm-sparc/termios.h b/include/asm-sparc/termios.h
> index d767f20..25e9cbb 100644
> --- a/include/asm-sparc/termios.h
> +++ b/include/asm-sparc/termios.h
> @@ -142,6 +142,11 @@ struct winsize {
> 0; \
> })
>
> +#define user_termios_to_kernel_termios_1(k, u) \
> + user_termios_to_kernel_termios(k, u)
> +#define kernel_termios_to_user_termios_1(u, k) \
> + kernel_termios_to_user_termios(u, k)
> +
> #endif /* __KERNEL__ */
>
> #endif /* _SPARC_TERMIOS_H */
> diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h
> index f05d390..6fc71e6 100644
> --- a/include/asm-sparc64/termios.h
> +++ b/include/asm-sparc64/termios.h
> @@ -145,6 +145,11 @@ struct winsize {
> err; \
> })
>
> +#define user_termios_to_kernel_termios_1(k, u) \
> + user_termios_to_kernel_termios(k, u)
> +#define kernel_termios_to_user_termios_1(u, k) \
> + kernel_termios_to_user_termios(u, k)
> +
> #endif /* __KERNEL__ */
>
> #endif /* _SPARC64_TERMIOS_H */

That fixes sparc, but I think other architectures are still broken. And if
we use Tony's ifdef patch to fix the other architectures, that makes the
above sparc-fix patch unneeded.

argh.

2007-09-14 22:30:35

by David Miller

[permalink] [raw]
Subject: Re: Define termios_1 functions for powerpc, s390, avr32 and frv

From: Andrew Morton <[email protected]>
Date: Fri, 14 Sep 2007 15:12:53 -0700

> That fixes sparc, but I think other architectures are still broken. And if
> we use Tony's ifdef patch to fix the other architectures, that makes the
> above sparc-fix patch unneeded.
>
> argh.

I don't care if we use Tony's fix or mine, both are fine.

What I do care about is that I spent 24 hours on trains and
planes, only to find more than a day later that Sparc still
didn't build.