Explorar el Código

fix(ntsync): reorder lockdep patches for android12-5.10 compat

- Remove unused 0001-mark-local_lock_t and 0002-fix-init-map-confusion
- Rename 0004-detect-recursive-read -> 0001 (sublevel ≤ 66 only)
- Rename 0003-assert-none-held -> 0002 (sublevel ≤ 209)
- Fixes hunk #2 failure in ntsync_compat_android12-5.10.patch
  (!!hlock->read context mismatch on 2022-01 baseline)
TheWildJames hace 1 mes
padre
commit
f337c3649d

+ 6 - 2
.github/actions/ntsync/action.yml

@@ -26,9 +26,13 @@ runs:
           rm -f drivers/misc/ntsync.c
         fi
 
-        # Apply lockdep_assert_none_held_once() for android12-5.10 only
+        # Apply lockdep prerequisites for android12-5.10 (2022-01 baseline)
+        if [[ ${{ inputs.version }} == "android12-5.10" && "${{ inputs.sublevel }}" -le "66" ]]; then
+          patch -p1 -N < ${{ github.action_path }}/patches/0001-lockdep-detect-recursive-read.patch
+        fi
+
         if [[ ${{ inputs.version }} == "android12-5.10" && "${{ inputs.sublevel }}" -le "209" ]]; then
-          patch -p1 -N < ${{ github.action_path }}/patches/0003-lockdep-assert-none-held.patch
+          patch -p1 -N < ${{ github.action_path }}/patches/0002-lockdep-assert-none-held.patch
         fi
 
         if [[ ${{ inputs.version }} = "android13-5.10" ]]; then

+ 42 - 0
.github/actions/ntsync/patches/0001-lockdep-detect-recursive-read.patch

@@ -0,0 +1,42 @@
+From fb4a58f5194e7391f4caff65041be243639ecbc5 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 3 Sep 2021 10:40:01 +0200
+Subject: [PATCH] lockdep: Let lock_is_held_type() detect recursive read as
+ read
+
+[ Upstream commit 2507003a1d10917c9158077bf6030719d02c941e ]
+
+lock_is_held_type(, 1) detects acquired read locks. It only recognized
+locks acquired with lock_acquire_shared(). Read locks acquired with
+lock_acquire_shared_recursive() are not recognized because a `2' is
+stored as the read value.
+
+Rework the check to additionally recognise lock's read value one and two
+as a read held lock.
+
+Fixes: e918188611f07 ("locking: More accurate annotations for read_lock()")
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Acked-by: Boqun Feng <boqun.feng@gmail.com>
+Acked-by: Waiman Long <longman@redhat.com>
+Link: https://lkml.kernel.org/r/20210903084001.lblecrvz4esl4mrr@linutronix.de
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/locking/lockdep.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
+index 282332914350..1f6a2f1226fa 100644
+--- a/kernel/locking/lockdep.c
++++ b/kernel/locking/lockdep.c
+@@ -5303,7 +5303,7 @@ int __lock_is_held(const struct lockdep_map *lock, int read)
+ 		struct held_lock *hlock = curr->held_locks + i;
+ 
+ 		if (match_held_lock(hlock, lock)) {
+-			if (read == -1 || hlock->read == read)
++			if (read == -1 || !!hlock->read == read)
+ 				return 1;
+ 
+ 			return 0;
+-- 
+2.55.0

+ 0 - 165
.github/actions/ntsync/patches/0001-lockdep-mark-local_lock_t.patch

@@ -1,165 +0,0 @@
-diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
-index 4a8795b..ded90b0 100644
---- a/include/linux/local_lock_internal.h
-+++ b/include/linux/local_lock_internal.h
-@@ -18,6 +18,7 @@ typedef struct {
- 	.dep_map = {					\
- 		.name = #lockname,			\
- 		.wait_type_inner = LD_WAIT_CONFIG,	\
-+		.lock_type = LD_LOCK_PERCPU,			\
- 	}
- #else
- # define LL_DEP_MAP_INIT(lockname)
-@@ -30,7 +31,9 @@ do {								\
- 	static struct lock_class_key __key;			\
- 								\
- 	debug_check_no_locks_freed((void *)lock, sizeof(*lock));\
--	lockdep_init_map_wait(&(lock)->dep_map, #lock, &__key, 0, LD_WAIT_CONFIG);\
-+	lockdep_init_map_type(&(lock)->dep_map, #lock, &__key, 0, \
-+			      LD_WAIT_CONFIG, LD_WAIT_INV,	\
-+			      LD_LOCK_PERCPU);			\
- } while (0)
- 
- #ifdef CONFIG_DEBUG_LOCK_ALLOC
-diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
-index f559487..20b6797 100644
---- a/include/linux/lockdep.h
-+++ b/include/linux/lockdep.h
-@@ -185,12 +185,19 @@ extern void lockdep_unregister_key(struct lock_class_key *key);
-  * to lockdep:
-  */
- 
--extern void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
--	struct lock_class_key *key, int subclass, short inner, short outer);
-+extern void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
-+	struct lock_class_key *key, int subclass, u8 inner, u8 outer, u8 lock_type);
-+
-+static inline void
-+lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
-+		       struct lock_class_key *key, int subclass, u8 inner, u8 outer)
-+{
-+	lockdep_init_map_type(lock, name, key, subclass, inner, LD_WAIT_INV, LD_LOCK_NORMAL);
-+}
- 
- static inline void
- lockdep_init_map_wait(struct lockdep_map *lock, const char *name,
--		      struct lock_class_key *key, int subclass, short inner)
-+		      struct lock_class_key *key, int subclass, u8 inner)
- {
- 	lockdep_init_map_waits(lock, name, key, subclass, inner, LD_WAIT_INV);
- }
-@@ -340,6 +347,8 @@ static inline void lockdep_set_selftest_task(struct task_struct *task)
- # define lock_set_class(l, n, k, s, i)		do { } while (0)
- # define lock_set_subclass(l, s, i)		do { } while (0)
- # define lockdep_init()				do { } while (0)
-+# define lockdep_init_map_type(lock, name, key, sub, inner, outer, type) \
-+		do { (void)(name); (void)(key); } while (0)
- # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \
- 		do { (void)(name); (void)(key); } while (0)
- # define lockdep_init_map_wait(lock, name, key, sub, inner) \
-diff --git a/include/linux/lockdep_types.h b/include/linux/lockdep_types.h
-index 9a1fd49..2ec9ff5 100644
---- a/include/linux/lockdep_types.h
-+++ b/include/linux/lockdep_types.h
-@@ -30,6 +30,12 @@ enum lockdep_wait_type {
- 	LD_WAIT_MAX,		/* must be last */
- };
- 
-+enum lockdep_lock_type {
-+	LD_LOCK_NORMAL = 0,	/* normal, catch all */
-+	LD_LOCK_PERCPU,		/* percpu */
-+	LD_LOCK_MAX,
-+};
-+
- #ifdef CONFIG_LOCKDEP
- 
- /*
-@@ -119,8 +125,10 @@ struct lock_class {
- 	int				name_version;
- 	const char			*name;
- 
--	short				wait_type_inner;
--	short				wait_type_outer;
-+	u8				wait_type_inner;
-+	u8				wait_type_outer;
-+	u8				lock_type;
-+	/* u8				hole; */
- 
- #ifdef CONFIG_LOCK_STAT
- 	unsigned long			contention_point[LOCKSTAT_POINTS];
-@@ -169,8 +177,10 @@ struct lockdep_map {
- 	struct lock_class_key		*key;
- 	struct lock_class		*class_cache[NR_LOCKDEP_CACHING_CLASSES];
- 	const char			*name;
--	short				wait_type_outer; /* can be taken in this context */
--	short				wait_type_inner; /* presents this context */
-+	u8				wait_type_outer; /* can be taken in this context */
-+	u8				wait_type_inner; /* presents this context */
-+	u8				lock_type;
-+	/* u8				hole; */
- #ifdef CONFIG_LOCK_STAT
- 	int				cpu;
- 	unsigned long			ip;
-diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
-index 8ae9d7a..5184f68 100644
---- a/kernel/locking/lockdep.c
-+++ b/kernel/locking/lockdep.c
-@@ -1293,6 +1293,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
- 	class->name_version = count_matching_names(class);
- 	class->wait_type_inner = lock->wait_type_inner;
- 	class->wait_type_outer = lock->wait_type_outer;
-+	class->lock_type = lock->lock_type;
- 	/*
- 	 * We use RCU's safe list-add method to make
- 	 * parallel walking of the hash-list safe:
-@@ -4621,9 +4622,9 @@ print_lock_invalid_wait_context(struct task_struct *curr,
-  */
- static int check_wait_context(struct task_struct *curr, struct held_lock *next)
- {
--	short next_inner = hlock_class(next)->wait_type_inner;
--	short next_outer = hlock_class(next)->wait_type_outer;
--	short curr_inner;
-+	u8 next_inner = hlock_class(next)->wait_type_inner;
-+	u8 next_outer = hlock_class(next)->wait_type_outer;
-+	u8 curr_inner;
- 	int depth;
- 
- 	if (!next_inner || next->trylock)
-@@ -4646,7 +4647,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
- 
- 	for (; depth < curr->lockdep_depth; depth++) {
- 		struct held_lock *prev = curr->held_locks + depth;
--		short prev_inner = hlock_class(prev)->wait_type_inner;
-+		u8 prev_inner = hlock_class(prev)->wait_type_inner;
- 
- 		if (prev_inner) {
- 			/*
-@@ -4695,9 +4696,9 @@ static inline int check_wait_context(struct task_struct *curr,
- /*
-  * Initialize a lock instance's lock-class mapping info:
-  */
--void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
-+void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
- 			    struct lock_class_key *key, int subclass,
--			    short inner, short outer)
-+			    u8 inner, u8 outer, u8 lock_type)
- {
- 	int i;
- 
-@@ -4720,6 +4721,7 @@ void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
- 
- 	lock->wait_type_outer = outer;
- 	lock->wait_type_inner = inner;
-+	lock->lock_type = lock_type;
- 
- 	/*
- 	 * No key, no joy, we need to hash something.
-@@ -4754,7 +4756,7 @@ void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
- 		raw_local_irq_restore(flags);
- 	}
- }
--EXPORT_SYMBOL_GPL(lockdep_init_map_waits);
-+EXPORT_SYMBOL_GPL(lockdep_init_map_type);
- 
- struct lock_class_key __lockdep_no_validate__;
- EXPORT_SYMBOL_GPL(__lockdep_no_validate__);

+ 0 - 0
.github/actions/ntsync/patches/0003-lockdep-assert-none-held.patch → .github/actions/ntsync/patches/0002-lockdep-assert-none-held.patch


+ 0 - 72
.github/actions/ntsync/patches/0002-lockdep-fix-init-map-confusion.patch

@@ -1,72 +0,0 @@
-diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
-index 20b6797..2c25863 100644
---- a/include/linux/lockdep.h
-+++ b/include/linux/lockdep.h
-@@ -192,7 +192,7 @@ static inline void
- lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
- 		       struct lock_class_key *key, int subclass, u8 inner, u8 outer)
- {
--	lockdep_init_map_type(lock, name, key, subclass, inner, LD_WAIT_INV, LD_LOCK_NORMAL);
-+	lockdep_init_map_type(lock, name, key, subclass, inner, outer, LD_LOCK_NORMAL);
- }
- 
- static inline void
-@@ -215,24 +215,28 @@ static inline void lockdep_init_map(struct lockdep_map *lock, const char *name,
-  * or they are too narrow (they suffer from a false class-split):
-  */
- #define lockdep_set_class(lock, key)				\
--	lockdep_init_map_waits(&(lock)->dep_map, #key, key, 0,	\
--			       (lock)->dep_map.wait_type_inner,	\
--			       (lock)->dep_map.wait_type_outer)
-+	lockdep_init_map_type(&(lock)->dep_map, #key, key, 0,	\
-+			      (lock)->dep_map.wait_type_inner,	\
-+			      (lock)->dep_map.wait_type_outer,	\
-+			      (lock)->dep_map.lock_type)
- 
- #define lockdep_set_class_and_name(lock, key, name)		\
--	lockdep_init_map_waits(&(lock)->dep_map, name, key, 0,	\
--			       (lock)->dep_map.wait_type_inner,	\
--			       (lock)->dep_map.wait_type_outer)
-+	lockdep_init_map_type(&(lock)->dep_map, name, key, 0,	\
-+			      (lock)->dep_map.wait_type_inner,	\
-+			      (lock)->dep_map.wait_type_outer,	\
-+			      (lock)->dep_map.lock_type)
- 
- #define lockdep_set_class_and_subclass(lock, key, sub)		\
--	lockdep_init_map_waits(&(lock)->dep_map, #key, key, sub,\
--			       (lock)->dep_map.wait_type_inner,	\
--			       (lock)->dep_map.wait_type_outer)
-+	lockdep_init_map_type(&(lock)->dep_map, #key, key, sub,	\
-+			      (lock)->dep_map.wait_type_inner,	\
-+			      (lock)->dep_map.wait_type_outer,	\
-+			      (lock)->dep_map.lock_type)
- 
- #define lockdep_set_subclass(lock, sub)					\
--	lockdep_init_map_waits(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\
--			       (lock)->dep_map.wait_type_inner,		\
--			       (lock)->dep_map.wait_type_outer)
-+	lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\
-+			      (lock)->dep_map.wait_type_inner,		\
-+			      (lock)->dep_map.wait_type_outer,		\
-+			      (lock)->dep_map.lock_type)
- 
- #define lockdep_set_novalidate_class(lock) \
- 	lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock)
-diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
-index c3387cdc..6cbd2b4 100644
---- a/kernel/locking/lockdep.c
-+++ b/kernel/locking/lockdep.c
-@@ -5139,9 +5139,10 @@ __lock_set_class(struct lockdep_map *lock, const char *name,
- 		return 0;
- 	}
- 
--	lockdep_init_map_waits(lock, name, key, 0,
--			       lock->wait_type_inner,
--			       lock->wait_type_outer);
-+	lockdep_init_map_type(lock, name, key, 0,
-+			      lock->wait_type_inner,
-+			      lock->wait_type_outer,
-+			      lock->lock_type);
- 	class = register_lock_class(lock, subclass, 0);
- 	hlock->class_idx = class - lock_classes;
-