tty: hvc: don't allocate a buffer for console print on stack
PATCH 1/1 tty: hvc: don't allocate a buffer for console print on stack
The buffer is used by virtio console driver as DMA buffer. Since v4.9 (if VMAP_STACK is enabled) we shouldn't use the stack for DMA.
--- drivers/tty/hvc/hvc_console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/tty/hvc/hvc_console.c +6 -1
@@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)static void hvc_console_print (struct console *co,const char *b,unsigned count) { - char c[N_OUTBUF] __ALIGNED__;unsigned i =0 , n =0 ;int r, donecr =0 , index = co->index; +/* +* Access to the buffer is serialized by console_sem in caller code from +* kernel/printk/printk.c +*/ + static char c[N_OUTBUF] __ALIGNED__; +/* Console access attempt outside of acceptable console range. */ if (index >=MAX_NR_HVC_CONSOLES )return ;
Signature · 1 line
1.9.1
Greg Kroah-Hartman
maintainerQuoted 2 lines · Jan Dakinevich
The buffer is used by virtio console driver as DMA buffer. Since v4.9 (if
VMAP_STACKis enabled) we shouldn't use the stack for DMA.
You shouldn't use 'static' data either, that's not always guaranteed to be DMA-able, right?
Quoted 13 lines
Signed-off-by Jan Dakinevich <[email protected]>--- drivers/tty/hvc/hvc_console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/tty/hvc/hvc_console.c +0
-0@@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)static void hvc_console_print (struct console *co,const char *b,unsigned count)
drivers/tty/hvc/hvc_console.c static struct hvc_struct *hvc_get_by_index(int index) · line 153
Quoted 10 lines
drivers/tty/hvc/hvc_console.c +5
-1{ - char c[N_OUTBUF] __ALIGNED__;unsigned i =0 , n =0 ;int r, donecr =0 , index = co->index; +/* +* Access to the buffer is serialized by console_sem in caller code from +* kernel/printk/printk.c +*/ + static char c[N_OUTBUF] __ALIGNED__;
What about allocating it dynamically? That's the correct thing to do.
thanks,
greg k-h
Quoted 2 lines
You shouldn't use 'static' data either, that's not always guaranteed to be DMA-able, right?
I naively thought all 'static' data was linked into .data and the section was always kmapped.
Quoted 1 line
What about allocating it dynamically? That's the correct thing to do.
Yep, the solution was more welcomed and happened earlier:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c4baad50297d84bde1a7ad45e50c73adae4a2192
Quoted 37 lines · Greg Kroah-Hartman
Quoted 2 lines · Jan Dakinevich
The buffer is used by virtio console driver as DMA buffer. Since v4.9 (if
VMAP_STACKis enabled) we shouldn't use the stack for DMA.You shouldn't use 'static' data either, that's not always guaranteed to be DMA-able, right?
Quoted 13 lines
Signed-off-by Jan Dakinevich <[email protected]>--- drivers/tty/hvc/hvc_console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/tty/hvc/hvc_console.c +0
-0@@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)static void hvc_console_print (struct console *co,const char *b,unsigned count)drivers/tty/hvc/hvc_console.c static struct hvc_struct *hvc_get_by_index(int index) · line 153
Quoted 10 lines
drivers/tty/hvc/hvc_console.c +5
-1{ - char c[N_OUTBUF] __ALIGNED__;unsigned i =0 , n =0 ;int r, donecr =0 , index = co->index; +/* +* Access to the buffer is serialized by console_sem in caller code from +* kernel/printk/printk.c +*/ + static char c[N_OUTBUF] __ALIGNED__;What about allocating it dynamically? That's the correct thing to do.
thanks,
greg k-h
Signature · 2 lines
Best regards Jan Dakinevich