提交 b170bad4 编写于 作者: S Sebastian Ott 提交者: Martin Schwidefsky

s390/pci: do not read data after failed load

If a pci load instruction fails the content of the register where the
data is stored is possibly unchanged. Fix the inline assembly wrapper
__pcilg to not return stale data. Additionally fix the callers of this
function who access uninitialized variables.
Reviewed-by: NGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: NSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 f0bacb7f
...@@ -92,6 +92,9 @@ static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len) ...@@ -92,6 +92,9 @@ static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len)
int cc; int cc;
cc = s390pci_load(&data, req, offset); cc = s390pci_load(&data, req, offset);
if (cc)
goto out;
switch (len) { switch (len) {
case 1: case 1:
*((u8 *) dst) = (u8) data; *((u8 *) dst) = (u8) data;
...@@ -106,6 +109,7 @@ static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len) ...@@ -106,6 +109,7 @@ static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len)
*((u64 *) dst) = (u64) data; *((u64 *) dst) = (u64) data;
break; break;
} }
out:
return cc; return cc;
} }
......
...@@ -281,11 +281,11 @@ static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) ...@@ -281,11 +281,11 @@ static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
int rc; int rc;
rc = s390pci_load(&data, req, offset); rc = s390pci_load(&data, req, offset);
data = data << ((8 - len) * 8); if (!rc) {
data = le64_to_cpu(data); data = data << ((8 - len) * 8);
if (!rc) data = le64_to_cpu(data);
*val = (u32) data; *val = (u32) data;
else } else
*val = 0xffffffff; *val = 0xffffffff;
return rc; return rc;
} }
......
...@@ -103,7 +103,9 @@ static inline int __pcilg(u64 *data, u64 req, u64 offset, u8 *status) ...@@ -103,7 +103,9 @@ static inline int __pcilg(u64 *data, u64 req, u64 offset, u8 *status)
: "d" (__offset) : "d" (__offset)
: "cc"); : "cc");
*status = __req >> 24 & 0xff; *status = __req >> 24 & 0xff;
*data = __data; if (!cc)
*data = __data;
return cc; return cc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册