]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.4/block-use-32-bit-blk_status_t-on-alpha.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / block-use-32-bit-blk_status_t-on-alpha.patch
1 From 6e2fb22103b99c26ae30a46512abe75526d8e4c9 Mon Sep 17 00:00:00 2001
2 From: Mikulas Patocka <mpatocka@redhat.com>
3 Date: Wed, 21 Mar 2018 12:42:25 -0400
4 Subject: block: use 32-bit blk_status_t on Alpha
5
6 From: Mikulas Patocka <mpatocka@redhat.com>
7
8 commit 6e2fb22103b99c26ae30a46512abe75526d8e4c9 upstream.
9
10 Early alpha processors cannot write a single byte or word; they read 8
11 bytes, modify the value in registers and write back 8 bytes.
12
13 The type blk_status_t is defined as one byte, it is often written
14 asynchronously by I/O completion routines, this asynchronous modification
15 can corrupt content of nearby bytes if these nearby bytes can be written
16 simultaneously by another CPU.
17
18 - one example of such corruption is the structure dm_io where
19 "blk_status_t status" is written by an asynchronous completion routine
20 and "atomic_t io_count" is modified synchronously
21 - another example is the structure dm_buffer where "unsigned hold_count"
22 is modified synchronously from process context and "blk_status_t
23 write_error" is modified asynchronously from bio completion routine
24
25 This patch fixes the bug by changing the type blk_status_t to 32 bits if
26 we are on Alpha and if we are compiling for a processor that doesn't have
27 the byte-word-extension.
28
29 Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
30 Cc: stable@vger.kernel.org # 4.13+
31 Signed-off-by: Jens Axboe <axboe@kernel.dk>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34 ---
35 include/linux/blk_types.h | 5 +++++
36 1 file changed, 5 insertions(+)
37
38 --- a/include/linux/blk_types.h
39 +++ b/include/linux/blk_types.h
40 @@ -20,8 +20,13 @@ typedef void (bio_end_io_t) (struct bio
41
42 /*
43 * Block error status values. See block/blk-core:blk_errors for the details.
44 + * Alpha cannot write a byte atomically, so we need to use 32-bit value.
45 */
46 +#if defined(CONFIG_ALPHA) && !defined(__alpha_bwx__)
47 +typedef u32 __bitwise blk_status_t;
48 +#else
49 typedef u8 __bitwise blk_status_t;
50 +#endif
51 #define BLK_STS_OK 0
52 #define BLK_STS_NOTSUPP ((__force blk_status_t)1)
53 #define BLK_STS_TIMEOUT ((__force blk_status_t)2)