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:   Wed, 2 Mar 2022 23:57:44 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Uwe Kleine-König' 
        <u.kleine-koenig@...gutronix.de>, Jiri Slaby <jslaby@...e.cz>
CC:     "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "Alexandre Belloni" <alexandre.belloni@...tlin.com>,
        Mateusz Holenko <mholenko@...micro.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        "Benjamin Herrenschmidt" <benh@...nel.crashing.org>,
        Liviu Dudau <liviu.dudau@....com>,
        Baruch Siach <baruch@...s.co.il>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Paul Cercueil <paul@...pouillou.net>,
        "Paul Mackerras" <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        "Michal Simek" <michal.simek@...inx.com>,
        Karol Gugala <kgugala@...micro.com>,
        Jerome Brunet <jbrunet@...libre.com>,
        Peter Korsgaard <peter@...sgaard.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "Alexander Shiyan" <shc_work@...l.ru>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...onical.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Fabio Estevam <festevam@...il.com>,
        "Russell King" <linux@...linux.org.uk>,
        Ludovic Desroches <ludovic.desroches@...rochip.com>,
        Andy Gross <agross@...nel.org>,
        "bcm-kernel-feedback-list@...adcom.com" 
        <bcm-kernel-feedback-list@...adcom.com>,
        NXP Linux Team <linux-imx@....com>,
        "linux-serial@...r.kernel.org" <linux-serial@...r.kernel.org>,
        Vineet Gupta <vgupta@...nel.org>,
        Orson Zhai <orsonzhai@...il.com>,
        Tobias Klauser <tklauser@...tanz.ch>,
        Patrice Chotard <patrice.chotard@...s.st.com>,
        "Albert Ou" <aou@...s.berkeley.edu>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Manivannan Sadhasivam <mani@...nel.org>,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Takao Orito <orito.takao@...ionext.com>,
        Vladimir Zapolskiy <vz@...ia.com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Sudeep Holla <sudeep.holla@....com>,
        Richard Genoud <richard.genoud@...il.com>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        "Nicolas Ferre" <nicolas.ferre@...rochip.com>,
        "David S. Miller" <davem@...emloft.net>,
        Taichi Sugaya <sugaya.taichi@...ionext.com>,
        "Palmer Dabbelt" <palmer@...belt.com>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Kevin Hilman <khilman@...libre.com>,
        Baolin Wang <baolin.wang7@...il.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Andreas Färber <afaerber@...e.de>,
        "Maciej W. Rozycki" <macro@...am.me.uk>
Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character
 an unsigned char

From: Uwe Kleine-König
> Sent: 02 March 2022 17:53
> 
> On Wed, Mar 02, 2022 at 08:27:32AM +0100, Jiri Slaby wrote:
> > Currently, uart_console_write->putchar's second parameter (the
> > character) is of type int. It makes little sense, provided uart_console_write()
> > accepts the input string as "const char *s" and passes its content -- the
> > characters -- to putchar(). So switch the character's type to unsigned
> > char.
> >
> > We don't use char as that is signed on some platforms. That would cause
> > troubles for drivers which (implicitly) cast the char to u16 when
> > writing to the device. Sign extension would happen in that case and the
> > value written would be completely different to the provided char. DZ is
> > an example of such a driver -- on MIPS, it uses u16 for dz_out in
> > dz_console_putchar().
> 
> I always thought this was bigger than 8bit for hardware that supports
> wider characters. But if that's the case that's completely unsupported,
> there isn't even CS9.

The real problem is that using char (or short) for a function parameter
or result is very likely to require the compile add code to mask
the value to 8 (or 16) bits.

Remember that almost every time you do anything with a signed or unsigned
char/short variable the compiler has to use the integer promotion rules
to convert the value to int.

You'll almost certainly get better code if the value is left in an
int (or unsigned int) variable until the low 8 bits get written to
a buffer (or hardware register).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ