linux-um archives
 help / color / mirror / Atom feed
From: Blaisorblade <blaisorblade@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Yu Dong-W4760C <W4760C@motorola.com>
Subject: Re: [uml-devel] bugs in line.c and stdio_console.c
Date: Fri, 29 Apr 2005 21:45:18 +0200	[thread overview]
Message-ID: <200504292145.19573.blaisorblade@yahoo.it> (raw)
In-Reply-To: <3BCB5FB76AFFF646BCFBC02A889B64F301799B27@ZCH07EXM05.corp.mot.com>

On Thursday 28 April 2005 03:24, Yu Dong-W4760C wrote:
> same bugs in the two files (uml-linux-2.4.26-3):
> arch/um/drivers/line.c

>  down(&line->sem);  ========================> may cause shedule in
> interrrupt 

> in arch/um/drivers/stdio_console.c
> static void console_write(struct console *console, const char *string,
>      unsigned len)
> {

>  if(con_init_done)
>   down(&line->sem);  ========================> may cause shedule in
> interrrupt console_write_chan(&line->chan_list, string, len);
>  if(con_init_done)
>   up(&line->sem);
> }
>
> my fix is change
> [w4760c@w4760c-x3 drivers]$ diff -Nru line.c line.c.old
> --- line.c      2005-04-28 09:22:29.000000000 +0800
> +++ line.c.old  2005-04-26 09:38:18.000000000 +0800
> @@ -134,9 +134,7 @@
>         i = minor(tty->device) - tty->driver.minor_start;
>         line = &lines[i];
>
> -       if(!in_interrupt())
> -               down(&line->sem);
> -
> +       down(&line->sem);
>         if(line->head != line->tail){
>                 local_irq_save(flags);
>                 ret += buffer_data(line, buf, len);
> @@ -159,8 +157,7 @@
>                         ret += buffer_data(line, buf + n, len);
>         }
>   out_up:
> -       if(!in_interrupt())
> -               up(&line->sem);
> +       up(&line->sem);
>
>   out_free:
>         if(from_user)
>
>
> --- stdio_console.c     2005-04-26 14:41:05.000000000 +0800
> +++ stdio_console.c.bak 2005-04-26 14:33:30.000000000 +0800
> @@ -188,10 +188,10 @@
>  {
>         struct line *line = &vts[console->index];
>
> -       if(con_init_done && !in_interrupt())
> +       if(con_init_done)
>                 down(&line->sem);
>         console_write_chan(&line->chan_list, string, len);
> -       if(con_init_done && !in_interrupt())
> +       if(con_init_done)
>                 up(&line->sem);
>  }
>

> please help to confirm if it's correct?

1) The patch is reversed, and after noticing this it seems a bit more 
meaningful.

2)But that's not the correct fix, because data corruption is as bad as 
schedule in interrupt.

3) The correct fix (which I just sent in with the title "uml: redo console 
locking" to this list) is to replace that semaphore with a spinlock.
-- 
Paolo Giarrusso, aka Blaisorblade
Skype user "PaoloGiarrusso"
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade




-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

      reply	other threads:[~2005-04-28 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-28  1:24 [uml-devel] bugs in line.c and stdio_console.c Yu Dong-W4760C
2005-04-29 19:45 ` Blaisorblade [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200504292145.19573.blaisorblade@yahoo.it \
    --to=blaisorblade@yahoo.it \
    --cc=W4760C@motorola.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox