From 1dd8074b61d49e5c3bd9f3940363e1e8906035ed Mon Sep 17 00:00:00 2001 From: Hsiu-Chang Chen Date: Tue, 6 Sep 2022 15:25:17 +0800 Subject: [PATCH 01/68] ANDROID: Update the ABI representation 1 symbol(s) added 'int __xa_insert(struct xarray *, unsigned long int, void *, gfp_t)' Bug: 245009352 Signed-off-by: Hsiu-Chang Chen Change-Id: I80dcbc7d4ef9c1429eace307845c67dc0604f8a0 --- android/abi_gki_aarch64.xml | 1423 ++++++++++++++----------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 652 insertions(+), 772 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 631ec84b350a..16cecdb1603b 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -339,6 +339,7 @@ + @@ -4068,71 +4069,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4888,7 +4824,7 @@ - + @@ -7619,43 +7555,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8728,7 +8664,7 @@ - + @@ -10135,9 +10071,6 @@ - - - @@ -11412,15 +11345,15 @@ - + - + - + - + @@ -11626,7 +11559,7 @@ - + @@ -14504,7 +14437,7 @@ - + @@ -20966,7 +20899,7 @@ - + @@ -23333,7 +23266,7 @@ - + @@ -25287,7 +25220,7 @@ - + @@ -32728,7 +32661,7 @@ - + @@ -35471,7 +35404,7 @@ - + @@ -36763,17 +36696,7 @@ - - - - - - - - - - - + @@ -41370,7 +41293,7 @@ - + @@ -42831,7 +42754,6 @@ - @@ -45853,81 +45775,81 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46118,14 +46040,6 @@ - - - - - - - - @@ -46421,13 +46335,13 @@ - + - + - + @@ -46436,7 +46350,7 @@ - + @@ -50408,7 +50322,7 @@ - + @@ -52921,7 +52835,6 @@ - @@ -54814,24 +54727,24 @@ - + - + - + - + - + - + - + @@ -56227,61 +56140,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -59342,15 +59255,15 @@ - + - + - + - + @@ -59693,7 +59606,7 @@ - + @@ -59775,7 +59688,7 @@ - + @@ -63538,7 +63451,7 @@ - + @@ -64241,7 +64154,7 @@ - + @@ -65093,25 +65006,25 @@ - + - + - + - + - + - + - + @@ -67657,7 +67570,7 @@ - + @@ -67684,7 +67597,7 @@ - + @@ -67695,7 +67608,7 @@ - + @@ -68407,7 +68320,7 @@ - + @@ -68420,7 +68333,7 @@ - + @@ -68450,7 +68363,7 @@ - + @@ -68493,7 +68406,7 @@ - + @@ -68520,7 +68433,7 @@ - + @@ -68528,7 +68441,7 @@ - + @@ -68536,7 +68449,7 @@ - + @@ -68549,25 +68462,25 @@ - + - + - + - + - + - + - + @@ -68600,7 +68513,7 @@ - + @@ -68611,7 +68524,7 @@ - + @@ -68624,7 +68537,7 @@ - + @@ -68670,7 +68583,7 @@ - + @@ -68695,15 +68608,15 @@ - + - + - + @@ -68711,7 +68624,7 @@ - + @@ -68797,7 +68710,7 @@ - + @@ -68805,21 +68718,21 @@ - + - + - + - + - + @@ -68856,10 +68769,10 @@ - + - + @@ -68875,7 +68788,7 @@ - + @@ -68902,10 +68815,10 @@ - + - + @@ -68949,7 +68862,7 @@ - + @@ -68962,7 +68875,7 @@ - + @@ -68992,7 +68905,7 @@ - + @@ -69005,7 +68918,7 @@ - + @@ -69041,13 +68954,13 @@ - + - + - + @@ -69108,7 +69021,7 @@ - + @@ -69119,13 +69032,13 @@ - + - + @@ -69133,7 +69046,7 @@ - + @@ -69149,7 +69062,7 @@ - + @@ -69253,7 +69166,7 @@ - + @@ -69402,10 +69315,10 @@ - + - + @@ -69421,27 +69334,27 @@ - + - + - + - + - + - + - + @@ -69457,22 +69370,22 @@ - + - + - + - + - + - + @@ -69496,36 +69409,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69536,7 +69449,7 @@ - + @@ -69560,96 +69473,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69662,13 +69575,13 @@ - + - + - + @@ -69802,7 +69715,7 @@ - + @@ -72624,15 +72537,15 @@ - + - + - + - + @@ -74231,7 +74144,7 @@ - + @@ -74278,7 +74191,6 @@ - @@ -82834,7 +82746,7 @@ - + @@ -84236,7 +84148,7 @@ - + @@ -84316,22 +84228,22 @@ - + - + - + - + - + - + @@ -89909,7 +89821,7 @@ - + @@ -90306,9 +90218,6 @@ - - - @@ -90439,12 +90348,12 @@ - + - + - + @@ -93708,7 +93617,7 @@ - + @@ -94746,39 +94655,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -94786,7 +94663,7 @@ - + @@ -94794,7 +94671,7 @@ - + @@ -94805,7 +94682,7 @@ - + @@ -94813,7 +94690,7 @@ - + @@ -94830,7 +94707,7 @@ - + @@ -94838,7 +94715,7 @@ - + @@ -94846,7 +94723,7 @@ - + @@ -94860,7 +94737,7 @@ - + @@ -94874,12 +94751,12 @@ - + - + @@ -94893,7 +94770,7 @@ - + @@ -94910,7 +94787,7 @@ - + @@ -94921,7 +94798,7 @@ - + @@ -94938,7 +94815,7 @@ - + @@ -94946,7 +94823,7 @@ - + @@ -94957,7 +94834,7 @@ - + @@ -94968,7 +94845,7 @@ - + @@ -94976,7 +94853,7 @@ - + @@ -95152,13 +95029,13 @@ - + - + @@ -95169,7 +95046,7 @@ - + @@ -95180,7 +95057,7 @@ - + @@ -95188,7 +95065,7 @@ - + @@ -95196,7 +95073,7 @@ - + @@ -95210,7 +95087,7 @@ - + @@ -95218,7 +95095,7 @@ - + @@ -95226,7 +95103,7 @@ - + @@ -95234,7 +95111,7 @@ - + @@ -95242,7 +95119,7 @@ - + @@ -95253,7 +95130,7 @@ - + @@ -95261,7 +95138,7 @@ - + @@ -95275,7 +95152,7 @@ - + @@ -95286,7 +95163,7 @@ - + @@ -95294,7 +95171,7 @@ - + @@ -95302,7 +95179,7 @@ - + @@ -95310,7 +95187,7 @@ - + @@ -95330,7 +95207,7 @@ - + @@ -95344,7 +95221,7 @@ - + @@ -95361,7 +95238,7 @@ - + @@ -95375,7 +95252,7 @@ - + @@ -95389,7 +95266,7 @@ - + @@ -95397,7 +95274,7 @@ - + @@ -95411,7 +95288,7 @@ - + @@ -95422,7 +95299,7 @@ - + @@ -95439,7 +95316,7 @@ - + @@ -95447,7 +95324,7 @@ - + @@ -95455,7 +95332,7 @@ - + @@ -95466,7 +95343,7 @@ - + @@ -95477,7 +95354,7 @@ - + @@ -95485,7 +95362,7 @@ - + @@ -95502,7 +95379,7 @@ - + @@ -95525,7 +95402,7 @@ - + @@ -95533,7 +95410,7 @@ - + @@ -95544,7 +95421,7 @@ - + @@ -95558,18 +95435,18 @@ - + - + - + @@ -95595,7 +95472,7 @@ - + @@ -95606,7 +95483,7 @@ - + @@ -95614,7 +95491,7 @@ - + @@ -95634,7 +95511,7 @@ - + @@ -95645,7 +95522,7 @@ - + @@ -95656,12 +95533,12 @@ - + - + @@ -95669,7 +95546,7 @@ - + @@ -95677,7 +95554,7 @@ - + @@ -95685,7 +95562,7 @@ - + @@ -95693,12 +95570,12 @@ - + - + @@ -95706,7 +95583,7 @@ - + @@ -95714,7 +95591,7 @@ - + @@ -95722,7 +95599,7 @@ - + @@ -95730,7 +95607,7 @@ - + @@ -95738,7 +95615,7 @@ - + @@ -95746,7 +95623,7 @@ - + @@ -95787,7 +95664,7 @@ - + @@ -95801,7 +95678,7 @@ - + @@ -95827,7 +95704,7 @@ - + @@ -95892,7 +95769,7 @@ - + @@ -95903,7 +95780,7 @@ - + @@ -95920,7 +95797,7 @@ - + @@ -95964,7 +95841,7 @@ - + @@ -95975,7 +95852,7 @@ - + @@ -95986,7 +95863,7 @@ - + @@ -96006,7 +95883,7 @@ - + @@ -96014,7 +95891,7 @@ - + @@ -96031,7 +95908,7 @@ - + @@ -96060,7 +95937,7 @@ - + @@ -96077,7 +95954,7 @@ - + @@ -96091,17 +95968,17 @@ - + - + - + @@ -96109,7 +95986,7 @@ - + @@ -96120,7 +95997,7 @@ - + @@ -96128,7 +96005,7 @@ - + @@ -96169,7 +96046,7 @@ - + @@ -96177,7 +96054,7 @@ - + @@ -96185,7 +96062,7 @@ - + @@ -96199,7 +96076,7 @@ - + @@ -96219,7 +96096,7 @@ - + @@ -96227,7 +96104,7 @@ - + @@ -96235,7 +96112,7 @@ - + @@ -96243,12 +96120,12 @@ - + - + @@ -96256,7 +96133,7 @@ - + @@ -96267,7 +96144,7 @@ - + @@ -96275,18 +96152,18 @@ - + - + - - + + @@ -96300,12 +96177,12 @@ - + - + @@ -96313,12 +96190,12 @@ - + - + @@ -96326,12 +96203,12 @@ - + - + @@ -96348,7 +96225,7 @@ - + @@ -96356,7 +96233,7 @@ - + @@ -96364,12 +96241,12 @@ - + - + @@ -96377,7 +96254,7 @@ - + @@ -96385,7 +96262,7 @@ - + @@ -96402,12 +96279,12 @@ - + - + @@ -96433,7 +96310,7 @@ - + @@ -96444,7 +96321,7 @@ - + @@ -96464,7 +96341,7 @@ - + @@ -96487,7 +96364,7 @@ - + @@ -96522,7 +96399,7 @@ - + @@ -96533,7 +96410,7 @@ - + @@ -96547,12 +96424,12 @@ - + - + @@ -96563,7 +96440,7 @@ - + @@ -96577,7 +96454,7 @@ - + @@ -96588,7 +96465,7 @@ - + @@ -96602,7 +96479,7 @@ - + @@ -96616,12 +96493,12 @@ - + - + @@ -96629,7 +96506,7 @@ - + @@ -96643,7 +96520,7 @@ - + @@ -96651,7 +96528,7 @@ - + @@ -96662,7 +96539,7 @@ - + @@ -96679,7 +96556,7 @@ - + @@ -96699,7 +96576,7 @@ - + @@ -96716,7 +96593,7 @@ - + @@ -96727,7 +96604,7 @@ - + @@ -96735,7 +96612,7 @@ - + @@ -96743,7 +96620,7 @@ - + @@ -96751,7 +96628,7 @@ - + @@ -96765,7 +96642,7 @@ - + @@ -96773,7 +96650,7 @@ - + @@ -96784,7 +96661,7 @@ - + @@ -96801,7 +96678,7 @@ - + @@ -96827,7 +96704,7 @@ - + @@ -96838,7 +96715,7 @@ - + @@ -96849,7 +96726,7 @@ - + @@ -97238,11 +97115,6 @@ - - - - - @@ -97581,7 +97453,7 @@ - + @@ -97715,30 +97587,30 @@ - + - + - + - + - + - + - + - + - + @@ -101532,7 +101404,7 @@ - + @@ -104247,7 +104119,7 @@ - + @@ -105545,7 +105417,7 @@ - + @@ -105974,11 +105846,11 @@ - - - - - + + + + + @@ -106423,14 +106295,14 @@ - - - + + + - - - + + + @@ -106639,9 +106511,9 @@ - - - + + + @@ -106699,8 +106571,8 @@ - - + + @@ -106780,9 +106652,9 @@ - - - + + + @@ -107084,12 +106956,12 @@ - - + + - - + + @@ -107109,10 +106981,10 @@ - - - - + + + + @@ -107129,22 +107001,22 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + + @@ -107153,12 +107025,12 @@ - - - - - - + + + + + + @@ -107168,17 +107040,17 @@ - - - - - + + + + + - - - - + + + + @@ -107226,11 +107098,11 @@ - - - - - + + + + + @@ -107259,9 +107131,9 @@ - - - + + + @@ -107276,15 +107148,15 @@ - - - - + + + + - - - + + + @@ -107332,21 +107204,21 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + @@ -107360,39 +107232,39 @@ - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + @@ -107476,10 +107348,10 @@ - - - - + + + + @@ -107572,11 +107444,11 @@ - - - - - + + + + + @@ -107584,11 +107456,11 @@ - - - - - + + + + + @@ -107908,47 +107780,47 @@ - + - - + + - + - - + + - + - + - - + + - - + + - - - - - + + + + + @@ -107960,7 +107832,7 @@ - + @@ -107975,9 +107847,9 @@ - + - + @@ -108107,6 +107979,13 @@ + + + + + + + @@ -108309,9 +108188,9 @@ - - - + + + @@ -108407,9 +108286,9 @@ - - - + + + @@ -108515,8 +108394,8 @@ - - + + @@ -114601,14 +114480,14 @@ - - - + + + - - - + + + @@ -114948,8 +114827,8 @@ - - + + @@ -116333,11 +116212,11 @@ - + - - + + @@ -116776,7 +116655,7 @@ - + @@ -116832,7 +116711,7 @@ - + @@ -117034,7 +116913,7 @@ - + @@ -117882,16 +117761,16 @@ - - - - - - + + + + + + - - + + @@ -118888,14 +118767,14 @@ - - - - + + + + - - + + @@ -119677,7 +119556,7 @@ - + @@ -119801,10 +119680,10 @@ - + - + @@ -120748,7 +120627,7 @@ - + @@ -120937,67 +120816,67 @@ - - + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + @@ -121277,10 +121156,10 @@ - - - - + + + + @@ -121423,9 +121302,9 @@ - - - + + + @@ -123200,19 +123079,19 @@ - - - - + + + + - - + + - - - + + + @@ -123351,10 +123230,10 @@ - - - - + + + + @@ -123481,8 +123360,8 @@ - - + + @@ -125376,8 +125255,8 @@ - - + + @@ -125630,8 +125509,8 @@ - - + + @@ -125667,9 +125546,9 @@ - - - + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 23ab56e53ad8..b5b8c15eddbc 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2666,6 +2666,7 @@ xa_find xa_find_after xa_get_mark + __xa_insert xa_load xa_set_mark xa_store From 23d664773fe7cfae6f2ee8fe37709d8b2ac0a55d Mon Sep 17 00:00:00 2001 From: Daeho Jeong Date: Mon, 20 Jun 2022 10:38:42 -0700 Subject: [PATCH 02/68] BACKPORT: f2fs: introduce memory mode Introduce memory mode to supports "normal" and "low" memory modes. "low" mode is to support low memory devices. Because of the nature of low memory devices, in this mode, f2fs will try to save memory sometimes by sacrificing performance. "normal" mode is the default mode and same as before. Bug: 232003054 Signed-off-by: Daeho Jeong Signed-off-by: Jaegeuk Kim (cherry picked from commit 60f60d1fd86a) Change-Id: I7cb719b18f0002d7af47f7a18e8ec2f4c534bdd9 --- Documentation/filesystems/f2fs.rst | 5 +++++ fs/f2fs/f2fs.h | 13 +++++++++++++ fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 5fda320354a6..b8cdd1fcb83e 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -342,6 +342,11 @@ discard_unit=%s Control discard unit, the argument can be "block", "segment" default, it is helpful for large sized SMR or ZNS devices to reduce memory cost by getting rid of fs metadata supports small discard. +memory=%s Control memory mode. This supports "normal" and "low" modes. + "low" mode is introduced to support low memory devices. + Because of the nature of low memory devices, in this mode, f2fs + will try to save memory sometimes by sacrificing performance. + "normal" mode is the default mode and same as before. ======================== ============================================================ Debugfs Entries diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 552ad16feeac..3c7c2f52b0d1 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -157,6 +157,7 @@ struct f2fs_mount_info { int fsync_mode; /* fsync policy */ int fs_mode; /* fs mode: LFS or ADAPTIVE */ int bggc_mode; /* bggc mode: off, on or sync */ + int memory_mode; /* memory mode */ int discard_unit; /* * discard command's offset/size should * be aligned to this unit: block, @@ -1367,6 +1368,13 @@ enum { DISCARD_UNIT_SECTION, /* basic discard unit is section */ }; +enum { + MEMORY_MODE_NORMAL, /* memory mode for normal devices */ + MEMORY_MODE_LOW, /* memory mode for low memry devices */ +}; + + + static inline int f2fs_test_bit(unsigned int nr, char *addr); static inline void f2fs_set_bit(unsigned int nr, char *addr); static inline void f2fs_clear_bit(unsigned int nr, char *addr); @@ -4423,6 +4431,11 @@ static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi) return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS; } +static inline bool f2fs_low_mem_mode(struct f2fs_sb_info *sbi) +{ + return F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW; +} + static inline bool f2fs_may_compress(struct inode *inode) { if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) || diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 48daa85746f8..4648cb843686 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -160,6 +160,7 @@ enum { Opt_gc_merge, Opt_nogc_merge, Opt_discard_unit, + Opt_memory_mode, Opt_err, }; @@ -237,6 +238,7 @@ static match_table_t f2fs_tokens = { {Opt_gc_merge, "gc_merge"}, {Opt_nogc_merge, "nogc_merge"}, {Opt_discard_unit, "discard_unit=%s"}, + {Opt_memory_mode, "memory=%s"}, {Opt_err, NULL}, }; @@ -1246,6 +1248,22 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) } kfree(name); break; + case Opt_memory_mode: + name = match_strdup(&args[0]); + if (!name) + return -ENOMEM; + if (!strcmp(name, "normal")) { + F2FS_OPTION(sbi).memory_mode = + MEMORY_MODE_NORMAL; + } else if (!strcmp(name, "low")) { + F2FS_OPTION(sbi).memory_mode = + MEMORY_MODE_LOW; + } else { + kfree(name); + return -EINVAL; + } + kfree(name); + break; default: f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value", p); @@ -2028,6 +2046,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION) seq_printf(seq, ",discard_unit=%s", "section"); + if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL) + seq_printf(seq, ",memory=%s", "normal"); + else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW) + seq_printf(seq, ",memory=%s", "low"); + return 0; } @@ -2050,6 +2073,7 @@ static void default_options(struct f2fs_sb_info *sbi) F2FS_OPTION(sbi).compress_ext_cnt = 0; F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS; F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; + F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL; sbi->sb->s_flags &= ~SB_INLINECRYPT; From 8ecc3b8d53b19d99e4fdb94b25aadecc9a8d3ecd Mon Sep 17 00:00:00 2001 From: Daeho Jeong Date: Tue, 2 Aug 2022 12:24:37 -0700 Subject: [PATCH 03/68] BACKPORT: f2fs: handle decompress only post processing in softirq Now decompression is being handled in workqueue and it makes read I/O latency non-deterministic, because of the non-deterministic scheduling nature of workqueues. So, I made it handled in softirq context only if possible, not in low memory devices, since this modification will maintain decompresion related memory a little longer. Bug: 232003054 Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Change-Id: I1a7c642e05c2f8544d475039b733403181de641e (cherry picked from commit 9ef8cd45d7a9) --- fs/f2fs/compress.c | 203 ++++++++++++++++++++++++++++++--------------- fs/f2fs/data.c | 52 ++++++++---- fs/f2fs/f2fs.h | 17 ++-- 3 files changed, 179 insertions(+), 93 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index e98a0ef71941..1e76c80a3eeb 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -728,14 +728,19 @@ out: return ret; } -void f2fs_decompress_cluster(struct decompress_io_ctx *dic) +static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic, + bool pre_alloc); +static void f2fs_release_decomp_mem(struct decompress_io_ctx *dic, + bool bypass_destroy_callback, bool pre_alloc); + +void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task) { struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode); struct f2fs_inode_info *fi = F2FS_I(dic->inode); const struct f2fs_compress_ops *cops = f2fs_cops[fi->i_compress_algorithm]; + bool bypass_callback = false; int ret; - int i; trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx, dic->cluster_size, fi->i_compress_algorithm); @@ -745,41 +750,10 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) goto out_end_io; } - dic->tpages = page_array_alloc(dic->inode, dic->cluster_size); - if (!dic->tpages) { - ret = -ENOMEM; - goto out_end_io; - } - - for (i = 0; i < dic->cluster_size; i++) { - if (dic->rpages[i]) { - dic->tpages[i] = dic->rpages[i]; - continue; - } - - dic->tpages[i] = f2fs_compress_alloc_page(); - if (!dic->tpages[i]) { - ret = -ENOMEM; - goto out_end_io; - } - } - - if (cops->init_decompress_ctx) { - ret = cops->init_decompress_ctx(dic); - if (ret) - goto out_end_io; - } - - dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size); - if (!dic->rbuf) { - ret = -ENOMEM; - goto out_destroy_decompress_ctx; - } - - dic->cbuf = f2fs_vmap(dic->cpages, dic->nr_cpages); - if (!dic->cbuf) { - ret = -ENOMEM; - goto out_vunmap_rbuf; + ret = f2fs_prepare_decomp_mem(dic, false); + if (ret) { + bypass_callback = true; + goto out_release; } dic->clen = le32_to_cpu(dic->cbuf->clen); @@ -787,7 +761,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) if (dic->clen > PAGE_SIZE * dic->nr_cpages - COMPRESS_HEADER_SIZE) { ret = -EFSCORRUPTED; - goto out_vunmap_cbuf; + goto out_release; } ret = cops->decompress_pages(dic); @@ -808,17 +782,13 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) } } -out_vunmap_cbuf: - vm_unmap_ram(dic->cbuf, dic->nr_cpages); -out_vunmap_rbuf: - vm_unmap_ram(dic->rbuf, dic->cluster_size); -out_destroy_decompress_ctx: - if (cops->destroy_decompress_ctx) - cops->destroy_decompress_ctx(dic); +out_release: + f2fs_release_decomp_mem(dic, bypass_callback, false); + out_end_io: trace_f2fs_decompress_pages_end(dic->inode, dic->cluster_idx, dic->clen, ret); - f2fs_decompress_end_io(dic, ret); + f2fs_decompress_end_io(dic, ret, in_task); } /* @@ -828,7 +798,7 @@ out_end_io: * (or in the case of a failure, cleans up without actually decompressing). */ void f2fs_end_read_compressed_page(struct page *page, bool failed, - block_t blkaddr) + block_t blkaddr, bool in_task) { struct decompress_io_ctx *dic = (struct decompress_io_ctx *)page_private(page); @@ -838,12 +808,12 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, if (failed) WRITE_ONCE(dic->failed, true); - else if (blkaddr) + else if (blkaddr && in_task) f2fs_cache_compressed_page(sbi, page, dic->inode->i_ino, blkaddr); if (atomic_dec_and_test(&dic->remaining_pages)) - f2fs_decompress_cluster(dic); + f2fs_decompress_cluster(dic, in_task); } static bool is_page_in_cluster(struct compress_ctx *cc, pgoff_t index) @@ -1551,16 +1521,85 @@ destroy_out: return err; } -static void f2fs_free_dic(struct decompress_io_ctx *dic); +static inline bool allow_memalloc_for_decomp(struct f2fs_sb_info *sbi, + bool pre_alloc) +{ + return pre_alloc ^ f2fs_low_mem_mode(sbi); +} + +static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic, + bool pre_alloc) +{ + const struct f2fs_compress_ops *cops = + f2fs_cops[F2FS_I(dic->inode)->i_compress_algorithm]; + int i; + + if (!allow_memalloc_for_decomp(F2FS_I_SB(dic->inode), pre_alloc)) + return 0; + + dic->tpages = page_array_alloc(dic->inode, dic->cluster_size); + if (!dic->tpages) + return -ENOMEM; + + for (i = 0; i < dic->cluster_size; i++) { + if (dic->rpages[i]) { + dic->tpages[i] = dic->rpages[i]; + continue; + } + + dic->tpages[i] = f2fs_compress_alloc_page(); + if (!dic->tpages[i]) + return -ENOMEM; + } + + dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size); + if (!dic->rbuf) + return -ENOMEM; + + dic->cbuf = f2fs_vmap(dic->cpages, dic->nr_cpages); + if (!dic->cbuf) + return -ENOMEM; + + if (cops->init_decompress_ctx) { + int ret = cops->init_decompress_ctx(dic); + + if (ret) + return ret; + } + + return 0; +} + +static void f2fs_release_decomp_mem(struct decompress_io_ctx *dic, + bool bypass_destroy_callback, bool pre_alloc) +{ + const struct f2fs_compress_ops *cops = + f2fs_cops[F2FS_I(dic->inode)->i_compress_algorithm]; + + if (!allow_memalloc_for_decomp(F2FS_I_SB(dic->inode), pre_alloc)) + return; + + if (!bypass_destroy_callback && cops->destroy_decompress_ctx) + cops->destroy_decompress_ctx(dic); + + if (dic->cbuf) + vm_unmap_ram(dic->cbuf, dic->nr_cpages); + + if (dic->rbuf) + vm_unmap_ram(dic->rbuf, dic->cluster_size); +} + +static void f2fs_free_dic(struct decompress_io_ctx *dic, + bool bypass_destroy_callback); struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) { struct decompress_io_ctx *dic; pgoff_t start_idx = start_idx_of_cluster(cc); - int i; + struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode); + int i, ret; - dic = f2fs_kmem_cache_alloc(dic_entry_slab, GFP_F2FS_ZERO, - false, F2FS_I_SB(cc->inode)); + dic = f2fs_kmem_cache_alloc(dic_entry_slab, GFP_F2FS_ZERO, false, sbi); if (!dic) return ERR_PTR(-ENOMEM); @@ -1586,32 +1625,43 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) dic->nr_rpages = cc->cluster_size; dic->cpages = page_array_alloc(dic->inode, dic->nr_cpages); - if (!dic->cpages) + if (!dic->cpages) { + ret = -ENOMEM; goto out_free; + } for (i = 0; i < dic->nr_cpages; i++) { struct page *page; page = f2fs_compress_alloc_page(); - if (!page) + if (!page) { + ret = -ENOMEM; goto out_free; + } f2fs_set_compressed_page(page, cc->inode, start_idx + i + 1, dic); dic->cpages[i] = page; } + ret = f2fs_prepare_decomp_mem(dic, true); + if (ret) + goto out_free; + return dic; out_free: - f2fs_free_dic(dic); - return ERR_PTR(-ENOMEM); + f2fs_free_dic(dic, true); + return ERR_PTR(ret); } -static void f2fs_free_dic(struct decompress_io_ctx *dic) +static void f2fs_free_dic(struct decompress_io_ctx *dic, + bool bypass_destroy_callback) { int i; + f2fs_release_decomp_mem(dic, bypass_destroy_callback, true); + if (dic->tpages) { for (i = 0; i < dic->cluster_size; i++) { if (dic->rpages[i]) @@ -1636,17 +1686,33 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic) kmem_cache_free(dic_entry_slab, dic); } -static void f2fs_put_dic(struct decompress_io_ctx *dic) +static void f2fs_late_free_dic(struct work_struct *work) { - if (refcount_dec_and_test(&dic->refcnt)) - f2fs_free_dic(dic); + struct decompress_io_ctx *dic = + container_of(work, struct decompress_io_ctx, free_work); + + f2fs_free_dic(dic, false); +} + +static void f2fs_put_dic(struct decompress_io_ctx *dic, bool in_task) +{ + if (refcount_dec_and_test(&dic->refcnt)) { + if (in_task) { + f2fs_free_dic(dic, false); + } else { + INIT_WORK(&dic->free_work, f2fs_late_free_dic); + queue_work(F2FS_I_SB(dic->inode)->post_read_wq, + &dic->free_work); + } + } } /* * Update and unlock the cluster's pagecache pages, and release the reference to * the decompress_io_ctx that was being held for I/O completion. */ -static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) +static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task) { int i; @@ -1667,7 +1733,7 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) unlock_page(rpage); } - f2fs_put_dic(dic); + f2fs_put_dic(dic, in_task); } static void f2fs_verify_cluster(struct work_struct *work) @@ -1684,14 +1750,15 @@ static void f2fs_verify_cluster(struct work_struct *work) SetPageError(rpage); } - __f2fs_decompress_end_io(dic, false); + __f2fs_decompress_end_io(dic, false, true); } /* * This is called when a compressed cluster has been decompressed * (or failed to be read and/or decompressed). */ -void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) +void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task) { if (!failed && dic->need_verity) { /* @@ -1703,7 +1770,7 @@ void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) INIT_WORK(&dic->verity_work, f2fs_verify_cluster); fsverity_enqueue_verify_work(&dic->verity_work); } else { - __f2fs_decompress_end_io(dic, failed); + __f2fs_decompress_end_io(dic, failed, in_task); } } @@ -1712,12 +1779,12 @@ void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) * * This is called when the page is no longer needed and can be freed. */ -void f2fs_put_page_dic(struct page *page) +void f2fs_put_page_dic(struct page *page, bool in_task) { struct decompress_io_ctx *dic = (struct decompress_io_ctx *)page_private(page); - f2fs_put_dic(dic); + f2fs_put_dic(dic, in_task); } /* diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 46a4322401b1..103e7038356f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -122,7 +122,7 @@ struct bio_post_read_ctx { block_t fs_blkaddr; }; -static void f2fs_finish_read_bio(struct bio *bio) +static void f2fs_finish_read_bio(struct bio *bio, bool in_task) { struct bio_vec *bv; struct bvec_iter_all iter_all; @@ -136,8 +136,9 @@ static void f2fs_finish_read_bio(struct bio *bio) if (f2fs_is_compressed_page(page)) { if (bio->bi_status) - f2fs_end_read_compressed_page(page, true, 0); - f2fs_put_page_dic(page); + f2fs_end_read_compressed_page(page, true, 0, + in_task); + f2fs_put_page_dic(page, in_task); continue; } @@ -194,7 +195,7 @@ static void f2fs_verify_bio(struct work_struct *work) fsverity_verify_bio(bio); } - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, true); } /* @@ -206,7 +207,7 @@ static void f2fs_verify_bio(struct work_struct *work) * can involve reading verity metadata pages from the file, and these verity * metadata pages may be encrypted and/or compressed. */ -static void f2fs_verify_and_finish_bio(struct bio *bio) +static void f2fs_verify_and_finish_bio(struct bio *bio, bool in_task) { struct bio_post_read_ctx *ctx = bio->bi_private; @@ -214,7 +215,7 @@ static void f2fs_verify_and_finish_bio(struct bio *bio) INIT_WORK(&ctx->work, f2fs_verify_bio); fsverity_enqueue_verify_work(&ctx->work); } else { - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, in_task); } } @@ -227,7 +228,8 @@ static void f2fs_verify_and_finish_bio(struct bio *bio) * that the bio includes at least one compressed page. The actual decompression * is done on a per-cluster basis, not a per-bio basis. */ -static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx) +static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx, + bool in_task) { struct bio_vec *bv; struct bvec_iter_all iter_all; @@ -240,7 +242,7 @@ static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx) /* PG_error was set if decryption failed. */ if (f2fs_is_compressed_page(page)) f2fs_end_read_compressed_page(page, PageError(page), - blkaddr); + blkaddr, in_task); else all_compressed = false; @@ -265,15 +267,16 @@ static void f2fs_post_read_work(struct work_struct *work) fscrypt_decrypt_bio(ctx->bio); if (ctx->enabled_steps & STEP_DECOMPRESS) - f2fs_handle_step_decompress(ctx); + f2fs_handle_step_decompress(ctx, true); - f2fs_verify_and_finish_bio(ctx->bio); + f2fs_verify_and_finish_bio(ctx->bio, true); } static void f2fs_read_end_io(struct bio *bio) { struct f2fs_sb_info *sbi = F2FS_P_SB(bio_first_page_all(bio)); struct bio_post_read_ctx *ctx; + bool intask = in_task(); iostat_update_and_unbind_ctx(bio, 0); ctx = bio->bi_private; @@ -284,16 +287,29 @@ static void f2fs_read_end_io(struct bio *bio) } if (bio->bi_status) { - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, intask); return; } - if (ctx && (ctx->enabled_steps & (STEP_DECRYPT | STEP_DECOMPRESS))) { - INIT_WORK(&ctx->work, f2fs_post_read_work); - queue_work(ctx->sbi->post_read_wq, &ctx->work); - } else { - f2fs_verify_and_finish_bio(bio); + if (ctx) { + unsigned int enabled_steps = ctx->enabled_steps & + (STEP_DECRYPT | STEP_DECOMPRESS); + + /* + * If we have only decompression step between decompression and + * decrypt, we don't need post processing for this. + */ + if (enabled_steps == STEP_DECOMPRESS && + !f2fs_low_mem_mode(sbi)) { + f2fs_handle_step_decompress(ctx, intask); + } else if (enabled_steps) { + INIT_WORK(&ctx->work, f2fs_post_read_work); + queue_work(ctx->sbi->post_read_wq, &ctx->work); + return; + } } + + f2fs_verify_and_finish_bio(bio, intask); } static void f2fs_write_end_io(struct bio *bio) @@ -2228,7 +2244,7 @@ skip_reading_dnode: if (f2fs_load_compressed_page(sbi, page, blkaddr)) { if (atomic_dec_and_test(&dic->remaining_pages)) - f2fs_decompress_cluster(dic); + f2fs_decompress_cluster(dic, true); continue; } @@ -2246,7 +2262,7 @@ submit_and_realloc: page->index, for_write); if (IS_ERR(bio)) { ret = PTR_ERR(bio); - f2fs_decompress_end_io(dic, ret); + f2fs_decompress_end_io(dic, ret, true); f2fs_put_dnode(&dn); *bio_ret = NULL; return ret; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3c7c2f52b0d1..d2d0a6e17ae3 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1595,6 +1595,7 @@ struct decompress_io_ctx { void *private; /* payload buffer for specified decompression algorithm */ void *private2; /* extra payload buffer */ struct work_struct verity_work; /* work to verify the decompressed pages */ + struct work_struct free_work; /* work for late free this structure itself */ }; #define NULL_CLUSTER ((unsigned int)(~0)) @@ -4185,9 +4186,9 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page); bool f2fs_is_compress_backend_ready(struct inode *inode); int f2fs_init_compress_mempool(void); void f2fs_destroy_compress_mempool(void); -void f2fs_decompress_cluster(struct decompress_io_ctx *dic); +void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task); void f2fs_end_read_compressed_page(struct page *page, bool failed, - block_t blkaddr); + block_t blkaddr, bool in_task); bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec *pvec, @@ -4206,8 +4207,9 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, unsigned nr_pages, sector_t *last_block_in_bio, bool is_readahead, bool for_write); struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc); -void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed); -void f2fs_put_page_dic(struct page *page); +void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task); +void f2fs_put_page_dic(struct page *page, bool in_task); unsigned int f2fs_cluster_blocks_are_contiguous(struct dnode_of_data *dn); int f2fs_init_compress_ctx(struct compress_ctx *cc); void f2fs_destroy_compress_ctx(struct compress_ctx *cc, bool reuse); @@ -4253,13 +4255,14 @@ static inline struct page *f2fs_compress_control_page(struct page *page) } static inline int f2fs_init_compress_mempool(void) { return 0; } static inline void f2fs_destroy_compress_mempool(void) { } -static inline void f2fs_decompress_cluster(struct decompress_io_ctx *dic) { } +static inline void f2fs_decompress_cluster(struct decompress_io_ctx *dic, + bool in_task) { } static inline void f2fs_end_read_compressed_page(struct page *page, - bool failed, block_t blkaddr) + bool failed, block_t blkaddr, bool in_task) { WARN_ON_ONCE(1); } -static inline void f2fs_put_page_dic(struct page *page) +static inline void f2fs_put_page_dic(struct page *page, bool in_task) { WARN_ON_ONCE(1); } From 68f703b19f82076aba0c9a1a798b2d6b6537f1df Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 12 Aug 2022 22:49:50 -0700 Subject: [PATCH 04/68] FROMGIT: f2fs: fix wrong continue condition in GC We should decrease the frozen counter. Cc: stable@vger.kernel.org Fixes: 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node") Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim (cherry picked from commit 605b0a778aa2599aa902ae639b8e9937c74b869b https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Change-Id: I892f215e778f7d89b9bbf3dfb292ed820944cf6b --- fs/f2fs/gc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 79dc38eacb19..e38beb82f61c 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -93,14 +93,10 @@ static int gc_thread_func(void *data) */ if (sbi->gc_mode == GC_URGENT_HIGH) { spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_limited) { - if (!sbi->gc_urgent_high_remaining) { - sbi->gc_urgent_high_limited = false; - spin_unlock(&sbi->gc_urgent_high_lock); - sbi->gc_mode = GC_NORMAL; - continue; - } - sbi->gc_urgent_high_remaining--; + if (sbi->gc_urgent_high_limited && + !sbi->gc_urgent_high_remaining--) { + sbi->gc_urgent_high_limited = false; + sbi->gc_mode = GC_NORMAL; } spin_unlock(&sbi->gc_urgent_high_lock); } From f18d40369c2afbe325dd06ba0a507499f6687f8a Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Sat, 20 Aug 2022 11:06:00 +0800 Subject: [PATCH 05/68] FROMGIT: f2fs: remove gc_urgent_high_limited for cleanup Remove redundant sbi->gc_urgent_high_limited. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim (cherry picked from commit 265576181b4afda8c60ae85261f55a8430419884 https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Change-Id: Id92efe0343922c0b0fc279332ec102f1d8de8ecc --- fs/f2fs/f2fs.h | 1 - fs/f2fs/gc.c | 8 ++++---- fs/f2fs/sysfs.c | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index d2d0a6e17ae3..1c2b5bd44cf2 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1728,7 +1728,6 @@ struct f2fs_sb_info { unsigned int gc_mode; /* current GC state */ unsigned int next_victim_seg[2]; /* next segment in victim section */ spinlock_t gc_urgent_high_lock; - bool gc_urgent_high_limited; /* indicates having limited trial count */ unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */ /* for skip statistic */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e38beb82f61c..3da5583f9dbb 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -93,10 +93,10 @@ static int gc_thread_func(void *data) */ if (sbi->gc_mode == GC_URGENT_HIGH) { spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_limited && - !sbi->gc_urgent_high_remaining--) { - sbi->gc_urgent_high_limited = false; - sbi->gc_mode = GC_NORMAL; + if (sbi->gc_urgent_high_remaining) { + sbi->gc_urgent_high_remaining--; + if (!sbi->gc_urgent_high_remaining) + sbi->gc_mode = GC_NORMAL; } spin_unlock(&sbi->gc_urgent_high_lock); } diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index f240f5593394..3ccbbee77cff 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -513,7 +513,6 @@ out: if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) { spin_lock(&sbi->gc_urgent_high_lock); - sbi->gc_urgent_high_limited = t != 0; sbi->gc_urgent_high_remaining = t; spin_unlock(&sbi->gc_urgent_high_lock); From 7a046711777024d45eeb48f97b6157b1c8081a6c Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 19 Aug 2022 15:52:02 -0700 Subject: [PATCH 06/68] FROMGIT: f2fs: flush pending checkpoints when freezing super This avoids -EINVAL when trying to freeze f2fs. Bug: 242127451 Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim Change-Id: Id2939642e3b93b42cf1ca03831d6c5e4e54d57fd (cherry picked from commit a36fe7301268524ffa56ff8a9ad0edec6bd5b85a https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/checkpoint.c | 24 ++++++++++++++++++------ fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 5 ++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index d93db6d29704..9aae2e6cc981 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -1895,15 +1895,27 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi) void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi) { struct ckpt_req_control *cprc = &sbi->cprc_info; + struct task_struct *ckpt_task; - if (cprc->f2fs_issue_ckpt) { - struct task_struct *ckpt_task = cprc->f2fs_issue_ckpt; + if (!cprc->f2fs_issue_ckpt) + return; - cprc->f2fs_issue_ckpt = NULL; - kthread_stop(ckpt_task); + ckpt_task = cprc->f2fs_issue_ckpt; + cprc->f2fs_issue_ckpt = NULL; + kthread_stop(ckpt_task); - flush_remained_ckpt_reqs(sbi, NULL); - } + f2fs_flush_ckpt_thread(sbi); +} + +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi) +{ + struct ckpt_req_control *cprc = &sbi->cprc_info; + + flush_remained_ckpt_reqs(sbi, NULL); + + /* Let's wait for the previous dispatched checkpoint. */ + while (atomic_read(&cprc->queued_ckpt)) + io_schedule_timeout(DEFAULT_IO_TIMEOUT); } void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 1c2b5bd44cf2..c5e7a34693b8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3681,6 +3681,7 @@ static inline bool f2fs_need_rand_seg(struct f2fs_sb_info *sbi) * checkpoint.c */ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io); +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi); struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 4648cb843686..22ec463155ff 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1689,9 +1689,8 @@ static int f2fs_freeze(struct super_block *sb) if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY)) return -EINVAL; - /* ensure no checkpoint required */ - if (!llist_empty(&F2FS_SB(sb)->cprc_info.issue_list)) - return -EINVAL; + /* Let's flush checkpoints and stop the thread. */ + f2fs_flush_ckpt_thread(F2FS_SB(sb)); /* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */ set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING); From 7af4b3ca302ba827f89c06ce837943e17f5213a6 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 18 Aug 2022 22:40:09 -0700 Subject: [PATCH 07/68] FROMGIT: f2fs: complete checkpoints during remount Otherwise, pending checkpoints can contribute a race condition to give a quota warning. - Thread - checkpoint thread add checkpoints to the list do_remount() down_write(&sb->s_umount); f2fs_remount() block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Or, do_remount() down_write(&sb->s_umount); f2fs_remount() create a ckpt thread f2fs_enable_checkpoint() adds checkpoints wait for f2fs_sync_fs() trigger another pending checkpoint block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Bug: 242127451 Bug: 215554521 Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim Change-Id: I85926fe14245058e48bac5699a7b760d7700c653 (cherry picked from commit d14393c5bff2f0c163e6bb384618300e30d19754 https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 22ec463155ff..b07d90a7f199 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2193,6 +2193,9 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) f2fs_up_write(&sbi->gc_lock); f2fs_sync_fs(sbi->sb, 1); + + /* Let's ensure there's no pending checkpoint anymore */ + f2fs_flush_ckpt_thread(sbi); } static int f2fs_remount(struct super_block *sb, int *flags, char *data) @@ -2359,6 +2362,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) f2fs_stop_ckpt_thread(sbi); need_restart_ckpt = true; } else { + /* Flush if the prevous checkpoint, if exists. */ + f2fs_flush_ckpt_thread(sbi); + err = f2fs_start_ckpt_thread(sbi); if (err) { f2fs_err(sbi, From 220890882465d2e6ed353fbe5a2d4a2b99c4c980 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 23 Aug 2022 10:18:42 -0700 Subject: [PATCH 08/68] FROMGIT: f2fs: increase the limit for reserve_root This patch increases the threshold that limits the reserved root space from 0.2% to 12.5% by using simple shift operation. Typically Android sets 128MB, but if the storage capacity is 32GB, 0.2% which is around 64MB becomes too small. Let's relax it. Bug: 243493735 Cc: stable@vger.kernel.org Reported-by: Aran Dalton Signed-off-by: Jaegeuk Kim Change-Id: Ia76ae8f9dd1c7a5f123a561f081bf5a4a29ac186 (cherry picked from commit cf42f1d7ab33ea2637f3c6b786a76302f719726b https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b07d90a7f199..bdea4ec6cebe 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -309,10 +309,10 @@ static void f2fs_destroy_casefold_cache(void) { } static inline void limit_reserve_root(struct f2fs_sb_info *sbi) { - block_t limit = min((sbi->user_block_count << 1) / 1000, + block_t limit = min((sbi->user_block_count >> 3), sbi->user_block_count - sbi->reserved_blocks); - /* limit is 0.2% */ + /* limit is 12.5% */ if (test_opt(sbi, RESERVE_ROOT) && F2FS_OPTION(sbi).root_reserved_blocks > limit) { F2FS_OPTION(sbi).root_reserved_blocks = limit; From 5c6d73ac2c042dabdc3d9d67b98212b1eb5204f8 Mon Sep 17 00:00:00 2001 From: Konstantin Vyshetsky Date: Wed, 20 Apr 2022 17:24:29 -0700 Subject: [PATCH 09/68] BACKPORT: scsi: ufs: core: Increase fDeviceInit poll frequency UFS devices are expected to clear fDeviceInit flag in single digit milliseconds. Current values of 5 to 10 millisecond sleep add to increased latency during the initialization and resume path. This CL lowers the sleep range to 500 to 1000 microseconds. Bug: 236993021 Link: https://lore.kernel.org/r/20220421002429.3136933-1-bvanassche@acm.org Acked-by: Avri Altman Signed-off-by: Konstantin Vyshetsky Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen (cherry picked from commit a4e6496fca3f32e997e8a3b5c44e2a1ae09d018e) Change-Id: I3a9a01853e89ea73ff5e355007db4730fa853ea0 --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b9df2db533d2..45ee1adefc08 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4553,7 +4553,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); if (!flag_res) break; - usleep_range(5000, 10000); + usleep_range(500, 1000); } while (ktime_before(ktime_get(), timeout)); if (err) { From 3d35c6b91d6d370ca5166efa990588ee43267721 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 11 Aug 2022 16:43:49 -0700 Subject: [PATCH 10/68] UPSTREAM: scsi: ufs: core: Reduce the power mode change timeout The current power mode change timeout (180 s) is so large that it can cause a watchdog timer to fire. Reduce the power mode change timeout to 10 seconds. Link: https://lore.kernel.org/r/20220811234401.1957911-1-bvanassche@acm.org Reviewed-by: Stanley Chu Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen (cherry picked from commit 8f2c96420c6ec3dcb18c8be923e24c6feaa5ccf6) Change-Id: I89a7f925812b6e1c4ca158bd7b22a41323557ec5 Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 45ee1adefc08..9ee325116902 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8826,6 +8826,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_device *sdp; unsigned long flags; int ret, retries; + unsigned long deadline; + int32_t remaining; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->sdev_ufs_device; @@ -8858,9 +8860,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ + deadline = jiffies + 10 * HZ; for (retries = 3; retries > 0; --retries) { + ret = -ETIMEDOUT; + remaining = deadline - jiffies; + if (remaining <= 0) + break; ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, - START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); + remaining / HZ, 0, 0, RQF_PM, NULL); if (!scsi_status_is_check_condition(ret) || !scsi_sense_valid(&sshdr) || sshdr.sense_key != UNIT_ATTENTION) From d451b4eee2469f8bafc6eb8db02728eacd851084 Mon Sep 17 00:00:00 2001 From: John Scheible Date: Thu, 8 Sep 2022 18:00:01 -0700 Subject: [PATCH 11/68] ANDROID: Update the ABI representation Add iommu_dma_enable_best_fit_algo symbol. 1 symbol(s) added 'int iommu_dma_enable_best_fit_algo(struct device *)' Bug: 245799843 Signed-off-by: John Scheible Change-Id: I5cc4d870556b62e43a3a5f717d23a512a138cb17 --- android/abi_gki_aarch64.xml | 822 +++++++++++++++++++------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 479 insertions(+), 344 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 16cecdb1603b..fa125a3765ea 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1910,6 +1910,7 @@ + @@ -4069,6 +4070,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4824,7 +4890,7 @@ - + @@ -7555,7 +7621,7 @@ - + @@ -8664,7 +8730,7 @@ - + @@ -10071,6 +10137,9 @@ + + + @@ -11559,7 +11628,7 @@ - + @@ -14437,7 +14506,7 @@ - + @@ -20899,7 +20968,7 @@ - + @@ -23266,7 +23335,7 @@ - + @@ -25220,7 +25289,7 @@ - + @@ -32661,7 +32730,7 @@ - + @@ -35404,7 +35473,7 @@ - + @@ -36696,7 +36765,17 @@ - + + + + + + + + + + + @@ -41293,7 +41372,7 @@ - + @@ -42754,6 +42833,7 @@ + @@ -46040,6 +46120,14 @@ + + + + + + + + @@ -46335,13 +46423,13 @@ - + - + - + @@ -46350,7 +46438,7 @@ - + @@ -50322,7 +50410,7 @@ - + @@ -52835,6 +52923,7 @@ + @@ -56140,61 +56229,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -59606,7 +59695,7 @@ - + @@ -59688,7 +59777,7 @@ - + @@ -63451,7 +63540,7 @@ - + @@ -64154,7 +64243,7 @@ - + @@ -65006,25 +65095,25 @@ - + - + - + - + - + - + - + @@ -67570,7 +67659,7 @@ - + @@ -67597,7 +67686,7 @@ - + @@ -67608,7 +67697,7 @@ - + @@ -68320,7 +68409,7 @@ - + @@ -68333,7 +68422,7 @@ - + @@ -68363,7 +68452,7 @@ - + @@ -68406,7 +68495,7 @@ - + @@ -68433,7 +68522,7 @@ - + @@ -68441,7 +68530,7 @@ - + @@ -68449,7 +68538,7 @@ - + @@ -68462,25 +68551,25 @@ - + - + - + - + - + - + - + @@ -68513,7 +68602,7 @@ - + @@ -68524,7 +68613,7 @@ - + @@ -68537,7 +68626,7 @@ - + @@ -68583,7 +68672,7 @@ - + @@ -68608,15 +68697,15 @@ - + - + - + @@ -68624,7 +68713,7 @@ - + @@ -68710,7 +68799,7 @@ - + @@ -68718,21 +68807,21 @@ - + - + - + - + - + @@ -68769,10 +68858,10 @@ - + - + @@ -68788,7 +68877,7 @@ - + @@ -68815,10 +68904,10 @@ - + - + @@ -68862,7 +68951,7 @@ - + @@ -68875,7 +68964,7 @@ - + @@ -68905,7 +68994,7 @@ - + @@ -68918,7 +69007,7 @@ - + @@ -68954,13 +69043,13 @@ - + - + - + @@ -69021,7 +69110,7 @@ - + @@ -69032,13 +69121,13 @@ - + - + @@ -69046,7 +69135,7 @@ - + @@ -69062,7 +69151,7 @@ - + @@ -69166,7 +69255,7 @@ - + @@ -69315,10 +69404,10 @@ - + - + @@ -69334,27 +69423,27 @@ - + - + - + - + - + - + - + @@ -69370,22 +69459,22 @@ - + - + - + - + - + - + @@ -69409,36 +69498,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69449,7 +69538,7 @@ - + @@ -69473,96 +69562,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69575,13 +69664,13 @@ - + - + - + @@ -69715,7 +69804,7 @@ - + @@ -74144,7 +74233,7 @@ - + @@ -74191,6 +74280,7 @@ + @@ -82746,7 +82836,7 @@ - + @@ -84148,7 +84238,7 @@ - + @@ -84228,22 +84318,22 @@ - + - + - + - + - + - + @@ -89821,7 +89911,7 @@ - + @@ -90218,6 +90308,9 @@ + + + @@ -93617,7 +93710,7 @@ - + @@ -94655,7 +94748,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -94663,7 +94788,7 @@ - + @@ -94671,7 +94796,7 @@ - + @@ -94682,7 +94807,7 @@ - + @@ -94690,7 +94815,7 @@ - + @@ -94707,7 +94832,7 @@ - + @@ -94715,7 +94840,7 @@ - + @@ -94723,7 +94848,7 @@ - + @@ -94737,7 +94862,7 @@ - + @@ -94751,12 +94876,12 @@ - + - + @@ -94770,7 +94895,7 @@ - + @@ -94787,7 +94912,7 @@ - + @@ -94798,7 +94923,7 @@ - + @@ -94815,7 +94940,7 @@ - + @@ -94823,7 +94948,7 @@ - + @@ -94834,7 +94959,7 @@ - + @@ -94845,7 +94970,7 @@ - + @@ -94853,7 +94978,7 @@ - + @@ -95029,13 +95154,13 @@ - + - + @@ -95046,7 +95171,7 @@ - + @@ -95057,7 +95182,7 @@ - + @@ -95065,7 +95190,7 @@ - + @@ -95073,7 +95198,7 @@ - + @@ -95087,7 +95212,7 @@ - + @@ -95095,7 +95220,7 @@ - + @@ -95103,7 +95228,7 @@ - + @@ -95111,7 +95236,7 @@ - + @@ -95119,7 +95244,7 @@ - + @@ -95130,7 +95255,7 @@ - + @@ -95138,7 +95263,7 @@ - + @@ -95152,7 +95277,7 @@ - + @@ -95163,7 +95288,7 @@ - + @@ -95171,7 +95296,7 @@ - + @@ -95179,7 +95304,7 @@ - + @@ -95187,7 +95312,7 @@ - + @@ -95207,7 +95332,7 @@ - + @@ -95221,7 +95346,7 @@ - + @@ -95238,7 +95363,7 @@ - + @@ -95252,7 +95377,7 @@ - + @@ -95266,7 +95391,7 @@ - + @@ -95274,7 +95399,7 @@ - + @@ -95288,7 +95413,7 @@ - + @@ -95299,7 +95424,7 @@ - + @@ -95316,7 +95441,7 @@ - + @@ -95324,7 +95449,7 @@ - + @@ -95332,7 +95457,7 @@ - + @@ -95343,7 +95468,7 @@ - + @@ -95354,7 +95479,7 @@ - + @@ -95362,7 +95487,7 @@ - + @@ -95379,7 +95504,7 @@ - + @@ -95402,7 +95527,7 @@ - + @@ -95410,7 +95535,7 @@ - + @@ -95421,7 +95546,7 @@ - + @@ -95435,18 +95560,18 @@ - + - + - + @@ -95472,7 +95597,7 @@ - + @@ -95483,7 +95608,7 @@ - + @@ -95491,7 +95616,7 @@ - + @@ -95511,7 +95636,7 @@ - + @@ -95522,7 +95647,7 @@ - + @@ -95533,12 +95658,12 @@ - + - + @@ -95546,7 +95671,7 @@ - + @@ -95554,7 +95679,7 @@ - + @@ -95562,7 +95687,7 @@ - + @@ -95570,12 +95695,12 @@ - + - + @@ -95583,7 +95708,7 @@ - + @@ -95591,7 +95716,7 @@ - + @@ -95599,7 +95724,7 @@ - + @@ -95607,7 +95732,7 @@ - + @@ -95615,7 +95740,7 @@ - + @@ -95623,7 +95748,7 @@ - + @@ -95664,7 +95789,7 @@ - + @@ -95678,7 +95803,7 @@ - + @@ -95704,7 +95829,7 @@ - + @@ -95769,7 +95894,7 @@ - + @@ -95780,7 +95905,7 @@ - + @@ -95797,7 +95922,7 @@ - + @@ -95841,7 +95966,7 @@ - + @@ -95852,7 +95977,7 @@ - + @@ -95863,7 +95988,7 @@ - + @@ -95883,7 +96008,7 @@ - + @@ -95891,7 +96016,7 @@ - + @@ -95908,7 +96033,7 @@ - + @@ -95937,7 +96062,7 @@ - + @@ -95954,7 +96079,7 @@ - + @@ -95968,17 +96093,17 @@ - + - + - + @@ -95986,7 +96111,7 @@ - + @@ -95997,7 +96122,7 @@ - + @@ -96005,7 +96130,7 @@ - + @@ -96046,7 +96171,7 @@ - + @@ -96054,7 +96179,7 @@ - + @@ -96062,7 +96187,7 @@ - + @@ -96076,7 +96201,7 @@ - + @@ -96096,7 +96221,7 @@ - + @@ -96104,7 +96229,7 @@ - + @@ -96112,7 +96237,7 @@ - + @@ -96120,12 +96245,12 @@ - + - + @@ -96133,7 +96258,7 @@ - + @@ -96144,7 +96269,7 @@ - + @@ -96152,18 +96277,18 @@ - + - + - - + + @@ -96177,12 +96302,12 @@ - + - + @@ -96190,12 +96315,12 @@ - + - + @@ -96203,12 +96328,12 @@ - + - + @@ -96225,7 +96350,7 @@ - + @@ -96233,7 +96358,7 @@ - + @@ -96241,12 +96366,12 @@ - + - + @@ -96254,7 +96379,7 @@ - + @@ -96262,7 +96387,7 @@ - + @@ -96279,12 +96404,12 @@ - + - + @@ -96310,7 +96435,7 @@ - + @@ -96321,7 +96446,7 @@ - + @@ -96341,7 +96466,7 @@ - + @@ -96364,7 +96489,7 @@ - + @@ -96399,7 +96524,7 @@ - + @@ -96410,7 +96535,7 @@ - + @@ -96424,12 +96549,12 @@ - + - + @@ -96440,7 +96565,7 @@ - + @@ -96454,7 +96579,7 @@ - + @@ -96465,7 +96590,7 @@ - + @@ -96479,7 +96604,7 @@ - + @@ -96493,12 +96618,12 @@ - + - + @@ -96506,7 +96631,7 @@ - + @@ -96520,7 +96645,7 @@ - + @@ -96528,7 +96653,7 @@ - + @@ -96539,7 +96664,7 @@ - + @@ -96556,7 +96681,7 @@ - + @@ -96576,7 +96701,7 @@ - + @@ -96593,7 +96718,7 @@ - + @@ -96604,7 +96729,7 @@ - + @@ -96612,7 +96737,7 @@ - + @@ -96620,7 +96745,7 @@ - + @@ -96628,7 +96753,7 @@ - + @@ -96642,7 +96767,7 @@ - + @@ -96650,7 +96775,7 @@ - + @@ -96661,7 +96786,7 @@ - + @@ -96678,7 +96803,7 @@ - + @@ -96704,7 +96829,7 @@ - + @@ -96715,7 +96840,7 @@ - + @@ -96726,7 +96851,7 @@ - + @@ -97115,6 +97240,11 @@ + + + + + @@ -97453,7 +97583,7 @@ - + @@ -101404,7 +101534,7 @@ - + @@ -104119,7 +104249,7 @@ - + @@ -105417,7 +105547,7 @@ - + @@ -116292,6 +116422,10 @@ + + + + @@ -123616,36 +123750,36 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index b5b8c15eddbc..fbfc15968c6f 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1092,6 +1092,7 @@ iommu_device_sysfs_remove iommu_device_unlink iommu_device_unregister + iommu_dma_enable_best_fit_algo iommu_domain_alloc iommu_domain_free iommu_fwspec_add_ids From 66047fb43166be89e8116444a948dd29f41fd562 Mon Sep 17 00:00:00 2001 From: Jack Diver Date: Fri, 9 Sep 2022 10:09:28 +0000 Subject: [PATCH 12/68] ANDROID: Update the ABI representation 1 symbol(s) added 'void __bitmap_xor(unsigned long int *, const unsigned long int *, const unsigned long int *, unsigned int)' Bug: 228779790 Signed-off-by: Jack Diver Change-Id: Ia7622941d313214eaf1aaf26aba64e0e149fa7ca --- android/abi_gki_aarch64.xml | 8 ++++++++ android/abi_gki_aarch64_generic | 1 + 2 files changed, 9 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index fa125a3765ea..ac5b15015083 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -23,6 +23,7 @@ + @@ -106038,6 +106039,13 @@ + + + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index fbfc15968c6f..966896aa05e3 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -78,6 +78,7 @@ __bitmap_set bitmap_to_arr32 __bitmap_weight + __bitmap_xor blk_abort_request blk_alloc_queue blk_check_plugged From aff23090349989a7aa39026fac2e27d5634cf2d4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 19 Jul 2022 11:09:01 -0700 Subject: [PATCH 13/68] BACKPORT: watchqueue: make sure to serialize 'wqueue->defunct' properly commit 353f7988dd8413c47718f7ca79c030b6fb62cfe5 upstream. When the pipe is closed, we mark the associated watchqueue defunct by calling watch_queue_clear(). However, while that is protected by the watchqueue lock, new watchqueue entries aren't actually added under that lock at all: they use the pipe->rd_wait.lock instead, and looking up that pipe happens without any locking. The watchqueue code uses the RCU read-side section to make sure that the wqueue entry itself hasn't disappeared, but that does not protect the pipe_info in any way. So make sure to actually hold the wqueue lock when posting watch events, properly serializing against the pipe being torn down. Bug: 235277737 Reported-by: Noam Rathaus Cc: Greg KH Cc: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I42b0d56021be1d8950c3642ae0acc5cdccadb394 --- kernel/watch_queue.c | 53 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index e3f144d96026..0d9f302a1bbe 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -34,6 +34,27 @@ MODULE_LICENSE("GPL"); #define WATCH_QUEUE_NOTE_SIZE 128 #define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE) +/* + * This must be called under the RCU read-lock, which makes + * sure that the wqueue still exists. It can then take the lock, + * and check that the wqueue hasn't been destroyed, which in + * turn makes sure that the notification pipe still exists. + */ +static inline bool lock_wqueue(struct watch_queue *wqueue) +{ + spin_lock_bh(&wqueue->lock); + if (unlikely(wqueue->defunct)) { + spin_unlock_bh(&wqueue->lock); + return false; + } + return true; +} + +static inline void unlock_wqueue(struct watch_queue *wqueue) +{ + spin_unlock_bh(&wqueue->lock); +} + static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { @@ -69,6 +90,10 @@ static const struct pipe_buf_operations watch_queue_pipe_buf_ops = { /* * Post a notification to a watch queue. + * + * Must be called with the RCU lock for reading, and the + * watch_queue lock held, which guarantees that the pipe + * hasn't been released. */ static bool post_one_notification(struct watch_queue *wqueue, struct watch_notification *n) @@ -85,9 +110,6 @@ static bool post_one_notification(struct watch_queue *wqueue, spin_lock_irq(&pipe->rd_wait.lock); - if (wqueue->defunct) - goto out; - mask = pipe->ring_size - 1; head = pipe->head; tail = pipe->tail; @@ -203,7 +225,10 @@ void __post_watch_notification(struct watch_list *wlist, if (security_post_notification(watch->cred, cred, n) < 0) continue; - post_one_notification(wqueue, n); + if (lock_wqueue(wqueue)) { + post_one_notification(wqueue, n); + unlock_wqueue(wqueue);; + } } rcu_read_unlock(); @@ -463,11 +488,12 @@ int add_watch_to_object(struct watch *watch, struct watch_list *wlist) return -EAGAIN; } - spin_lock_bh(&wqueue->lock); - kref_get(&wqueue->usage); - kref_get(&watch->usage); - hlist_add_head(&watch->queue_node, &wqueue->watches); - spin_unlock_bh(&wqueue->lock); + if (lock_wqueue(wqueue)) { + kref_get(&wqueue->usage); + kref_get(&watch->usage); + hlist_add_head(&watch->queue_node, &wqueue->watches); + unlock_wqueue(wqueue); + } hlist_add_head(&watch->list_node, &wlist->watchers); return 0; @@ -521,20 +547,15 @@ found: wqueue = rcu_dereference(watch->queue); - /* We don't need the watch list lock for the next bit as RCU is - * protecting *wqueue from deallocation. - */ - if (wqueue) { + if (lock_wqueue(wqueue)) { post_one_notification(wqueue, &n.watch); - spin_lock_bh(&wqueue->lock); - if (!hlist_unhashed(&watch->queue_node)) { hlist_del_init_rcu(&watch->queue_node); put_watch(watch); } - spin_unlock_bh(&wqueue->lock); + unlock_wqueue(wqueue); } if (wlist->release_watch) { From aa381a5c71469188ea57ff86f511341c66cdf285 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 7 Sep 2022 13:25:46 -0700 Subject: [PATCH 14/68] ANDROID: remove CONFIG_TRACEPOINTS from hook definition headers Remove the obsolete use of CONFIG_TRACEPOINTS in hook definition header files. The !CONFIG_TRACEPOINTS case is correctly handled by the included trace header files. Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: I957649bcfef375284f2885cf732ff2960c303837 --- include/trace/hooks/debug.h | 5 ----- include/trace/hooks/gpiolib.h | 4 ---- include/trace/hooks/iommu.h | 8 -------- include/trace/hooks/psi.h | 7 ------- 4 files changed, 24 deletions(-) diff --git a/include/trace/hooks/debug.h b/include/trace/hooks/debug.h index 892c60ac6f34..58ec198ceb6d 100644 --- a/include/trace/hooks/debug.h +++ b/include/trace/hooks/debug.h @@ -9,7 +9,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) #ifdef __GENKSYMS__ struct pt_regs; #else @@ -20,10 +19,6 @@ struct pt_regs; DECLARE_HOOK(android_vh_ipi_stop, TP_PROTO(struct pt_regs *regs), TP_ARGS(regs)) -#else -#define trace_android_vh_ipi_stop(regs) -#define trace_android_vh_ipi_stop_rcuidle(regs) -#endif #endif /* _TRACE_HOOK_DEBUG_H */ /* This part must be outside protection */ diff --git a/include/trace/hooks/gpiolib.h b/include/trace/hooks/gpiolib.h index 24cb3f54fb82..307fbaa2cae0 100644 --- a/include/trace/hooks/gpiolib.h +++ b/include/trace/hooks/gpiolib.h @@ -10,13 +10,9 @@ #include #include "../drivers/gpio/gpiolib.h" -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) DECLARE_HOOK(android_vh_gpio_block_read, TP_PROTO(struct gpio_device *gdev, bool *block_gpio_read), TP_ARGS(gdev, block_gpio_read)); -#else -#define trace_android_vh_gpio_block_read(gdev, block_gpio_read) -#endif #endif /* _TRACE_HOOK_GPIOLIB_H */ /* This part must be outside protection */ diff --git a/include/trace/hooks/iommu.h b/include/trace/hooks/iommu.h index 6c30cb7932fa..c09f1a4bf65a 100644 --- a/include/trace/hooks/iommu.h +++ b/include/trace/hooks/iommu.h @@ -11,7 +11,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) DECLARE_RESTRICTED_HOOK(android_rvh_iommu_setup_dma_ops, TP_PROTO(struct device *dev, u64 dma_base, u64 size), TP_ARGS(dev, dma_base, size), 1); @@ -23,13 +22,6 @@ DECLARE_HOOK(android_vh_iommu_alloc_iova, DECLARE_HOOK(android_vh_iommu_free_iova, TP_PROTO(dma_addr_t iova, size_t size), TP_ARGS(iova, size)); -#else - -#define trace_android_rvh_iommu_setup_dma_ops(dev, dma_base, size) -#define trace_android_vh_iommu_alloc_iova(dev, iova, size) -#define trace_android_vh_iommu_free_iova(iova, size) - -#endif #endif /* _TRACE_HOOK_IOMMU_H */ diff --git a/include/trace/hooks/psi.h b/include/trace/hooks/psi.h index ffda9543357e..32c7a273c5e2 100644 --- a/include/trace/hooks/psi.h +++ b/include/trace/hooks/psi.h @@ -9,8 +9,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) - #ifdef __GENKSYMS__ struct psi_group; struct psi_trigger; @@ -26,11 +24,6 @@ DECLARE_HOOK(android_vh_psi_group, TP_PROTO(struct psi_group *group), TP_ARGS(group)); -#else -#define trace_android_vh_psi_event(t) -#define trace_android_vh_psi_group(group) -#endif - #endif /* _TRACE_HOOK_PSI_H */ /* This part must be outside protection */ From d6ab8e3ba2d7f0060959bb607959cd8df5aa7b56 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Thu, 8 Sep 2022 20:49:23 +0000 Subject: [PATCH 15/68] Revert "ANDROID: arm64: smp: fix Lockdep warning: RCU used illegally from idle CPU." This reverts commit 4af50419dbc04512c2ca6c2085a2bf6b4a397541. Causes a build break for kernel_microdroid_aarch64 builds Change-Id: I385a8e56ae1245bccba4d1b641175e73807da88b Signed-off-by: Todd Kjos --- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index fd9c0ce1b645..da66f6ac590b 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -915,7 +915,7 @@ static void do_handle_IPI(int ipinr) break; case IPI_CPU_STOP: - trace_android_vh_ipi_stop_rcuidle(get_irq_regs()); + trace_android_vh_ipi_stop(get_irq_regs()); local_cpu_stop(); break; From 7108d9d0e5f2ff1a531dd36714c68a330ba84823 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 31 Aug 2022 15:59:29 -0700 Subject: [PATCH 16/68] ANDROID: remove inclusions from hook definition headers To avoid changing the visibiliy of data types when including hook definition headers remove header file inclusions from the hook definition header files. Instead, the hook definition headers should just have forward declarations that don't require full definition. To provide full definitions of the types for the KMI, the headers that define the types should be included by the source file that instantiates the hooks - normally vendor_hooks.c. Since the KMI is frozen, some of the inclusions are still required to preserve the CRC associated with symbols. Keep these inclusions under #ifdef __GENKSYMS__. This patch results in 17 fewer opaque types in the KMI (80 vs 97). Of the remaining 80 opaque types, 50 are defined in C files (and therefore are truly opaque and cannot be used by vendor modules). That leaves 30 types that still need definition in the KMI. Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: Ibc1173eb4b07fcec21c7abd8e0ab1950b3fb5b34 --- android/abi_gki_aarch64.xml | 6902 ++++++++++++++++++++------- drivers/android/vendor_hooks.c | 22 + include/trace/hooks/binder.h | 14 +- include/trace/hooks/block.h | 9 - include/trace/hooks/cgroup.h | 10 +- include/trace/hooks/cpufreq.h | 9 +- include/trace/hooks/cpuidle.h | 5 - include/trace/hooks/cpuidle_psci.h | 6 +- include/trace/hooks/creds.h | 8 +- include/trace/hooks/debug.h | 5 - include/trace/hooks/dtask.h | 12 +- include/trace/hooks/fault.h | 6 +- include/trace/hooks/fips140.h | 5 - include/trace/hooks/ftrace_dump.h | 5 +- include/trace/hooks/gic_v3.h | 8 +- include/trace/hooks/gpiolib.h | 5 + include/trace/hooks/gup.h | 5 - include/trace/hooks/logbuf.h | 5 - include/trace/hooks/mm.h | 20 +- include/trace/hooks/mmc_core.h | 9 - include/trace/hooks/mpam.h | 6 +- include/trace/hooks/net.h | 14 +- include/trace/hooks/pci.h | 3 + include/trace/hooks/pm_domain.h | 6 +- include/trace/hooks/power.h | 13 +- include/trace/hooks/psi.h | 6 +- include/trace/hooks/remoteproc.h | 5 - include/trace/hooks/rwsem.h | 6 +- include/trace/hooks/sched.h | 16 +- include/trace/hooks/shmem_fs.h | 6 +- include/trace/hooks/signal.h | 6 +- include/trace/hooks/softlockup.h | 6 +- include/trace/hooks/sys.h | 6 +- include/trace/hooks/syscall_check.h | 8 +- include/trace/hooks/thermal.h | 6 +- include/trace/hooks/topology.h | 5 + include/trace/hooks/traps.h | 6 +- include/trace/hooks/ufshcd.h | 9 - include/trace/hooks/usb.h | 8 +- include/trace/hooks/user.h | 6 +- include/trace/hooks/v4l2core.h | 10 +- include/trace/hooks/v4l2mc.h | 8 +- include/trace/hooks/workqueue.h | 6 +- 43 files changed, 5268 insertions(+), 1973 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index ac5b15015083..1b628cab49f8 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3964,7 +3964,7 @@ - + @@ -4115,16 +4115,16 @@ - + - + - + - + @@ -4219,6 +4219,14 @@ + + + + + + + + @@ -4356,7 +4364,20 @@ - + + + + + + + + + + + + + + @@ -4433,7 +4454,7 @@ - + @@ -4468,7 +4489,7 @@ - + @@ -4891,7 +4912,7 @@ - + @@ -4923,11 +4944,60 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5061,6 +5131,14 @@ + + + + + + + + @@ -5150,6 +5228,7 @@ + @@ -5180,6 +5259,14 @@ + + + + + + + + @@ -5337,9 +5424,12 @@ - + + + + @@ -5403,6 +5493,7 @@ + @@ -5466,6 +5557,7 @@ + @@ -5616,6 +5708,7 @@ + @@ -5762,6 +5855,7 @@ + @@ -6151,6 +6245,7 @@ + @@ -6372,43 +6467,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -6423,6 +6482,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6492,6 +6587,7 @@ + @@ -6912,7 +7008,7 @@ - + @@ -7052,12 +7148,20 @@ + + + + + + + + - + @@ -7310,6 +7414,7 @@ + @@ -7319,6 +7424,23 @@ + + + + + + + + + + + + + + + + + @@ -7585,7 +7707,7 @@ - + @@ -7594,6 +7716,9 @@ + + + @@ -7622,7 +7747,7 @@ - + @@ -7810,6 +7935,12 @@ + + + + + + @@ -8163,6 +8294,17 @@ + + + + + + + + + + + @@ -8290,42 +8432,42 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8342,7 +8484,19 @@ + + + + + + + + + + + + @@ -8731,7 +8885,7 @@ - + @@ -8789,6 +8943,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -8858,6 +9036,7 @@ + @@ -9017,6 +9196,7 @@ + @@ -9114,7 +9294,62 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9144,7 +9379,7 @@ - + @@ -9320,6 +9555,17 @@ + + + + + + + + + + + @@ -9341,6 +9587,14 @@ + + + + + + + + @@ -9357,7 +9611,7 @@ - + @@ -9617,14 +9871,16 @@ + - + + @@ -9712,7 +9968,23 @@ - + + + + + + + + + + + + + + + + + @@ -9844,7 +10116,7 @@ - + @@ -9856,7 +10128,7 @@ - + @@ -9883,10 +10155,10 @@ - + - + @@ -10717,7 +10989,7 @@ - + @@ -10746,52 +11018,60 @@ - - + - - - - - - - + - + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + @@ -11305,18 +11585,18 @@ - + - + - + - + - + @@ -11356,7 +11636,7 @@ - + @@ -11404,6 +11684,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11460,7 +11781,7 @@ - + @@ -11567,7 +11888,7 @@ - + @@ -11629,7 +11950,7 @@ - + @@ -11822,7 +12143,7 @@ - + @@ -12207,7 +12528,7 @@ - + @@ -12644,21 +12965,38 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + @@ -13031,7 +13369,7 @@ - + @@ -13317,6 +13655,7 @@ + @@ -13335,6 +13674,12 @@ + + + + + + @@ -13386,7 +13731,7 @@ - + @@ -13544,6 +13889,14 @@ + + + + + + + + @@ -13699,6 +14052,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -13752,6 +14128,7 @@ + @@ -13784,7 +14161,65 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -14011,6 +14446,12 @@ + + + + + + @@ -14077,7 +14518,7 @@ - + @@ -14459,6 +14900,10 @@ + + + + @@ -14507,7 +14952,7 @@ - + @@ -14673,6 +15118,12 @@ + + + + + + @@ -14752,9 +15203,12 @@ - + + + + @@ -15328,6 +15782,20 @@ + + + + + + + + + + + + + + @@ -15361,7 +15829,7 @@ - + @@ -15401,11 +15869,12 @@ + - + @@ -15587,6 +16056,7 @@ + @@ -15810,7 +16280,7 @@ - + @@ -15828,39 +16298,39 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -16001,6 +16471,8 @@ + + @@ -16221,6 +16693,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -16300,7 +16855,7 @@ - + @@ -16394,7 +16949,7 @@ - + @@ -16790,6 +17345,7 @@ + @@ -17240,7 +17796,194 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -17298,6 +18041,12 @@ + + + + + + @@ -17808,7 +18557,7 @@ - + @@ -17926,6 +18675,7 @@ + @@ -18099,7 +18849,20 @@ - + + + + + + + + + + + + + + @@ -18197,6 +18960,7 @@ + @@ -18768,6 +19532,14 @@ + + + + + + + + @@ -18799,6 +19571,7 @@ + @@ -18841,7 +19614,7 @@ - + @@ -19089,6 +19862,7 @@ + @@ -19416,6 +20190,23 @@ + + + + + + + + + + + + + + + + + @@ -19642,6 +20433,7 @@ + @@ -19888,7 +20680,7 @@ - + @@ -20403,6 +21195,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -20512,7 +21369,7 @@ - + @@ -20661,7 +21518,7 @@ - + @@ -20963,13 +21820,21 @@ + + + + + + + + - + @@ -20989,6 +21854,7 @@ + @@ -21073,6 +21939,7 @@ + @@ -21082,7 +21949,7 @@ - + @@ -21101,6 +21968,7 @@ + @@ -21132,6 +22000,20 @@ + + + + + + + + + + + + + + @@ -21437,6 +22319,7 @@ + @@ -21582,6 +22465,16 @@ + + + + + + + + + + @@ -21653,6 +22546,10 @@ + + + + @@ -22039,6 +22936,9 @@ + + + @@ -22112,6 +23012,12 @@ + + + + + + @@ -22122,6 +23028,7 @@ + @@ -22443,6 +23350,7 @@ + @@ -22515,6 +23423,7 @@ + @@ -22855,7 +23764,7 @@ - + @@ -22908,6 +23817,7 @@ + @@ -23087,6 +23997,7 @@ + @@ -23142,6 +24053,12 @@ + + + + + + @@ -23237,6 +24154,11 @@ + + + + + @@ -23336,7 +24258,7 @@ - + @@ -23942,6 +24864,14 @@ + + + + + + + + @@ -24377,6 +25307,7 @@ + @@ -24387,6 +25318,7 @@ + @@ -25290,7 +26222,7 @@ - + @@ -25346,6 +26278,14 @@ + + + + + + + + @@ -25661,6 +26601,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -25670,6 +26633,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -25771,7 +26775,7 @@ - + @@ -26322,27 +27326,27 @@ - + - + - + - + - + - + - + - + @@ -26424,6 +27428,9 @@ + + + @@ -26544,6 +27551,7 @@ + @@ -26748,6 +27756,12 @@ + + + + + + @@ -26867,7 +27881,7 @@ - + @@ -26918,7 +27932,7 @@ - + @@ -26926,6 +27940,9 @@ + + + @@ -27135,7 +28152,7 @@ - + @@ -27181,7 +28198,7 @@ - + @@ -27292,7 +28309,7 @@ - + @@ -27472,6 +28489,23 @@ + + + + + + + + + + + + + + + + + @@ -27492,7 +28526,7 @@ - + @@ -27505,6 +28539,11 @@ + + + + + @@ -27626,6 +28665,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -28098,11 +29169,12 @@ - + + @@ -28437,6 +29509,12 @@ + + + + + + @@ -28466,12 +29544,12 @@ - + - + @@ -28707,6 +29785,10 @@ + + + + @@ -28787,6 +29869,7 @@ + @@ -28797,7 +29880,7 @@ - + @@ -28954,7 +30037,7 @@ - + @@ -29045,6 +30128,14 @@ + + + + + + + + @@ -29098,6 +30189,7 @@ + @@ -29860,6 +30952,12 @@ + + + + + + @@ -30130,7 +31228,7 @@ - + @@ -30183,6 +31281,7 @@ + @@ -30261,7 +31360,7 @@ - + @@ -30312,6 +31411,12 @@ + + + + + + @@ -30584,6 +31689,10 @@ + + + + @@ -30742,6 +31851,7 @@ + @@ -31208,6 +32318,14 @@ + + + + + + + + @@ -31791,6 +32909,10 @@ + + + + @@ -31906,6 +33028,13 @@ + + + + + + + @@ -32333,7 +33462,7 @@ - + @@ -32344,7 +33473,14 @@ - + + + + + + + + @@ -32480,24 +33616,24 @@ - + - + - + - + - + - + - + @@ -32731,7 +33867,7 @@ - + @@ -32906,7 +34042,7 @@ - + @@ -32944,6 +34080,14 @@ + + + + + + + + @@ -33120,7 +34264,7 @@ - + @@ -33340,6 +34484,7 @@ + @@ -33494,7 +34639,22 @@ + + + + + + + + + + + + + + + @@ -33541,18 +34701,18 @@ - + - + - + - + - + @@ -34118,6 +35278,17 @@ + + + + + + + + + + + @@ -34237,7 +35408,7 @@ - + @@ -34303,7 +35474,7 @@ - + @@ -34659,6 +35830,7 @@ + @@ -34759,13 +35931,13 @@ - + - + - + @@ -34789,7 +35961,7 @@ - + @@ -34807,13 +35979,13 @@ - + - + @@ -34822,7 +35994,7 @@ - + @@ -34831,7 +36003,7 @@ - + @@ -35203,6 +36375,14 @@ + + + + + + + + @@ -35474,7 +36654,7 @@ - + @@ -35753,13 +36933,13 @@ - + - + @@ -35777,7 +36957,7 @@ - + @@ -35871,10 +37051,17 @@ + + + + + + + @@ -35980,6 +37167,7 @@ + @@ -36148,6 +37336,7 @@ + @@ -36791,6 +37980,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -36864,6 +38079,7 @@ + @@ -36886,7 +38102,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -37067,7 +38305,7 @@ - + @@ -37076,7 +38314,7 @@ - + @@ -37535,7 +38773,23 @@ - + + + + + + + + + + + + + + + + + @@ -37813,7 +39067,7 @@ - + @@ -38369,6 +39623,12 @@ + + + + + + @@ -38379,7 +39639,7 @@ - + @@ -39055,6 +40315,7 @@ + @@ -39085,7 +40346,7 @@ - + @@ -39438,6 +40699,14 @@ + + + + + + + + @@ -39689,9 +40958,15 @@ - + + + + + + + @@ -39907,6 +41182,7 @@ + @@ -40058,6 +41334,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -40146,6 +41470,20 @@ + + + + + + + + + + + + + + @@ -40851,7 +42189,7 @@ - + @@ -40917,6 +42255,7 @@ + @@ -41048,6 +42387,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -41373,7 +42735,7 @@ - + @@ -41850,6 +43212,7 @@ + @@ -41966,7 +43329,7 @@ - + @@ -42015,6 +43378,11 @@ + + + + + @@ -42115,7 +43483,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -42469,6 +43865,11 @@ + + + + + @@ -42623,7 +44024,7 @@ - + @@ -42639,6 +44040,7 @@ + @@ -43242,6 +44644,7 @@ + @@ -43744,6 +45147,11 @@ + + + + + @@ -43923,6 +45331,7 @@ + @@ -44134,6 +45543,7 @@ + @@ -44396,6 +45806,12 @@ + + + + + + @@ -44612,6 +46028,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44644,7 +46098,77 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44684,7 +46208,7 @@ - + @@ -44833,7 +46357,7 @@ - + @@ -45138,6 +46662,9 @@ + + + @@ -46170,6 +47697,13 @@ + + + + + + + @@ -46272,6 +47806,7 @@ + @@ -46424,13 +47959,13 @@ - + - + - + @@ -46439,7 +47974,7 @@ - + @@ -46453,7 +47988,7 @@ - + @@ -46476,7 +48011,7 @@ - + @@ -46522,7 +48057,7 @@ - + @@ -46617,6 +48152,14 @@ + + + + + + + + @@ -47060,6 +48603,10 @@ + + + + @@ -47134,6 +48681,23 @@ + + + + + + + + + + + + + + + + + @@ -47703,7 +49267,7 @@ - + @@ -47816,6 +49380,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -47907,6 +49503,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -47978,6 +49594,14 @@ + + + + + + + + @@ -47995,7 +49619,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -48043,6 +49692,20 @@ + + + + + + + + + + + + + + @@ -48487,6 +50150,7 @@ + @@ -48600,7 +50264,7 @@ - + @@ -48763,6 +50427,12 @@ + + + + + + @@ -49168,12 +50838,34 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -49392,7 +51084,7 @@ - + @@ -49530,6 +51222,7 @@ + @@ -49676,7 +51369,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -50411,7 +52126,7 @@ - + @@ -50453,30 +52168,30 @@ - + - + - + - + - + - + - + - + - + @@ -50877,6 +52592,7 @@ + @@ -51003,7 +52719,7 @@ - + @@ -51142,6 +52858,7 @@ + @@ -51293,7 +53010,7 @@ - + @@ -51329,6 +53046,7 @@ + @@ -51492,7 +53210,146 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -51678,6 +53535,7 @@ + @@ -52104,6 +53962,11 @@ + + + + + @@ -52112,7 +53975,7 @@ - + @@ -52207,6 +54070,14 @@ + + + + + + + + @@ -52357,6 +54228,15 @@ + + + + + + + + + @@ -52515,7 +54395,7 @@ - + @@ -52548,6 +54428,11 @@ + + + + + @@ -52939,6 +54824,20 @@ + + + + + + + + + + + + + + @@ -53127,6 +55026,14 @@ + + + + + + + + @@ -53251,7 +55158,7 @@ - + @@ -53284,10 +55191,10 @@ - + - + @@ -53312,6 +55219,7 @@ + @@ -53480,7 +55388,7 @@ - + @@ -53587,6 +55495,7 @@ + @@ -53809,7 +55718,7 @@ - + @@ -53981,7 +55890,7 @@ - + @@ -54072,7 +55981,7 @@ - + @@ -54090,6 +55999,7 @@ + @@ -54575,10 +56485,15 @@ - + + + + + + @@ -54604,7 +56519,7 @@ - + @@ -55163,7 +57078,7 @@ - + @@ -55171,6 +57086,7 @@ + @@ -55439,7 +57355,20 @@ - + + + + + + + + + + + + + + @@ -55508,7 +57437,7 @@ - + @@ -56010,7 +57939,7 @@ - + @@ -56072,13 +58001,13 @@ - + - + @@ -56230,61 +58159,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56324,7 +58253,7 @@ - + @@ -56374,6 +58303,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -56416,16 +58365,16 @@ - + - + - + - + @@ -56569,7 +58518,53 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57517,15 +59512,15 @@ - + - + - + - + @@ -57715,6 +59710,9 @@ + + + @@ -57784,6 +59782,13 @@ + + + + + + + @@ -57852,6 +59857,10 @@ + + + + @@ -57966,6 +59975,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -58211,7 +60246,7 @@ - + @@ -58401,72 +60436,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -58509,6 +60544,7 @@ + @@ -58528,6 +60564,13 @@ + + + + + + + @@ -58902,7 +60945,7 @@ - + @@ -58981,6 +61024,12 @@ + + + + + + @@ -59210,6 +61259,20 @@ + + + + + + + + + + + + + + @@ -59266,7 +61329,7 @@ - + @@ -59696,7 +61759,7 @@ - + @@ -59768,6 +61831,15 @@ + + + + + + + + + @@ -59778,7 +61850,7 @@ - + @@ -59880,6 +61952,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -59938,6 +62033,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -60097,7 +62215,7 @@ - + @@ -60138,6 +62256,7 @@ + @@ -60281,7 +62400,7 @@ - + @@ -60310,6 +62429,13 @@ + + + + + + + @@ -60348,13 +62474,13 @@ - + - + @@ -60366,7 +62492,7 @@ - + @@ -60625,7 +62751,7 @@ - + @@ -60745,6 +62871,7 @@ + @@ -60930,12 +63057,12 @@ - + - + - + @@ -61112,6 +63239,17 @@ + + + + + + + + + + + @@ -61244,7 +63382,7 @@ - + @@ -61344,7 +63482,191 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62087,6 +64409,7 @@ + @@ -62331,7 +64654,7 @@ - + @@ -62403,7 +64726,7 @@ - + @@ -62847,6 +65170,7 @@ + @@ -63238,6 +65562,7 @@ + @@ -63289,7 +65614,7 @@ - + @@ -63302,7 +65627,7 @@ - + @@ -63422,7 +65747,7 @@ - + @@ -63541,7 +65866,7 @@ - + @@ -63559,7 +65884,7 @@ - + @@ -63586,7 +65911,7 @@ - + @@ -63834,16 +66159,27 @@ - + - + - + + + + + + + + + + + + @@ -63977,6 +66313,7 @@ + @@ -64244,7 +66581,7 @@ - + @@ -64489,6 +66826,9 @@ + + + @@ -64616,6 +66956,7 @@ + @@ -64739,6 +67080,7 @@ + @@ -64935,6 +67277,7 @@ + @@ -64962,7 +67305,7 @@ - + @@ -65096,25 +67439,25 @@ - + - + - + - + - + - + - + @@ -65267,6 +67610,7 @@ + @@ -65327,7 +67671,7 @@ - + @@ -65396,15 +67740,15 @@ - + - + - + @@ -65464,7 +67808,7 @@ - + @@ -65639,6 +67983,9 @@ + + + @@ -65902,11 +68249,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -66022,7 +68397,7 @@ - + @@ -66067,6 +68442,7 @@ + @@ -66078,6 +68454,7 @@ + @@ -66207,7 +68584,7 @@ - + @@ -66326,6 +68703,10 @@ + + + + @@ -66581,6 +68962,7 @@ + @@ -66692,7 +69074,7 @@ - + @@ -66833,6 +69215,7 @@ + @@ -66847,6 +69230,7 @@ + @@ -66916,7 +69300,7 @@ - + @@ -66983,59 +69367,65 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + @@ -67058,7 +69448,7 @@ - + @@ -67214,7 +69604,7 @@ - + @@ -67400,7 +69790,7 @@ - + @@ -67660,7 +70050,7 @@ - + @@ -67687,7 +70077,7 @@ - + @@ -67698,7 +70088,7 @@ - + @@ -67749,66 +70139,160 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - + - - - - - - - - - - - - - - - - - + - + - + @@ -67825,23 +70309,23 @@ - + - + - + - + - + @@ -67852,15 +70336,15 @@ - + - + - + - + @@ -67877,7 +70361,7 @@ - + @@ -67885,7 +70369,7 @@ - + @@ -67896,12 +70380,12 @@ - + - + @@ -67909,7 +70393,7 @@ - + @@ -67917,7 +70401,7 @@ - + @@ -67925,7 +70409,7 @@ - + @@ -67933,7 +70417,7 @@ - + @@ -67950,7 +70434,7 @@ - + @@ -67967,21 +70451,21 @@ - + - + - + - + - + - + @@ -67992,7 +70476,7 @@ - + @@ -68000,12 +70484,12 @@ - + - + @@ -68013,7 +70497,7 @@ - + @@ -68024,7 +70508,7 @@ - + @@ -68035,7 +70519,7 @@ - + @@ -68046,12 +70530,12 @@ - + - + - + @@ -68059,13 +70543,13 @@ - + - + - + @@ -68073,7 +70557,7 @@ - + @@ -68081,7 +70565,7 @@ - + @@ -68089,7 +70573,7 @@ - + @@ -68097,7 +70581,7 @@ - + @@ -68108,7 +70592,7 @@ - + @@ -68122,7 +70606,7 @@ - + @@ -68130,7 +70614,7 @@ - + @@ -68138,7 +70622,7 @@ - + @@ -68146,7 +70630,7 @@ - + @@ -68172,12 +70656,12 @@ - + - + @@ -68185,23 +70669,23 @@ - + - + - + - + - + - + - + @@ -68209,7 +70693,7 @@ - + @@ -68235,7 +70719,7 @@ - + @@ -68246,7 +70730,7 @@ - + @@ -68254,7 +70738,7 @@ - + @@ -68262,7 +70746,7 @@ - + @@ -68273,7 +70757,7 @@ - + @@ -68281,7 +70765,7 @@ - + @@ -68292,7 +70776,7 @@ - + @@ -68300,7 +70784,7 @@ - + @@ -68311,7 +70795,7 @@ - + @@ -68322,7 +70806,7 @@ - + @@ -68330,7 +70814,7 @@ - + @@ -68350,19 +70834,19 @@ - + - + - + - - + + @@ -68370,7 +70854,7 @@ - + @@ -68378,7 +70862,7 @@ - + @@ -68386,7 +70870,7 @@ - + @@ -68394,7 +70878,7 @@ - + @@ -68405,15 +70889,15 @@ - + - + - + @@ -68421,15 +70905,15 @@ - + - + - + @@ -68437,7 +70921,7 @@ - + @@ -68445,7 +70929,7 @@ - + @@ -68453,10 +70937,10 @@ - + - + @@ -68464,7 +70948,7 @@ - + @@ -68472,7 +70956,7 @@ - + @@ -68483,7 +70967,7 @@ - + @@ -68494,15 +70978,15 @@ - + - + - + @@ -68510,7 +70994,7 @@ - + @@ -68518,31 +71002,31 @@ - + - + - + - + - + - + - + @@ -68550,33 +71034,33 @@ - + - + - + - + - + - + - + - + - + @@ -68590,7 +71074,7 @@ - + @@ -68598,15 +71082,15 @@ - + - + - + @@ -68614,10 +71098,10 @@ - + - + @@ -68625,15 +71109,15 @@ - + - + - + @@ -68644,7 +71128,7 @@ - + @@ -68652,7 +71136,7 @@ - + @@ -68663,7 +71147,7 @@ - + @@ -68671,15 +71155,15 @@ - + - + - + @@ -68693,31 +71177,31 @@ - + - + - + - + - + - + - + - + @@ -68725,7 +71209,7 @@ - + @@ -68736,7 +71220,7 @@ - + @@ -68744,7 +71228,15 @@ - + + + + + + + + + @@ -68752,7 +71244,7 @@ - + @@ -68760,7 +71252,7 @@ - + @@ -68771,7 +71263,7 @@ - + @@ -68779,7 +71271,7 @@ - + @@ -68787,7 +71279,7 @@ - + @@ -68795,37 +71287,37 @@ - + - + - + - + - + - + - + - + - + - + @@ -68833,7 +71325,7 @@ - + @@ -68841,7 +71333,7 @@ - + @@ -68849,23 +71341,23 @@ - + - + - + - + - + @@ -68873,15 +71365,15 @@ - + - + - + @@ -68889,7 +71381,7 @@ - + @@ -68903,15 +71395,15 @@ - + - + - + - + @@ -68919,7 +71411,7 @@ - + @@ -68933,7 +71425,7 @@ - + @@ -68947,15 +71439,15 @@ - + - + - + @@ -68963,9 +71455,9 @@ - + - + @@ -68977,7 +71469,7 @@ - + @@ -68985,7 +71477,7 @@ - + @@ -68993,12 +71485,12 @@ - + - + - + @@ -69006,15 +71498,15 @@ - + - + - + @@ -69034,7 +71526,7 @@ - + @@ -69042,18 +71534,18 @@ - + - + - + - + - + @@ -69061,7 +71553,7 @@ - + @@ -69069,7 +71561,7 @@ - + @@ -69077,7 +71569,7 @@ - + @@ -69091,7 +71583,7 @@ - + @@ -69111,7 +71603,7 @@ - + @@ -69120,26 +71612,26 @@ - + - + - + - + - + - + @@ -69147,15 +71639,15 @@ - + - + - + @@ -69163,7 +71655,7 @@ - + @@ -69174,7 +71666,7 @@ - + @@ -69182,7 +71674,7 @@ - + @@ -69193,7 +71685,7 @@ - + @@ -69204,7 +71696,7 @@ - + @@ -69218,7 +71710,7 @@ - + @@ -69226,7 +71718,7 @@ - + @@ -69243,7 +71735,7 @@ - + @@ -69251,15 +71743,15 @@ - + - + - + @@ -69267,7 +71759,7 @@ - + @@ -69293,12 +71785,12 @@ - + - + @@ -69339,7 +71831,7 @@ - + @@ -69347,7 +71839,7 @@ - + @@ -69355,7 +71847,7 @@ - + @@ -69363,7 +71855,7 @@ - + @@ -69371,15 +71863,15 @@ - + - + - + - + @@ -69387,7 +71879,7 @@ - + @@ -69395,7 +71887,7 @@ - + @@ -69403,18 +71895,18 @@ - + - + - + - + @@ -69422,32 +71914,32 @@ - + - + - + - + - + - + - + - + - + - + @@ -69455,30 +71947,49 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + @@ -69486,7 +71997,23 @@ - + + + + + + + + + + + + + + + + + @@ -69497,38 +72024,38 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -69537,15 +72064,15 @@ - + - + - + @@ -69553,7 +72080,7 @@ - + @@ -69561,101 +72088,101 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69663,38 +72190,38 @@ - + - + - + - + - + - + - + - + - + - + @@ -69702,7 +72229,7 @@ - + @@ -69710,7 +72237,7 @@ - + @@ -69718,7 +72245,7 @@ - + @@ -69726,7 +72253,7 @@ - + @@ -69734,7 +72261,7 @@ - + @@ -69742,7 +72269,7 @@ - + @@ -69753,7 +72280,7 @@ - + @@ -69761,7 +72288,7 @@ - + @@ -69771,6 +72298,7 @@ + @@ -69805,7 +72333,7 @@ - + @@ -70089,7 +72617,14 @@ - + + + + + + + + @@ -70231,6 +72766,7 @@ + @@ -70825,6 +73361,7 @@ + @@ -70859,6 +73396,7 @@ + @@ -71213,6 +73751,7 @@ + @@ -71662,6 +74201,7 @@ + @@ -71984,6 +74524,7 @@ + @@ -72165,6 +74706,11 @@ + + + + + @@ -72378,6 +74924,11 @@ + + + + + @@ -72408,10 +74959,12 @@ + + @@ -72519,7 +75072,7 @@ - + @@ -72553,6 +75106,11 @@ + + + + + @@ -72623,6 +75181,7 @@ + @@ -72689,10 +75248,26 @@ - + + + + + + + + + + + + + + + + + + - @@ -72917,7 +75492,7 @@ - + @@ -73027,6 +75602,12 @@ + + + + + + @@ -73402,7 +75983,7 @@ - + @@ -73633,6 +76214,7 @@ + @@ -73880,6 +76462,7 @@ + @@ -74027,6 +76610,7 @@ + @@ -74076,7 +76660,7 @@ - + @@ -74223,7 +76807,7 @@ - + @@ -74234,7 +76818,7 @@ - + @@ -74856,7 +77440,7 @@ - + @@ -75001,6 +77585,7 @@ + @@ -75139,9 +77724,6 @@ - - - @@ -75492,12 +78074,12 @@ - + - + - + @@ -75693,7 +78275,7 @@ - + @@ -75795,7 +78377,7 @@ - + @@ -75815,6 +78397,9 @@ + + + @@ -76569,7 +79154,7 @@ - + @@ -76707,312 +79292,312 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -77321,6 +79906,10 @@ + + + + @@ -77750,6 +80339,7 @@ + @@ -77967,7 +80557,7 @@ - + @@ -78186,6 +80776,12 @@ + + + + + + @@ -78200,6 +80796,7 @@ + @@ -78275,6 +80872,14 @@ + + + + + + + + @@ -78283,6 +80888,7 @@ + @@ -78307,6 +80913,7 @@ + @@ -78396,6 +81003,20 @@ + + + + + + + + + + + + + + @@ -78404,6 +81025,7 @@ + @@ -78438,7 +81060,7 @@ - + @@ -78516,6 +81138,7 @@ + @@ -78823,6 +81446,20 @@ + + + + + + + + + + + + + + @@ -78882,7 +81519,7 @@ - + @@ -78921,6 +81558,12 @@ + + + + + + @@ -79003,10 +81646,10 @@ - + - + @@ -79109,6 +81752,23 @@ + + + + + + + + + + + + + + + + + @@ -79375,7 +82035,7 @@ - + @@ -79710,7 +82370,7 @@ - + @@ -79812,7 +82472,7 @@ - + @@ -79829,7 +82489,7 @@ - + @@ -79891,6 +82551,13 @@ + + + + + + + @@ -79922,6 +82589,7 @@ + @@ -80015,6 +82683,7 @@ + @@ -80186,6 +82855,14 @@ + + + + + + + + @@ -81042,6 +83719,12 @@ + + + + + + @@ -81487,6 +84170,7 @@ + @@ -81575,6 +84259,7 @@ + @@ -81759,6 +84444,10 @@ + + + + @@ -82197,7 +84886,7 @@ - + @@ -82310,7 +84999,7 @@ - + @@ -82400,7 +85089,7 @@ - + @@ -82432,6 +85121,7 @@ + @@ -82801,7 +85491,7 @@ - + @@ -82837,7 +85527,7 @@ - + @@ -82955,9 +85645,6 @@ - - - @@ -83141,6 +85828,7 @@ + @@ -83608,13 +86296,13 @@ - + - + @@ -83712,7 +86400,7 @@ - + @@ -83826,7 +86514,7 @@ - + @@ -83840,7 +86528,7 @@ - + @@ -83962,13 +86650,13 @@ - + - + - + @@ -84016,7 +86704,7 @@ - + @@ -84122,6 +86810,14 @@ + + + + + + + + @@ -84239,7 +86935,7 @@ - + @@ -84319,22 +87015,22 @@ - + - + - + - + - + - + @@ -84481,6 +87177,17 @@ + + + + + + + + + + + @@ -84816,6 +87523,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -84894,7 +87657,7 @@ - + @@ -85120,7 +87883,7 @@ - + @@ -85255,7 +88018,7 @@ - + @@ -85360,7 +88123,7 @@ - + @@ -85572,6 +88335,7 @@ + @@ -85686,6 +88450,7 @@ + @@ -85718,7 +88483,28 @@ + + + + + + + + + + + + + + + + + + + + + @@ -85822,6 +88608,7 @@ + @@ -85965,7 +88752,7 @@ - + @@ -86148,7 +88935,7 @@ - + @@ -86219,6 +89006,17 @@ + + + + + + + + + + + @@ -86756,6 +89554,11 @@ + + + + + @@ -87126,7 +89929,7 @@ - + @@ -87135,7 +89938,7 @@ - + @@ -87531,6 +90334,9 @@ + + + @@ -87695,6 +90501,7 @@ + @@ -87734,6 +90541,7 @@ + @@ -88133,7 +90941,7 @@ - + @@ -88210,7 +91018,7 @@ - + @@ -88220,6 +91028,14 @@ + + + + + + + + @@ -88374,10 +91190,10 @@ - + - + @@ -89220,10 +92036,10 @@ - + - + @@ -89235,7 +92051,7 @@ - + @@ -89393,6 +92209,7 @@ + @@ -89593,6 +92410,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -89618,6 +92455,14 @@ + + + + + + + + @@ -89654,6 +92499,10 @@ + + + + @@ -89675,6 +92524,17 @@ + + + + + + + + + + + @@ -89754,7 +92614,86 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89912,7 +92851,7 @@ - + @@ -90013,7 +92952,7 @@ - + @@ -90231,7 +93170,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -90318,6 +93294,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -90395,7 +93394,7 @@ - + @@ -90893,6 +93892,7 @@ + @@ -91553,6 +94553,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -91678,6 +94707,12 @@ + + + + + + @@ -91862,7 +94897,7 @@ - + @@ -91886,6 +94921,11 @@ + + + + + @@ -92024,7 +95064,7 @@ - + @@ -92295,7 +95335,7 @@ - + @@ -92380,7 +95420,7 @@ - + @@ -92602,6 +95642,11 @@ + + + + + @@ -93711,7 +96756,7 @@ - + @@ -93944,21 +96989,21 @@ - + - + - + - + - + - + @@ -94010,6 +97055,9 @@ + + + @@ -94246,7 +97294,206 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -94254,7 +97501,15 @@ - + + + + + + + + + @@ -94262,7 +97517,7 @@ - + @@ -94270,7 +97525,7 @@ - + @@ -94317,7 +97572,7 @@ - + @@ -94328,7 +97583,7 @@ - + @@ -94348,7 +97603,7 @@ - + @@ -94371,7 +97626,7 @@ - + @@ -94391,26 +97646,26 @@ - + - + - + - + - + @@ -94424,7 +97679,7 @@ - + @@ -94432,7 +97687,7 @@ - + @@ -94452,7 +97707,7 @@ - + @@ -94475,7 +97730,7 @@ - + @@ -94483,7 +97738,7 @@ - + @@ -94491,7 +97746,7 @@ - + @@ -94499,7 +97754,7 @@ - + @@ -94507,7 +97762,7 @@ - + @@ -94533,17 +97788,17 @@ - + - + - + @@ -94551,17 +97806,17 @@ - + - + - + @@ -94578,7 +97833,7 @@ - + @@ -94592,7 +97847,7 @@ - + @@ -94606,7 +97861,7 @@ - + @@ -94635,7 +97890,7 @@ - + @@ -94652,7 +97907,7 @@ - + @@ -94666,7 +97921,7 @@ - + @@ -94680,7 +97935,7 @@ - + @@ -94694,7 +97949,7 @@ - + @@ -94705,7 +97960,7 @@ - + @@ -94719,15 +97974,15 @@ - + - + - + @@ -94735,7 +97990,7 @@ - + @@ -94749,12 +98004,12 @@ - + - + @@ -94762,7 +98017,7 @@ - + @@ -94770,7 +98025,7 @@ - + @@ -94781,7 +98036,7 @@ - + @@ -94789,7 +98044,7 @@ - + @@ -94797,7 +98052,7 @@ - + @@ -94808,7 +98063,7 @@ - + @@ -94816,7 +98071,7 @@ - + @@ -94833,7 +98088,7 @@ - + @@ -94841,7 +98096,7 @@ - + @@ -94849,7 +98104,7 @@ - + @@ -94863,7 +98118,7 @@ - + @@ -94877,14 +98132,14 @@ - + - + - + @@ -94893,10 +98148,10 @@ - + - + @@ -94913,7 +98168,7 @@ - + @@ -94924,7 +98179,7 @@ - + @@ -94935,13 +98190,13 @@ - + - + @@ -94949,7 +98204,7 @@ - + @@ -94960,7 +98215,7 @@ - + @@ -94971,7 +98226,7 @@ - + @@ -94979,7 +98234,7 @@ - + @@ -95155,13 +98410,13 @@ - + - + @@ -95172,7 +98427,7 @@ - + @@ -95180,10 +98435,10 @@ - + - + @@ -95191,7 +98446,7 @@ - + @@ -95199,7 +98454,7 @@ - + @@ -95213,7 +98468,7 @@ - + @@ -95221,7 +98476,7 @@ - + @@ -95229,7 +98484,7 @@ - + @@ -95237,7 +98492,7 @@ - + @@ -95245,7 +98500,7 @@ - + @@ -95256,7 +98511,7 @@ - + @@ -95264,7 +98519,7 @@ - + @@ -95278,7 +98533,7 @@ - + @@ -95289,7 +98544,7 @@ - + @@ -95297,7 +98552,7 @@ - + @@ -95305,7 +98560,7 @@ - + @@ -95313,7 +98568,7 @@ - + @@ -95333,7 +98588,7 @@ - + @@ -95341,13 +98596,13 @@ - + - + @@ -95364,7 +98619,7 @@ - + @@ -95378,7 +98633,7 @@ - + @@ -95392,7 +98647,7 @@ - + @@ -95400,7 +98655,7 @@ - + @@ -95414,7 +98669,7 @@ - + @@ -95425,7 +98680,7 @@ - + @@ -95442,15 +98697,15 @@ - + - + - + @@ -95458,7 +98713,7 @@ - + @@ -95469,7 +98724,7 @@ - + @@ -95480,7 +98735,7 @@ - + @@ -95488,7 +98743,7 @@ - + @@ -95505,7 +98760,7 @@ - + @@ -95528,7 +98783,7 @@ - + @@ -95536,7 +98791,7 @@ - + @@ -95547,7 +98802,7 @@ - + @@ -95561,18 +98816,18 @@ - + - + - + - + @@ -95598,7 +98853,7 @@ - + @@ -95609,7 +98864,7 @@ - + @@ -95617,7 +98872,7 @@ - + @@ -95637,7 +98892,7 @@ - + @@ -95648,7 +98903,7 @@ - + @@ -95659,12 +98914,12 @@ - + - + @@ -95672,7 +98927,7 @@ - + @@ -95680,7 +98935,7 @@ - + @@ -95688,7 +98943,7 @@ - + @@ -95696,12 +98951,12 @@ - + - + @@ -95709,7 +98964,7 @@ - + @@ -95717,7 +98972,7 @@ - + @@ -95725,7 +98980,7 @@ - + @@ -95733,7 +98988,7 @@ - + @@ -95741,7 +98996,7 @@ - + @@ -95749,7 +99004,7 @@ - + @@ -95790,7 +99045,7 @@ - + @@ -95798,13 +99053,13 @@ - + - + @@ -95830,7 +99085,7 @@ - + @@ -95895,7 +99150,7 @@ - + @@ -95906,7 +99161,7 @@ - + @@ -95923,7 +99178,7 @@ - + @@ -95967,9 +99222,9 @@ - + - + @@ -95978,7 +99233,7 @@ - + @@ -95989,7 +99244,7 @@ - + @@ -96009,7 +99264,7 @@ - + @@ -96017,7 +99272,7 @@ - + @@ -96034,7 +99289,7 @@ - + @@ -96063,12 +99318,12 @@ - + - + @@ -96077,10 +99332,10 @@ - + - + @@ -96094,17 +99349,17 @@ - + - + - + @@ -96112,7 +99367,7 @@ - + @@ -96123,7 +99378,7 @@ - + @@ -96131,7 +99386,7 @@ - + @@ -96172,7 +99427,7 @@ - + @@ -96180,7 +99435,7 @@ - + @@ -96188,7 +99443,7 @@ - + @@ -96202,7 +99457,7 @@ - + @@ -96222,7 +99477,7 @@ - + @@ -96230,7 +99485,7 @@ - + @@ -96238,7 +99493,7 @@ - + @@ -96246,12 +99501,12 @@ - + - + @@ -96259,7 +99514,7 @@ - + @@ -96267,10 +99522,10 @@ - + - + @@ -96278,23 +99533,23 @@ - + - + - - + + - + @@ -96303,12 +99558,12 @@ - + - + @@ -96316,12 +99571,12 @@ - + - + @@ -96329,12 +99584,12 @@ - + - + @@ -96351,7 +99606,7 @@ - + @@ -96359,7 +99614,7 @@ - + @@ -96367,12 +99622,12 @@ - + - + @@ -96380,7 +99635,7 @@ - + @@ -96388,9 +99643,9 @@ - + - + @@ -96405,12 +99660,12 @@ - + - + @@ -96436,7 +99691,7 @@ - + @@ -96447,7 +99702,7 @@ - + @@ -96467,7 +99722,7 @@ - + @@ -96490,53 +99745,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -96550,12 +99759,12 @@ - + - + @@ -96566,7 +99775,7 @@ - + @@ -96580,7 +99789,7 @@ - + @@ -96591,7 +99800,7 @@ - + @@ -96605,7 +99814,7 @@ - + @@ -96619,20 +99828,20 @@ - + - + - + - + @@ -96646,7 +99855,7 @@ - + @@ -96654,7 +99863,7 @@ - + @@ -96665,7 +99874,7 @@ - + @@ -96682,7 +99891,7 @@ - + @@ -96702,7 +99911,7 @@ - + @@ -96719,7 +99928,7 @@ - + @@ -96730,7 +99939,7 @@ - + @@ -96738,7 +99947,7 @@ - + @@ -96746,7 +99955,7 @@ - + @@ -96754,7 +99963,7 @@ - + @@ -96768,7 +99977,7 @@ - + @@ -96776,7 +99985,7 @@ - + @@ -96787,7 +99996,7 @@ - + @@ -96804,7 +100013,7 @@ - + @@ -96830,7 +100039,7 @@ - + @@ -96841,7 +100050,7 @@ - + @@ -96852,7 +100061,7 @@ - + @@ -96909,20 +100118,7 @@ - - - - - - - - - - - - - - + @@ -97158,6 +100354,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -97219,7 +100438,7 @@ - + @@ -97238,6 +100457,14 @@ + + + + + + + + @@ -97413,7 +100640,7 @@ - + @@ -97584,7 +100811,7 @@ - + @@ -97616,6 +100843,7 @@ + @@ -98499,6 +101727,7 @@ + @@ -98508,6 +101737,7 @@ + @@ -98709,6 +101939,7 @@ + @@ -98896,7 +102127,7 @@ - + @@ -98952,7 +102183,7 @@ - + @@ -98979,7 +102210,7 @@ - + @@ -99107,24 +102338,25 @@ - + + - + - + - + - + - + - + @@ -99247,84 +102479,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -99360,12 +102592,12 @@ - + - + @@ -99504,6 +102736,13 @@ + + + + + + + @@ -100076,6 +103315,9 @@ + + + @@ -100096,7 +103338,7 @@ - + @@ -100390,6 +103632,23 @@ + + + + + + + + + + + + + + + + + @@ -100529,7 +103788,7 @@ - + @@ -100792,10 +104051,10 @@ - + - + @@ -101099,6 +104358,20 @@ + + + + + + + + + + + + + + @@ -101203,7 +104476,7 @@ - + @@ -101342,6 +104615,7 @@ + @@ -101380,6 +104654,7 @@ + @@ -101453,7 +104728,7 @@ - + @@ -101504,7 +104779,7 @@ - + @@ -101535,7 +104810,7 @@ - + @@ -101975,7 +105250,7 @@ - + @@ -102090,6 +105365,7 @@ + @@ -102165,7 +105441,7 @@ - + @@ -102224,6 +105500,7 @@ + @@ -102318,7 +105595,7 @@ - + @@ -102896,6 +106173,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -102952,12 +106255,12 @@ - + - + @@ -103040,6 +106343,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103254,6 +106649,7 @@ + @@ -103322,7 +106718,7 @@ - + @@ -103380,6 +106776,7 @@ + @@ -103533,6 +106930,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103796,7 +107219,7 @@ - + @@ -103945,6 +107368,10 @@ + + + + @@ -103970,6 +107397,7 @@ + @@ -104198,6 +107626,7 @@ + @@ -104250,7 +107679,7 @@ - + @@ -104473,6 +107902,7 @@ + @@ -105001,7 +108431,7 @@ - + @@ -105073,7 +108503,7 @@ - + @@ -105094,7 +108524,7 @@ - + @@ -105106,7 +108536,7 @@ - + @@ -105146,6 +108576,23 @@ + + + + + + + + + + + + + + + + + @@ -105204,13 +108651,13 @@ - + - + @@ -105548,7 +108995,7 @@ - + @@ -105703,6 +109150,7 @@ + @@ -105841,6 +109289,7 @@ + @@ -105863,6 +109312,17 @@ + + + + + + + + + + + @@ -107113,101 +110573,93 @@ - - - - - - - - - - - - - + - - - - - - + + + + - - - - - - - - - - - + + + + + - - - + + + + + - - - - + + + + + + + + + + + - - - - - - + + + - - - - - + + + + - - - - - + + + + + + - - - - + + + + + - - - - - - + + + + + - - - - - - + + + + - + + + + + + + + + @@ -107215,40 +110667,48 @@ - - - - - - + + + + + + - - - - + + + + + + - - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + + + + + + + + @@ -107263,15 +110723,15 @@ - - - - + + + + - - - + + + @@ -107286,45 +110746,45 @@ - - - - + + + + - - - + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - + + + + @@ -107342,161 +110802,161 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - + + + - - - - + + + + - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - + + + + - - - - + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - + + + + + @@ -107505,50 +110965,50 @@ - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - - - - + + + + + @@ -107557,62 +111017,62 @@ - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - + + + + @@ -107633,10 +111093,10 @@ - - - - + + + + @@ -107645,17 +111105,17 @@ - - - - - - + + + + + + - - - + + + @@ -107692,76 +111152,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - + + + + - - - + + + + + + - - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107917,102 +111377,102 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - + - - + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 3607c500f192..8ddb3f6664fc 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -5,6 +5,28 @@ * * Copyright 2020 Google LLC */ +#ifndef __GENKSYMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include <../drivers/net/wireless/intel/ipw2x00/libipw.h> +#include <../fs/mount.h> +#include <../fs/kernfs/kernfs-internal.h> +#include <../kernel/audit.h> +#include <../net/can/af_can.h> +#include <../net/tipc/bearer.h> +#include <../net/xdp/xsk_queue.h> +#include <../security/keys/internal.h> +#endif #define CREATE_TRACE_POINTS #include diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 001780156c5d..c46264c38dde 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -10,7 +10,6 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct binder_alloc; struct binder_proc; struct binder_thread; @@ -18,18 +17,7 @@ struct binder_transaction; struct task_struct; struct seq_file; struct binder_transaction_data; -#else -/* struct binder_alloc */ -#include <../drivers/android/binder_alloc.h> -/* struct binder_proc, struct binder_thread, struct binder_transaction */ -#include <../drivers/android/binder_internal.h> -/* struct task_struct */ -#include -/* struct seq_file */ -#include -/* struct binder_transaction_data */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_binder_transaction_init, TP_PROTO(struct binder_transaction *t), TP_ARGS(t)); diff --git a/include/trace/hooks/block.h b/include/trace/hooks/block.h index 0828a306ea13..e8bee374f989 100644 --- a/include/trace/hooks/block.h +++ b/include/trace/hooks/block.h @@ -9,18 +9,9 @@ #include -#ifdef __GENKSYMS__ struct blk_mq_tags; struct blk_mq_alloc_data; struct blk_mq_tag_set; -#else -/* struct blk_mq_tags */ -#include <../block/blk-mq-tag.h> -/* struct blk_mq_alloc_data */ -#include <../block/blk-mq.h> -/* struct blk_mq_tag_set */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_blk_alloc_rqs, TP_PROTO(size_t *rq_size, struct blk_mq_tag_set *set, diff --git a/include/trace/hooks/cgroup.h b/include/trace/hooks/cgroup.h index 5546d390cb50..116a2afabf99 100644 --- a/include/trace/hooks/cgroup.h +++ b/include/trace/hooks/cgroup.h @@ -7,18 +7,10 @@ #define _TRACE_HOOK_CGROUP_H #include -#ifdef __GENKSYMS__ struct cgroup_taskset; struct cgroup_subsys; struct task_struct; -#else -/* Including ../kernel/cgroup/cgroup-internal.h breaks builds. */ -struct cgroup_taskset; -/* struct cgroup_subsys */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_cgroup_set_task, TP_PROTO(int ret, struct task_struct *task), TP_ARGS(ret, task)); diff --git a/include/trace/hooks/cpufreq.h b/include/trace/hooks/cpufreq.h index 70f90a3ef25c..2739a0f9a547 100644 --- a/include/trace/hooks/cpufreq.h +++ b/include/trace/hooks/cpufreq.h @@ -6,10 +6,15 @@ #if !defined(_TRACE_HOOK_CPUFREQ_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_CPUFREQ_H - -#include #include +#ifdef __GENKSYMS__ +#include +#endif + +struct cpufreq_policy; +struct task_struct; + DECLARE_HOOK(android_vh_show_max_freq, TP_PROTO(struct cpufreq_policy *policy, unsigned int *max_freq), TP_ARGS(policy, max_freq)); diff --git a/include/trace/hooks/cpuidle.h b/include/trace/hooks/cpuidle.h index 9addbdf32913..c2ddabe37b00 100644 --- a/include/trace/hooks/cpuidle.h +++ b/include/trace/hooks/cpuidle.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct cpuidle_device; -#else -/* struct cpuidle_device */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_cpu_idle_enter, TP_PROTO(int *state, struct cpuidle_device *dev), diff --git a/include/trace/hooks/cpuidle_psci.h b/include/trace/hooks/cpuidle_psci.h index 4881f35712c0..3ca307a3d82b 100644 --- a/include/trace/hooks/cpuidle_psci.h +++ b/include/trace/hooks/cpuidle_psci.h @@ -10,12 +10,8 @@ * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cpuidle_device; -#else -/* struct cpuidle_device */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_cpuidle_psci_enter, TP_PROTO(struct cpuidle_device *dev, bool s2idle), TP_ARGS(dev, s2idle)); diff --git a/include/trace/hooks/creds.h b/include/trace/hooks/creds.h index 9544ee2e827c..12f92be91c24 100644 --- a/include/trace/hooks/creds.h +++ b/include/trace/hooks/creds.h @@ -10,15 +10,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cred; struct task_struct; -#else -/* struct cred */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_commit_creds, TP_PROTO(const struct task_struct *task, const struct cred *new), TP_ARGS(task, new)); diff --git a/include/trace/hooks/debug.h b/include/trace/hooks/debug.h index 58ec198ceb6d..5a20141d742b 100644 --- a/include/trace/hooks/debug.h +++ b/include/trace/hooks/debug.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_ipi_stop, TP_PROTO(struct pt_regs *regs), diff --git a/include/trace/hooks/dtask.h b/include/trace/hooks/dtask.h index be037865cdbc..749dc5b4078b 100644 --- a/include/trace/hooks/dtask.h +++ b/include/trace/hooks/dtask.h @@ -10,21 +10,11 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct mutex; struct rt_mutex; struct rw_semaphore; struct task_struct; -#else -/* struct mutex */ -#include -/* struct rt_mutex */ -#include -/* struct rw_semaphore */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_mutex_wait_start, TP_PROTO(struct mutex *lock), TP_ARGS(lock)); diff --git a/include/trace/hooks/fault.h b/include/trace/hooks/fault.h index 920772177bb0..1b6e0b0911f5 100644 --- a/include/trace/hooks/fault.h +++ b/include/trace/hooks/fault.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_die_kernel_fault, TP_PROTO(struct pt_regs *regs, unsigned int esr, unsigned long addr, const char *msg), TP_ARGS(regs, esr, addr, msg), 1); diff --git a/include/trace/hooks/fips140.h b/include/trace/hooks/fips140.h index 6a777771a6c8..fd4a42c013c7 100644 --- a/include/trace/hooks/fips140.h +++ b/include/trace/hooks/fips140.h @@ -7,12 +7,7 @@ #define _TRACE_HOOK_FIPS140_H #include -#ifdef __GENKSYMS__ struct crypto_aes_ctx; -#else -/* struct crypto_aes_ctx */ -#include -#endif /* __GENKSYMS__ */ /* * These hooks exist only for the benefit of the FIPS140 crypto module, which diff --git a/include/trace/hooks/ftrace_dump.h b/include/trace/hooks/ftrace_dump.h index b63d9c809426..0594e8bee2e2 100644 --- a/include/trace/hooks/ftrace_dump.h +++ b/include/trace/hooks/ftrace_dump.h @@ -6,11 +6,14 @@ #if !defined(_TRACE_HOOK_FTRACE_DUMP_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_FTRACE_DUMP_H +#include +#ifdef __GENKSYMS__ #include #include +#endif -#include +struct trace_seq; DECLARE_HOOK(android_vh_ftrace_oops_enter, TP_PROTO(bool *ftrace_check), diff --git a/include/trace/hooks/gic_v3.h b/include/trace/hooks/gic_v3.h index 8db98581eebc..647514f8d7a4 100644 --- a/include/trace/hooks/gic_v3.h +++ b/include/trace/hooks/gic_v3.h @@ -9,15 +9,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cpumask; struct irq_data; -#else -/* struct cpumask */ -#include -/* struct irq_data */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_gic_v3_affinity_init, TP_PROTO(int irq, u32 offset, u64 *affinity), TP_ARGS(irq, offset, affinity)); diff --git a/include/trace/hooks/gpiolib.h b/include/trace/hooks/gpiolib.h index 307fbaa2cae0..20115981de55 100644 --- a/include/trace/hooks/gpiolib.h +++ b/include/trace/hooks/gpiolib.h @@ -8,7 +8,12 @@ #define _TRACE_HOOK_GPIOLIB_H #include + +#ifdef __GENKSYMS__ #include "../drivers/gpio/gpiolib.h" +#endif + +struct gpio_device; DECLARE_HOOK(android_vh_gpio_block_read, TP_PROTO(struct gpio_device *gdev, bool *block_gpio_read), diff --git a/include/trace/hooks/gup.h b/include/trace/hooks/gup.h index 3135cd538a92..47ea47eeede4 100644 --- a/include/trace/hooks/gup.h +++ b/include/trace/hooks/gup.h @@ -7,12 +7,7 @@ #define _TRACE_HOOK_GUP_H #include -#ifdef __GENKSYMS__ struct page; -#else -/* struct page */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_try_grab_compound_head, TP_PROTO(struct page *page, int refs, unsigned int flags, bool *ret), diff --git a/include/trace/hooks/logbuf.h b/include/trace/hooks/logbuf.h index caec0d062476..c5ad3ba85174 100644 --- a/include/trace/hooks/logbuf.h +++ b/include/trace/hooks/logbuf.h @@ -9,13 +9,8 @@ #include -#ifdef __GENKSYMS__ struct printk_record; struct printk_ringbuffer; -#else -/* struct printk_record, struct printk_ringbuffer */ -#include <../kernel/printk/printk_ringbuffer.h> -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_logbuf, TP_PROTO(struct printk_ringbuffer *rb, struct printk_record *r), diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 9e8f234545b1..c3113e14e847 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -8,30 +8,20 @@ #define _TRACE_HOOK_MM_H #include - -#include -#include #include #ifdef __GENKSYMS__ +#include +#include +#endif + +struct oom_control; struct cma; struct acr_info; struct compact_control; struct slabinfo; struct cgroup_subsys_state; struct mem_cgroup; -#else -/* struct compact_control */ -#include <../mm/internal.h> -/* struct slabinfo */ -#include <../mm/slab.h> -/* struct cgroup_subsys_state */ -#include -/* struct acr_info */ -#include -/* struct mem_cgroup */ -#include -#endif /* __GENKSYMS__ */ struct cma; struct acr_info; diff --git a/include/trace/hooks/mmc_core.h b/include/trace/hooks/mmc_core.h index 1889cc54a2b3..c59b4accc9fd 100644 --- a/include/trace/hooks/mmc_core.h +++ b/include/trace/hooks/mmc_core.h @@ -9,18 +9,9 @@ #include -#ifdef __GENKSYMS__ struct sdhci_host; struct mmc_card; struct mmc_host; -#else -/* struct sdhci_host */ -#include <../drivers/mmc/host/sdhci.h> -/* struct mmc_card */ -#include -/* struct mmc_host */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_mmc_blk_reset, TP_PROTO(struct mmc_host *host, int err, bool *allow), diff --git a/include/trace/hooks/mpam.h b/include/trace/hooks/mpam.h index f7f5e468bcef..06b96b1309f8 100644 --- a/include/trace/hooks/mpam.h +++ b/include/trace/hooks/mpam.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_mpam_set, TP_PROTO(struct task_struct *prev, struct task_struct *next), TP_ARGS(prev, next)); diff --git a/include/trace/hooks/net.h b/include/trace/hooks/net.h index 97f15ba6ae3c..4fcd632b2f96 100644 --- a/include/trace/hooks/net.h +++ b/include/trace/hooks/net.h @@ -8,24 +8,12 @@ #define _TRACE_HOOK_NET_VH_H #include -#ifdef __GENKSYMS__ struct packet_type; struct sk_buff; struct list_head; struct nf_conn; struct sock; -#else -/* struct packet_type */ -#include -/* struct sk_buff */ -#include -/* struct list_head */ -#include -/* struct nf_conn */ -#include -/* struct sock */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_ptype_head, TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt), TP_ARGS(pt, vendor_pt)); diff --git a/include/trace/hooks/pci.h b/include/trace/hooks/pci.h index 00d38980ec49..40255448c83c 100644 --- a/include/trace/hooks/pci.h +++ b/include/trace/hooks/pci.h @@ -6,6 +6,9 @@ #if !defined(_TRACE_HOOK_PCI_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_PCI_H #include + +struct pci_dev; + /* * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality diff --git a/include/trace/hooks/pm_domain.h b/include/trace/hooks/pm_domain.h index 1a8ce26ccc3d..eaee85b9c00c 100644 --- a/include/trace/hooks/pm_domain.h +++ b/include/trace/hooks/pm_domain.h @@ -10,12 +10,8 @@ #include -#ifdef __GENKSYMS__ struct generic_pm_domain; -#else -/* struct generic_pm_domain */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_allow_domain_state, TP_PROTO(struct generic_pm_domain *genpd, uint32_t idx, bool *allow), TP_ARGS(genpd, idx, allow)) diff --git a/include/trace/hooks/power.h b/include/trace/hooks/power.h index 3c735b7a5abd..f9b7bbec1531 100644 --- a/include/trace/hooks/power.h +++ b/include/trace/hooks/power.h @@ -10,17 +10,14 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ -enum freq_qos_req_type; + +/* needed for enum freq_qos_req_types */ +#include + struct freq_constraints; struct freq_qos_request; struct task_struct; -#else -/* enum freq_qos_req_type, struct freq_constraints, struct freq_qos_request */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_try_to_freeze_todo, TP_PROTO(unsigned int todo, unsigned int elapsed_msecs, bool wq_busy), TP_ARGS(todo, elapsed_msecs, wq_busy)); diff --git a/include/trace/hooks/psi.h b/include/trace/hooks/psi.h index 32c7a273c5e2..deeb3dfbeeb0 100644 --- a/include/trace/hooks/psi.h +++ b/include/trace/hooks/psi.h @@ -9,13 +9,9 @@ #include -#ifdef __GENKSYMS__ struct psi_group; struct psi_trigger; -#else -/* struct psi_group, struct psi_trigger */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_psi_event, TP_PROTO(struct psi_trigger *t), TP_ARGS(t)); diff --git a/include/trace/hooks/remoteproc.h b/include/trace/hooks/remoteproc.h index 4d3311b1fee4..ee0a2f0ea147 100644 --- a/include/trace/hooks/remoteproc.h +++ b/include/trace/hooks/remoteproc.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct rproc; -#else -/* struct rproc */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_rproc_recovery, TP_PROTO(struct rproc *rproc), diff --git a/include/trace/hooks/rwsem.h b/include/trace/hooks/rwsem.h index 3d6877f166ed..e3fd21729eee 100644 --- a/include/trace/hooks/rwsem.h +++ b/include/trace/hooks/rwsem.h @@ -9,13 +9,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct rw_semaphore; struct rwsem_waiter; -#else -/* struct rw_semaphore, struct rwsem_waiter */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_rwsem_init, TP_PROTO(struct rw_semaphore *sem), TP_ARGS(sem)); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 3a8eee2345af..4f345029ea09 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -9,7 +9,6 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cgroup_taskset; struct cgroup_subsys_state; struct cpufreq_policy; @@ -18,20 +17,7 @@ enum uclamp_id; struct sched_entity; struct task_struct; struct uclamp_se; -#else -/* Including ../kernel/cgroup/cgroup-internal.h breaks builds. */ -struct cgroup_taskset; -/* struct cgroup_subsys_state */ -#include -/* struct cpufreq_policy */ -#include -/* struct em_perf_domain */ -#include -/* enum uclamp_id, struct sched_entity, struct task_struct, struct uclamp_se */ -#include -/* Only defined with CONFIG_UCLAMP_TASK, so declare unconditionally. */ -struct uclamp_se; -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_fair, TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu), TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1); diff --git a/include/trace/hooks/shmem_fs.h b/include/trace/hooks/shmem_fs.h index adfd05825928..29c45d1e0571 100644 --- a/include/trace/hooks/shmem_fs.h +++ b/include/trace/hooks/shmem_fs.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SHMEM_FS_H #include -#ifdef __GENKSYMS__ struct page; -#else -/* struct page */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_shmem_alloc_page, TP_PROTO(struct page **page), TP_ARGS(page)); diff --git a/include/trace/hooks/signal.h b/include/trace/hooks/signal.h index 04976ed38cc7..6338274f27c4 100644 --- a/include/trace/hooks/signal.h +++ b/include/trace/hooks/signal.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SIGNAL_H #include -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_do_send_sig_info, TP_PROTO(int sig, struct task_struct *killer, struct task_struct *dst), TP_ARGS(sig, killer, dst)); diff --git a/include/trace/hooks/softlockup.h b/include/trace/hooks/softlockup.h index d90571a3f0fc..d9806aeb5aa8 100644 --- a/include/trace/hooks/softlockup.h +++ b/include/trace/hooks/softlockup.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_watchdog_timer_softlockup, TP_PROTO(int duration, struct pt_regs *regs, bool is_panic), TP_ARGS(duration, regs, is_panic)); diff --git a/include/trace/hooks/sys.h b/include/trace/hooks/sys.h index 819a126ce0ae..a14bd4135410 100644 --- a/include/trace/hooks/sys.h +++ b/include/trace/hooks/sys.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SYS_H #include -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_syscall_prctl_finished, TP_PROTO(int option, struct task_struct *task), TP_ARGS(option, task)); diff --git a/include/trace/hooks/syscall_check.h b/include/trace/hooks/syscall_check.h index aa563ad1c510..c906ff6b8e7f 100644 --- a/include/trace/hooks/syscall_check.h +++ b/include/trace/hooks/syscall_check.h @@ -10,15 +10,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct file; union bpf_attr; -#else -/* struct file */ -#include -/* union bpf_attr */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_check_mmap_file, TP_PROTO(const struct file *file, unsigned long prot, unsigned long flag, unsigned long ret), diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h index e9a9a4ae3e07..97074725fb08 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -10,12 +10,8 @@ #include #include -#ifdef __GENKSYMS__ struct thermal_zone_device; -#else -/* struct thermal_zone_device */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_enable_thermal_genl_check, TP_PROTO(int event, int tz_id, int *enable_thermal_genl), TP_ARGS(event, tz_id, enable_thermal_genl)); diff --git a/include/trace/hooks/topology.h b/include/trace/hooks/topology.h index 5d29893ba477..e924c97ab4d9 100644 --- a/include/trace/hooks/topology.h +++ b/include/trace/hooks/topology.h @@ -8,7 +8,12 @@ #define _TRACE_HOOK_TOPOLOGY_H #include + +#ifdef __GENKSYMS__ #include +#endif + +struct cpumask; DECLARE_HOOK(android_vh_arch_set_freq_scale, TP_PROTO(const struct cpumask *cpus, unsigned long freq, diff --git a/include/trace/hooks/traps.h b/include/trace/hooks/traps.h index 6b9b986f7a30..f0ede1e69b15 100644 --- a/include/trace/hooks/traps.h +++ b/include/trace/hooks/traps.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_do_undefinstr, TP_PROTO(struct pt_regs *regs, bool user), TP_ARGS(regs, user), diff --git a/include/trace/hooks/ufshcd.h b/include/trace/hooks/ufshcd.h index 32a7f98da4c1..ad2c067f02c4 100644 --- a/include/trace/hooks/ufshcd.h +++ b/include/trace/hooks/ufshcd.h @@ -9,20 +9,11 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct ufs_hba; struct ufshcd_lrb; struct uic_command; struct request; struct scsi_device; -#else -/* struct ufs_hba, struct ufshcd_lrb, struct uic_command */ -#include <../drivers/scsi/ufs/ufshcd.h> -/* struct request */ -#include -/* struct scsi_device */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_ufs_fill_prdt, TP_PROTO(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, diff --git a/include/trace/hooks/usb.h b/include/trace/hooks/usb.h index f4d5ff04b6b8..3a22a2971c24 100644 --- a/include/trace/hooks/usb.h +++ b/include/trace/hooks/usb.h @@ -5,8 +5,14 @@ #define TRACE_INCLUDE_PATH trace/hooks #if !defined(_TRACE_HOOK_USB_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_USB_H -#include #include + +#ifdef __GENKSYMS__ +#include +#endif + +struct usb_device; + /* * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality diff --git a/include/trace/hooks/user.h b/include/trace/hooks/user.h index 6a39785a52e1..1a41c12edd58 100644 --- a/include/trace/hooks/user.h +++ b/include/trace/hooks/user.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_USER_H #include -#ifdef __GENKSYMS__ struct user_struct; -#else -/* struct user_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_alloc_uid, TP_PROTO(struct user_struct *user), TP_ARGS(user)); diff --git a/include/trace/hooks/v4l2core.h b/include/trace/hooks/v4l2core.h index 3dec47042a86..e209621cd66c 100644 --- a/include/trace/hooks/v4l2core.h +++ b/include/trace/hooks/v4l2core.h @@ -9,7 +9,6 @@ #include -#ifdef __GENKSYMS__ struct v4l2_subdev; struct v4l2_subdev_pad_config; struct v4l2_subdev_format; @@ -17,14 +16,7 @@ struct v4l2_subdev_frame_interval; struct v4l2_subdev_selection; struct v4l2_fmtdesc; struct v4l2_format; -#else -/* struct v4l2_subdev, struct v4l2_subdev_pad_config */ -#include -/* struct v4l2_subdev_format, struct v4l2_subdev_frame_interval, struct v4l2_subdev_selection */ -#include -/* struct v4l2_fmtdesc, struct v4l2_format */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_clear_reserved_fmt_fields, TP_PROTO(struct v4l2_format *fmt, int *ret), TP_ARGS(fmt, ret)); diff --git a/include/trace/hooks/v4l2mc.h b/include/trace/hooks/v4l2mc.h index 332a3a09680d..cafc74f14e9b 100644 --- a/include/trace/hooks/v4l2mc.h +++ b/include/trace/hooks/v4l2mc.h @@ -9,15 +9,9 @@ #include -#ifdef __GENKSYMS__ struct media_link; struct media_link_desc; -#else -/* struct media_link */ -#include -/* struct media_link_desc */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_media_device_setup_link, TP_PROTO(struct media_link *link, struct media_link_desc *linkd, int *ret), TP_ARGS(link, linkd, ret)); diff --git a/include/trace/hooks/workqueue.h b/include/trace/hooks/workqueue.h index 3d6d0d61040d..284b3ff86fa8 100644 --- a/include/trace/hooks/workqueue.h +++ b/include/trace/hooks/workqueue.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct worker; -#else -/* struct worker */ -#include <../kernel/workqueue_internal.h> -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_create_worker, TP_PROTO(struct worker *worker, struct workqueue_attrs *attrs), TP_ARGS(worker, attrs)); From ee742bccf646e249fbcc4d635ee71649ff915205 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Thu, 25 Aug 2022 17:55:19 +0000 Subject: [PATCH 17/68] ANDROID: power: fix vendor hook in suspend.c Fix the position of the trace point. Bug: 241946090 Fixes: 737a5314c9f3 ("ANDROID: power: Add vendor hook for suspend") Signed-off-by: Ziyi Cui Change-Id: I8bf231ee35e0c0ebcb35722f4c527ab61116901e --- kernel/power/suspend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 731e79844739..e4c5dcf91033 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -440,7 +440,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) BUG_ON(!irqs_disabled()); system_state = SYSTEM_SUSPEND; - trace_android_vh_early_resume_begin(NULL); error = syscore_suspend(); if (!error) { *wakeup = pm_wakeup_pending(); @@ -450,6 +449,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) error = suspend_ops->enter(state); trace_suspend_resume(TPS("machine_suspend"), state, false); + trace_android_vh_early_resume_begin(NULL); } else if (*wakeup) { error = -EBUSY; } From 790fa51f7bd2f9e464a845bb0caabe1bf0f7fde8 Mon Sep 17 00:00:00 2001 From: Sean Christopherson Date: Fri, 11 Mar 2022 03:27:41 +0000 Subject: [PATCH 18/68] BACKPORT: KVM: x86: avoid calling x86 emulator without a decoded instruction commit fee060cd52d69c114b62d1a2948ea9648b5131f9 upstream. Whenever x86_decode_emulated_instruction() detects a breakpoint, it returns the value that kvm_vcpu_check_breakpoint() writes into its pass-by-reference second argument. Unfortunately this is completely bogus because the expected outcome of x86_decode_emulated_instruction is an EMULATION_* value. Then, if kvm_vcpu_check_breakpoint() does "*r = 0" (corresponding to a KVM_EXIT_DEBUG userspace exit), it is misunderstood as EMULATION_OK and x86_emulate_instruction() is called without having decoded the instruction. This causes various havoc from running with a stale emulation context. The fix is to move the call to kvm_vcpu_check_breakpoint() where it was before commit 4aa2691dcbd3 ("KVM: x86: Factor out x86 instruction emulation with decoding") introduced x86_decode_emulated_instruction(). The other caller of the function does not need breakpoint checks, because it is invoked as part of a vmexit and the processor has already checked those before executing the instruction that #GP'd. This fixes CVE-2022-1852. Bug: 235183128 Reported-by: Qiuhao Li Reported-by: Gaoning Pan Reported-by: Yongkang Jia Fixes: 4aa2691dcbd3 ("KVM: x86: Factor out x86 instruction emulation with decoding") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220311032801.3467418-2-seanjc@google.com> [Rewrote commit message according to Qiuhao's report, since a patch already existed to fix the bug. - Paolo] Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I3acbb7fc23566c4108f15960c420384af52c2703 --- arch/x86/kvm/x86.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a5d6d79b023b..0ecdb3a81f95 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7289,7 +7289,7 @@ int kvm_skip_emulated_instruction(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(kvm_skip_emulated_instruction); -static bool kvm_vcpu_check_breakpoint(struct kvm_vcpu *vcpu, int *r) +static bool kvm_vcpu_check_code_breakpoint(struct kvm_vcpu *vcpu, int *r) { if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) && (vcpu->arch.guest_debug_dr7 & DR7_BP_EN_MASK)) { @@ -7358,25 +7358,23 @@ static bool is_vmware_backdoor_opcode(struct x86_emulate_ctxt *ctxt) } /* - * Decode to be emulated instruction. Return EMULATION_OK if success. + * Decode an instruction for emulation. The caller is responsible for handling + * code breakpoints. Note, manually detecting code breakpoints is unnecessary + * (and wrong) when emulating on an intercepted fault-like exception[*], as + * code breakpoints have higher priority and thus have already been done by + * hardware. + * + * [*] Except #MC, which is higher priority, but KVM should never emulate in + * response to a machine check. */ int x86_decode_emulated_instruction(struct kvm_vcpu *vcpu, int emulation_type, void *insn, int insn_len) { - int r = EMULATION_OK; struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt; + int r; init_emulate_ctxt(vcpu); - /* - * We will reenter on the same instruction since we do not set - * complete_userspace_io. This does not handle watchpoints yet, - * those would be handled in the emulate_ops. - */ - if (!(emulation_type & EMULTYPE_SKIP) && - kvm_vcpu_check_breakpoint(vcpu, &r)) - return r; - ctxt->ud = emulation_type & EMULTYPE_TRAP_UD; r = x86_decode_insn(ctxt, insn, insn_len); @@ -7411,6 +7409,15 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, if (!(emulation_type & EMULTYPE_NO_DECODE)) { kvm_clear_exception_queue(vcpu); + /* + * Return immediately if RIP hits a code breakpoint, such #DBs + * are fault-like and are higher priority than any faults on + * the code fetch itself. + */ + if (!(emulation_type & EMULTYPE_SKIP) && + kvm_vcpu_check_code_breakpoint(vcpu, &r)) + return r; + r = x86_decode_emulated_instruction(vcpu, emulation_type, insn, insn_len); if (r != EMULATION_OK) { From b5fe8c470e8528e85aba5471218ef9fb656ec6aa Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 26 May 2022 07:34:52 +0100 Subject: [PATCH 19/68] BACKPORT: pipe: Fix missing lock in pipe_resize_ring() commit 189b0ddc245139af81198d1a3637cac74f96e13a upstream. pipe_resize_ring() needs to take the pipe->rd_wait.lock spinlock to prevent post_one_notification() from trying to insert into the ring whilst the ring is being replaced. The occupancy check must be done after the lock is taken, and the lock must be taken after the new ring is allocated. The bug can lead to an oops looking something like: BUG: KASAN: use-after-free in post_one_notification.isra.0+0x62e/0x840 Read of size 4 at addr ffff88801cc72a70 by task poc/27196 ... Call Trace: post_one_notification.isra.0+0x62e/0x840 __post_watch_notification+0x3b7/0x650 key_create_or_update+0xb8b/0xd20 __do_sys_add_key+0x175/0x340 __x64_sys_add_key+0xbe/0x140 do_syscall_64+0x5c/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Reported by Selim Enes Karaduman @Enesdex working with Trend Micro Zero Day Initiative. Bug: 244395411 Fixes: c73be61cede5 ("pipe: Add general notification queue support") Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17291 Signed-off-by: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I129164eb9dba557d5a4370f4eca124b9916774a6 --- fs/pipe.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 9f2ca1b1c17a..434b0a274468 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1244,30 +1244,33 @@ unsigned int round_pipe_size(unsigned long size) /* * Resize the pipe ring to a number of slots. + * + * Note the pipe can be reduced in capacity, but only if the current + * occupancy doesn't exceed nr_slots; if it does, EBUSY will be + * returned instead. */ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) { struct pipe_buffer *bufs; unsigned int head, tail, mask, n; - /* - * We can shrink the pipe, if arg is greater than the ring occupancy. - * Since we don't expect a lot of shrink+grow operations, just free and - * allocate again like we would do for growing. If the pipe currently - * contains more buffers than arg, then return busy. - */ - mask = pipe->ring_size - 1; - head = pipe->head; - tail = pipe->tail; - n = pipe_occupancy(pipe->head, pipe->tail); - if (nr_slots < n) - return -EBUSY; - bufs = kcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (unlikely(!bufs)) return -ENOMEM; + spin_lock_irq(&pipe->rd_wait.lock); + mask = pipe->ring_size - 1; + head = pipe->head; + tail = pipe->tail; + + n = pipe_occupancy(head, tail); + if (nr_slots < n) { + spin_unlock_irq(&pipe->rd_wait.lock); + kfree(bufs); + return -EBUSY; + } + /* * The pipe array wraps around, so just start the new one at zero * and adjust the indices. @@ -1299,6 +1302,8 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) pipe->tail = tail; pipe->head = head; + spin_unlock_irq(&pipe->rd_wait.lock); + /* This might have made more room for writers */ wake_up_interruptible(&pipe->wr_wait); return 0; From 952141fb9237ec54cda66e04622725daae29d273 Mon Sep 17 00:00:00 2001 From: Sarthak Kukreti Date: Tue, 31 May 2022 15:56:40 -0400 Subject: [PATCH 20/68] BACKPORT: dm verity: set DM_TARGET_IMMUTABLE feature flag commit 4caae58406f8ceb741603eee460d79bacca9b1b5 upstream. The device-mapper framework provides a mechanism to mark targets as immutable (and hence fail table reloads that try to change the target type). Add the DM_TARGET_IMMUTABLE flag to the dm-verity target's feature flags to prevent switching the verity target with a different target type. Bug: 234475629 Fixes: a4ffc152198e ("dm: add verity target") Cc: stable@vger.kernel.org Signed-off-by: Sarthak Kukreti Reviewed-by: Kees Cook Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: Iaeec7fa3be98a646062439e4551f84242dacfb45 --- drivers/md/dm-verity-target.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 9d5c6dd5b756..2c355b58d078 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -1252,6 +1252,7 @@ bad: static struct target_type verity_target = { .name = "verity", .version = {1, 7, 0}, + .features = DM_TARGET_IMMUTABLE, .module = THIS_MODULE, .ctr = verity_ctr, .dtr = verity_dtr, From d1b29856cad674e59a182e45983ed1abf4f5489d Mon Sep 17 00:00:00 2001 From: Soukjin Bae Date: Tue, 13 Sep 2022 07:51:58 +0900 Subject: [PATCH 21/68] ANDROID: net: export symbol for tracepoint_consume_skb Need to use the tracepoint_consume_skb symbol at module driver Bug: 244504166 Link: https://lore.kernel.org/lkml/20220617200021.02ad8ffc@kernel.org/T Signed-off-by: Soukjin Bae Change-Id: Icffa3e7d2045156691a7711c5f19b309f8356261 --- net/core/net-traces.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/net-traces.c b/net/core/net-traces.c index 465362a9b55d..42f242394135 100644 --- a/net/core/net-traces.c +++ b/net/core/net-traces.c @@ -54,6 +54,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(neigh_event_send_dead); EXPORT_TRACEPOINT_SYMBOL_GPL(neigh_cleanup_and_release); EXPORT_TRACEPOINT_SYMBOL_GPL(kfree_skb); +EXPORT_TRACEPOINT_SYMBOL_GPL(consume_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(napi_poll); From 185f60f2bbabcda5dc7e10a241016cba20b6e949 Mon Sep 17 00:00:00 2001 From: Robin Peng Date: Thu, 15 Sep 2022 09:20:23 +0800 Subject: [PATCH 22/68] ANDROID: add forward declaration vm_unmapped_area_info aosp/2215503 remove inclusions from hook definition headers and build breakage detected on pixel device. include/trace/hooks/mm.h:80:40: error: declaration of 'struct vm_unmapped_area_info' will not be visible outside of this function Fix this by adding struct vm_unmapped_area_info forward declaration. Fixes: 7108d9d0e5f2 ("ANDROID: remove inclusions from hook definition headers") Bug: 233047575 Signed-off-by: Robin Peng Change-Id: I8989ba78977a26e13c79f9efb156bf8317c1010e --- include/trace/hooks/mm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index c3113e14e847..263b867d453c 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -24,6 +24,7 @@ struct cgroup_subsys_state; struct mem_cgroup; struct cma; struct acr_info; +struct vm_unmapped_area_info; DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, TP_PROTO(gfp_t *flags), From 6140082c11069782cb83f26f7ef9fb65292e4938 Mon Sep 17 00:00:00 2001 From: Cheng-Yi Chiang Date: Wed, 18 Nov 2020 12:38:52 +0800 Subject: [PATCH 23/68] UPSTREAM: ASoC: hdmi-codec: Get ELD in before reporting plugged event In plugged callback, ELD should be updated from display driver so that user space can query information from ELD immediately after receiving jack plugged event. When jack is unplugged, clear ELD buffer so that user space does not get obsolete information of unplugged HDMI. Bug: 239396464 Change-Id: I2245de6e6f7dbc64863267db864dafdd3af95747 Signed-off-by: Cheng-Yi Chiang Link: https://lore.kernel.org/r/20201118043852.1338877-1-cychiang@chromium.org Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 25ce4f2b3593fa6bba70ddabbd2ee297b262784f) --- sound/soc/codecs/hdmi-codec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 403d4c6a49a8..e8410b2433de 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -692,10 +692,16 @@ static void plugged_cb(struct device *dev, bool plugged) { struct hdmi_codec_priv *hcp = dev_get_drvdata(dev); - if (plugged) + if (plugged) { + if (hcp->hcd.ops->get_eld) { + hcp->hcd.ops->get_eld(dev->parent, hcp->hcd.data, + hcp->eld, sizeof(hcp->eld)); + } hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); - else + } else { hdmi_codec_jack_report(hcp, 0); + memset(hcp->eld, 0, sizeof(hcp->eld)); + } } static int hdmi_codec_set_jack(struct snd_soc_component *component, From f5a1cb7fd6e41462c939d59da37f120da2a6c375 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Thu, 26 Nov 2020 14:36:48 +0800 Subject: [PATCH 24/68] UPSTREAM: ASoC: hdmi-codec: Add RX support HDMI interface can also be used as receiver, this patch is to add such support. The most difference compare with TX is that RX don't need to get edid information. Bug: 239396464 Change-Id: Ib5f9f347cd50abe95fa9c8a4856bd1a91117ca67 Signed-off-by: Shengjiu Wang Link: https://lore.kernel.org/r/1606372608-2329-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 144f836646989783cb018d00fa69f3f8dab58349) --- sound/soc/codecs/hdmi-codec.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index e8410b2433de..d5fcc4db8284 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -282,6 +282,7 @@ struct hdmi_codec_priv { static const struct snd_soc_dapm_widget hdmi_widgets[] = { SND_SOC_DAPM_OUTPUT("TX"), + SND_SOC_DAPM_OUTPUT("RX"), }; enum { @@ -389,6 +390,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; int ret = 0; mutex_lock(&hcp->lock); @@ -404,7 +406,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, goto err; } - if (hcp->hcd.ops->get_eld) { + if (tx && hcp->hcd.ops->get_eld) { ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); if (ret) @@ -660,14 +662,20 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) { struct snd_soc_dapm_context *dapm; struct hdmi_codec_daifmt *daifmt; - struct snd_soc_dapm_route route = { - .sink = "TX", - .source = dai->driver->playback.stream_name, + struct snd_soc_dapm_route route[] = { + { + .sink = "TX", + .source = dai->driver->playback.stream_name, + }, + { + .sink = dai->driver->capture.stream_name, + .source = "RX", + }, }; int ret; dapm = snd_soc_component_get_dapm(dai->component); - ret = snd_soc_dapm_add_routes(dapm, &route, 1); + ret = snd_soc_dapm_add_routes(dapm, route, 2); if (ret) return ret; @@ -757,6 +765,14 @@ static const struct snd_soc_dai_driver hdmi_i2s_dai = { .formats = I2S_FORMATS, .sig_bits = 24, }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 8, + .rates = HDMI_RATES, + .formats = I2S_FORMATS, + .sig_bits = 24, + }, .ops = &hdmi_codec_i2s_dai_ops, .pcm_new = hdmi_codec_pcm_new, }; @@ -773,6 +789,13 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = { .rates = HDMI_RATES, .formats = SPDIF_FORMATS, }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 2, + .rates = HDMI_RATES, + .formats = SPDIF_FORMATS, + }, .ops = &hdmi_codec_spdif_dai_ops, .pcm_new = hdmi_codec_pcm_new, }; From c584eb99bb43ec13aab379702206edd27f8d8ca4 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Thu, 7 Jan 2021 17:51:31 +0100 Subject: [PATCH 25/68] UPSTREAM: ASoC: hdmi-codec: Fix return value in hdmi_codec_set_jack() Sound is broken on the DragonBoard 410c (apq8016_sbc) since 5.10: hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_component_set_jack on hdmi-audio-codec.1.auto: -95 qcom-apq8016-sbc 7702000.sound: Failed to set jack: -95 ADV7533: ASoC: error at snd_soc_link_init on ADV7533: -95 hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_component_set_jack on hdmi-audio-codec.1.auto: -95 qcom-apq8016-sbc: probe of 7702000.sound failed with error -95 This happens because apq8016_sbc calls snd_soc_component_set_jack() on all codec DAIs and attempts to ignore failures with return code -ENOTSUPP. -ENOTSUPP is also excluded from error logging in soc_component_ret(). However, hdmi_codec_set_jack() returns -E*OP*NOTSUPP if jack detection is not supported, which is not handled in apq8016_sbc and soc_component_ret(). Make it return -ENOTSUPP instead to fix sound and silence the errors. Bug: 239396464 Change-Id: Id38ce1cdfc80daaac7d77212cecd29dd6fa4e877 Cc: Cheng-Yi Chiang Cc: Srinivas Kandagatla Fixes: 55c5cc63ab32 ("ASoC: hdmi-codec: Use set_jack ops to set jack") Signed-off-by: Stephan Gerhold Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/20210107165131.2535-1-stephan@gerhold.net Signed-off-by: Mark Brown (cherry picked from commit 2a0435df963f996ca870a2ef1cbf1773dc0ea25a) Signed-off-by: Sugar Zhang --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index d5fcc4db8284..0f3ac22f2cf8 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -717,7 +717,7 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, void *data) { struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); - int ret = -EOPNOTSUPP; + int ret = -ENOTSUPP; if (hcp->hcd.ops->hook_plugged_cb) { hcp->jack = jack; From a7633aa2d93d5fb87f14b6757c9c5a5e70350123 Mon Sep 17 00:00:00 2001 From: Sia Jee Heng Date: Thu, 4 Feb 2021 09:42:55 +0800 Subject: [PATCH 26/68] UPSTREAM: ASoC: codec: hdmi-codec: Support IEC958 encoded PCM format Existing hdmi-codec driver only support standard pcm format. Support of IEC958 encoded format pass from ALSA IEC958 plugin is needed so that the IEC958 encoded data can be streamed to the HDMI chip. Bug: 239396464 Change-Id: I01516e34605e380995b5312273035a0d000d36f1 Signed-off-by: Sia Jee Heng Link: https://lore.kernel.org/r/20210204014258.10197-2-jee.heng.sia@intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 28785f548d18e6d52785a1172e5c176784ce74cd) --- include/sound/hdmi-codec.h | 5 +++++ sound/soc/codecs/hdmi-codec.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index b55970859a13..4b3a1d374b90 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -34,6 +34,11 @@ struct hdmi_codec_daifmt { unsigned int frame_clk_inv:1; unsigned int bit_clk_master:1; unsigned int frame_clk_master:1; + /* bit_fmt could be standard PCM format or + * IEC958 encoded format. ALSA IEC958 plugin will pass + * IEC958_SUBFRAME format to the underneath driver. + */ + snd_pcm_format_t bit_fmt; }; /* diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 0f3ac22f2cf8..422539f933de 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -489,6 +489,7 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, hp.sample_rate = params_rate(params); hp.channels = params_channels(params); + cf->bit_fmt = params_format(params); return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, cf, &hp); } @@ -617,7 +618,8 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE |\ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |\ - SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE) + SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) From 004a44b9138aaf167d8d7be5df8f7fb292a73352 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 12 Mar 2021 12:22:33 -0600 Subject: [PATCH 27/68] UPSTREAM: ASoC: hdmi-codec: remove useless initialization Fix cppcheck warning: sound/soc/codecs/hdmi-codec.c:745:5: style: Redundant initialization for 'cf'. The initialized value is overwritten before it is read. [redundantInitialization] cf = dai->playback_dma_data; ^ sound/soc/codecs/hdmi-codec.c:738:31: note: cf is initialized struct hdmi_codec_daifmt *cf = dai->playback_dma_data; ^ sound/soc/codecs/hdmi-codec.c:745:5: note: cf is overwritten cf = dai->playback_dma_data; ^ Bug: 239396464 Change-Id: Ia903635862e043207929827afcaeb531e6344283 Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210312182246.5153-11-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 3c011ef344cddd15be0a9b2256f7886f6b5eeec5) --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 422539f933de..83e74ddccf59 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -735,7 +735,7 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) { - struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + struct hdmi_codec_daifmt *cf; int ret; ret = hdmi_dai_probe(dai); From 6cc06d03bff9aee9006166f597d5174fd7722db2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 12 Mar 2021 12:22:34 -0600 Subject: [PATCH 28/68] UPSTREAM: ASoC: hdmi-codec: remove unused spk_mask member fix cppcheck warning: sound/soc/codecs/hdmi-codec.c:25:16: style: struct member 'hdmi_codec_channel_map_table::spk_mask' is never used. [unusedStructMember] unsigned long spk_mask; /* speaker position bit mask */ ^ Bug: 239396464 Change-Id: I235b7757db88bfbd059ad0f9795908fbfbb1cfdb Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210312182246.5153-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 9ad869fee5c598d914fa5cf8fb26f5e106e90956) --- sound/soc/codecs/hdmi-codec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 83e74ddccf59..1567ba196ab9 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -22,7 +22,6 @@ struct hdmi_codec_channel_map_table { unsigned char map; /* ALSA API channel map position */ - unsigned long spk_mask; /* speaker position bit mask */ }; /* From 92c209708ae171a955c29e07d10e9cf951c30ec5 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:43 +0200 Subject: [PATCH 29/68] UPSTREAM: ALSA: doc: Clarify IEC958 controls iface The doc currently mentions that the IEC958 Playback Default should be exposed on the PCM iface, and the Playback Mask on the mixer iface. It's a bit confusing to advise to have two related controls on two separate ifaces, and it looks like the drivers that currently expose those controls use any combination of the mixer and PCM ifaces. Let's try to clarify the situation a bit, and encourage to at least have the controls on the same iface. Bug: 239396464 Change-Id: Ie0fb033564972f74154c378c644c581dc4d06dfa Signed-off-by: Maxime Ripard Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20210525132354.297468-2-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit aa7899537a4ec63ac3d58c9ece945c2750d22168) --- .../sound/kernel-api/writing-an-alsa-driver.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst index 73bbd59afc33..690c5238f904 100644 --- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst +++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst @@ -3508,14 +3508,15 @@ field must be set, though). “IEC958 Playback Con Mask” is used to return the bit-mask for the IEC958 status bits of consumer mode. Similarly, “IEC958 Playback Pro Mask” -returns the bitmask for professional mode. They are read-only controls, -and are defined as MIXER controls (iface = -``SNDRV_CTL_ELEM_IFACE_MIXER``). +returns the bitmask for professional mode. They are read-only controls. Meanwhile, “IEC958 Playback Default” control is defined for getting and -setting the current default IEC958 bits. Note that this one is usually -defined as a PCM control (iface = ``SNDRV_CTL_ELEM_IFACE_PCM``), -although in some places it's defined as a MIXER control. +setting the current default IEC958 bits. + +Due to historical reasons, both variants of the Playback Mask and the +Playback Default controls can be implemented on either a +``SNDRV_CTL_ELEM_IFACE_PCM`` or a ``SNDRV_CTL_ELEM_IFACE_MIXER`` iface. +Drivers should expose the mask and default on the same iface though. In addition, you can define the control switches to enable/disable or to set the raw bit mode. The implementation will depend on the chip, but From 8de9ae8605ff355e2991370eff904669f96e4307 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:44 +0200 Subject: [PATCH 30/68] UPSTREAM: ALSA: iec958: Split status creation and fill In some situations, like a codec probe, we need to provide an IEC status default but don't have access to the sampling rate and width yet since no stream has been configured yet. Each and every driver has its own default, whereas the core iec958 code also has some buried in the snd_pcm_create_iec958_consumer functions. Let's split these functions in two to provide a default that doesn't rely on the sampling rate and width, and another function to fill them when available. Bug: 239396464 Change-Id: I277899145367b219b337bc796f2faee8c4917082 Signed-off-by: Maxime Ripard Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20210525132354.297468-3-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 9eafc11f921b8cb7d7e28ab1fdcf6b92fcbcb0be) --- include/sound/pcm_iec958.h | 8 ++ sound/core/pcm_iec958.c | 176 ++++++++++++++++++++++++++++--------- 2 files changed, 141 insertions(+), 43 deletions(-) diff --git a/include/sound/pcm_iec958.h b/include/sound/pcm_iec958.h index 0939aa45e2fe..64e84441cde1 100644 --- a/include/sound/pcm_iec958.h +++ b/include/sound/pcm_iec958.h @@ -4,6 +4,14 @@ #include +int snd_pcm_create_iec958_consumer_default(u8 *cs, size_t len); + +int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, + size_t len); + +int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, + u8 *cs, size_t len); + int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len); diff --git a/sound/core/pcm_iec958.c b/sound/core/pcm_iec958.c index f9a211cc1f2c..7a1b816f67cc 100644 --- a/sound/core/pcm_iec958.c +++ b/sound/core/pcm_iec958.c @@ -9,41 +9,85 @@ #include #include -static int create_iec958_consumer(uint rate, uint sample_width, - u8 *cs, size_t len) +/** + * snd_pcm_create_iec958_consumer_default - create default consumer format IEC958 channel status + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Create the consumer format channel status data in @cs of maximum size + * @len. When relevant, the configuration-dependant bits will be set as + * unspecified. + * + * Drivers should then call einter snd_pcm_fill_iec958_consumer() or + * snd_pcm_fill_iec958_consumer_hw_params() to replace these unspecified + * bits by their actual values. + * + * Drivers may wish to tweak the contents of the buffer after creation. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_create_iec958_consumer_default(u8 *cs, size_t len) { - unsigned int fs, ws; - if (len < 4) return -EINVAL; - switch (rate) { - case 32000: - fs = IEC958_AES3_CON_FS_32000; - break; - case 44100: - fs = IEC958_AES3_CON_FS_44100; - break; - case 48000: - fs = IEC958_AES3_CON_FS_48000; - break; - case 88200: - fs = IEC958_AES3_CON_FS_88200; - break; - case 96000: - fs = IEC958_AES3_CON_FS_96000; - break; - case 176400: - fs = IEC958_AES3_CON_FS_176400; - break; - case 192000: - fs = IEC958_AES3_CON_FS_192000; - break; - default: + memset(cs, 0, len); + + cs[0] = IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_NONE; + cs[1] = IEC958_AES1_CON_GENERAL; + cs[2] = IEC958_AES2_CON_SOURCE_UNSPEC | IEC958_AES2_CON_CHANNEL_UNSPEC; + cs[3] = IEC958_AES3_CON_CLOCK_1000PPM | IEC958_AES3_CON_FS_NOTID; + + if (len > 4) + cs[4] = IEC958_AES4_CON_WORDLEN_NOTID; + + return len; +} +EXPORT_SYMBOL_GPL(snd_pcm_create_iec958_consumer_default); + +static int fill_iec958_consumer(uint rate, uint sample_width, + u8 *cs, size_t len) +{ + if (len < 4) return -EINVAL; + + if ((cs[3] & IEC958_AES3_CON_FS) == IEC958_AES3_CON_FS_NOTID) { + unsigned int fs; + + switch (rate) { + case 32000: + fs = IEC958_AES3_CON_FS_32000; + break; + case 44100: + fs = IEC958_AES3_CON_FS_44100; + break; + case 48000: + fs = IEC958_AES3_CON_FS_48000; + break; + case 88200: + fs = IEC958_AES3_CON_FS_88200; + break; + case 96000: + fs = IEC958_AES3_CON_FS_96000; + break; + case 176400: + fs = IEC958_AES3_CON_FS_176400; + break; + case 192000: + fs = IEC958_AES3_CON_FS_192000; + break; + default: + return -EINVAL; + } + + cs[3] &= ~IEC958_AES3_CON_FS; + cs[3] |= fs; } - if (len > 4) { + if (len > 4 && + (cs[4] & IEC958_AES4_CON_WORDLEN) == IEC958_AES4_CON_WORDLEN_NOTID) { + unsigned int ws; + switch (sample_width) { case 16: ws = IEC958_AES4_CON_WORDLEN_20_16; @@ -64,21 +108,58 @@ static int create_iec958_consumer(uint rate, uint sample_width, default: return -EINVAL; } + + cs[4] &= ~IEC958_AES4_CON_WORDLEN; + cs[4] |= ws; } - memset(cs, 0, len); - - cs[0] = IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_NONE; - cs[1] = IEC958_AES1_CON_GENERAL; - cs[2] = IEC958_AES2_CON_SOURCE_UNSPEC | IEC958_AES2_CON_CHANNEL_UNSPEC; - cs[3] = IEC958_AES3_CON_CLOCK_1000PPM | fs; - - if (len > 4) - cs[4] = ws; - return len; } +/** + * snd_pcm_fill_iec958_consumer - Fill consumer format IEC958 channel status + * @runtime: pcm runtime structure with ->rate filled in + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Fill the unspecified bits in an IEC958 status bits array using the + * parameters of the PCM runtime @runtime. + * + * Drivers may wish to tweak the contents of the buffer after its been + * filled. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *runtime, + u8 *cs, size_t len) +{ + return fill_iec958_consumer(runtime->rate, + snd_pcm_format_width(runtime->format), + cs, len); +} +EXPORT_SYMBOL_GPL(snd_pcm_fill_iec958_consumer); + +/** + * snd_pcm_fill_iec958_consumer_hw_params - Fill consumer format IEC958 channel status + * @params: the hw_params instance for extracting rate and sample format + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Fill the unspecified bits in an IEC958 status bits array using the + * parameters of the PCM hardware parameters @params. + * + * Drivers may wish to tweak the contents of the buffer after its been + * filled.. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, + u8 *cs, size_t len) +{ + return fill_iec958_consumer(params_rate(params), params_width(params), cs, len); +} +EXPORT_SYMBOL_GPL(snd_pcm_fill_iec958_consumer_hw_params); + /** * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status * @runtime: pcm runtime structure with ->rate filled in @@ -95,9 +176,13 @@ static int create_iec958_consumer(uint rate, uint sample_width, int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { - return create_iec958_consumer(runtime->rate, - snd_pcm_format_width(runtime->format), - cs, len); + int ret; + + ret = snd_pcm_create_iec958_consumer_default(cs, len); + if (ret < 0) + return ret; + + return snd_pcm_fill_iec958_consumer(runtime, cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); @@ -117,7 +202,12 @@ EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len) { - return create_iec958_consumer(params_rate(params), params_width(params), - cs, len); + int ret; + + ret = snd_pcm_create_iec958_consumer_default(cs, len); + if (ret < 0) + return ret; + + return fill_iec958_consumer(params_rate(params), params_width(params), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer_hw_params); From 9e9d26699dbce100121481676e14acf44d50ddaa Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:45 +0200 Subject: [PATCH 31/68] UPSTREAM: ASoC: hdmi-codec: Rework to support more controls We're going to add more controls to support the IEC958 output, so let's rework the control registration a bit to support more of them. Bug: 239396464 Change-Id: Ia8c0bf8c997638b5a121ae7356fa1eb27746036f Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-4-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 366b45b974481bea9603843d308aded519aab7dc) --- sound/soc/codecs/hdmi-codec.c | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 1567ba196ab9..65bde6f0ea1c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -620,21 +620,23 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) +struct snd_kcontrol_new hdmi_codec_controls[] = { + { + .access = (SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE), + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = "ELD", + .info = hdmi_eld_ctl_info, + .get = hdmi_eld_ctl_get, + }, +}; + static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) { struct snd_soc_dai_driver *drv = dai->driver; struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - struct snd_kcontrol *kctl; - struct snd_kcontrol_new hdmi_eld_ctl = { - .access = SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "ELD", - .info = hdmi_eld_ctl_info, - .get = hdmi_eld_ctl_get, - .device = rtd->pcm->device, - }; + unsigned int i; int ret; ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -651,12 +653,21 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - /* add ELD ctl with the device number corresponding to the PCM stream */ - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); - if (!kctl) - return -ENOMEM; + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) { + struct snd_kcontrol *kctl; - return snd_ctl_add(rtd->card->snd_card, kctl); + /* add ELD ctl with the device number corresponding to the PCM stream */ + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component); + if (!kctl) + return -ENOMEM; + + kctl->id.device = rtd->pcm->device; + ret = snd_ctl_add(rtd->card->snd_card, kctl); + if (ret < 0) + return ret; + } + + return 0; } static int hdmi_dai_probe(struct snd_soc_dai *dai) From 21e97dfa193b49b56a65db92c0a1ca531abe0f20 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:46 +0200 Subject: [PATCH 32/68] UPSTREAM: ASoC: hdmi-codec: Add iec958 controls The IEC958 status bits can be exposed and modified by the userspace through dedicated ALSA controls. This patch implements those controls for the hdmi-codec driver. It relies on a default value being setup at probe time that can later be overridden by the control put. The hw_params callback is then called with a buffer filled with the proper bits for the current parameters being passed on so the underlying driver can just reuse those bits as is. Bug: 239396464 Change-Id: I99f37b7e74655687e73a75ba19fd2de8041f8646 Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-5-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 7a8e1d44211e16eb394b7b9e0b236ee1503a3ad3) --- sound/soc/codecs/hdmi-codec.c | 66 +++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 65bde6f0ea1c..a0834b784814 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -277,6 +277,7 @@ struct hdmi_codec_priv { bool busy; struct snd_soc_jack *jack; unsigned int jack_status; + u8 iec_status[5]; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -385,6 +386,47 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } +static int hdmi_codec_iec958_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; + uinfo->count = 1; + return 0; +} + +static int hdmi_codec_iec958_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + memcpy(ucontrol->value.iec958.status, hcp->iec_status, + sizeof(hcp->iec_status)); + + return 0; +} + +static int hdmi_codec_iec958_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + memcpy(hcp->iec_status, ucontrol->value.iec958.status, + sizeof(hcp->iec_status)); + + return 0; +} + +static int hdmi_codec_iec958_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + memset(ucontrol->value.iec958.status, 0xff, + sizeof_field(struct hdmi_codec_priv, iec_status)); + + return 0; +} + static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -459,8 +501,9 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, params_width(params), params_rate(params), params_channels(params)); - ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status, - sizeof(hp.iec.status)); + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); + ret = snd_pcm_fill_iec958_consumer_hw_params(params, hp.iec.status, + sizeof(hp.iec.status)); if (ret < 0) { dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", ret); @@ -621,6 +664,20 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) struct snd_kcontrol_new hdmi_codec_controls[] = { + { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK), + .info = hdmi_codec_iec958_info, + .get = hdmi_codec_iec958_mask_get, + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), + .info = hdmi_codec_iec958_info, + .get = hdmi_codec_iec958_default_get, + .put = hdmi_codec_iec958_default_put, + }, { .access = (SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), @@ -873,6 +930,11 @@ static int hdmi_codec_probe(struct platform_device *pdev) hcp->hcd = *hcd; mutex_init(&hcp->lock); + ret = snd_pcm_create_iec958_consumer_default(hcp->iec_status, + sizeof(hcp->iec_status)); + if (ret < 0) + return ret; + daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL); if (!daidrv) return -ENOMEM; From 46a21348d6142240a27c8a48b105c12029174fc6 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:47 +0200 Subject: [PATCH 33/68] UPSTREAM: ASoC: hdmi-codec: Add a prepare hook The IEC958 status bit is usually set by the userspace after hw_params has been called, so in order to use whatever is set by the userspace, we need to implement the prepare hook. Let's add it to the hdmi_codec_ops, and mandate that either prepare or hw_params is implemented. Bug: 239396464 Change-Id: I06ccde5d8185955bb60783b597f0205811460968 Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-6-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 2fef64eec23a0840c97977b16dd8919afaffa876) --- include/sound/hdmi-codec.h | 12 +++- sound/soc/codecs/hdmi-codec.c | 110 +++++++++++++++++++++++++++------- 2 files changed, 98 insertions(+), 24 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 4b3a1d374b90..4fc733c8c570 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -65,12 +65,22 @@ struct hdmi_codec_ops { /* * Configures HDMI-encoder for audio stream. - * Mandatory + * Having either prepare or hw_params is mandatory. */ int (*hw_params)(struct device *dev, void *data, struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); + /* + * Configures HDMI-encoder for audio stream. Can be called + * multiple times for each setup. + * + * Having either prepare or hw_params is mandatory. + */ + int (*prepare)(struct device *dev, void *data, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms); + /* * Shuts down the audio stream. * Mandatory diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index a0834b784814..a67c92032e11 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -481,6 +481,42 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, mutex_unlock(&hcp->lock); } +static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai, + unsigned int sample_width, + unsigned int sample_rate, + unsigned int channels, + struct hdmi_codec_params *hp) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + int idx; + + /* Select a channel allocation that matches with ELD and pcm channels */ + idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels); + if (idx < 0) { + dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", + idx); + hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; + return idx; + } + + memset(hp, 0, sizeof(*hp)); + + hdmi_audio_infoframe_init(&hp->cea); + hp->cea.channels = channels; + hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; + hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM; + hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; + hp->cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id; + + hp->sample_width = sample_width; + hp->sample_rate = sample_rate; + hp->channels = channels; + + hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id; + + return 0; +} + static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -495,12 +531,23 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, .dig_subframe = { 0 }, } }; - int ret, idx; + int ret; + + if (!hcp->hcd.ops->hw_params) + return 0; dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, params_width(params), params_rate(params), params_channels(params)); + ret = hdmi_codec_fill_codec_params(dai, + params_width(params), + params_rate(params), + params_channels(params), + &hp); + if (ret < 0) + return ret; + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); ret = snd_pcm_fill_iec958_consumer_hw_params(params, hp.iec.status, sizeof(hp.iec.status)); @@ -510,32 +557,47 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, return ret; } - hdmi_audio_infoframe_init(&hp.cea); - hp.cea.channels = params_channels(params); - hp.cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; - hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM; - hp.cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; - - /* Select a channel allocation that matches with ELD and pcm channels */ - idx = hdmi_codec_get_ch_alloc_table_idx(hcp, hp.cea.channels); - if (idx < 0) { - dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", - idx); - hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - return idx; - } - hp.cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id; - hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id; - - hp.sample_width = params_width(params); - hp.sample_rate = params_rate(params); - hp.channels = params_channels(params); - cf->bit_fmt = params_format(params); return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, cf, &hp); } +static int hdmi_codec_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + struct snd_pcm_runtime *runtime = substream->runtime; + unsigned int channels = runtime->channels; + unsigned int width = snd_pcm_format_width(runtime->format); + unsigned int rate = runtime->rate; + struct hdmi_codec_params hp; + int ret; + + if (!hcp->hcd.ops->prepare) + return 0; + + dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, + width, rate, channels); + + ret = hdmi_codec_fill_codec_params(dai, width, rate, channels, &hp); + if (ret < 0) + return ret; + + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); + ret = snd_pcm_fill_iec958_consumer(runtime, hp.iec.status, + sizeof(hp.iec.status)); + if (ret < 0) { + dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", + ret); + return ret; + } + + cf->bit_fmt = runtime->format; + return hcp->hcd.ops->prepare(dai->dev->parent, hcp->hcd.data, + cf, &hp); +} + static int hdmi_codec_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { @@ -627,6 +689,7 @@ static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, + .prepare = hdmi_codec_prepare, .set_fmt = hdmi_codec_i2s_set_fmt, .mute_stream = hdmi_codec_mute, }; @@ -917,7 +980,8 @@ static int hdmi_codec_probe(struct platform_device *pdev) } dai_count = hcd->i2s + hcd->spdif; - if (dai_count < 1 || !hcd->ops || !hcd->ops->hw_params || + if (dai_count < 1 || !hcd->ops || + (!hcd->ops->hw_params && !hcd->ops->prepare) || !hcd->ops->audio_shutdown) { dev_err(dev, "%s: Invalid parameters\n", __func__); return -EINVAL; From 32934b542c3d01951279eb79b9beaa3ede4d12a8 Mon Sep 17 00:00:00 2001 From: Jiapeng Chong Date: Wed, 16 Jun 2021 13:55:41 +0800 Subject: [PATCH 34/68] UPSTREAM: ASoC: hdmi-codec: make hdmi_codec_controls static This symbol is not used outside of hdmi-codec.c, so marks it static. Fix the following sparse warning: sound/soc/codecs/hdmi-codec.c:750:25: warning: symbol 'hdmi_codec_controls' was not declared. Should it be static? Bug: 239396464 Change-Id: I6569284ef557fee683afb9031e5cc1b5684a1c30 Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong Link: https://lore.kernel.org/r/1623822941-3077-1-git-send-email-jiapeng.chong@linux.alibaba.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit e99d7c69fd4c18e7319f8aab8e252b12130796bf) --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index a67c92032e11..d0fb04ae372c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -726,7 +726,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) -struct snd_kcontrol_new hdmi_codec_controls[] = { +static struct snd_kcontrol_new hdmi_codec_controls[] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, From f68d040c318f8022628d89e794b78326b352a9fe Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 16 Sep 2022 06:37:59 -0700 Subject: [PATCH 35/68] FROMLIST: scsi: ufs: Fix deadlocks between power management and error handler The following deadlocks have been observed on multiple test setups: * ufshcd_wl_suspend() is waiting for blk_execute_rq() to complete while it holds host_sem. * ufshcd_eh_host_reset_handler() invokes ufshcd_err_handler() and the latter function tries to obtain host_sem. This is a deadlock because blk_execute_rq() can't execute SCSI commands while the host is in the SHOST_RECOVERY state and because the error handler cannot make progress either. * ufshcd_wl_runtime_resume() is waiting for blk_execute_rq() to finish while it holds host_sem. * ufshcd_eh_host_reset_handler() invokes ufshcd_err_handler() and the latter function calls pm_runtime_resume(). This is a deadlock because of the same reason as the previous scenario. Fix both deadlocks by not obtaining host_sem from the power management code paths. Removing the host_sem locking from the power management code is safe because the ufshcd_err_handler() is already serialized against SCSI command execution. Cc: dh0421.hwang@samsung.com Cc: Asutosh Das Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Signed-off-by: Bart Van Assche Bug: 240498410 Bug: 246990788 Bug: 247073231 Bug: 247081382 Bug: 247082093 Link: https://lore.kernel.org/linux-scsi/ Signed-off-by: Bart Van Assche Change-Id: Ifb9b429ba89ff6d8a133d96a172eaefc09d85955 --- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9ee325116902..fb62a8210075 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9337,16 +9337,13 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); - down(&hba->host_sem); if (pm_runtime_suspended(dev)) goto out; ret = __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM); - if (ret) { + if (ret) dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret); - up(&hba->host_sem); - } out: if (!ret) @@ -9379,7 +9376,6 @@ out: hba->curr_dev_pwr_mode, hba->uic_link_state); if (!ret) hba->is_sys_suspended = false; - up(&hba->host_sem); return ret; } #endif From dd18c291f9a958a1e285ce0e84ec6b5879fe10ab Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 10 Jan 2022 03:15:27 +0900 Subject: [PATCH 36/68] BACKPORT: UPSTREAM: kbuild: rename cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22} GZIP-compressed files end with 4 byte data that represents the size of the original input. The decompressors (the self-extracting kernel) exploit it to know the vmlinux size beforehand. To mimic the GZIP's trailer, Kbuild provides cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}. Unfortunately these macros are used everywhere despite the appended size data is only useful for the decompressors. There is no guarantee that such hand-crafted trailers are safely ignored. In fact, the kernel refuses compressed initramdfs with the garbage data. That is why usr/Makefile overrides size_append to make it no-op. To limit the use of such broken compressed files, this commit renames the existing macros as follows: cmd_bzip2 --> cmd_bzip2_with_size cmd_lzma --> cmd_lzma_with_size cmd_lzo --> cmd_lzo_with_size cmd_lz4 --> cmd_lz4_with_size cmd_xzkern --> cmd_xzkern_with_size cmd_zstd22 --> cmd_zstd22_with_size To keep the decompressors working, I updated the following Makefiles accordingly: arch/arm/boot/compressed/Makefile arch/h8300/boot/compressed/Makefile arch/mips/boot/compressed/Makefile arch/parisc/boot/compressed/Makefile arch/s390/boot/compressed/Makefile arch/sh/boot/compressed/Makefile arch/x86/boot/compressed/Makefile I reused the current macro names for the normal usecases; they produce the compressed data in the proper format. I did not touch the following: arch/arc/boot/Makefile arch/arm64/boot/Makefile arch/csky/boot/Makefile arch/mips/boot/Makefile arch/riscv/boot/Makefile arch/sh/boot/Makefile kernel/Makefile This means those Makefiles will stop appending the size data. I dropped the 'override size_append' hack from usr/Makefile. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Bug: 135791357 (cherry picked from commit 7ce7e984ab2b218d6e92d5165629022fe2daf9ee https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master) Change-Id: I3524909ef3daab85f7d22afdebc2e5bbfd5e5cf3 [szuweilin: Resolved the conflict about non-existing zstd22 in arch/s390/boot/compressed/Makefile] Signed-off-by: SzuWei Lin --- arch/arm/boot/compressed/Makefile | 8 +++---- arch/h8300/boot/compressed/Makefile | 4 +++- arch/mips/boot/compressed/Makefile | 12 +++++------ arch/parisc/boot/compressed/Makefile | 10 ++++----- arch/s390/boot/compressed/Makefile | 10 ++++----- arch/sh/boot/compressed/Makefile | 8 +++---- arch/x86/boot/compressed/Makefile | 12 +++++------ scripts/Makefile.lib | 31 +++++++++++++++++++++------- usr/Makefile | 5 ----- 9 files changed, 57 insertions(+), 43 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 175213d7a1aa..37c3036cd468 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -76,10 +76,10 @@ CPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" CPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" compress-$(CONFIG_KERNEL_GZIP) = gzip -compress-$(CONFIG_KERNEL_LZO) = lzo -compress-$(CONFIG_KERNEL_LZMA) = lzma -compress-$(CONFIG_KERNEL_XZ) = xzkern -compress-$(CONFIG_KERNEL_LZ4) = lz4 +compress-$(CONFIG_KERNEL_LZO) = lzo_with_size +compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size +compress-$(CONFIG_KERNEL_XZ) = xzkern_with_size +compress-$(CONFIG_KERNEL_LZ4) = lz4_with_size libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile index 5942793f77a0..6ab2fa5ba105 100644 --- a/arch/h8300/boot/compressed/Makefile +++ b/arch/h8300/boot/compressed/Makefile @@ -30,9 +30,11 @@ $(obj)/vmlinux.bin: vmlinux FORCE suffix-$(CONFIG_KERNEL_GZIP) := gzip suffix-$(CONFIG_KERNEL_LZO) := lzo +compress-$(CONFIG_KERNEL_GZIP) := gzip +compress-$(CONFIG_KERNEL_LZO) := lzo_with_size $(obj)/vmlinux.bin.$(suffix-y): $(obj)/vmlinux.bin FORCE - $(call if_changed,$(suffix-y)) + $(call if_changed,$(compress-y)) LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T OBJCOPYFLAGS := -O binary diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index eae0fad30f27..69eda7ab110a 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -71,12 +71,12 @@ $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE $(call if_changed,objcopy) tool_$(CONFIG_KERNEL_GZIP) = gzip -tool_$(CONFIG_KERNEL_BZIP2) = bzip2 -tool_$(CONFIG_KERNEL_LZ4) = lz4 -tool_$(CONFIG_KERNEL_LZMA) = lzma -tool_$(CONFIG_KERNEL_LZO) = lzo -tool_$(CONFIG_KERNEL_XZ) = xzkern -tool_$(CONFIG_KERNEL_ZSTD) = zstd22 +tool_$(CONFIG_KERNEL_BZIP2) = bzip2_with_size +tool_$(CONFIG_KERNEL_LZ4) = lz4_with_size +tool_$(CONFIG_KERNEL_LZMA) = lzma_with_size +tool_$(CONFIG_KERNEL_LZO) = lzo_with_size +tool_$(CONFIG_KERNEL_XZ) = xzkern_with_size +tool_$(CONFIG_KERNEL_ZSTD) = zstd22_with_size targets += vmlinux.bin.z $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compressed/Makefile index dff453687530..c09300a6ba98 100644 --- a/arch/parisc/boot/compressed/Makefile +++ b/arch/parisc/boot/compressed/Makefile @@ -73,15 +73,15 @@ suffix-$(CONFIG_KERNEL_XZ) := xz $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile index b235ed95a3d8..0e4b585885f0 100644 --- a/arch/s390/boot/compressed/Makefile +++ b/arch/s390/boot/compressed/Makefile @@ -49,15 +49,15 @@ suffix-$(CONFIG_KERNEL_XZ) := .xz $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index 589d2d8a573d..0525d8abdf45 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -58,13 +58,13 @@ vmlinux.bin.all-y := $(obj)/vmlinux.bin $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) OBJCOPYFLAGS += -R .empty_zero_page diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index bf91e0a36d77..57820a9763df 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -125,17 +125,17 @@ vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE - $(call if_changed,zstd22) + $(call if_changed,zstd22_with_size) suffix-$(CONFIG_KERNEL_GZIP) := gz suffix-$(CONFIG_KERNEL_BZIP2) := bz2 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 28f73e4355b1..33aaad005caa 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -401,20 +401,31 @@ printf "%08x\n" $$dec_size | \ ) quiet_cmd_bzip2 = BZIP2 $@ - cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ + cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@ + +quiet_cmd_bzip2_with_size = BZIP2 $@ + cmd_bzip2_with_size = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ - cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ + cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@ + +quiet_cmd_lzma_with_size = LZMA $@ + cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ quiet_cmd_lzo = LZO $@ - cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ + cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@ + +quiet_cmd_lzo_with_size = LZO $@ + cmd_lzo_with_size = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ quiet_cmd_lz4 = LZ4 $@ - cmd_lz4 = { cat $(real-prereqs) | \ - $(LZ4) -l -12 --favor-decSpeed stdin stdout; \ + cmd_lz4 = cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout > $@ + +quiet_cmd_lz4_with_size = LZ4 $@ + cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout; \ $(size_append); } > $@ # U-Boot mkimage @@ -457,7 +468,10 @@ quiet_cmd_uimage = UIMAGE $@ # big dictionary would increase the memory usage too much in the multi-call # decompression mode. A BCJ filter isn't used either. quiet_cmd_xzkern = XZKERN $@ - cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ + cmd_xzkern = cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh > $@ + +quiet_cmd_xzkern_with_size = XZKERN $@ + cmd_xzkern_with_size = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ $(size_append); } > $@ quiet_cmd_xzmisc = XZMISC $@ @@ -483,7 +497,10 @@ quiet_cmd_zstd = ZSTD $@ cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@ quiet_cmd_zstd22 = ZSTD22 $@ - cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ + cmd_zstd22 = cat $(real-prereqs) | $(ZSTD) -22 --ultra > $@ + +quiet_cmd_zstd22_with_size = ZSTD22 $@ + cmd_zstd22_with_size = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ # ASM offsets # --------------------------------------------------------------------------- diff --git a/usr/Makefile b/usr/Makefile index b1a81a40eab1..7b89c0175a3a 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -3,11 +3,6 @@ # kbuild file for usr/ - including initramfs image # -# cmd_bzip2, cmd_lzma, cmd_lzo, cmd_lz4 from scripts/Makefile.lib appends the -# size at the end of the compressed file, which unfortunately does not work -# with unpack_to_rootfs(). Make size_append no-op. -override size_append := : - compress-y := shipped compress-$(CONFIG_INITRAMFS_COMPRESSION_GZIP) := gzip compress-$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) := bzip2 From 1d61c5b5a06a3a19c2cfcb84f7a907827875c829 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 19 Sep 2022 15:20:43 -0700 Subject: [PATCH 37/68] Revert "FROMLIST: scsi: ufs: Fix deadlocks between power management and error handler" This reverts commit f68d040c318f8022628d89e794b78326b352a9fe. Patch "scsi: ufs: core: Reduce the power mode change timeout" caused a spike in the number of UFS suspend timeouts. Hence revert that change and also later UFS driver changes. Bug: b/246990788 Change-Id: Ic20594727d47dc6d9af9a320d64bd7011112e789 Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index fb62a8210075..9ee325116902 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9337,13 +9337,16 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); + down(&hba->host_sem); if (pm_runtime_suspended(dev)) goto out; ret = __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM); - if (ret) + if (ret) { dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret); + up(&hba->host_sem); + } out: if (!ret) @@ -9376,6 +9379,7 @@ out: hba->curr_dev_pwr_mode, hba->uic_link_state); if (!ret) hba->is_sys_suspended = false; + up(&hba->host_sem); return ret; } #endif From 0cf7d9ce9f839d9e268e4073753dfb2cdb9eb704 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 19 Sep 2022 15:20:50 -0700 Subject: [PATCH 38/68] Revert "UPSTREAM: scsi: ufs: core: Reduce the power mode change timeout" This reverts commit 3d35c6b91d6d370ca5166efa990588ee43267721. Patch "scsi: ufs: core: Reduce the power mode change timeout" caused a spike in the number of UFS suspend timeouts. Hence revert that change and also later UFS driver changes. Bug: b/246990788 Change-Id: I5aae929f0598020dc5e7c440946eb0d2101b07cc Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9ee325116902..45ee1adefc08 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8826,8 +8826,6 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_device *sdp; unsigned long flags; int ret, retries; - unsigned long deadline; - int32_t remaining; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->sdev_ufs_device; @@ -8860,14 +8858,9 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ - deadline = jiffies + 10 * HZ; for (retries = 3; retries > 0; --retries) { - ret = -ETIMEDOUT; - remaining = deadline - jiffies; - if (remaining <= 0) - break; ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, - remaining / HZ, 0, 0, RQF_PM, NULL); + START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); if (!scsi_status_is_check_condition(ret) || !scsi_sense_valid(&sshdr) || sshdr.sense_key != UNIT_ATTENTION) From 5625e355a9c41837357efdeb6ac7bc07ddef122b Mon Sep 17 00:00:00 2001 From: Tadeusz Struk Date: Tue, 13 Sep 2022 10:56:54 -0700 Subject: [PATCH 39/68] ANDROID: incfs: Add check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr Add an explicite check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr. Both of these attributes can not be set at the same time, otherwise notify_change() function will check it and invoke BUG(), crashing the system. Bug: 243394930 Signed-off-by: Tadeusz Struk Change-Id: I91080d68efbd62f1441e20a5c02feef3d1b06e4e --- fs/incfs/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index e97b843a4da5..7d349ee73bc3 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -1592,6 +1592,10 @@ static int incfs_setattr(struct dentry *dentry, struct iattr *ia) if (ia->ia_valid & ATTR_SIZE) return -EINVAL; + if ((ia->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) && + (ia->ia_valid & ATTR_MODE)) + return -EINVAL; + if (!di) return -EINVAL; backing_dentry = di->backing_path.dentry; From d25aa0dbae2a9ab2f1b117a164ea935c584cb01e Mon Sep 17 00:00:00 2001 From: Weichao Guo Date: Wed, 7 Sep 2022 10:38:48 +0800 Subject: [PATCH 40/68] FROMLIST: f2fs: let FI_OPU_WRITE override FADVISE_COLD_BIT Cold files may be fragmented due to SSR, defragment is needed as sequential reads are dominant scenarios of these files. FI_OPU_WRITE should override FADVISE_COLD_BIT to avoid defragment fails. Bug: 246903585 Signed-off-by: Weichao Guo Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Weichao Guo Link: https://lore.kernel.org/all/YxlTQ3H+PPKcvpyc@google.com/T/ Change-Id: I52ab86a15ec275772c5356bfc985803bbdde4408 --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 103e7038356f..75446c54624b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2549,7 +2549,7 @@ bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio) return true; /* if this is cold file, we should overwrite to avoid fragmentation */ - if (file_is_cold(inode)) + if (file_is_cold(inode) && !is_inode_flag_set(inode, FI_OPU_WRITE)) return true; return check_inplace_update_policy(inode, fio); From 7b87b9ddb4ef0308c8bd4c862a720001ef5ced79 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 15 Sep 2022 11:39:30 -0700 Subject: [PATCH 41/68] ANDROID: kleaf: Explicit list of ABI files. In BUILD.bazel, explicitly list abi_definition, kmi_symbol_list, and additional_kmi_symbol_lists. This avoids using the glob expression which may accidentally match editor backup files. Bug: 246344503 Test: TH Change-Id: I3cd494dee47b68a0fe7c3c80dd379b5af6b060fe Signed-off-by: Yifan Hong --- BUILD.bazel | 28 +++++++++++++++++++++++----- build.config.gki.aarch64 | 3 +-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 885571722c52..f780ffd87460 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -19,8 +19,26 @@ package( load("//build/kernel/kleaf:common_kernels.bzl", "define_common_kernels") -# This uses android/abi_gki_aarch64* in kmi_configs. If the list of -# glob(["android/abi_gki_aarch64*"]) differs from -# KMI_SYMBOL_LIST + ADDITIONAL_KMI_SYMBOL_LISTS in build.config.gki.aarch64, -# or TRIM_NONLISTED_KMI changes, override kmi_configs here. -define_common_kernels() +_aarch64_additional_kmi_symbol_lists = [ + # keep sorted + "android/abi_gki_aarch64_core", + "android/abi_gki_aarch64_db845c", + "android/abi_gki_aarch64_fips140", + "android/abi_gki_aarch64_generic", + "android/abi_gki_aarch64_hikey960", + "android/abi_gki_aarch64_virtual_device", +] + +define_common_kernels(target_configs = { + # Sync with build.config.gki.aarch64 + "kernel_aarch64": { + "kmi_symbol_list": "android/abi_gki_aarch64", + "additional_kmi_symbol_lists": _aarch64_additional_kmi_symbol_lists, + "abi_definition": "android/abi_gki_aarch64.xml", + }, + "kernel_aarch64_debug": { + "kmi_symbol_list": "android/abi_gki_aarch64", + "additional_kmi_symbol_lists": _aarch64_additional_kmi_symbol_lists, + "abi_definition": "android/abi_gki_aarch64.xml", + }, +}) diff --git a/build.config.gki.aarch64 b/build.config.gki.aarch64 index 479bed504395..45f1caeb3ff6 100644 --- a/build.config.gki.aarch64 +++ b/build.config.gki.aarch64 @@ -7,9 +7,8 @@ Image.lz4 Image.gz " +# Sync with BUILD.bazel ABI_DEFINITION=android/abi_gki_aarch64.xml -# Update BUILD.bazel, define_common_kernels() if the list differs from -# android/abi_gki_aarch64* in the filesystem. KMI_SYMBOL_LIST=android/abi_gki_aarch64 ADDITIONAL_KMI_SYMBOL_LISTS=" android/abi_gki_aarch64_core From aec8f79a0fc6da7662842a4f77cc4c40df0bcf10 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Wed, 21 Sep 2022 21:08:55 +0530 Subject: [PATCH 42/68] ANDROID: GKI: db845c: Update symbols list and ABI android13-5.10 is broken on Dragonboard 845c because of recently added snd_pcm_* symbols. So updated the symbols list by running: "BUILD_CONFIG=common/build.config.db845c \ KMI_SYMBOL_LIST_ADD_ONLY=1 build/build_abi.sh -s" And the abi_gki_aarch64 ABI by running: "BUILD_CONFIG=common/build.config.gki.aarch64 \ ABI_DEFINITION=abi_gki_aarch64.xml KMI_SYMBOL_LIST_ADD_ONLY=1 \ build/build_abi.sh --update --print-report" ======================================================== ABI DIFFERENCES HAVE BEEN DETECTED! 3 symbol(s) added 'int snd_pcm_create_iec958_consumer_default(u8 *, size_t)' 'int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *, u8 *, size_t)' 'int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *, u8 *, size_t)' ======================================================== Bug: 146449535 Fixes: 8de9ae8605ff ("UPSTREAM: ALSA: iec958: Split status creation and fill") Signed-off-by: Amit Pundir Change-Id: I0ae0be501faea03f67feb9358b8e44f70571f2df --- android/abi_gki_aarch64.xml | 202 ++++++++++++++++++--------------- android/abi_gki_aarch64_db845c | 94 +++++++-------- 2 files changed, 158 insertions(+), 138 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 1b628cab49f8..24fb6b9a3465 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3001,7 +3001,10 @@ + + + @@ -9968,23 +9971,7 @@ - - - - - - - - - - - - - - - - - + @@ -45147,11 +45134,6 @@ - - - - - @@ -77724,6 +77706,9 @@ + + + @@ -85645,6 +85630,9 @@ + + + @@ -100118,7 +100106,20 @@ - + + + + + + + + + + + + + + @@ -110904,25 +110905,25 @@ - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + @@ -110982,21 +110983,21 @@ - - - + + + - - - - + + + + - - - - + + + + @@ -111017,13 +111018,13 @@ - - - - - - - + + + + + + + @@ -111032,14 +111033,14 @@ - - - - - - - - + + + + + + + + @@ -111424,9 +111425,9 @@ - - - + + + @@ -111436,15 +111437,15 @@ - - - + + + - + - + @@ -125515,10 +125516,27 @@ - - - - + + + + + + + + + + + + + + + + + + + + + @@ -127218,36 +127236,36 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/android/abi_gki_aarch64_db845c b/android/abi_gki_aarch64_db845c index 69be1905a229..ec944e48a1b9 100644 --- a/android/abi_gki_aarch64_db845c +++ b/android/abi_gki_aarch64_db845c @@ -54,7 +54,6 @@ cpumask_next cpu_number __cpu_online_mask - crc32_le debugfs_create_dir debugfs_create_file debugfs_create_u32 @@ -185,7 +184,6 @@ free_irq generic_handle_irq get_device - get_random_bytes gic_nonsecure_priorities gpiochip_add_data_with_key gpiochip_add_pin_range @@ -419,7 +417,6 @@ preempt_schedule_notrace prepare_to_wait_event printk - pskb_expand_head put_device __put_task_struct qcom_smem_state_register @@ -505,7 +502,6 @@ simple_read_from_buffer single_open single_release - skb_clone skb_dequeue skb_pull skb_push @@ -553,6 +549,7 @@ strlen strncmp strncpy + strnlen strpbrk strsep __sw_hweight32 @@ -655,9 +652,11 @@ cfg80211_vendor_cmd_reply cpu_latency_qos_add_request cpu_latency_qos_remove_request + crc32_le device_get_mac_address device_set_wakeup_enable firmware_request_nowarn + get_random_bytes guid_gen idr_for_each ieee80211_alloc_hw_nm @@ -710,11 +709,13 @@ init_uts_ns __kfifo_alloc __kfifo_free + ktime_get_with_offset __local_bh_enable_ip memmove __nla_parse nla_put param_ops_ulong + pskb_expand_head regulatory_hint rfc1042_header skb_copy @@ -751,44 +752,6 @@ devm_clk_bulk_get_optional iommu_map -# required by ax88179_178a.ko - eth_platform_get_mac_address - ethtool_op_get_link - ethtool_op_get_ts_info - eth_validate_addr - generic_mii_ioctl - mii_ethtool_get_link_ksettings - mii_ethtool_gset - mii_ethtool_set_link_ksettings - mii_nway_restart - netdev_err - netdev_info - netdev_warn - netif_carrier_on - usb_deregister - usbnet_disconnect - usbnet_get_endpoints - usbnet_get_msglevel - usbnet_get_stats64 - usbnet_link_change - usbnet_nway_reset - usbnet_open - usbnet_probe - usbnet_read_cmd - usbnet_read_cmd_nopm - usbnet_resume - usbnet_set_msglevel - usbnet_skb_return - usbnet_start_xmit - usbnet_stop - usbnet_suspend - usbnet_tx_timeout - usbnet_update_max_qlen - usbnet_write_cmd - usbnet_write_cmd_async - usbnet_write_cmd_nopm - usb_register_driver - # required by bam_dma.ko dma_async_device_register dma_async_device_unregister @@ -1303,9 +1266,6 @@ usb_put_hcd usb_remove_hcd -# required by pdr_interface.ko - strnlen - # required by phy-qcom-qmp.ko of_clk_get_by_name __of_reset_control_get @@ -1489,6 +1449,7 @@ refcount_dec_and_mutex_lock release_sock sk_alloc + skb_clone skb_copy_bits skb_copy_datagram_iter skb_free_datagram @@ -1577,7 +1538,9 @@ snd_ctl_add snd_ctl_new1 snd_pcm_add_chmap_ctls - snd_pcm_create_iec958_consumer_hw_params + snd_pcm_create_iec958_consumer_default + snd_pcm_fill_iec958_consumer + snd_pcm_fill_iec958_consumer_hw_params snd_pcm_hw_constraint_eld # required by snd-soc-qcom-common.ko @@ -1701,3 +1664,42 @@ # required by wcd934x.ko mfd_add_devices mfd_remove_devices + +# preserved by --additions-only + eth_platform_get_mac_address + ethtool_op_get_link + ethtool_op_get_ts_info + eth_validate_addr + generic_mii_ioctl + mii_ethtool_get_link_ksettings + mii_ethtool_gset + mii_ethtool_set_link_ksettings + mii_nway_restart + netdev_err + netdev_info + netdev_warn + netif_carrier_on + snd_pcm_create_iec958_consumer_hw_params + usb_deregister + usbnet_disconnect + usbnet_get_endpoints + usbnet_get_msglevel + usbnet_get_stats64 + usbnet_link_change + usbnet_nway_reset + usbnet_open + usbnet_probe + usbnet_read_cmd + usbnet_read_cmd_nopm + usbnet_resume + usbnet_set_msglevel + usbnet_skb_return + usbnet_start_xmit + usbnet_stop + usbnet_suspend + usbnet_tx_timeout + usbnet_update_max_qlen + usbnet_write_cmd + usbnet_write_cmd_async + usbnet_write_cmd_nopm + usb_register_driver From af4d4153ca0cda390521ff612061750bfdec9424 Mon Sep 17 00:00:00 2001 From: Hongyu Jin Date: Fri, 1 Apr 2022 19:55:27 +0800 Subject: [PATCH 43/68] BACKPORT: erofs: fix use-after-free of on-stack io[] The root cause is the race as follows: Thread #1 Thread #2(irq ctx) z_erofs_runqueue() struct z_erofs_decompressqueue io_A[]; submit bio A z_erofs_decompress_kickoff(,,1) z_erofs_decompressqueue_endio(bio A) z_erofs_decompress_kickoff(,,-1) spin_lock_irqsave() atomic_add_return() io_wait_event() -> pending_bios is already 0 [end of function] wake_up_locked(io_A[]) // crash Referenced backtrace in kernel 5.4: [ 10.129422] Unable to handle kernel paging request at virtual address eb0454a4 [ 10.364157] CPU: 0 PID: 709 Comm: getprop Tainted: G WC O 5.4.147-ab09225 #1 [ 11.556325] [] (__wake_up_common) from [] (__wake_up_locked+0x40/0x48) [ 11.565487] [] (__wake_up_locked) from [] (z_erofs_vle_unzip_kickoff+0x6c/0xc0) [ 11.575438] [] (z_erofs_vle_unzip_kickoff) from [] (z_erofs_vle_read_endio+0x16c/0x17c) [ 11.586082] [] (z_erofs_vle_read_endio) from [] (clone_endio+0xb4/0x1d0) [ 11.595428] [] (clone_endio) from [] (blk_update_request+0x150/0x4dc) [ 11.604516] [] (blk_update_request) from [] (mmc_blk_cqe_complete_rq+0x144/0x15c) [ 11.614640] [] (mmc_blk_cqe_complete_rq) from [] (blk_done_softirq+0xb0/0xcc) [ 11.624419] [] (blk_done_softirq) from [] (__do_softirq+0x184/0x56c) [ 11.633419] [] (__do_softirq) from [] (irq_exit+0xd4/0x138) [ 11.641640] [] (irq_exit) from [] (__handle_domain_irq+0x94/0xd0) [ 11.650381] [] (__handle_domain_irq) from [] (gic_handle_irq+0x50/0xd4) [ 11.659641] [] (gic_handle_irq) from [] (__irq_svc+0x70/0xb0) Bug: 246657836 Change-Id: Ieebf1c5abb48723538d05a5e65b5179a382dab3f (cherry picked from commit 60b30050116c0351b90154044345c1b53ae1f323) [Hongyu: Resolved minor conflict in fs/erofs/zdata.c ] Signed-off-by: Hongyu Jin Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20220401115527.4935-1-hongyu.jin.cn@gmail.com Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 12 ++++-------- fs/erofs/zdata.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 03a3dafc82f3..bff7bf2f7586 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -770,12 +770,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, /* wake up the caller thread for sync decompression */ if (sync) { - unsigned long flags; - - spin_lock_irqsave(&io->u.wait.lock, flags); if (!atomic_add_return(bios, &io->pending_bios)) - wake_up_locked(&io->u.wait); - spin_unlock_irqrestore(&io->u.wait.lock, flags); + complete(&io->u.done); + return; } @@ -1186,7 +1183,7 @@ jobqueue_init(struct super_block *sb, } else { fg_out: q = fgq; - init_waitqueue_head(&fgq->u.wait); + init_completion(&fgq->u.done); atomic_set(&fgq->pending_bios, 0); } q->sb = sb; @@ -1360,8 +1357,7 @@ static void z_erofs_runqueue(struct super_block *sb, return; /* wait until all bios are completed */ - io_wait_event(io[JQ_SUBMIT].u.wait, - !atomic_read(&io[JQ_SUBMIT].pending_bios)); + wait_for_completion_io(&io[JQ_SUBMIT].u.done); /* handle synchronous decompress queue in the caller context */ z_erofs_decompress_queue(&io[JQ_SUBMIT], pagepool); diff --git a/fs/erofs/zdata.h b/fs/erofs/zdata.h index 4a69515dea75..5e9a0eb54c89 100644 --- a/fs/erofs/zdata.h +++ b/fs/erofs/zdata.h @@ -89,7 +89,7 @@ struct z_erofs_decompressqueue { z_erofs_next_pcluster_t head; union { - wait_queue_head_t wait; + struct completion done; struct work_struct work; } u; }; From 3dc6e416a159a0bf3336e4c3469531fbbd128146 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 21 Sep 2022 20:34:48 +0000 Subject: [PATCH 44/68] ANDROID: force struct blk_mq_alloc_data to be defined in KMI There were 3 remaining types directly referenced by vendor hooks that were not fully-defined in the KMI: struct blk_mq_alloc_data is defined in block/blk-mq.h, however libabigail is not finding its definition based on the instantiation of the hooks, so force it to be defined by defining a dummy exported symbol. Since blk_mq_alloc_data is defined in a subsystem-private header, create a new vendor_hooks.c file in block/ to define the dummy symbol. Bug: 233047575 Bug: 248263460 Signed-off-by: Todd Kjos Change-Id: I6419caba1c6a159b7a64b9d28e983d753393af86 --- BUILD.bazel | 1 + android/abi_gki_aarch64_type_visibility | 4 ++++ block/Makefile | 1 + block/vendor_hooks.c | 24 ++++++++++++++++++++++++ build.config.gki.aarch64 | 1 + drivers/android/vendor_hooks.c | 3 --- 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 android/abi_gki_aarch64_type_visibility create mode 100644 block/vendor_hooks.c diff --git a/BUILD.bazel b/BUILD.bazel index f780ffd87460..8a7f131ba6e7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -26,6 +26,7 @@ _aarch64_additional_kmi_symbol_lists = [ "android/abi_gki_aarch64_fips140", "android/abi_gki_aarch64_generic", "android/abi_gki_aarch64_hikey960", + "android/abi_gki_aarch64_type_visibility", "android/abi_gki_aarch64_virtual_device", ] diff --git a/android/abi_gki_aarch64_type_visibility b/android/abi_gki_aarch64_type_visibility new file mode 100644 index 000000000000..4f826b7b1f87 --- /dev/null +++ b/android/abi_gki_aarch64_type_visibility @@ -0,0 +1,4 @@ +[abi_symbol_list] + +# for type visibility + GKI_struct_blk_mq_alloc_data diff --git a/block/Makefile b/block/Makefile index af3d044abaf1..05daaf8282a1 100644 --- a/block/Makefile +++ b/block/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o obj-$(CONFIG_BLK_PM) += blk-pm.o obj-$(CONFIG_BLK_INLINE_ENCRYPTION) += keyslot-manager.o blk-crypto.o obj-$(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) += blk-crypto-fallback.o +obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/block/vendor_hooks.c b/block/vendor_hooks.c new file mode 100644 index 000000000000..db033b9e2835 --- /dev/null +++ b/block/vendor_hooks.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* vendor_hook.c + * + * Copyright 2022 Google LLC + */ +#include "blk.h" +#include "blk-mq-tag.h" +#include "blk-mq.h" +#include + +#define CREATE_TRACE_POINTS +#include +#include +#include + +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_rq_ctx_init); + +/* + * For type visibility + */ +const struct blk_mq_alloc_data *GKI_struct_blk_mq_alloc_data; +EXPORT_SYMBOL_GPL(GKI_struct_blk_mq_alloc_data); + diff --git a/build.config.gki.aarch64 b/build.config.gki.aarch64 index 45f1caeb3ff6..dde70d69dd33 100644 --- a/build.config.gki.aarch64 +++ b/build.config.gki.aarch64 @@ -11,6 +11,7 @@ Image.gz ABI_DEFINITION=android/abi_gki_aarch64.xml KMI_SYMBOL_LIST=android/abi_gki_aarch64 ADDITIONAL_KMI_SYMBOL_LISTS=" +android/abi_gki_aarch64_type_visibility android/abi_gki_aarch64_core android/abi_gki_aarch64_fips140 android/abi_gki_aarch64_generic diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 8ddb3f6664fc..d313d85eb576 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -270,8 +269,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_insert); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_node_delete); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_node_replace); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_lookup); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_rq_ctx_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_commit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_override_creds); From f8136944246662cdc7992765f89434049b546fb0 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 21 Sep 2022 22:31:07 +0000 Subject: [PATCH 45/68] ANDROID: force struct cgroup_taskset to be defined in KMI struct cgroup_taskset is defined in kernel/cgroup/cgroup-internal.h, however libabigail is not finding its definition based on the instantiation of the hooks, so force it to be defined by defining a dummy exported symbol. Since cgroup_taskset is defined in a subsystem-private header, create a new vendor_hooks.c file in kernel/cgroup to define the dummy symbol. Update the XML with the new type definitions Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: I7a2bf2a722bf5aec0c702f215d572cc8e5336f9a --- android/abi_gki_aarch64.xml | 250 +++++++++++++----------- android/abi_gki_aarch64_type_visibility | 1 + drivers/android/vendor_hooks.c | 7 +- kernel/cgroup/Makefile | 1 + kernel/cgroup/vendor_hooks.c | 37 ++++ 5 files changed, 174 insertions(+), 122 deletions(-) create mode 100644 kernel/cgroup/vendor_hooks.c diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 24fb6b9a3465..aa802204073f 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3716,6 +3716,8 @@ + + @@ -4222,14 +4224,6 @@ - - - - - - - - @@ -8888,7 +8882,7 @@ - + @@ -12473,6 +12467,7 @@ + @@ -13014,7 +13009,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -15068,6 +15085,7 @@ + @@ -26209,7 +26227,7 @@ - + @@ -29784,6 +29802,7 @@ + @@ -45473,6 +45492,7 @@ + @@ -49601,32 +49621,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -72008,36 +72003,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72048,7 +72043,7 @@ - + @@ -72072,96 +72067,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -73495,7 +73490,26 @@ - + + + + + + + + + + + + + + + + + + + + @@ -76800,7 +76814,7 @@ - + @@ -99577,7 +99591,7 @@ - + @@ -99594,7 +99608,7 @@ - + @@ -99602,7 +99616,7 @@ - + @@ -99610,12 +99624,12 @@ - + - + @@ -99623,7 +99637,7 @@ - + @@ -99631,7 +99645,7 @@ - + @@ -99648,12 +99662,12 @@ - + - + @@ -99679,7 +99693,7 @@ - + @@ -99690,7 +99704,7 @@ - + @@ -99710,7 +99724,7 @@ - + @@ -99733,7 +99747,7 @@ - + @@ -99747,12 +99761,12 @@ - + - + @@ -99763,7 +99777,7 @@ - + @@ -99777,7 +99791,7 @@ - + @@ -99788,7 +99802,7 @@ - + @@ -99802,7 +99816,7 @@ - + @@ -99816,12 +99830,12 @@ - + - + @@ -99829,7 +99843,7 @@ - + @@ -99843,7 +99857,7 @@ - + @@ -99851,7 +99865,7 @@ - + @@ -99862,7 +99876,7 @@ - + @@ -99879,7 +99893,7 @@ - + @@ -99899,7 +99913,7 @@ - + @@ -99916,7 +99930,7 @@ - + @@ -99927,7 +99941,7 @@ - + @@ -99935,7 +99949,7 @@ - + @@ -99943,7 +99957,7 @@ - + @@ -99951,7 +99965,7 @@ - + @@ -99965,7 +99979,7 @@ - + @@ -99973,7 +99987,7 @@ - + @@ -99984,7 +99998,7 @@ - + @@ -100001,7 +100015,7 @@ - + @@ -107680,7 +107694,7 @@ - + @@ -109402,6 +109416,8 @@ + + diff --git a/android/abi_gki_aarch64_type_visibility b/android/abi_gki_aarch64_type_visibility index 4f826b7b1f87..8a98e59ea81b 100644 --- a/android/abi_gki_aarch64_type_visibility +++ b/android/abi_gki_aarch64_type_visibility @@ -2,3 +2,4 @@ # for type visibility GKI_struct_blk_mq_alloc_data + GKI_struct_cgroup_taskset diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d313d85eb576..7966f96c1834 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -62,7 +62,9 @@ #include #include #include +#ifdef __GENKSYMS__ #include +#endif #include #include #include @@ -104,7 +106,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_fair); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_rt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_dl); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_fallback_rq); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_refrigerator); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scheduler_tick); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_enqueue_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dequeue_task); @@ -249,8 +250,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_eff_get); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_task_util); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_rq_util_with); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_create_worker); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick); @@ -315,7 +314,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_slab_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_comm); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_setaffinity_early); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_task); @@ -333,7 +331,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_is_initialized); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_inactive_ratio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_of_i2c_get_board_info); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_dirty_limits); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks); diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile index 5d7a76bfbbb7..c8bc5cbe1d45 100644 --- a/kernel/cgroup/Makefile +++ b/kernel/cgroup/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_CGROUP_PIDS) += pids.o obj-$(CONFIG_CGROUP_RDMA) += rdma.o obj-$(CONFIG_CPUSETS) += cpuset.o obj-$(CONFIG_CGROUP_DEBUG) += debug.o +obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/kernel/cgroup/vendor_hooks.c b/kernel/cgroup/vendor_hooks.c new file mode 100644 index 000000000000..95f7e3410d7d --- /dev/null +++ b/kernel/cgroup/vendor_hooks.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* vendor_hook.c + * + * Android Vendor Hook Support + * + * Copyright 2022 Google LLC + */ +#ifndef __GENKSYMS__ +#include "cgroup-internal.h" +#else +/* + * Needed to preserve CRC for cgroup-related hooks + */ +#include +#include <../drivers/gpio/gpiolib.h> +#endif + +#define CREATE_TRACE_POINTS +#include +#include +#include + +/* + * Export tracepoints that act as a bare tracehook (ie: have no trace event + * associated with them) to allow external modules to probe them. + */ +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_refrigerator); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); + +/* + * For type visibility + */ +const struct cgroup_taskset *GKI_struct_cgroup_taskset; +EXPORT_SYMBOL_GPL(GKI_struct_cgroup_taskset); From 8483cc3a75a2ec9c646551737db5bb42b6362468 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Thu, 22 Sep 2022 17:24:36 +0800 Subject: [PATCH 46/68] ANDROID: Enable BUILD_GKI_CERTIFICATION_TOOLS for x86_64 GKI The tools are required to certify a x86_64 GKI boot.img. Bug: 241497048 Test: BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh Signed-off-by: Bowgo Tsai Change-Id: I0a34b9c8376cdfd77fb9b58b1b50ac734696672f (cherry picked from commit 35b34f288013b85fffee79525c711a6d1f49753e) --- build.config.gki.x86_64 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.config.gki.x86_64 b/build.config.gki.x86_64 index 7ecd1dfe7dcb..3d81fea6aacb 100644 --- a/build.config.gki.x86_64 +++ b/build.config.gki.x86_64 @@ -5,5 +5,7 @@ BUILD_SYSTEM_DLKM=1 MODULES_LIST=${ROOT_DIR}/${KERNEL_DIR}/android/gki_system_dlkm_modules +BUILD_GKI_CERTIFICATION_TOOLS=1 + BUILD_GKI_ARTIFACTS=1 BUILD_GKI_BOOT_IMG_SIZE=67108864 From 494e7075c95df7c664a6eb8aa97ca89e9661a2b6 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Mon, 15 Aug 2022 10:12:59 -0700 Subject: [PATCH 47/68] ANDROID: fuse-bpf: readddir postfilter fixes Test: fuse_test passes, with appropriate user code directories can be hidden Bug: 219958836 Signed-off-by: Paul Lawrence Change-Id: Ia77d4bf9e63d0dd4535e53e9e07c3216fd4b8430 --- fs/fuse/backing.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index b536fd9e99b7..49b848e4462d 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -23,6 +23,9 @@ struct fuse_bpf_aio_req { static struct kmem_cache *fuse_bpf_aio_request_cachep; +static void fuse_stat_to_attr(struct fuse_conn *fc, struct inode *inode, + struct kstat *stat, struct fuse_attr *attr); + static void fuse_file_accessed(struct file *dst_file, struct file *src_file) { struct inode *dst_inode; @@ -181,8 +184,10 @@ void *fuse_open_finalize(struct fuse_bpf_args *fa, struct fuse_file *ff = file->private_data; struct fuse_open_out *foo = fa->out_args[0].value; - if (ff) + if (ff) { ff->fh = foo->fh; + ff->nodeid = get_fuse_inode(inode)->nodeid; + } return 0; } @@ -1153,6 +1158,9 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, struct dentry *dir_backing_entry = dir_fuse_entry->backing_path.dentry; struct inode *dir_backing_inode = dir_backing_entry->d_inode; struct dentry *backing_entry; + struct fuse_entry_out *feo = (void *)fa->out_args[0].value; + struct kstat stat; + int err; /* TODO this will not handle lookups over mount points */ inode_lock_nested(dir_backing_inode, I_MUTEX_PARENT); @@ -1165,10 +1173,21 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, fuse_entry->backing_path = (struct path) { .dentry = backing_entry, - .mnt = dir_fuse_entry->backing_path.mnt, + .mnt = mntget(dir_fuse_entry->backing_path.mnt), }; - mntget(fuse_entry->backing_path.mnt); + if (d_is_negative(backing_entry)) + return 0; + + err = vfs_getattr(&fuse_entry->backing_path, &stat, + STATX_BASIC_STATS, 0); + if (err) { + path_put_init(&fuse_entry->backing_path); + return err; + } + + fuse_stat_to_attr(get_fuse_conn(dir), + backing_entry->d_inode, &stat, &feo->attr); return 0; } From 1bd5344779e7d607fecdb47a2536d676fa0330ab Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Wed, 31 Aug 2022 14:41:11 -0700 Subject: [PATCH 48/68] ANDROID: fuse-bpf: Add test for lookup postfilter Test: fuse_test passes Bug: 219958836 Signed-off-by: Paul Lawrence Change-Id: I04a68af274ecf823a96e2f0ead49f56d2f1c1452 --- .../selftests/filesystems/fuse/fuse_test.c | 60 ++++++++++++++++++- .../selftests/filesystems/fuse/test_bpf.c | 13 ++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index 58a0dd587fec..ffc960aa6315 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1911,6 +1911,63 @@ out: return result; } +static int bpf_test_lookup_postfilter(const char *mount_dir) +{ + const char *file1_name = "file1"; + const char *file2_name = "file2"; + int result = TEST_FAILURE; + int bpf_fd = -1; + int src_fd = -1; + int fuse_dev = -1; + int file_fd = -1; + int pid = -1; + int status; + + TEST(file_fd = s_creat(s_path(s(ft_src), s(file1_name)), 0777), + file_fd != -1); + TESTSYSCALL(close(file_fd)); + TEST(file_fd = s_creat(s_path(s(ft_src), s(file2_name)), 0777), + file_fd != -1); + TESTSYSCALL(close(file_fd)); + file_fd = -1; + TESTEQUAL(install_elf_bpf("test_bpf.bpf", "test_lookup_postfilter", + &bpf_fd, NULL, NULL), 0); + TEST(src_fd = open(ft_src, O_DIRECTORY | O_RDONLY | O_CLOEXEC), + src_fd != -1); + TESTEQUAL(mount_fuse(mount_dir, bpf_fd, src_fd, &fuse_dev), 0); + FUSE_ACTION + int fd = -1; + + TESTEQUAL(s_open(s_path(s(mount_dir), s(file1_name)), O_RDONLY), + -1); + TESTEQUAL(errno, ENOENT); + TEST(fd = s_open(s_path(s(mount_dir), s(file2_name)), O_RDONLY), + fd != -1); + TESTSYSCALL(close(fd)); + FUSE_DAEMON + struct fuse_entry_out *feo; + struct fuse_entry_bpf_out *febo; + + TESTFUSELOOKUP(file1_name, FUSE_POSTFILTER); + TESTFUSEOUTERROR(-ENOENT); + TESTFUSELOOKUP(file2_name, FUSE_POSTFILTER); + feo = (struct fuse_entry_out *) (bytes_in + + sizeof(struct fuse_in_header) + strlen(file2_name) + 1); + febo = (struct fuse_entry_bpf_out *) ((char *)feo + + sizeof(*feo)); + TESTFUSEOUT2(fuse_entry_out, *feo, fuse_entry_bpf_out, *febo); + FUSE_DONE + + result = TEST_SUCCESS; +out: + close(file_fd); + close(fuse_dev); + umount(mount_dir); + close(src_fd); + close(bpf_fd); + return result; +} + static int parse_options(int argc, char *const *argv) { signed char c; @@ -2017,7 +2074,8 @@ int main(int argc, char *argv[]) MAKE_TEST(bpf_test_lseek), MAKE_TEST(bpf_test_readdirplus_not_overriding_backing), MAKE_TEST(bpf_test_no_readdirplus_without_nodeid), - MAKE_TEST(bpf_test_revalidate_handle_backing_fd) + MAKE_TEST(bpf_test_revalidate_handle_backing_fd), + MAKE_TEST(bpf_test_lookup_postfilter), }; #undef MAKE_TEST diff --git a/tools/testing/selftests/filesystems/fuse/test_bpf.c b/tools/testing/selftests/filesystems/fuse/test_bpf.c index 472a02aef5b5..b47445735ab6 100644 --- a/tools/testing/selftests/filesystems/fuse/test_bpf.c +++ b/tools/testing/selftests/filesystems/fuse/test_bpf.c @@ -524,3 +524,16 @@ int readdirplus_test(struct fuse_bpf_args *fa) } return FUSE_BPF_BACKING; } + +SEC("test_lookup_postfilter") +int lookuppostfilter_test(struct fuse_bpf_args *fa) +{ + switch(fa->opcode) { + case FUSE_LOOKUP | FUSE_PREFILTER: + return FUSE_BPF_BACKING | FUSE_BPF_POST_FILTER; + case FUSE_LOOKUP | FUSE_POSTFILTER: + return FUSE_BPF_USER_FILTER; + default: + return FUSE_BPF_BACKING; + } +} From 1856a68952a90a34d459f55d06f84f2177601ca6 Mon Sep 17 00:00:00 2001 From: Hsiu-Chang Chen Date: Fri, 23 Sep 2022 14:40:39 +0800 Subject: [PATCH 49/68] ANDROID: Update the ABI representation 2 symbol(s) added 'struct user_namespace init_user_ns' 'bool ns_capable_noaudit(struct user_namespace *, int)' Bug: 234311675 Signed-off-by: Hsiu-Chang Chen Change-Id: I78851c0ada381095bbac338a331bcd2cc2cd8cde --- android/abi_gki_aarch64.xml | 192 +++++++++++++++++--------------- android/abi_gki_aarch64_generic | 2 + 2 files changed, 102 insertions(+), 92 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index aa802204073f..8e649b4467c9 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -2272,6 +2272,7 @@ + @@ -3891,6 +3892,7 @@ + @@ -5421,7 +5423,7 @@ - + @@ -8882,7 +8884,7 @@ - + @@ -16954,7 +16956,7 @@ - + @@ -26227,7 +26229,7 @@ - + @@ -71872,7 +71874,15 @@ - + + + + + + + + + @@ -71883,14 +71893,6 @@ - - - - - - - - @@ -72003,36 +72005,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72043,7 +72045,7 @@ - + @@ -72067,96 +72069,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76814,7 +76816,7 @@ - + @@ -99591,7 +99593,7 @@ - + @@ -99608,7 +99610,7 @@ - + @@ -99616,7 +99618,7 @@ - + @@ -99624,12 +99626,12 @@ - + - + @@ -99637,7 +99639,7 @@ - + @@ -99645,7 +99647,7 @@ - + @@ -99662,12 +99664,12 @@ - + - + @@ -99693,7 +99695,7 @@ - + @@ -99704,7 +99706,7 @@ - + @@ -99724,7 +99726,7 @@ - + @@ -99747,7 +99749,7 @@ - + @@ -99761,12 +99763,12 @@ - + - + @@ -99777,7 +99779,7 @@ - + @@ -99791,7 +99793,7 @@ - + @@ -99802,7 +99804,7 @@ - + @@ -99816,7 +99818,7 @@ - + @@ -99830,12 +99832,12 @@ - + - + @@ -99843,7 +99845,7 @@ - + @@ -99857,7 +99859,7 @@ - + @@ -99865,7 +99867,7 @@ - + @@ -99876,7 +99878,7 @@ - + @@ -99893,7 +99895,7 @@ - + @@ -99913,7 +99915,7 @@ - + @@ -99930,7 +99932,7 @@ - + @@ -99941,7 +99943,7 @@ - + @@ -99949,7 +99951,7 @@ - + @@ -99957,7 +99959,7 @@ - + @@ -99965,7 +99967,7 @@ - + @@ -99979,7 +99981,7 @@ - + @@ -99987,7 +99989,7 @@ - + @@ -99998,7 +100000,7 @@ - + @@ -100015,7 +100017,7 @@ - + @@ -107694,7 +107696,7 @@ - + @@ -119667,6 +119669,7 @@ + @@ -121729,6 +121732,11 @@ + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 966896aa05e3..ad0af06c1cd6 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1052,6 +1052,7 @@ __init_swait_queue_head init_task init_timer_key + init_user_ns init_wait_entry __init_waitqueue_head input_alloc_absinfo @@ -1375,6 +1376,7 @@ nr_cpu_ids nr_irqs ns_capable + ns_capable_noaudit nsec_to_clock_t ns_to_timespec64 __num_online_cpus From 7b19b0064b9bc52f5bd09b253d0d3003eb13d70d Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Fri, 5 Mar 2021 16:06:58 +0800 Subject: [PATCH 50/68] UPSTREAM: kernel/irq: export irq_gc_set_wake Module driver may use irq_gc_set_wake. Bug: 194515348 Change-Id: I52f43e1dff15d987532395e5151e65419b5904b2 Signed-off-by: Jianqun Xu Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20210305080658.2422114-1-jay.xu@rock-chips.com Signed-off-by: Linus Walleij (cherry picked from commit 024c79520ff5f8cfb9666cdb877af30c554c540f) Signed-off-by: Kever Yang --- kernel/irq/generic-chip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index e2999a070a99..79cb6d063b80 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c @@ -200,6 +200,7 @@ int irq_gc_set_wake(struct irq_data *d, unsigned int on) irq_gc_unlock(gc); return 0; } +EXPORT_SYMBOL_GPL(irq_gc_set_wake); static u32 irq_readl_be(void __iomem *addr) { From 7a6ea55aa01ad68460ef10b47abedef555b0a4a1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 27 Sep 2022 14:04:37 +0200 Subject: [PATCH 51/68] Revert "ANDROID: workqueue: add vendor hook for wq lockup information" This reverts commit 34f087452f27d1f07a6f8a214fdeb83846e9e670. The hook android_vh_wq_lockup_pool is not used by any vendor, so remove it to help with merge issues with future LTS releases. If this is needed by any real user, it can easily be reverted to add it back and then the symbol should be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 169374262 Cc: Sangmoon Kim Signed-off-by: Greg Kroah-Hartman Change-Id: I84eb7e1abc535a4efecd2b6071ef6d25fa2c1e2e --- drivers/android/vendor_hooks.c | 2 -- include/trace/hooks/wqlockup.h | 21 --------------------- kernel/workqueue.c | 2 -- 3 files changed, 25 deletions(-) delete mode 100644 include/trace/hooks/wqlockup.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 7966f96c1834..9d54e5a7d6d1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -148,7 +147,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mpam_set); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_resume); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_lockup_pool); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ipi_stop); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sysrq_crash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dump_throttled_rt_tasks); diff --git a/include/trace/hooks/wqlockup.h b/include/trace/hooks/wqlockup.h deleted file mode 100644 index 2572ebf5eff4..000000000000 --- a/include/trace/hooks/wqlockup.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM wqlockup -#define TRACE_INCLUDE_PATH trace/hooks - -#if !defined(_TRACE_HOOK_WQLOCKUP_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_HOOK_WQLOCKUP_H -#include -/* - * Following tracepoints are not exported in tracefs and provide a - * mechanism for vendor modules to hook and extend functionality - */ -DECLARE_HOOK(android_vh_wq_lockup_pool, - TP_PROTO(int cpu, unsigned long pool_ts), - TP_ARGS(cpu, pool_ts)); - -/* macro versions of hooks are no longer required */ - -#endif /* _TRACE_HOOK_WQLOCKUP_H */ -/* This part must be outside protection */ -#include diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 9334aef949f5..d89b24db809f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -54,7 +54,6 @@ #include "workqueue_internal.h" -#include #include /* events/workqueue.h uses default TRACE_INCLUDE_PATH */ #undef TRACE_INCLUDE_PATH @@ -5845,7 +5844,6 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) pr_cont_pool_info(pool); pr_cont(" stuck for %us!\n", jiffies_to_msecs(now - pool_ts) / 1000); - trace_android_vh_wq_lockup_pool(pool->cpu, pool_ts); } } From 14e1028389b8641d034d0d6978cc1e7e0e58d54b Mon Sep 17 00:00:00 2001 From: John Stultz Date: Mon, 8 Aug 2022 16:56:00 +0000 Subject: [PATCH 52/68] ANDROID: sched: Fix off-by-one with cpupri MAX_RT_PRIO evaluation This patch addresses an issue seen where SCHED_FIFO prio 99 tasks were being woken up on a cpu where a long-running softirq was executing, and the RT task was not being migrated, causing long (10+ms wakeup latencies). Prior to upstream commit 934fc3314b39 ("sched/cpupri: Remap CPUPRI_NORMAL to MAX_RT_PRIO-1") the task->prio -> cpupri mapping is a little ackward. For RT tasks, its calculated as: cpupri = MAX_RT_PRIO - prio + 1; See: https://android.googlesource.com/kernel/common/+/refs/heads/android13-5.10/kernel/sched/cpupri.c#39 This is added ontop of the also ackward detail that the task->prio is inverted (RT prio99 -> 0), means the cpupri mapping for RT tasks goes from 2->101. This makes it easy to evaluate the cpupri incorrectly. Which it turns out happened In commit 3adfd8e344ac ("ANDROID: sched: avoid placing RT threads on cores handling softirqs"): https://android.googlesource.com/kernel/common/+/3adfd8e344ac32845eb3c15743f90a7e3b49dcf3%5E%21/ With the lines: int task_pri = convert_prio(p->prio); bool drop_nopreempts = task_pri <= MAX_RT_PRIO; Where the added logic to decide to migrate a rt task off of a cpu depended on this drop_nopreempts being true. This works properly for rt tasks from prio 99 to 1, but for the case of task->prio == 0 (userland rt prio 99 tasks) it breaks, as the cpupri will be MAX_RT_PRIO - 0 + 1, which then gets checked as <= MAX_RT_PRIO. This prevents the cpu from being dropped from the scheduling set and prevents the rt user prio 99 task from migrating, which results in high priority rt tasks being left on cpus where long running softirqs are executing, causing long latencies. This patch fixes the off by one by changing the evaulation to MAX_RT_PRIO + 1, so that user-prio 99 tasks will also be migrated if appropriate. Luckilly this odd cpupri mapping has been fixed upstream, making this patch no longer necessary in 5.15 and newer kernels. Fixes: 3adfd8e344ac ("ANDROID: sched: avoid placing RT threads on cores handling softirqs") Signed-off-by: John Stultz Change-Id: Ia2db7cd461eb4c90f5850b791de1ae95582f7530 --- kernel/sched/cpupri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index 450a724b4542..2896860c8333 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -150,7 +150,7 @@ int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p, { int task_pri = convert_prio(p->prio); int idx, cpu; - bool drop_nopreempts = task_pri <= MAX_RT_PRIO; + bool drop_nopreempts = task_pri <= MAX_RT_PRIO + 1; BUG_ON(task_pri >= CPUPRI_NR_PRIORITIES); From d91e7b80d89a382a32d16eaefdf548e3d37436ff Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 29 Sep 2022 03:57:37 +0000 Subject: [PATCH 53/68] ANDROID: Update the ABI representation 1 symbol(s) added 'void drm_atomic_bridge_chain_disable(struct drm_bridge *, struct drm_atomic_state *)' Bug: 233709537 Signed-off-by: Leo Chen Change-Id: I1e3e5c41f3c32404dc25c1f69f447efb3cbafb5d --- android/abi_gki_aarch64.xml | 248 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 2 + 2 files changed, 129 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 8e649b4467c9..9ef5c780fb9e 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1197,6 +1197,7 @@ + @@ -5423,7 +5424,7 @@ - + @@ -13295,72 +13296,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16956,7 +16957,7 @@ - + @@ -67103,69 +67104,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -68535,12 +68536,12 @@ - + - + - + @@ -71874,15 +71875,7 @@ - - - - - - - - - + @@ -71893,6 +71886,14 @@ + + + + + + + + @@ -73750,45 +73751,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -84666,15 +84667,15 @@ - + - + - + - + @@ -111916,10 +111917,10 @@ - - - - + + + + @@ -112859,16 +112860,16 @@ - - + + - - + + - - + + @@ -114217,7 +114218,7 @@ - + @@ -114397,16 +114398,16 @@ - - + + - - + + @@ -116187,8 +116188,8 @@ - - + + @@ -116237,6 +116238,11 @@ + + + + + @@ -118051,16 +118057,16 @@ - - + + - - + + - - + + @@ -121371,11 +121377,11 @@ - - - - - + + + + + @@ -123549,17 +123555,17 @@ - - - - - + + + + + - - - - + + + + @@ -126703,12 +126709,12 @@ - - - + + + - - + + @@ -128997,8 +129003,8 @@ - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index ad0af06c1cd6..51f6c19865a1 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -629,6 +629,7 @@ drm_add_modes_noedid drm_atomic_add_affected_connectors drm_atomic_add_affected_planes + drm_atomic_bridge_chain_disable drm_atomic_commit drm_atomic_get_connector_state drm_atomic_get_crtc_state @@ -964,6 +965,7 @@ gpiod_get_raw_value_cansleep gpiod_get_value gpiod_get_value_cansleep + gpiod_set_debounce gpiod_set_raw_value gpiod_set_raw_value_cansleep gpiod_set_value From 9fafd34f1d7088338612338cb98b4a3010645433 Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Mon, 4 Jul 2022 17:43:54 +0900 Subject: [PATCH 54/68] UPSTREAM: wifi: mac80211_hwsim: fix race condition in pending packet commit 4ee186fa7e40ae06ebbfbad77e249e3746e14114 upstream. A pending packet uses a cookie as an unique key, but it can be duplicated because it didn't use atomic operators. And also, a pending packet can be null in hwsim_tx_info_frame_received_nl due to race condition with mac80211_hwsim_stop. For this, * Use an atomic type and operator for a cookie * Add a lock around the loop for pending packets Signed-off-by: Jeongik Cha Link: https://lore.kernel.org/r/20220704084354.3556326-1-jeongik@google.com Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman (cherry picked from commit eb8fc4277b628ac81db806c130a500dd48a9e524) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: Ic6613c8869a51b5de303e40406f023af689b9d64 --- drivers/net/wireless/mac80211_hwsim.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6911e588e578..85fc2b6aa45c 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -597,7 +597,7 @@ struct mac80211_hwsim_data { bool ps_poll_pending; struct dentry *debugfs; - uintptr_t pending_cookie; + atomic64_t pending_cookie; struct sk_buff_head pending; /* packets pending */ /* * Only radios in the same group can communicate together (the @@ -1204,7 +1204,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, int i; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; - uintptr_t cookie; + u64 cookie; if (data->ps != PS_DISABLED) hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -1273,8 +1273,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; /* We create a cookie to identify this skb */ - data->pending_cookie++; - cookie = data->pending_cookie; + cookie = (u64)atomic64_inc_return(&data->pending_cookie); info->rate_driver_data[0] = (void *)cookie; if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) goto nla_put_failure; @@ -3511,6 +3510,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, const u8 *src; unsigned int hwsim_flags; int i; + unsigned long flags; bool found = false; if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || @@ -3538,18 +3538,20 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, } /* look for the skb matching the cookie passed back from user */ + spin_lock_irqsave(&data2->pending.lock, flags); skb_queue_walk_safe(&data2->pending, skb, tmp) { u64 skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; + skb_cookie = (u64)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { - skb_unlink(skb, &data2->pending); + __skb_unlink(skb, &data2->pending); found = true; break; } } + spin_unlock_irqrestore(&data2->pending.lock, flags); /* not found */ if (!found) From 80c59100dade6805d807181102a01b369955a0d9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 11 Jul 2022 13:14:24 +0200 Subject: [PATCH 55/68] UPSTREAM: wifi: mac80211_hwsim: add back erroneously removed cast commit 58b6259d820d63c2adf1c7541b54cce5a2ae6073 upstream. The robots report that we're now casting to a differently sized integer, which is correct, and the previous patch had erroneously removed it. Reported-by: kernel test robot Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet") Signed-off-by: Johannes Berg Cc: Jeongik Cha Signed-off-by: Greg Kroah-Hartman (cherry picked from commit d400222f49599423862010f0c7f6fee142be72d7) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: I4b5cfa77c47d4d03b46600f0b543e27340c228c0 --- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 85fc2b6aa45c..9ca6497c6bf9 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3543,7 +3543,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, u64 skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)txi->rate_driver_data[0]; + skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { __skb_unlink(skb, &data2->pending); From 9c24cb8704b15761290390010a211e8ea1eebe22 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 13 Jul 2022 21:16:45 +0200 Subject: [PATCH 56/68] UPSTREAM: wifi: mac80211_hwsim: use 32-bit skb cookie commit cc5250cdb43d444061412df7fae72d2b4acbdf97 upstream. We won't really have enough skbs to need a 64-bit cookie, and on 32-bit platforms storing the 64-bit cookie into the void *rate_driver_data doesn't work anyway. Switch back to using just a 32-bit cookie and uintptr_t for the type to avoid compiler warnings about all this. Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet") Signed-off-by: Johannes Berg Cc: Jeongik Cha Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 6dece5ad6e1e7d8c2bacfae606dc6f18a18c51e0) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: I81b075297ec2248f706aebc914cd5e2783665bbc --- drivers/net/wireless/mac80211_hwsim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 9ca6497c6bf9..9157257925e1 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -597,7 +597,7 @@ struct mac80211_hwsim_data { bool ps_poll_pending; struct dentry *debugfs; - atomic64_t pending_cookie; + atomic_t pending_cookie; struct sk_buff_head pending; /* packets pending */ /* * Only radios in the same group can communicate together (the @@ -1204,7 +1204,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, int i; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; - u64 cookie; + uintptr_t cookie; if (data->ps != PS_DISABLED) hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -1273,7 +1273,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; /* We create a cookie to identify this skb */ - cookie = (u64)atomic64_inc_return(&data->pending_cookie); + cookie = atomic_inc_return(&data->pending_cookie); info->rate_driver_data[0] = (void *)cookie; if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) goto nla_put_failure; @@ -3540,10 +3540,10 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, /* look for the skb matching the cookie passed back from user */ spin_lock_irqsave(&data2->pending.lock, flags); skb_queue_walk_safe(&data2->pending, skb, tmp) { - u64 skb_cookie; + uintptr_t skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; + skb_cookie = (uintptr_t)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { __skb_unlink(skb, &data2->pending); From 5495c19c30eab29208c5209bb019c280064c057e Mon Sep 17 00:00:00 2001 From: Oleg Matcovschi Date: Wed, 28 Sep 2022 15:47:05 -0700 Subject: [PATCH 57/68] ANDROID: Update the ABI symbol list and xml 1 symbol(s) added 'bool drm_mode_parse_command_line_for_connector(const char *, const struct drm_connector *, struct drm_cmdline_mode *)' Bug: 197774385 Signed-off-by: Oleg Matcovschi Signed-off-by: Will McVicker Change-Id: If1686604cc37be5698b4a80f574ad1c907d80137 --- android/abi_gki_aarch64.xml | 250 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 130 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 9ef5c780fb9e..d590d27623ce 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1418,6 +1418,7 @@ + @@ -4912,7 +4913,7 @@ - + @@ -8885,7 +8886,7 @@ - + @@ -15836,6 +15837,7 @@ + @@ -26230,7 +26232,7 @@ - + @@ -61739,7 +61741,7 @@ - + @@ -61830,7 +61832,7 @@ - + @@ -71896,27 +71898,27 @@ - + - + - + - + - + - + - + @@ -71932,22 +71934,22 @@ - + - + - + - + - + - + @@ -72006,36 +72008,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72046,7 +72048,7 @@ - + @@ -72070,96 +72072,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76817,7 +76819,7 @@ - + @@ -86940,7 +86942,7 @@ - + @@ -87020,22 +87022,22 @@ - + - + - + - + - + - + @@ -99482,7 +99484,7 @@ - + @@ -99490,7 +99492,7 @@ - + @@ -99498,7 +99500,7 @@ - + @@ -99506,12 +99508,12 @@ - + - + @@ -99519,7 +99521,7 @@ - + @@ -99530,7 +99532,7 @@ - + @@ -99538,18 +99540,18 @@ - + - + - - + + @@ -99563,12 +99565,12 @@ - + - + @@ -99576,12 +99578,12 @@ - + - + @@ -99589,12 +99591,12 @@ - + - + @@ -99611,7 +99613,7 @@ - + @@ -99619,7 +99621,7 @@ - + @@ -99627,12 +99629,12 @@ - + - + @@ -99640,7 +99642,7 @@ - + @@ -99648,7 +99650,7 @@ - + @@ -99665,12 +99667,12 @@ - + - + @@ -99696,7 +99698,7 @@ - + @@ -99707,7 +99709,7 @@ - + @@ -99727,7 +99729,7 @@ - + @@ -99750,7 +99752,7 @@ - + @@ -99764,12 +99766,12 @@ - + - + @@ -99780,7 +99782,7 @@ - + @@ -99794,7 +99796,7 @@ - + @@ -99805,7 +99807,7 @@ - + @@ -99819,7 +99821,7 @@ - + @@ -99833,12 +99835,12 @@ - + - + @@ -99846,7 +99848,7 @@ - + @@ -99860,7 +99862,7 @@ - + @@ -99868,7 +99870,7 @@ - + @@ -99879,7 +99881,7 @@ - + @@ -99896,7 +99898,7 @@ - + @@ -99916,7 +99918,7 @@ - + @@ -99933,7 +99935,7 @@ - + @@ -99944,7 +99946,7 @@ - + @@ -99952,7 +99954,7 @@ - + @@ -99960,7 +99962,7 @@ - + @@ -99968,7 +99970,7 @@ - + @@ -99982,7 +99984,7 @@ - + @@ -99990,7 +99992,7 @@ - + @@ -100001,7 +100003,7 @@ - + @@ -100018,7 +100020,7 @@ - + @@ -104828,7 +104830,7 @@ - + @@ -107697,7 +107699,7 @@ - + @@ -117364,6 +117366,12 @@ + + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 51f6c19865a1..cc974608cece 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -755,6 +755,7 @@ drm_mode_object_find drm_mode_object_get drm_mode_object_put + drm_mode_parse_command_line_for_connector drm_mode_probed_add drm_modeset_acquire_fini drm_modeset_acquire_init From 8015dd49c00e036b214801b34a727b7c98aa84e3 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 20 Sep 2022 12:06:58 -0700 Subject: [PATCH 58/68] FROMGIT: KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available() Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is not available. This prevents "Protected KVM" cpu capability being reported when Linux is booting in EL1 and would not have KVM enabled. Reasonably though, we should warn if the command line is requesting a KVM mode at all if KVM isn't actually available. Allow "kvm-arm.mode=none" to skip the warning since this would disable KVM anyway. Signed-off-by: Elliot Berman Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220920190658.2880184-1-quic_eberman@quicinc.com Bug: 249052880 (cherry picked from commit b2a4d007c347b4cb4c60f7512733c3f8300a129c https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next) Change-Id: I196649fc00537e563a1fab0a22bf23c5b7abe00d Signed-off-by: Elliot Berman --- arch/arm64/kvm/arm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 86cbee644a39..8e22c300752c 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2286,6 +2286,16 @@ static int __init early_kvm_mode_cfg(char *arg) if (!arg) return -EINVAL; + if (strcmp(arg, "none") == 0) { + kvm_mode = KVM_MODE_NONE; + return 0; + } + + if (!is_hyp_mode_available()) { + pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n"); + return 0; + } + if (strcmp(arg, "protected") == 0) { if (!is_kernel_in_hyp_mode()) kvm_mode = KVM_MODE_PROTECTED; @@ -2300,11 +2310,6 @@ static int __init early_kvm_mode_cfg(char *arg) return 0; } - if (strcmp(arg, "none") == 0) { - kvm_mode = KVM_MODE_NONE; - return 0; - } - return -EINVAL; } early_param("kvm-arm.mode", early_kvm_mode_cfg); From ab9c52146ff66b4e14f0d3c2dc6014212db235c0 Mon Sep 17 00:00:00 2001 From: Rick Yiu Date: Thu, 22 Sep 2022 07:18:33 +0000 Subject: [PATCH 59/68] ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass Vendor could decide to bypass this function. Bug: 238390134 Change-Id: Ia6bc71c7569d21da9ae226e5d8739f97b9ca1a4f Signed-off-by: Rick Yiu --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 4 ++++ kernel/cgroup/cpuset.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9d54e5a7d6d1..73efd5503d2f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -409,3 +409,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmput); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_early_resume_begin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rebuild_root_domains_bypass); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 4f345029ea09..bb84a6c428ad 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -392,6 +392,10 @@ DECLARE_HOOK(android_vh_pidfd_open, DECLARE_HOOK(android_vh_mmput, TP_PROTO(void *unused), TP_ARGS(unused)); + +DECLARE_HOOK(android_vh_rebuild_root_domains_bypass, + TP_PROTO(bool cpuhp_tasks_frozen, bool *bypass), + TP_ARGS(cpuhp_tasks_frozen, bypass)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3a0204d880db..76440c9e545b 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -941,6 +941,12 @@ static void rebuild_root_domains(void) { struct cpuset *cs = NULL; struct cgroup_subsys_state *pos_css; + bool bypass = false; + + trace_android_vh_rebuild_root_domains_bypass(cpuhp_tasks_frozen, &bypass); + + if (bypass) + return; lockdep_assert_held(&cpuset_mutex); lockdep_assert_cpus_held(); From e56825d04840d2c577a033544782c7cd8abacad9 Mon Sep 17 00:00:00 2001 From: Fuad Tabba Date: Wed, 28 Sep 2022 11:24:05 +0100 Subject: [PATCH 60/68] ANDROID: KVM: arm64: Initialize ptr auth in protected mode Ensure that pointer authentication is initialized when the vcpu is initialized as well, and not only when the vcpu is reset. Bug: 249192647 Signed-off-by: Fuad Tabba Change-Id: Ida39a3ee5e6b4b0d3255bfef95601890afd80709 --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 9b2e303dd124..50717a46e735 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -414,6 +414,15 @@ static int set_host_vcpus(struct shadow_vcpu_state *shadow_vcpus, int nr_vcpus, return 0; } +static int init_ptrauth(struct kvm_vcpu *shadow_vcpu) +{ + int ret = 0; + if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, shadow_vcpu->arch.features) || + test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, shadow_vcpu->arch.features)) + ret = kvm_vcpu_enable_ptrauth(shadow_vcpu); + return ret; +} + static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm, struct kvm_vcpu **vcpu_array, int nr_vcpus) { @@ -438,6 +447,10 @@ static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm, if (ret) return ret; + ret = init_ptrauth(shadow_vcpu); + if (ret) + return ret; + if (test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features)) { size_t sve_state_size; void *sve_state; @@ -851,14 +864,7 @@ void pkvm_reset_vcpu(struct kvm_vcpu *vcpu) WARN_ON(!reset_state->reset); - if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) || - test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) { - /* - * This call should not fail since we've already checked for - * feature support on initialization. - */ - WARN_ON(kvm_vcpu_enable_ptrauth(vcpu)); - } + init_ptrauth(vcpu); /* Reset core registers */ memset(vcpu_gp_regs(vcpu), 0, sizeof(*vcpu_gp_regs(vcpu))); From cd9914280a17bdae03e7e655e2dbf8f2ea67277d Mon Sep 17 00:00:00 2001 From: Duoming Zhou Date: Wed, 4 May 2022 13:58:47 +0800 Subject: [PATCH 61/68] BACKPORT: NFC: netlink: fix sleep in atomic bug when firmware download timeout commit 4071bf121d59944d5cd2238de0642f3d7995a997 upstream. There are sleep in atomic bug that could cause kernel panic during firmware download process. The root cause is that nlmsg_new with GFP_KERNEL parameter is called in fw_dnld_timeout which is a timer handler. The call trace is shown below: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:265 Call Trace: kmem_cache_alloc_node __alloc_skb nfc_genl_fw_download_done call_timer_fn __run_timers.part.0 run_timer_softirq __do_softirq ... The nlmsg_new with GFP_KERNEL parameter may sleep during memory allocation process, and the timer handler is run as the result of a "software interrupt" that should not call any other function that could sleep. This patch changes allocation mode of netlink message from GFP_KERNEL to GFP_ATOMIC in order to prevent sleep in atomic bug. The GFP_ATOMIC flag makes memory allocation operation could be used in atomic context. Bug: 245675148 Fixes: 9674da8759df ("NFC: Add firmware upload netlink command") Fixes: 9ea7187c53f6 ("NFC: netlink: Rename CMD_FW_UPLOAD to CMD_FW_DOWNLOAD") Signed-off-by: Duoming Zhou Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20220504055847.38026-1-duoming@zju.edu.cn Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I510b617174c0575cc6f438b2edf44f0262f9c09c --- net/nfc/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 78acc4e9ac93..b8939ebaa6d3 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1244,7 +1244,7 @@ int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, struct sk_buff *msg; void *hdr; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!msg) return -ENOMEM; @@ -1260,7 +1260,7 @@ int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, genlmsg_end(msg, hdr); - genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL); + genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC); return 0; From 92fc848ef5480edc74d72099bfa4b9dc77c2b6f9 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Fri, 23 Sep 2022 10:48:51 -0700 Subject: [PATCH 62/68] ANDROID: fuse-bpf: Add ability to run ranges of tests to fuse_test Test: run various range options Signed-off-by: Paul Lawrence Bug: 248576331 Change-Id: I75bfa9b499b974250d4d3e375537de1807268c47 --- .../selftests/filesystems/fuse/fuse_test.c | 127 ++++++++++++------ .../filesystems/fuse/test_framework.h | 1 - 2 files changed, 84 insertions(+), 44 deletions(-) diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index ffc960aa6315..9fe5bfd286be 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1968,7 +1968,50 @@ out: return result; } -static int parse_options(int argc, char *const *argv) +static void parse_range(const char *ranges, bool *run_test, size_t tests) +{ + size_t i; + char *range; + + for (i = 0; i < tests; ++i) + run_test[i] = false; + + range = strtok(optarg, ","); + while (range) { + char *dash = strchr(range, '-'); + + if (dash) { + size_t start = 1, end = tests; + char *end_ptr; + + if (dash > range) { + start = strtol(range, &end_ptr, 10); + if (*end_ptr != '-' || start <= 0 || start > tests) + ksft_exit_fail_msg("Bad range\n"); + } + + if (dash[1]) { + end = strtol(dash + 1, &end_ptr, 10); + if (*end_ptr || end <= start || end > tests) + ksft_exit_fail_msg("Bad range\n"); + } + + for (i = start; i <= end; ++i) + run_test[i - 1] = true; + } else { + char *end; + long value = strtol(range, &end, 10); + + if (*end || value <= 0 || value > tests) + ksft_exit_fail_msg("Bad range\n"); + run_test[value - 1] = true; + } + range = strtok(NULL, ","); + } +} + +static int parse_options(int argc, char *const *argv, bool *run_test, + size_t tests) { signed char c; @@ -1979,7 +2022,7 @@ static int parse_options(int argc, char *const *argv) break; case 't': - test_options.test = strtol(optarg, NULL, 10); + parse_range(optarg, run_test, tests); break; case 'v': @@ -1998,7 +2041,8 @@ struct test_case { const char *name; }; -static void run_one_test(const char *mount_dir, struct test_case *test_case) +static void run_one_test(const char *mount_dir, + const struct test_case *test_case) { ksft_print_msg("Running %s\n", test_case->name); if (test_case->pfunc(mount_dir) == TEST_SUCCESS) @@ -2014,37 +2058,11 @@ int main(int argc, char *argv[]) int i; int fd, count; - if (parse_options(argc, argv)) - ksft_exit_fail_msg("Bad options\n"); - - // Seed randomness pool for testing on QEMU - // NOTE - this abuses the concept of randomness - do *not* ever do this - // on a machine for production use - the device will think it has good - // randomness when it does not. - fd = open("/dev/urandom", O_WRONLY | O_CLOEXEC); - count = 4096; - for (int i = 0; i < 128; ++i) - ioctl(fd, RNDADDTOENTCNT, &count); - close(fd); - - ksft_print_header(); - - if (geteuid() != 0) - ksft_print_msg("Not a root, might fail to mount.\n"); - - if (tracing_on() != TEST_SUCCESS) - ksft_exit_fail_msg("Can't turn on tracing\n"); - - src_dir = setup_mount_dir(ft_src); - mount_dir = setup_mount_dir(ft_dst); - if (src_dir == NULL || mount_dir == NULL) - ksft_exit_fail_msg("Can't create a mount dir\n"); - #define MAKE_TEST(test) \ { \ test, #test \ } - struct test_case cases[] = { + const struct test_case cases[] = { MAKE_TEST(basic_test), MAKE_TEST(bpf_test_real), MAKE_TEST(bpf_test_partial), @@ -2079,23 +2097,46 @@ int main(int argc, char *argv[]) }; #undef MAKE_TEST - if (test_options.test) { - if (test_options.test <= 0 || - test_options.test > ARRAY_SIZE(cases)) - ksft_exit_fail_msg("Invalid test\n"); + bool run_test[ARRAY_SIZE(cases)]; - ksft_set_plan(1); - delete_dir_tree(mount_dir, false); - delete_dir_tree(src_dir, false); - run_one_test(mount_dir, &cases[test_options.test - 1]); - } else { - ksft_set_plan(ARRAY_SIZE(cases)); - for (i = 0; i < ARRAY_SIZE(cases); ++i) { + for (int i = 0; i < ARRAY_SIZE(cases); ++i) + run_test[i] = true; + + if (parse_options(argc, argv, run_test, ARRAY_SIZE(cases))) + ksft_exit_fail_msg("Bad options\n"); + + // Seed randomness pool for testing on QEMU + // NOTE - this abuses the concept of randomness - do *not* ever do this + // on a machine for production use - the device will think it has good + // randomness when it does not. + fd = open("/dev/urandom", O_WRONLY | O_CLOEXEC); + count = 4096; + for (int i = 0; i < 128; ++i) + ioctl(fd, RNDADDTOENTCNT, &count); + close(fd); + + ksft_print_header(); + + if (geteuid() != 0) + ksft_print_msg("Not a root, might fail to mount.\n"); + + if (tracing_on() != TEST_SUCCESS) + ksft_exit_fail_msg("Can't turn on tracing\n"); + + src_dir = setup_mount_dir(ft_src); + mount_dir = setup_mount_dir(ft_dst); + if (src_dir == NULL || mount_dir == NULL) + ksft_exit_fail_msg("Can't create a mount dir\n"); + + ksft_set_plan(ARRAY_SIZE(run_test)); + + for (i = 0; i < ARRAY_SIZE(run_test); ++i) + if (run_test[i]) { delete_dir_tree(mount_dir, false); delete_dir_tree(src_dir, false); run_one_test(mount_dir, &cases[i]); - } - } + } else + ksft_cnt.ksft_xskip++; umount2(mount_dir, MNT_FORCE); delete_dir_tree(mount_dir, true); diff --git a/tools/testing/selftests/filesystems/fuse/test_framework.h b/tools/testing/selftests/filesystems/fuse/test_framework.h index 945f141e9a66..7e832e901d50 100644 --- a/tools/testing/selftests/filesystems/fuse/test_framework.h +++ b/tools/testing/selftests/filesystems/fuse/test_framework.h @@ -40,7 +40,6 @@ static int test_case_fail; struct _test_options { int file; - int test; bool verbose; }; From 9bc66fe57c42cf7580b4b3ed9f6369884aef1d32 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Mon, 3 Oct 2022 09:56:21 -0700 Subject: [PATCH 63/68] ANDROID: fuse-bpf: set error_in to ENOENT in negative lookup Bug: 250617797 Test: fuse-test passes, app installs Signed-off-by: Paul Lawrence Change-Id: I44544f8989d0ddf00a98eaddce5751df6598130f --- fs/fuse/backing.c | 4 +++- tools/testing/selftests/filesystems/fuse/fuse_test.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 49b848e4462d..9f78384b021f 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -1176,8 +1176,10 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, .mnt = mntget(dir_fuse_entry->backing_path.mnt), }; - if (d_is_negative(backing_entry)) + if (d_is_negative(backing_entry)) { + fa->error_in = -ENOENT; return 0; + } err = vfs_getattr(&fuse_entry->backing_path, &stat, STATX_BASIC_STATS, 0); diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index 9fe5bfd286be..461b79656973 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1915,6 +1915,7 @@ static int bpf_test_lookup_postfilter(const char *mount_dir) { const char *file1_name = "file1"; const char *file2_name = "file2"; + const char *file3_name = "file3"; int result = TEST_FAILURE; int bpf_fd = -1; int src_fd = -1; @@ -1944,18 +1945,27 @@ static int bpf_test_lookup_postfilter(const char *mount_dir) TEST(fd = s_open(s_path(s(mount_dir), s(file2_name)), O_RDONLY), fd != -1); TESTSYSCALL(close(fd)); + TESTEQUAL(s_open(s_path(s(mount_dir), s(file3_name)), O_RDONLY), + -1); FUSE_DAEMON + struct fuse_in_header *in_header = + (struct fuse_in_header *)bytes_in; struct fuse_entry_out *feo; struct fuse_entry_bpf_out *febo; TESTFUSELOOKUP(file1_name, FUSE_POSTFILTER); TESTFUSEOUTERROR(-ENOENT); + TESTFUSELOOKUP(file2_name, FUSE_POSTFILTER); feo = (struct fuse_entry_out *) (bytes_in + sizeof(struct fuse_in_header) + strlen(file2_name) + 1); febo = (struct fuse_entry_bpf_out *) ((char *)feo + sizeof(*feo)); TESTFUSEOUT2(fuse_entry_out, *feo, fuse_entry_bpf_out, *febo); + + TESTFUSELOOKUP(file3_name, FUSE_POSTFILTER); + TESTEQUAL(in_header->error_in, -ENOENT); + TESTFUSEOUTERROR(-ENOENT); FUSE_DONE result = TEST_SUCCESS; From b6a23be181a16e9161853b373d7bad8b2c135fbf Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Tue, 4 Oct 2022 20:52:53 +0000 Subject: [PATCH 64/68] ANDROID: Fix for kernelci !CONFIG_SMP break-breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ab9c52146ff6 ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass") introduced a hook that declared a parameter whose name collided with a global variable. If !CONFIG_SMP, this global variable is instead a compile-time constant which causes this error: include/linux/cpu.h:101:28: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant Fixes: ab9c52146ff6 ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass") Signed-off-by: Todd Kjos Change-Id: I7831c5067be2ee548e8f6885eec99ab9085414fa --- include/trace/hooks/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index bb84a6c428ad..4233384f6ff8 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -394,8 +394,8 @@ DECLARE_HOOK(android_vh_mmput, TP_ARGS(unused)); DECLARE_HOOK(android_vh_rebuild_root_domains_bypass, - TP_PROTO(bool cpuhp_tasks_frozen, bool *bypass), - TP_ARGS(cpuhp_tasks_frozen, bypass)); + TP_PROTO(bool tasks_frozen, bool *bypass), + TP_ARGS(tasks_frozen, bypass)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ From 800870b6d4ce9f44d667cb53ff41b6632e2472e1 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 4 Oct 2022 18:57:00 +0000 Subject: [PATCH 65/68] ANDROID: Update the ABI representation 2 function symbol(s) added 'int __traceiter_android_vh_early_resume_begin(void *, void *)' 'int __traceiter_android_vh_resume_end(void *, void *)' 2 variable symbol(s) added 'struct tracepoint __tracepoint_android_vh_early_resume_begin' 'struct tracepoint __tracepoint_android_vh_resume_end' Bug: 241946090 Signed-off-by: Ziyi Cui Change-Id: Ie131055ec01e31a7b72ccb997215c67f71ce6bdc --- android/abi_gki_aarch64.xml | 258 +++++++++++++++++--------------- android/abi_gki_aarch64_generic | 4 + 2 files changed, 141 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index d590d27623ce..bc974a4a06e5 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -260,6 +260,7 @@ + @@ -273,6 +274,7 @@ + @@ -3782,6 +3784,7 @@ + @@ -3795,6 +3798,7 @@ + @@ -4913,7 +4917,7 @@ - + @@ -8886,7 +8890,7 @@ - + @@ -26232,7 +26236,7 @@ - + @@ -61741,7 +61745,7 @@ - + @@ -61832,7 +61836,7 @@ - + @@ -71898,27 +71902,27 @@ - + - + - + - + - + - + - + @@ -71934,22 +71938,22 @@ - + - + - + - + - + - + @@ -72008,36 +72012,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72048,7 +72052,7 @@ - + @@ -72072,96 +72076,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76819,7 +76823,7 @@ - + @@ -86942,7 +86946,7 @@ - + @@ -87022,22 +87026,22 @@ - + - + - + - + - + - + @@ -99484,7 +99488,7 @@ - + @@ -99492,7 +99496,7 @@ - + @@ -99500,7 +99504,7 @@ - + @@ -99508,12 +99512,12 @@ - + - + @@ -99521,7 +99525,7 @@ - + @@ -99532,7 +99536,7 @@ - + @@ -99540,18 +99544,18 @@ - + - + - - + + @@ -99565,12 +99569,12 @@ - + - + @@ -99578,12 +99582,12 @@ - + - + @@ -99591,12 +99595,12 @@ - + - + @@ -99613,7 +99617,7 @@ - + @@ -99621,7 +99625,7 @@ - + @@ -99629,12 +99633,12 @@ - + - + @@ -99642,7 +99646,7 @@ - + @@ -99650,7 +99654,7 @@ - + @@ -99667,12 +99671,12 @@ - + - + @@ -99698,7 +99702,7 @@ - + @@ -99709,7 +99713,7 @@ - + @@ -99729,7 +99733,7 @@ - + @@ -99752,7 +99756,7 @@ - + @@ -99766,12 +99770,12 @@ - + - + @@ -99782,7 +99786,7 @@ - + @@ -99796,7 +99800,7 @@ - + @@ -99807,7 +99811,7 @@ - + @@ -99821,7 +99825,7 @@ - + @@ -99835,12 +99839,12 @@ - + - + @@ -99848,7 +99852,7 @@ - + @@ -99862,7 +99866,7 @@ - + @@ -99870,7 +99874,7 @@ - + @@ -99881,7 +99885,7 @@ - + @@ -99898,7 +99902,7 @@ - + @@ -99918,7 +99922,7 @@ - + @@ -99935,7 +99939,7 @@ - + @@ -99946,7 +99950,7 @@ - + @@ -99954,7 +99958,7 @@ - + @@ -99962,7 +99966,7 @@ - + @@ -99970,7 +99974,7 @@ - + @@ -99984,7 +99988,7 @@ - + @@ -99992,7 +99996,7 @@ - + @@ -100003,7 +100007,7 @@ - + @@ -100020,7 +100024,7 @@ - + @@ -104830,7 +104834,7 @@ - + @@ -107699,7 +107703,7 @@ - + @@ -110974,6 +110978,11 @@ + + + + + @@ -111054,6 +111063,11 @@ + + + + + @@ -111453,6 +111467,7 @@ + @@ -111466,6 +111481,7 @@ + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index cc974608cece..a7069c587ab7 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2244,6 +2244,7 @@ __traceiter_android_vh_cpu_idle_exit __traceiter_android_vh_dump_throttled_rt_tasks __traceiter_android_vh_dup_task_struct + __traceiter_android_vh_early_resume_begin __traceiter_android_vh_enable_thermal_genl_check __traceiter_android_vh_ep_create_wakeup_source __traceiter_android_vh_get_user_pages @@ -2256,6 +2257,7 @@ __traceiter_android_vh_of_i2c_get_board_info __traceiter_android_vh_pagecache_get_page __traceiter_android_vh_pin_user_pages + __traceiter_android_vh_resume_end __traceiter_android_vh_rmqueue __traceiter_android_vh_sched_setaffinity_early __traceiter_android_vh_scheduler_tick @@ -2358,6 +2360,7 @@ __tracepoint_android_vh_cpu_idle_exit __tracepoint_android_vh_dump_throttled_rt_tasks __tracepoint_android_vh_dup_task_struct + __tracepoint_android_vh_early_resume_begin __tracepoint_android_vh_enable_thermal_genl_check __tracepoint_android_vh_ep_create_wakeup_source __tracepoint_android_vh_get_user_pages @@ -2370,6 +2373,7 @@ __tracepoint_android_vh_of_i2c_get_board_info __tracepoint_android_vh_pagecache_get_page __tracepoint_android_vh_pin_user_pages + __tracepoint_android_vh_resume_end __tracepoint_android_vh_rmqueue __tracepoint_android_vh_sched_setaffinity_early __tracepoint_android_vh_scheduler_tick From 9a8b45a9e4311668052f233bc66b7ead85400237 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Wed, 28 Sep 2022 23:38:53 +0800 Subject: [PATCH 66/68] FROMGIT: f2fs: support recording stop_checkpoint reason into super_block This patch supports to record stop_checkpoint error into f2fs_super_block.s_stop_reason[]. Bug: 247456379 Bug: 246094874 (cherry picked from commit 93523dddd98b9838896277fa9cad238a72214f02 https: //git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Change-Id: I3e5fb355a7a7413b1e4bb4937791491ca73e6853 --- fs/f2fs/checkpoint.c | 10 +++++++--- fs/f2fs/data.c | 6 ++++-- fs/f2fs/f2fs.h | 4 +++- fs/f2fs/file.c | 11 ++++++----- fs/f2fs/gc.c | 6 ++++-- fs/f2fs/inode.c | 3 ++- fs/f2fs/segment.c | 5 +++-- fs/f2fs/super.c | 20 ++++++++++++++++++++ include/linux/f2fs_fs.h | 17 ++++++++++++++++- 9 files changed, 65 insertions(+), 17 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 9aae2e6cc981..bf8059060766 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -26,12 +26,16 @@ static struct kmem_cache *ino_entry_slab; struct kmem_cache *f2fs_inode_entry_slab; -void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io) +void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io, + unsigned char reason) { f2fs_build_fault_attr(sbi, 0, 0); set_ckpt_flags(sbi, CP_ERROR_FLAG); - if (!end_io) + if (!end_io) { f2fs_flush_merged_writes(sbi); + + f2fs_handle_stop(sbi, reason); + } } /* @@ -122,7 +126,7 @@ retry: if (PTR_ERR(page) == -EIO && ++count <= DEFAULT_RETRY_IO_COUNT) goto retry; - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_META_PAGE); } return page; } diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 75446c54624b..0b2196e997b8 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -336,7 +336,8 @@ static void f2fs_write_end_io(struct bio *bio) mempool_free(page, sbi->write_io_dummy); if (unlikely(bio->bi_status)) - f2fs_stop_checkpoint(sbi, true); + f2fs_stop_checkpoint(sbi, true, + STOP_CP_REASON_WRITE_FAIL); continue; } @@ -352,7 +353,8 @@ static void f2fs_write_end_io(struct bio *bio) if (unlikely(bio->bi_status)) { mapping_set_error(page->mapping, -EIO); if (type == F2FS_WB_CP_DATA) - f2fs_stop_checkpoint(sbi, true); + f2fs_stop_checkpoint(sbi, true, + STOP_CP_REASON_WRITE_FAIL); } f2fs_bug_on(sbi, page->mapping == NODE_MAPPING(sbi) && diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c5e7a34693b8..c09650fea4ef 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3516,6 +3516,7 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly); int f2fs_quota_sync(struct super_block *sb, int type); loff_t max_file_blocks(struct inode *inode); void f2fs_quota_off_umount(struct super_block *sb); +void f2fs_handle_stop(struct f2fs_sb_info *sbi, unsigned char reason); int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover); int f2fs_sync_fs(struct super_block *sb, int sync); int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi); @@ -3680,7 +3681,8 @@ static inline bool f2fs_need_rand_seg(struct f2fs_sb_info *sbi) /* * checkpoint.c */ -void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io); +void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io, + unsigned char reason); void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi); struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index ea2a5260758c..10612740060d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2273,7 +2273,8 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) if (ret) { if (ret == -EROFS) { ret = 0; - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, + STOP_CP_REASON_SHUTDOWN); set_sbi_flag(sbi, SBI_IS_SHUTDOWN); trace_f2fs_shutdown(sbi, in, ret); } @@ -2286,7 +2287,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ret = freeze_bdev(sb->s_bdev); if (ret) goto out; - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); set_sbi_flag(sbi, SBI_IS_SHUTDOWN); thaw_bdev(sb->s_bdev); break; @@ -2295,16 +2296,16 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ret = f2fs_sync_fs(sb, 1); if (ret) goto out; - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); set_sbi_flag(sbi, SBI_IS_SHUTDOWN); break; case F2FS_GOING_DOWN_NOSYNC: - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); set_sbi_flag(sbi, SBI_IS_SHUTDOWN); break; case F2FS_GOING_DOWN_METAFLUSH: f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO); - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); set_sbi_flag(sbi, SBI_IS_SHUTDOWN); break; case F2FS_GOING_DOWN_NEED_FSCK: diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 3da5583f9dbb..f48b60553630 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -70,7 +70,8 @@ static int gc_thread_func(void *data) if (time_to_inject(sbi, FAULT_CHECKPOINT)) { f2fs_show_injection_info(sbi, FAULT_CHECKPOINT); - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, + STOP_CP_REASON_FAULT_INJECT); } if (!sb_start_write_trylock(sbi->sb)) { @@ -1651,7 +1652,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, f2fs_err(sbi, "Inconsistent segment (%u) type [%d, %d] in SSA and SIT", segno, type, GET_SUM_TYPE((&sum->footer))); set_sbi_flag(sbi, SBI_NEED_FSCK); - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, + STOP_CP_REASON_CORRUPTED_SUMMARY); goto skip; } diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 5fffc2268964..d9757673f45e 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -700,7 +700,8 @@ retry: cond_resched(); goto retry; } else if (err != -ENOENT) { - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, + STOP_CP_REASON_UPDATE_INODE); } return; } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index de1f4ac8191a..af6b14191076 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -498,7 +498,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) { if (time_to_inject(sbi, FAULT_CHECKPOINT)) { f2fs_show_injection_info(sbi, FAULT_CHECKPOINT); - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_FAULT_INJECT); } /* balance_fs_bg is able to be pending */ @@ -809,7 +809,8 @@ int f2fs_flush_device_cache(struct f2fs_sb_info *sbi) } while (ret && --count); if (ret) { - f2fs_stop_checkpoint(sbi, false); + f2fs_stop_checkpoint(sbi, false, + STOP_CP_REASON_FLUSH_FAIL); break; } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index bdea4ec6cebe..28541a527c64 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3861,6 +3861,26 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) return err; } +void f2fs_handle_stop(struct f2fs_sb_info *sbi, unsigned char reason) +{ + struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); + int err; + + f2fs_bug_on(sbi, reason >= MAX_STOP_REASON); + + f2fs_down_write(&sbi->sb_lock); + + if (raw_super->s_stop_reason[reason] < ((1 << BITS_PER_BYTE) - 1)) + raw_super->s_stop_reason[reason]++; + + err = f2fs_commit_super(sbi, false); + if (err) + f2fs_err(sbi, "f2fs_commit_super fails to record reason:%u err:%d", + reason, err); + + f2fs_up_write(&sbi->sb_lock); +} + static int f2fs_scan_devices(struct f2fs_sb_info *sbi) { struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h index d445150c5350..5dd1e52b8997 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h @@ -73,6 +73,20 @@ struct f2fs_device { __le32 total_segments; } __packed; +/* reason of stop_checkpoint */ +enum stop_cp_reason { + STOP_CP_REASON_SHUTDOWN, + STOP_CP_REASON_FAULT_INJECT, + STOP_CP_REASON_META_PAGE, + STOP_CP_REASON_WRITE_FAIL, + STOP_CP_REASON_CORRUPTED_SUMMARY, + STOP_CP_REASON_UPDATE_INODE, + STOP_CP_REASON_FLUSH_FAIL, + STOP_CP_REASON_MAX, +}; + +#define MAX_STOP_REASON 32 + struct f2fs_super_block { __le32 magic; /* Magic Number */ __le16 major_ver; /* Major Version */ @@ -116,7 +130,8 @@ struct f2fs_super_block { __u8 hot_ext_count; /* # of hot file extension */ __le16 s_encoding; /* Filename charset encoding */ __le16 s_encoding_flags; /* Filename charset encoding flags */ - __u8 reserved[306]; /* valid reserved region */ + __u8 s_stop_reason[MAX_STOP_REASON]; /* stop checkpoint reason */ + __u8 reserved[274]; /* valid reserved region */ __le32 crc; /* checksum of superblock */ } __packed; From 6ed90e9805b8d154ed9d3421a188bf6c3584dd30 Mon Sep 17 00:00:00 2001 From: Rick Yiu Date: Thu, 6 Oct 2022 14:59:14 +0000 Subject: [PATCH 67/68] ANDROID: Update the ABI representation 1 function symbol(s) added 'int __traceiter_android_vh_rebuild_root_domains_bypass(void *, bool, bool *)' 1 variable symbol(s) added 'struct tracepoint __tracepoint_android_vh_rebuild_root_domains_bypass' Bug: 238390134 Signed-off-by: Rick Yiu Change-Id: Ic03880e8ad87d07ce3560a1fd4ba456cdd510ab8 --- android/abi_gki_aarch64.xml | 9 +++++++++ android/abi_gki_aarch64_generic | 2 ++ 2 files changed, 11 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index bc974a4a06e5..532be833ec36 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -274,6 +274,7 @@ + @@ -3798,6 +3799,7 @@ + @@ -111063,6 +111065,12 @@ + + + + + + @@ -111481,6 +111489,7 @@ + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index a7069c587ab7..81746e107e32 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2257,6 +2257,7 @@ __traceiter_android_vh_of_i2c_get_board_info __traceiter_android_vh_pagecache_get_page __traceiter_android_vh_pin_user_pages + __traceiter_android_vh_rebuild_root_domains_bypass __traceiter_android_vh_resume_end __traceiter_android_vh_rmqueue __traceiter_android_vh_sched_setaffinity_early @@ -2373,6 +2374,7 @@ __tracepoint_android_vh_of_i2c_get_board_info __tracepoint_android_vh_pagecache_get_page __tracepoint_android_vh_pin_user_pages + __tracepoint_android_vh_rebuild_root_domains_bypass __tracepoint_android_vh_resume_end __tracepoint_android_vh_rmqueue __tracepoint_android_vh_sched_setaffinity_early From befd3e393e6470f7e7acae512e2778eb733d6eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BCller?= Date: Mon, 20 Dec 2021 07:21:53 +0100 Subject: [PATCH 68/68] UPSTREAM: crypto: jitter - add oversampling of noise source The output n bits can receive more than n bits of min entropy, of course, but the fixed output of the conditioning function can only asymptotically approach the output size bits of min entropy, not attain that bound. Random maps will tend to have output collisions, which reduces the creditable output entropy (that is what SP 800-90B Section 3.1.5.1.2 attempts to bound). The value "64" is justified in Appendix A.4 of the current 90C draft, and aligns with NIST's in "epsilon" definition in this document, which is that a string can be considered "full entropy" if you can bound the min entropy in each bit of output to at least 1-epsilon, where epsilon is required to be <= 2^(-32). Note, this patch causes the Jitter RNG to cut its performance in half in FIPS mode because the conditioning function of the LFSR produces 64 bits of entropy in one block. The oversampling requires that additionally 64 bits of entropy are sampled from the noise source. If the conditioner is changed, such as using SHA-256, the impact of the oversampling is only one fourth, because for the 256 bit block of the conditioner, only 64 additional bits from the noise source must be sampled. This patch is derived from the user space jitterentropy-library. Signed-off-by: Stephan Mueller Reviewed-by: Simo Sorce Signed-off-by: Herbert Xu Bug: 188620248 (cherry picked from commit 908dffaf88a248e542bdae3ca174f27b8f4ccf37) Change-Id: I7ae1fe58c1b5ea5f206a8f3675f0c20e255a97ec Signed-off-by: Eric Biggers --- crypto/jitterentropy.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c index 37c4c308339e..423c55d0e165 100644 --- a/crypto/jitterentropy.c +++ b/crypto/jitterentropy.c @@ -117,6 +117,22 @@ struct rand_data { #define JENT_EHEALTH 9 /* Health test failed during initialization */ #define JENT_ERCT 10 /* RCT failed during initialization */ +/* + * The output n bits can receive more than n bits of min entropy, of course, + * but the fixed output of the conditioning function can only asymptotically + * approach the output size bits of min entropy, not attain that bound. Random + * maps will tend to have output collisions, which reduces the creditable + * output entropy (that is what SP 800-90B Section 3.1.5.1.2 attempts to bound). + * + * The value "64" is justified in Appendix A.4 of the current 90C draft, + * and aligns with NIST's in "epsilon" definition in this document, which is + * that a string can be considered "full entropy" if you can bound the min + * entropy in each bit of output to at least 1-epsilon, where epsilon is + * required to be <= 2^(-32). + */ +#define JENT_ENTROPY_SAFETY_FACTOR 64 + +#include #include "jitterentropy.h" /*************************************************************************** @@ -546,7 +562,10 @@ static int jent_measure_jitter(struct rand_data *ec) */ static void jent_gen_entropy(struct rand_data *ec) { - unsigned int k = 0; + unsigned int k = 0, safety_factor = 0; + + if (fips_enabled) + safety_factor = JENT_ENTROPY_SAFETY_FACTOR; /* priming of the ->prev_time value */ jent_measure_jitter(ec); @@ -560,7 +579,7 @@ static void jent_gen_entropy(struct rand_data *ec) * We multiply the loop value with ->osr to obtain the * oversampling rate requested by the caller */ - if (++k >= (DATA_SIZE_BITS * ec->osr)) + if (++k >= ((DATA_SIZE_BITS + safety_factor) * ec->osr)) break; } }