Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1583725

[PATCH] tty: hvc: don't allocate a buffer for console print on stack

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From Jan Dakinevich <jan.dakinevich@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] tty: hvc: don't allocate a buffer for console print on stack
Date Fri, 17 Feb 2017 21:50:02 +0100
Message-ID <tbXDA-DC-5@gated-at.bofh.it> (permalink)
X-Original-To Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jslaby@suse.com>, Jan Dakinevich <jan.dakinevich@gmail.com>, Peter Hurley <peter@hurleysoftware.com>, Dan Carpenter <dan.carpenter@oracle.com>, Arnd Bergmann <arnd@arndb.de>, Amit Shah <amit@kernel.org>, virtualization@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=nWL2XhS9dz5CYdS1E/R4owNgnQNB/9iPHsIKXzOoQ+Q=; b=u12IPh1i/9OPCwmyGtGa4uE62vpfKjnH6PMLx1ealM/1yi3i+ApCjS2xr1rsmXVAEy P30w7MnM/iI9sur/0fA7qJC1wLEryuLKuZ1lqvyLkgfX4swjlhH5Risrs205JSDavKsd q+DnbQ5xuRS4UVBW+M7hX+/0ti/RSDUSn2MrtoAEj+LIenJ+8eVsIq+BgFMs3I6ULQOX 3zn7LblMpkXjXpSDbFXxfBTFGkwqic0DzKNYF9hqssuQ4FwbPmzlXR60Hg/JCg8/rIgL ZijCBw07MheXHagC6dW4Am6deeo6Qc7NiBG9aWKqjOSe5RnHi6jqYePu6mbpoenDGbh4 rnBA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=nWL2XhS9dz5CYdS1E/R4owNgnQNB/9iPHsIKXzOoQ+Q=; b=taWA0OQf61hsTXLDHlYHMfo9m5i9bJdyNBmyL/KKKTFy30x9UZhBglJAhHvlE95jus fKOlPt6jiaekO5eNuDxPHYh5NmrEJE6WD8OV4m/cEcq1/m/z2W6/kFV7nl+hakpto6bO fSmhoEWNnnoQiHh1UL35VxtpAYoOozJDCWkfOydRK6WFWtfVaHiNzW8ABzQGJzEWxSY7 gPHAYDHfh8g+xXcQSe5svkapvcjyzQOMcipiLTuwZ6RrCKjXxCEffZOb6kn/HR6J33cC CHqPd+hQ19qOg2Vy2C5Jl3sjL9OlsLb6m/LbEoFJWLnYGNJ4vu1SRWvSDX8Av96BN8BA GF/w==
X-Gm-Message-State AMke39mRvDK6fdEx5KRmnVFO9H8refPCLNbNBEvr8HjLdpRNharK5dMRtlJzkpY737STCA==
X-Received by 10.25.170.7 with SMTP id t7mr2852347lfe.105.1487364215474; Fri, 17 Feb 2017 12:43:35 -0800 (PST)
X-Mailer git-send-email 1.9.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 31
Organization linux.* mail to news gateway
X-Original-Date Fri, 17 Feb 2017 23:42:45 +0300
X-Original-Message-ID <1487364165-21882-1-git-send-email-jan.dakinevich@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1583725

Show key headers only | View raw


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.

Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
---
 drivers/tty/hvc/hvc_console.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 9b5c0fb..1ce6aaf 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -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;
-- 
1.9.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] tty: hvc: don't allocate a buffer for console print on stack Jan Dakinevich <jan.dakinevich@gmail.com> - 2017-02-17 21:50 +0100

csiph-web