<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">在 2021/8/2 下午3:25, Jiri Slaby 写道:<br>
</div>
<blockquote type="cite"
cite="mid:b5554967-a683-96ae-deb9-2d4980d33b41@kernel.org">Hi,
<br>
<br>
why is this 2/2? I seem (Lore neither) to find 1/2.
<br>
</blockquote>
You didn't receive 1/2?<br>
<span style="color: rgb(0, 0, 0); font-family: courier, monospace;
font-size: medium; font-style: normal; font-variant-ligatures:
normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; orphans: 2; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration-style: initial; text-decoration-color: initial;
display: inline !important; float: none;">[PATCH 1/2] tty: hvc:
pass DMA capable memory to put_chars()</span><br>
<a href="https://lkml.org/lkml/2021/8/1/8">https://lkml.org/lkml/2021/8/1/8</a>
<blockquote type="cite"
cite="mid:b5554967-a683-96ae-deb9-2d4980d33b41@kernel.org">
<br>
On 01. 08. 21, 7:16, Xianting Tian wrote:
<br>
<blockquote type="cite">hvc framework will never pass stack memory
to the put_chars() function,
<br>
</blockquote>
<br>
Am I blind or missing something?
<br>
<br>
hvc_console_print(...)
<br>
{
<br>
char c[N_OUTBUF]
<br>
...
<br>
cons_ops[index]->put_chars(vtermnos[index], c, i);
<br>
<br>
The same here:
<br>
<br>
hvc_poll_put_char(..., char ch)
<br>
{
<br>
...
<br>
n = hp->ops->put_chars(hp->vtermno, &ch, 1);
<br>
<br>
AFAICS both of them *pass* a pointer to stack variable.
<br>
</blockquote>
<p>yes, I discussed the issue with Arnd before in below thread, you
can get the history, thanks<br>
</p>
<p><a href="https://lkml.org/lkml/2021/7/27/494">https://lkml.org/lkml/2021/7/27/494</a>
</p>
<blockquote type="cite"
cite="mid:b5554967-a683-96ae-deb9-2d4980d33b41@kernel.org">
<br>
<blockquote type="cite">So the calling of kmemdup() is
unnecessary, remove it.
<br>
<br>
Fixes: c4baad5029 ("virtio-console: avoid DMA from stack")
<br>
</blockquote>
<br>
This patch doesn't "Fix" -- it reverts the commit. You should've
CCed the author too.
<br>
</blockquote>
<p>yes, we discussed ther issue in above thread, which we CCed the
author.</p>
<blockquote type="cite"
cite="mid:b5554967-a683-96ae-deb9-2d4980d33b41@kernel.org">
<br>
<blockquote type="cite">Signed-off-by: Xianting Tian
<a class="moz-txt-link-rfc2396E" href="mailto:xianting.tian@linux.alibaba.com"><xianting.tian@linux.alibaba.com></a>
<br>
---
<br>
drivers/char/virtio_console.c | 12 ++----------
<br>
1 file changed, 2 insertions(+), 10 deletions(-)
<br>
<br>
diff --git a/drivers/char/virtio_console.c
b/drivers/char/virtio_console.c
<br>
index 7eaf303a7..4ed3ffb1d 100644
<br>
--- a/drivers/char/virtio_console.c
<br>
+++ b/drivers/char/virtio_console.c
<br>
@@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const
char *buf, int count)
<br>
{
<br>
struct port *port;
<br>
struct scatterlist sg[1];
<br>
- void *data;
<br>
- int ret;
<br>
if (unlikely(early_put_chars))
<br>
return early_put_chars(vtermno, buf, count);
<br>
@@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const
char *buf, int count)
<br>
if (!port)
<br>
return -EPIPE;
<br>
- data = kmemdup(buf, count, GFP_ATOMIC);
<br>
- if (!data)
<br>
- return -ENOMEM;
<br>
-
<br>
- sg_init_one(sg, data, count);
<br>
- ret = __send_to_port(port, sg, 1, count, data, false);
<br>
- kfree(data);
<br>
- return ret;
<br>
+ sg_init_one(sg, buf, count);
<br>
+ return __send_to_port(port, sg, 1, count, (void *)buf,
false);
<br>
}
<br>
/*
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
</body>
</html>