nvme-cli/SOURCES/0001-Prevent-compiler-from-optimizing-mmio_read64-to-sing.patch
2021-09-09 22:59:22 +00:00

34 lines
912 B
Diff

From 33e60ff64a043b189d2661543b417b21b6f3667b Mon Sep 17 00:00:00 2001
From: Adam Judge <ajudge@iol.unh.edu>
Date: Tue, 9 Jun 2020 15:58:49 -0400
Subject: [PATCH] Prevent compiler from optimizing mmio_read64 to single 64b
read
---
nvme-print.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/nvme-print.c b/nvme-print.c
index fc8f99d..c0de928 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -1311,9 +1311,13 @@ static inline uint32_t mmio_read32(void *addr)
/* Access 64-bit registers as 2 32-bit; Some devices fail 64-bit MMIO. */
static inline __u64 mmio_read64(void *addr)
{
- __le32 *p = addr;
+ const volatile __u32 *p = addr;
+ __u32 low, high;
+
+ low = le32_to_cpu(*p);
+ high = le32_to_cpu(*(p + 1));
- return le32_to_cpu(*p) | ((uint64_t)le32_to_cpu(*(p + 1)) << 32);
+ return ((__u64) high << 32) | low;
}
static void json_ctrl_registers(void *bar)
--
2.31.1