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-next>] [day] [month] [year] [list]
Message-Id: <20210309224313.956065-1-laurent@vivier.eu>
Date:   Tue,  9 Mar 2021 23:43:13 +0100
From:   Laurent Vivier <laurent@...ier.eu>
To:     linux-kernel@...r.kernel.org
Cc:     virtualization@...ts.linux-foundation.org,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        Laurent Vivier <laurent@...ier.eu>
Subject: [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian

read[wl]()/write[wl] already access memory in little-endian mode.
No need to convert the value with cpu_to_leXX()/leXX_to_cpu()

Signed-off-by: Laurent Vivier <laurent@...ier.eu>
---
 drivers/virtio/virtio_mmio.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index a286d22b6551..3f6a5588f77d 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -168,17 +168,17 @@ static void vm_get(struct virtio_device *vdev, unsigned offset,
 		memcpy(buf, &b, sizeof b);
 		break;
 	case 2:
-		w = cpu_to_le16(readw(base + offset));
+		w = readw(base + offset);
 		memcpy(buf, &w, sizeof w);
 		break;
 	case 4:
-		l = cpu_to_le32(readl(base + offset));
+		l = readl(base + offset);
 		memcpy(buf, &l, sizeof l);
 		break;
 	case 8:
-		l = cpu_to_le32(readl(base + offset));
+		l = readl(base + offset);
 		memcpy(buf, &l, sizeof l);
-		l = cpu_to_le32(ioread32(base + offset + sizeof l));
+		l = ioread32(base + offset + sizeof l);
 		memcpy(buf + sizeof l, &l, sizeof l);
 		break;
 	default:
@@ -212,17 +212,17 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
 		break;
 	case 2:
 		memcpy(&w, buf, sizeof w);
-		writew(le16_to_cpu(w), base + offset);
+		writew(w, base + offset);
 		break;
 	case 4:
 		memcpy(&l, buf, sizeof l);
-		writel(le32_to_cpu(l), base + offset);
+		writel(l, base + offset);
 		break;
 	case 8:
 		memcpy(&l, buf, sizeof l);
-		writel(le32_to_cpu(l), base + offset);
+		writel(l, base + offset);
 		memcpy(&l, buf + sizeof l, sizeof l);
-		writel(le32_to_cpu(l), base + offset + sizeof l);
+		writel(l, base + offset + sizeof l);
 		break;
 	default:
 		BUG();
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ