1 // SPDX-License-Identifier: GPL-2.0+ 2 (* 3 * Copyright (C) 2015 Jade Alglave <j.alglave@u 4 * Copyright (C) 2016 Luc Maranget <luc.marange 5 * Copyright (C) 2017 Alan Stern <stern@rowland 6 * Andrea Parri <parri.andre 7 * 8 * An earlier version of this file appeared in 9 * "Frightening small children and disconcerti 10 * in the Linux kernel" by Alglave, Maranget, 11 * which appeared in ASPLOS 2018. 12 *) 13 14 "Linux-kernel memory consistency model" 15 16 enum Accesses = 'once (*READ_ONCE,WRITE_ONCE*) 17 'release (*smp_store_release*) 18 'acquire (*smp_load_acquire*) 19 'noreturn (* R of non-return R 20 instructions R[{'once,'acquire,'noreturn}] 21 instructions W[{'once,'release}] 22 instructions RMW[{'once,'acquire,'release}] 23 24 enum Barriers = 'wmb (*smp_wmb*) || 25 'rmb (*smp_rmb*) || 26 'mb (*smp_mb*) || 27 'barrier (*barrier*) || 28 'rcu-lock (*rcu_read_lock*) | 29 'rcu-unlock (*rcu_read_unlock* 30 'sync-rcu (*synchronize_rcu*) 31 'before-atomic (*smp_mb__befor 32 'after-atomic (*smp_mb__after_ 33 'after-spinlock (*smp_mb__afte 34 'after-unlock-lock (*smp_mb__a 35 'after-srcu-read-unlock (*smp_ 36 instructions F[Barriers] 37 38 (* SRCU *) 39 enum SRCU = 'srcu-lock || 'srcu-unlock || 'syn 40 instructions SRCU[SRCU] 41 (* All srcu events *) 42 let Srcu = Srcu-lock | Srcu-unlock | Sync-srcu 43 44 (* Compute matching pairs of nested Rcu-lock a 45 let rcu-rscs = let rec 46 unmatched-locks = Rcu-lock \ domai 47 and unmatched-unlocks = Rcu-unlock \ r 48 and unmatched = unmatched-locks | unma 49 and unmatched-po = [unmatched] ; po ; 50 and unmatched-locks-to-unlocks = 51 [unmatched-locks] ; po ; [unma 52 and matched = matched | (unmatched-loc 53 (unmatched-po ; unmatched-po)) 54 in matched 55 56 (* Validate nesting *) 57 flag ~empty Rcu-lock \ domain(rcu-rscs) as unm 58 flag ~empty Rcu-unlock \ range(rcu-rscs) as un 59 60 (* Compute matching pairs of nested Srcu-lock 61 let carry-srcu-data = (data ; [~ Srcu-unlock] 62 let srcu-rscs = ([Srcu-lock] ; carry-srcu-data 63 64 (* Validate nesting *) 65 flag ~empty Srcu-lock \ domain(srcu-rscs) as u 66 flag ~empty Srcu-unlock \ range(srcu-rscs) as 67 flag ~empty (srcu-rscs^-1 ; srcu-rscs) \ id as 68 69 (* Check for use of synchronize_srcu() inside 70 flag ~empty rcu-rscs & (po ; [Sync-srcu] ; po) 71 72 (* Validate SRCU dynamic match *) 73 flag ~empty different-values(srcu-rscs) as src 74 75 (* Compute marked and plain memory accesses *) 76 let Marked = (~M) | IW | Once | Release | Acqu 77 LKR | LKW | UL | LF | RL | RU 78 let Plain = M \ Marked 79 80 (* Redefine dependencies to include those carr 81 let carry-dep = (data ; [~ Srcu-unlock] ; rfi) 82 let addr = carry-dep ; addr 83 let ctrl = carry-dep ; ctrl 84 let data = carry-dep ; data
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.