lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Mar 2019 21:43:24 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        linux-kernel@...r.kernel.org
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 6/7] x86/boot: Introduce MMIO accessors and their support in earlyprintk

If user supplied serial base address via kernel command line and
at the same time the word 'mmio' is present, use MMIO accessors.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 arch/x86/boot/early_serial_console.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 98aee6c6e374..cfc9e55cd68a 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -33,6 +33,20 @@ static void io_serial_out(unsigned long addr, int offset, int value)
 	outb(value, addr + offset);
 }
 
+static void mem8_serial_out(unsigned long addr, int offset, int value)
+{
+	u8 __iomem *vaddr = (u8 __iomem *)addr;
+	/* shift implied by pointer type */
+	writeb(value, vaddr + offset);
+}
+
+static unsigned int mem8_serial_in(unsigned long addr, int offset)
+{
+	u8 __iomem *vaddr = (u8 __iomem *)addr;
+	/* shift implied by pointer type */
+	return readb(vaddr + offset);
+}
+
 static void early_serial_configure(unsigned long port, int baud)
 {
 	unsigned char c;
@@ -59,6 +73,13 @@ static void early_serial_use_io_accessors(void)
 	serial_out = io_serial_out;
 }
 
+static void early_serial_use_mmio_accessors(void)
+{
+	/* It is memory mapped - assume 8-bit alignment */
+	serial_in = mem8_serial_in;
+	serial_out = mem8_serial_out;
+}
+
 static void early_serial_init(unsigned long port, int baud)
 {
 	early_serial_configure(port, baud);
@@ -101,12 +122,16 @@ static void parse_earlyprintk(void)
 		/*
 		 * make sure we have
 		 *	"serial,0x3f8,115200"
+		 *	"serial,mmio,0xff010180,115200"
 		 *	"serial,ttyS0,115200"
 		 *	"ttyS0,115200"
 		 */
 		if (pos == 7 && !strncmp(arg + pos, "0x", 2)) {
 			port = parse_serial_port(arg, pos + 0, &pos);
 			early_serial_use_io_accessors();
+		} else if (pos == 7 && !strncmp(arg + pos, "mmio,0x", 7)) {
+			port = parse_serial_port(arg, pos + 5, &pos);
+			early_serial_use_mmio_accessors();
 		} else if (!strncmp(arg + pos, "ttyS", 4)) {
 			static const int bases[] = { 0x3f8, 0x2f8 };
 			int idx = 0;
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ