From 64d769e53f2094eb2b39c1de0d920969168dcf12 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 2 Nov 2021 14:50:17 -0700 Subject: [PATCH 01/13] ANDROID: fips140: add service indicators To satisfy the FIPS 140-3 "service indicators" requirement, add a function which checks whether the given algorithm is "approved" or not. Note that this function is a bit different from the module's other APIs in that it is an exported symbol rather than a registration-based API. This avoids needing to make kernel/KMI changes, so I think we should do it this way if possible, given that it's unlikely this function will be used in practice outside of the lab test. Built-in code can still call this function via symbol_get() if it really wants to. Bug: 188620248 Change-Id: I26c976258fa9446b34eb189bba7154142d85da16 Signed-off-by: Eric Biggers (cherry picked from commit fe4b8d3c687efcf27064e472730291edbd81dad6) --- crypto/fips140-module.c | 91 ++++++++++++++++++++++++++++++----------- crypto/fips140-module.h | 2 + 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/crypto/fips140-module.c b/crypto/fips140-module.c index 951fc8ea8255..79b09b070463 100644 --- a/crypto/fips140-module.c +++ b/crypto/fips140-module.c @@ -14,6 +14,8 @@ * don't need to meet these requirements. */ +#undef __DISABLE_EXPORTS + #include #include #include @@ -86,34 +88,37 @@ const u8 *__rodata_start = &__fips140_rodata_start; * When adding a new algorithm here, make sure to consider whether it needs a * self-test added to fips140_selftests[] as well. */ -static const char * const fips140_algorithms[] __initconst = { - "aes", +static const struct { + const char *name; + bool approved; +} fips140_algs_to_replace[] = { + {"aes", true}, - "cmac(aes)", - "ecb(aes)", + {"cmac(aes)", true}, + {"ecb(aes)", true}, - "cbc(aes)", - "cts(cbc(aes))", - "ctr(aes)", - "xts(aes)", - "gcm(aes)", + {"cbc(aes)", true}, + {"cts(cbc(aes))", true}, + {"ctr(aes)", true}, + {"xts(aes)", true}, + {"gcm(aes)", false}, - "hmac(sha1)", - "hmac(sha224)", - "hmac(sha256)", - "hmac(sha384)", - "hmac(sha512)", - "sha1", - "sha224", - "sha256", - "sha384", - "sha512", + {"hmac(sha1)", true}, + {"hmac(sha224)", true}, + {"hmac(sha256)", true}, + {"hmac(sha384)", true}, + {"hmac(sha512)", true}, + {"sha1", true}, + {"sha224", true}, + {"sha256", true}, + {"sha384", true}, + {"sha512", true}, - "stdrng", - "jitterentropy_rng", + {"stdrng", true}, + {"jitterentropy_rng", false}, }; -static bool __init is_fips140_algo(struct crypto_alg *alg) +static bool __init fips140_should_unregister_alg(struct crypto_alg *alg) { int i; @@ -124,12 +129,48 @@ static bool __init is_fips140_algo(struct crypto_alg *alg) if (alg->cra_flags & CRYPTO_ALG_ASYNC) return false; - for (i = 0; i < ARRAY_SIZE(fips140_algorithms); i++) - if (!strcmp(alg->cra_name, fips140_algorithms[i])) + for (i = 0; i < ARRAY_SIZE(fips140_algs_to_replace); i++) { + if (!strcmp(alg->cra_name, fips140_algs_to_replace[i].name)) return true; + } return false; } +/* + * FIPS 140-3 service indicators. FIPS 140-3 requires that all services + * "provide an indicator when the service utilises an approved cryptographic + * algorithm, security function or process in an approved manner". What this + * means is very debatable, even with the help of the FIPS 140-3 Implementation + * Guidance document. However, it was decided that a function that takes in an + * algorithm name and returns whether that algorithm is approved or not will + * meet this requirement. Note, this relies on some properties of the module: + * + * - The module doesn't distinguish between "services" and "algorithms"; its + * services are simply its algorithms. + * + * - The status of an approved algorithm is never non-approved, since (a) the + * module doesn't support operating in a non-approved mode, such as a mode + * where the self-tests are skipped; (b) there are no cases where the module + * supports non-approved settings for approved algorithms, e.g. + * non-approved key sizes; and (c) this function isn't available to be + * called until the module_init function has completed, so it's guaranteed + * that the self-tests and integrity check have already passed. + * + * - The module does support some non-approved algorithms, so a single static + * indicator ("return true;") would not be acceptable. + */ +bool fips140_is_approved_service(const char *name) +{ + size_t i; + + for (i = 0; i < ARRAY_SIZE(fips140_algs_to_replace); i++) { + if (!strcmp(name, fips140_algs_to_replace[i].name)) + return fips140_algs_to_replace[i].approved; + } + return false; +} +EXPORT_SYMBOL_GPL(fips140_is_approved_service); + static LIST_HEAD(existing_live_algos); /* @@ -180,7 +221,7 @@ static void __init unregister_existing_fips140_algos(void) * that new users won't use them. */ list_for_each_entry_safe(alg, tmp, &crypto_alg_list, cra_list) { - if (!is_fips140_algo(alg)) + if (!fips140_should_unregister_alg(alg)) continue; if (refcount_read(&alg->cra_refcnt) == 1) { /* diff --git a/crypto/fips140-module.h b/crypto/fips140-module.h index f33580cf7bf8..a01d6c5c1049 100644 --- a/crypto/fips140-module.h +++ b/crypto/fips140-module.h @@ -21,4 +21,6 @@ extern struct task_struct *fips140_init_thread; bool __init __must_check fips140_run_selftests(void); +bool fips140_is_approved_service(const char *name); + #endif /* _CRYPTO_FIPS140_MODULE_H */ From 8d7f609cdaa460ca266af45ae132bec6ffbe9558 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 2 Nov 2021 14:50:18 -0700 Subject: [PATCH 02/13] ANDROID: fips140: add name and version, and a function to retrieve them This is needed to meet a FIPS 140-3 requirement that modules provide a service that retrieves their name and versioning information. Bug: 188620248 Change-Id: I36049c839c4217e3616daab52ec536b46479c12a Signed-off-by: Eric Biggers (cherry picked from commit 2888f960d09f3af00d1e45f1facd311ccd5b778a) --- crypto/fips140-module.c | 23 ++++++++++++++++++++++- crypto/fips140-module.h | 9 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crypto/fips140-module.c b/crypto/fips140-module.c index 79b09b070463..5e42891fbd0d 100644 --- a/crypto/fips140-module.c +++ b/crypto/fips140-module.c @@ -171,6 +171,27 @@ bool fips140_is_approved_service(const char *name) } EXPORT_SYMBOL_GPL(fips140_is_approved_service); +/* + * FIPS 140-3 requires that modules provide a "service" that outputs "the name + * or module identifier and the versioning information that can be correlated + * with a validation record". This function meets that requirement. + * + * Note: the module also prints this same information to the kernel log when it + * is loaded. That might meet the requirement by itself. However, given the + * vagueness of what counts as a "service", we provide this function too, just + * in case the certification lab or CMVP is happier with an explicit function. + * + * Note: /sys/modules/fips140/scmversion also provides versioning information + * about the module. However that file just shows the bare git commit ID, so it + * probably isn't sufficient to meet the FIPS requirement, which seems to want + * the "official" module name and version number used in the FIPS certificate. + */ +const char *fips140_module_version(void) +{ + return FIPS140_MODULE_NAME " " FIPS140_MODULE_VERSION; +} +EXPORT_SYMBOL_GPL(fips140_module_version); + static LIST_HEAD(existing_live_algos); /* @@ -478,7 +499,7 @@ fips140_init(void) { const u32 *initcall; - pr_info("loading module\n"); + pr_info("loading " FIPS140_MODULE_NAME " " FIPS140_MODULE_VERSION "\n"); fips140_init_thread = current; unregister_existing_fips140_algos(); diff --git a/crypto/fips140-module.h b/crypto/fips140-module.h index a01d6c5c1049..ff99d5b2ab4a 100644 --- a/crypto/fips140-module.h +++ b/crypto/fips140-module.h @@ -12,6 +12,14 @@ #undef pr_fmt #define pr_fmt(fmt) "fips140: " fmt +/* + * This is the name and version number of the module that are shown on the FIPS + * certificate. These don't necessarily have any relation to the filename of + * the .ko file, or to the git branch or commit ID. + */ +#define FIPS140_MODULE_NAME "Android Kernel Cryptographic Module" +#define FIPS140_MODULE_VERSION "v1.0" + #ifdef CONFIG_CRYPTO_FIPS140_MOD_ERROR_INJECTION extern char *fips140_broken_alg; #endif @@ -22,5 +30,6 @@ extern struct task_struct *fips140_init_thread; bool __init __must_check fips140_run_selftests(void); bool fips140_is_approved_service(const char *name); +const char *fips140_module_version(void); #endif /* _CRYPTO_FIPS140_MODULE_H */ From 29af14b0862ae80a515c8cdb82963e4ac965f8d7 Mon Sep 17 00:00:00 2001 From: xieliujie Date: Wed, 3 Nov 2021 21:19:35 +0800 Subject: [PATCH 03/13] ANDROID: GKI: Update symbols to symbol list Update symbols to symbol list externed by oem modules. Leaf changes summary: 4 artifacts changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 2 Added functions Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 2 Added variables 2 Added functions: [A] 'function int __traceiter_sched_stat_sleep(void*, task_struct*, u64)' [A] 'function int __traceiter_sched_waking(void*, task_struct*)' 2 Added variables: [A] 'tracepoint __tracepoint_sched_stat_sleep' [A] 'tracepoint __tracepoint_sched_waking' Bug: 193384408 Change-Id: I9979f21fb3feec8dadc57ef515ab7697cc84e2ca Signed-off-by: xieliujie --- android/abi_gki_aarch64.xml | 17 +++++++++++++++++ android/abi_gki_aarch64_oplus | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 2293576626f4..f621d304fe1b 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -555,11 +555,13 @@ + + @@ -5931,11 +5933,13 @@ + + @@ -116191,6 +116195,12 @@ + + + + + + @@ -116220,6 +116230,11 @@ + + + + + @@ -116599,11 +116614,13 @@ + + diff --git a/android/abi_gki_aarch64_oplus b/android/abi_gki_aarch64_oplus index e04180910b8e..5476614fa58e 100644 --- a/android/abi_gki_aarch64_oplus +++ b/android/abi_gki_aarch64_oplus @@ -2689,9 +2689,11 @@ __traceiter_sched_overutilized_tp __traceiter_sched_stat_blocked __traceiter_sched_stat_iowait + __traceiter_sched_stat_sleep __traceiter_sched_stat_wait __traceiter_sched_switch __traceiter_sched_update_nr_running_tp + __traceiter_sched_waking __traceiter_suspend_resume __traceiter_task_newtask __traceiter_task_rename @@ -2876,9 +2878,11 @@ __tracepoint_sched_overutilized_tp __tracepoint_sched_stat_blocked __tracepoint_sched_stat_iowait + __tracepoint_sched_stat_sleep __tracepoint_sched_stat_wait __tracepoint_sched_switch __tracepoint_sched_update_nr_running_tp + __tracepoint_sched_waking tracepoint_srcu __tracepoint_suspend_resume __tracepoint_task_newtask From 2cfefe22b999a24970508dc43ae9079673af419b Mon Sep 17 00:00:00 2001 From: Liujie Xie Date: Wed, 27 Oct 2021 14:11:36 +0800 Subject: [PATCH 04/13] ANDROID: GKI: Add symbols to abi_gki_aarch64_oplus Add some file nodes to control and tune the memcg status in the memory cgroup, need add some symbols to abi_gki_aarch64_oplus. Leaf changes summary: 5 artifacts changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 3 Added functions Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 2 Added variables 3 Added functions: [A] 'function int cgroup_add_legacy_cftypes(cgroup_subsys*, cftype*)' [A] 'function mem_cgroup* mem_cgroup_from_id(unsigned short int)' [A] 'function void unregister_memory_notifier(notifier_block*)' 2 Added variables: [A] 'cgroup_subsys memory_cgrp_subsys' [A] 'static_key_true memory_cgrp_subsys_enabled_key' Bug: 204860045 Signed-off-by: Liujie Xie Change-Id: I69805dcdfbe363c13031ae0a9556761b71a67428 --- android/abi_gki_aarch64.xml | 20 ++++++++++++++++++++ android/abi_gki_aarch64_oplus | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index f621d304fe1b..cac6507ea5d7 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -947,6 +947,7 @@ + @@ -3042,6 +3043,7 @@ + @@ -5050,6 +5052,7 @@ + @@ -6042,6 +6045,8 @@ + + @@ -118675,6 +118680,11 @@ + + + + + @@ -129621,6 +129631,10 @@ + + + + @@ -129649,6 +129663,8 @@ + + @@ -139889,6 +139905,10 @@ + + + + diff --git a/android/abi_gki_aarch64_oplus b/android/abi_gki_aarch64_oplus index 5476614fa58e..793058c27644 100644 --- a/android/abi_gki_aarch64_oplus +++ b/android/abi_gki_aarch64_oplus @@ -134,6 +134,7 @@ cdev_device_del cdev_init __cfi_slowpath + cgroup_add_legacy_cftypes cgroup_path_ns cgroup_taskset_first cgroup_taskset_next @@ -1421,6 +1422,7 @@ memblock_end_of_DRAM __memcat_p memcg_kmem_enabled_key + mem_cgroup_from_id memchr memchr_inv memcmp @@ -1430,6 +1432,8 @@ memdup_user memmove memory_block_size_bytes + memory_cgrp_subsys + memory_cgrp_subsys_enabled_key memory_read_from_buffer memparse mempool_alloc @@ -1575,6 +1579,7 @@ of_count_phandle_with_args of_cpufreq_cooling_register of_cpu_node_to_id + of_css of_devfreq_cooling_register of_device_get_match_data of_device_is_available @@ -2898,6 +2903,7 @@ trace_seq_putc tracing_off try_module_get + try_to_free_mem_cgroup_pages try_wait_for_completion tty_flip_buffer_push __tty_insert_flip_char @@ -2991,6 +2997,7 @@ unregister_inetaddr_notifier unregister_kprobe unregister_kretprobe + unregister_memory_notifier unregister_module_notifier unregister_netdev unregister_netdevice_many From 8c2c4d12bbfa67ab6f055ded5089e8f91d2e6692 Mon Sep 17 00:00:00 2001 From: JianMin Liu Date: Tue, 2 Nov 2021 16:32:07 +0800 Subject: [PATCH 05/13] ANDROID: sched: Add vendor hooks for sync_entity_load_avg Add vendor hooks to monitor more update load-avg point where tasks on the run-queue will go through. Bug: 204857484 Signed-off-by: JianMin Liu Change-Id: I440d7b9686a37508bd7568454472ab014ba0d0c9 --- kernel/sched/fair.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 939cdcbbf780..74ee2d1d16ce 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3871,7 +3871,9 @@ static void sync_entity_load_avg(struct sched_entity *se) u64 last_update_time; last_update_time = cfs_rq_last_update_time(cfs_rq); + trace_android_vh_prepare_update_load_avg_se(se, 0); __update_load_avg_blocked_se(last_update_time, se); + trace_android_vh_finish_update_load_avg_se(se, 0); } /* From d05410851914a96dbac3e5608384530f211069d1 Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Thu, 29 Jul 2021 15:18:23 +0300 Subject: [PATCH 06/13] FROMGIT: scsi: ufshpb: rewind the read timeout on every read The "cold"-timer purpose is not to hang-on to active regions with no reads. Therefore the read-timeout should be re-wind on every read, and not just when the region is activated. Link: https://lore.kernel.org/r/20210808090024.21721-2-avri.altman@wdc.com Fixes: 13c044e91678 (scsi: ufs: ufshpb: Add "cold" regions timer) (cherry picked from commit 283e61c5a9bed2c2acde3f50a3f76f09816c0aab git: //git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Avri Altman Change-Id: If174a161028cf2382538d69e30181cda979a12de --- drivers/scsi/ufs/ufshpb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 3cce91d1e63f..49348b8ea57a 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -184,9 +184,19 @@ next_srgn: set_bit_len = cnt; spin_lock_irqsave(&hpb->rgn_state_lock, flags); - if (set_dirty && rgn->rgn_state != HPB_RGN_INACTIVE && - srgn->srgn_state == HPB_SRGN_VALID) - bitmap_set(srgn->mctx->ppn_dirty, srgn_offset, set_bit_len); + if (rgn->rgn_state != HPB_RGN_INACTIVE) { + if (set_dirty) { + if (srgn->srgn_state == HPB_SRGN_VALID) + bitmap_set(srgn->mctx->ppn_dirty, srgn_offset, + set_bit_len); + } else if (hpb->is_hcm) { + /* rewind the read timer for lru regions */ + rgn->read_timeout = ktime_add_ms(ktime_get(), + rgn->hpb->params.read_timeout_ms); + rgn->read_timeout_expiries = + rgn->hpb->params.read_timeout_expiries; + } + } spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); if (hpb->is_hcm && prev_srgn != srgn) { From 193f33d061d2e8b8297a1870f3134491a9251874 Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Thu, 20 May 2021 15:04:35 +0300 Subject: [PATCH 07/13] FROMGIT: scsi: ufshpb: Use a correct max multi chunk In HPB2.0, if pre_req_min_tr_len < transfer_len < pre_req_max_tr_len the driver is expected to send a HPB-WRITE-BUFFER companion to HPB-READ. The upper bound should fit into a single byte, regardless of bMAX_ DATA_SIZE_FOR_HPB_SINGLE_CMD which being an attribute (u32) can be significantly larger. To further illustrate the issue let us consider the following scenario: - SCSI_DEFAULT_MAX_SECTORS is 1024 limiting the IO chunks to 512KB - The OEM changes scsi_host_template .max_sectors to be 2048, which allows a 1M requests: transfer_len = 256 - pre_req_max_tr_len = HPB_MULTI_CHUNK_HIGH = 256 - ufshpb_is_supported_chunk returns true (256 <= 256) - WARN_ON_ONCE(transfer_len > HPB_MULTI_CHUNK_HIGH) doesn't warn - ufshpb_set_hpb_read_to_upiu cast transfer_len to u8: transfer_len = 0 - the command is failing with illegal request Link: https://lore.kernel.org/r/20210808090024.21721-3-avri.altman@wdc.com Fixes: 41d8a9333cc9 (scsi: ufs: ufshpb: Add HPB 2.0 support) (cherry picked from commit 07106f86ae13d9197bfd38c2d47743304b14099e git: //git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Avri Altman Change-Id: I0dc568020a0fe6c4ddf6952f89ad5230770fd7f3 --- drivers/scsi/ufs/ufshpb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index c74a6c35a446..6df317dfe034 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -32,7 +32,7 @@ /* hpb support chunk size */ #define HPB_LEGACY_CHUNK_HIGH 1 #define HPB_MULTI_CHUNK_LOW 7 -#define HPB_MULTI_CHUNK_HIGH 256 +#define HPB_MULTI_CHUNK_HIGH 255 /* hpb vender defined opcode */ #define UFSHPB_READ 0xF8 From e2766208d745c54eef7c0deee8eb5b1ba0a475eb Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Tue, 20 Jul 2021 11:56:53 +0300 Subject: [PATCH 08/13] FROMGIT: scsi: ufshpb: Verify that num_inflight_map_req is non-negative num_inflight_map_req should not be negative. It is incremented and decremented without any protection, allowing it theoretically to be negative, should some weird unbalanced count occur. Verify that the those calls are properly serielized. Link: https://lore.kernel.org/r/20210808090024.21721-4-avri.altman@wdc.com Fixes: 33845a2d844b (scsi: ufs: ufshpb: Limit the number of in-flight map requests) (cherry picked from commit 22aede9f48b6766fb67441610120db9b04adf109 git: //git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Avri Altman Change-Id: I8a8252c919e6678752b60bcd950cb08e765e6aed --- drivers/scsi/ufs/ufshpb.c | 10 ++++++++++ drivers/scsi/ufs/ufshpb.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 49348b8ea57a..2bcc4e1dc506 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -763,6 +763,7 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb, { struct ufshpb_req *map_req; struct bio *bio; + unsigned long flags; if (hpb->is_hcm && hpb->num_inflight_map_req >= hpb->params.inflight_map_req) { @@ -787,7 +788,10 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb, map_req->rb.srgn_idx = srgn->srgn_idx; map_req->rb.mctx = srgn->mctx; + + spin_lock_irqsave(&hpb->param_lock, flags); hpb->num_inflight_map_req++; + spin_unlock_irqrestore(&hpb->param_lock, flags); return map_req; } @@ -795,9 +799,14 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb, static void ufshpb_put_map_req(struct ufshpb_lu *hpb, struct ufshpb_req *map_req) { + unsigned long flags; + bio_put(map_req->bio); ufshpb_put_req(hpb, map_req); + + spin_lock_irqsave(&hpb->param_lock, flags); hpb->num_inflight_map_req--; + spin_unlock_irqrestore(&hpb->param_lock, flags); } static int ufshpb_clear_dirty_bitmap(struct ufshpb_lu *hpb, @@ -2396,6 +2405,7 @@ static int ufshpb_lu_hpb_init(struct ufs_hba *hba, struct ufshpb_lu *hpb) spin_lock_init(&hpb->rgn_state_lock); spin_lock_init(&hpb->rsp_list_lock); + spin_lock_init(&hpb->param_lock); INIT_LIST_HEAD(&hpb->lru_info.lh_lru_rgn); INIT_LIST_HEAD(&hpb->lh_act_srgn); diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index 6df317dfe034..a79e07398970 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -237,7 +237,9 @@ struct ufshpb_lu { struct ufshpb_req *pre_req; int num_inflight_pre_req; int throttle_pre_req; - int num_inflight_map_req; + int num_inflight_map_req; /* hold param_lock */ + spinlock_t param_lock; + struct list_head lh_pre_req_free; int cur_read_id; int pre_req_min_tr_len; From 335046583cd13e7bc687e953b1ea4262d7086914 Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Tue, 20 Jul 2021 13:15:58 +0300 Subject: [PATCH 09/13] FROMGIT: scsi: ufshpb: Do not report victim error in HCM In host control mode, eviction is precieved as an extreme measure. There are several conditions that both the entering and exiting regions should meet, so that eviction will take place. The common case however, is that those conditions are rarely met, so it is normal that the act of eviction fails. Therefore, Do not report an error in host control mode if eviction fails. Link: https://lore.kernel.org/r/20210808090024.21721-5-avri.altman@wdc.com Fixes: 6c59cb501b86 (scsi: ufs: ufshpb: Make eviction depend on region's reads) (cherry picked from commit 10163cee1f06fc2e17bcf7bbc2982337202d1d5c git: //git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Avri Altman Change-Id: Id6aa444ea5e2efd15c507bbd586c421018c75998 --- drivers/scsi/ufs/ufshpb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 2bcc4e1dc506..a869668f3061 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1391,7 +1391,8 @@ static int ufshpb_add_region(struct ufshpb_lu *hpb, struct ufshpb_region *rgn) victim_rgn = ufshpb_victim_lru_info(hpb); if (!victim_rgn) { dev_warn(&hpb->sdev_ufs_lu->sdev_dev, - "cannot get victim region error\n"); + "cannot get victim region %s\n", + hpb->is_hcm ? "" : "error"); ret = -ENOMEM; goto out; } From e35a305d19a29e1c2ba3359afb31047511bf11d9 Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Wed, 13 Oct 2021 21:52:17 -0700 Subject: [PATCH 10/13] UPSTREAM: tracing/cfi: Fix cmp_entries_* functions signature mismatch If CONFIG_CFI_CLANG=y, attempting to read an event histogram will cause the kernel to panic due to failed CFI check. 1. echo 'hist:keys=common_pid' >> events/sched/sched_switch/trigger 2. cat events/sched/sched_switch/hist 3. kernel panics on attempting to read hist This happens because the sort() function expects a generic int (*)(const void *, const void *) pointer for the compare function. To prevent this CFI failure, change tracing map cmp_entries_* function signatures to match this. Also, fix the build error reported by the kernel test robot [1]. [1] https://lore.kernel.org/r/202110141140.zzi4dRh4-lkp@intel.com/ Link: https://lkml.kernel.org/r/20211014045217.3265162-1-kaleshsingh@google.com Signed-off-by: Kalesh Singh Reported-by: kernel test robot Signed-off-by: Steven Rostedt (VMware) Bug: 204946901 (cherry picked from commit 7ce1bb83a14019f8c396d57ec704d19478747716) Signed-off-by: Elliot Berman Change-Id: I4a1a39b086b5e306ddecabd9a6076e2fb14c3f70 --- kernel/trace/tracing_map.c | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index 4b50fc0cb12c..d63e51dde0d2 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c @@ -834,29 +834,35 @@ int tracing_map_init(struct tracing_map *map) return err; } -static int cmp_entries_dup(const struct tracing_map_sort_entry **a, - const struct tracing_map_sort_entry **b) +static int cmp_entries_dup(const void *A, const void *B) { + const struct tracing_map_sort_entry *a, *b; int ret = 0; - if (memcmp((*a)->key, (*b)->key, (*a)->elt->map->key_size)) + a = *(const struct tracing_map_sort_entry **)A; + b = *(const struct tracing_map_sort_entry **)B; + + if (memcmp(a->key, b->key, a->elt->map->key_size)) ret = 1; return ret; } -static int cmp_entries_sum(const struct tracing_map_sort_entry **a, - const struct tracing_map_sort_entry **b) +static int cmp_entries_sum(const void *A, const void *B) { const struct tracing_map_elt *elt_a, *elt_b; + const struct tracing_map_sort_entry *a, *b; struct tracing_map_sort_key *sort_key; struct tracing_map_field *field; tracing_map_cmp_fn_t cmp_fn; void *val_a, *val_b; int ret = 0; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A; + b = *(const struct tracing_map_sort_entry **)B; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key; @@ -873,18 +879,21 @@ static int cmp_entries_sum(const struct tracing_map_sort_entry **a, return ret; } -static int cmp_entries_key(const struct tracing_map_sort_entry **a, - const struct tracing_map_sort_entry **b) +static int cmp_entries_key(const void *A, const void *B) { const struct tracing_map_elt *elt_a, *elt_b; + const struct tracing_map_sort_entry *a, *b; struct tracing_map_sort_key *sort_key; struct tracing_map_field *field; tracing_map_cmp_fn_t cmp_fn; void *val_a, *val_b; int ret = 0; - elt_a = (*a)->elt; - elt_b = (*b)->elt; + a = *(const struct tracing_map_sort_entry **)A; + b = *(const struct tracing_map_sort_entry **)B; + + elt_a = a->elt; + elt_b = b->elt; sort_key = &elt_a->map->sort_key; @@ -989,10 +998,8 @@ static void sort_secondary(struct tracing_map *map, struct tracing_map_sort_key *primary_key, struct tracing_map_sort_key *secondary_key) { - int (*primary_fn)(const struct tracing_map_sort_entry **, - const struct tracing_map_sort_entry **); - int (*secondary_fn)(const struct tracing_map_sort_entry **, - const struct tracing_map_sort_entry **); + int (*primary_fn)(const void *, const void *); + int (*secondary_fn)(const void *, const void *); unsigned i, start = 0, n_sub = 1; if (is_key(map, primary_key->field_idx)) @@ -1061,8 +1068,7 @@ int tracing_map_sort_entries(struct tracing_map *map, unsigned int n_sort_keys, struct tracing_map_sort_entry ***sort_entries) { - int (*cmp_entries_fn)(const struct tracing_map_sort_entry **, - const struct tracing_map_sort_entry **); + int (*cmp_entries_fn)(const void *, const void *); struct tracing_map_sort_entry *sort_entry, **entries; int i, n_entries, ret; From cde1d53cc9b62bdf7cbb8e5cc4887b28e9314983 Mon Sep 17 00:00:00 2001 From: Wesley Cheng Date: Tue, 26 Oct 2021 19:30:38 -0700 Subject: [PATCH 11/13] FROMGIT: usb: gadget: udc: core: Revise comments for USB ep enable/disable The usb_ep_disable() and usb_ep_enable() routines are being widely used in atomic/interrupt context by function drivers. Hence, the statement about it being able to only run in process context may not be true. Add an explicit comment mentioning that it can be used in atomic context. Signed-off-by: Wesley Cheng Acked-by: Alan Stern Bug: 204343836 (cherry picked from commit b0d5d2a71641bb50cada708cc8fdca946a837e9a https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing) Change-Id: I1adb5d074fe2f9e33ebfdb30d335283c56bc7b39 Signed-off-by: Wesley Cheng --- drivers/usb/gadget/udc/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index edb83c8825de..24d0ace3ed3c 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -89,7 +89,7 @@ EXPORT_SYMBOL_GPL(usb_ep_set_maxpacket_limit); * configurable, with more generic names like "ep-a". (remember that for * USB, "in" means "towards the USB host".) * - * This routine must be called in process context. + * This routine may be called in an atomic (interrupt) context. * * returns zero, or a negative error code. */ @@ -134,7 +134,7 @@ EXPORT_SYMBOL_GPL(usb_ep_enable); * gadget drivers must call usb_ep_enable() again before queueing * requests to the endpoint. * - * This routine must be called in process context. + * This routine may be called in an atomic (interrupt) context. * * returns zero, or a negative error code. */ From 8c9d9d8e44aa69102ed589e66a55e6ef93b834ef Mon Sep 17 00:00:00 2001 From: Wesley Cheng Date: Wed, 27 Oct 2021 13:00:37 -0700 Subject: [PATCH 12/13] FROMGIT: usb: gadget: f_mass_storage: Disable eps during disconnect When receiving a disconnect event from the UDC, the mass storage function driver currently runs the handle_exception() routine asynchronously. For UDCs that support runtime PM, there is a possibility the UDC is already suspended by the time the do_set_interface() is executed. This can lead to HW register access while the UDC is already suspended. Signed-off-by: Wesley Cheng Acked-by: Alan Stern Bug: 204343836 (cherry picked from commit 9fff139aeb11186fd8e75860c959c86cb43ab2f6 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing) Change-Id: I6c8011baddf02d6b0eadb5934416bc24b8a93f4a Signed-off-by: Wesley Cheng --- drivers/usb/gadget/function/f_mass_storage.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 950c9435beec..73a28f8a38a7 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2301,6 +2301,16 @@ static void fsg_disable(struct usb_function *f) { struct fsg_dev *fsg = fsg_from_func(f); + /* Disable the endpoints */ + if (fsg->bulk_in_enabled) { + usb_ep_disable(fsg->bulk_in); + fsg->bulk_in_enabled = 0; + } + if (fsg->bulk_out_enabled) { + usb_ep_disable(fsg->bulk_out); + fsg->bulk_out_enabled = 0; + } + __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL); } From dd78ccadc46f86c0cfebcfc38c4939bf9a9c7ff0 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Fri, 5 Nov 2021 10:11:15 +0800 Subject: [PATCH 13/13] ANDROID: GKI: Update symbol list for VIVO Leaf changes summary: 6 artifacts changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 3 Added functions Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 3 Added variables 3 Added functions: [A] 'function int __traceiter_android_vh_blk_alloc_rqs(void*, size_t*, blk_mq_tag_set*, blk_mq_tags*)' [A] 'function int __traceiter_android_vh_blk_rq_ctx_init(void*, request*, blk_mq_tags*, blk_mq_alloc_data*, u64)' [A] 'function int __traceiter_android_vh_mm_dirty_limits(void*, dirty_throttle_control* const, bool, unsigned long int, unsigned long int, unsigned long int, unsigned long int)' 3 Added variables: [A] 'tracepoint __tracepoint_android_vh_blk_alloc_rqs' [A] 'tracepoint __tracepoint_android_vh_blk_rq_ctx_init' [A] 'tracepoint __tracepoint_android_vh_mm_dirty_limits' Bug: 205166460 Change-Id: Iec948f354fe142576525a2f35769077d8c63788d Signed-off-by: Yang Yang --- android/abi_gki_aarch64.xml | 37 ++++++++++++++++++++++++++++++++++++ android/abi_gki_aarch64_vivo | 9 +++++++++ 2 files changed, 46 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index cac6507ea5d7..476d11871e69 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -370,6 +370,8 @@ + + @@ -437,6 +439,7 @@ + @@ -5733,6 +5736,8 @@ + + @@ -5802,6 +5807,7 @@ + @@ -11275,6 +11281,7 @@ + @@ -28069,6 +28076,7 @@ + @@ -83751,6 +83759,7 @@ + @@ -115061,6 +115070,21 @@ + + + + + + + + + + + + + + + @@ -115478,6 +115502,16 @@ + + + + + + + + + + @@ -116416,6 +116450,8 @@ + + @@ -116485,6 +116521,7 @@ + diff --git a/android/abi_gki_aarch64_vivo b/android/abi_gki_aarch64_vivo index d8703539183d..f464cbad7f17 100644 --- a/android/abi_gki_aarch64_vivo +++ b/android/abi_gki_aarch64_vivo @@ -54,6 +54,8 @@ __bitmap_set blk_alloc_queue blk_bio_list_merge + blkcg_policy_register + blkcg_policy_unregister blk_cleanup_queue blk_execute_rq blk_execute_rq_nowait @@ -1001,6 +1003,7 @@ of_count_phandle_with_args of_cpufreq_cooling_register of_cpu_node_to_id + of_css of_devfreq_cooling_register of_device_get_match_data of_device_is_available @@ -1711,6 +1714,8 @@ __traceiter_android_vh_binder_restore_priority __traceiter_android_vh_binder_set_priority __traceiter_android_vh_binder_wakeup_ilocked + __traceiter_android_vh_blk_alloc_rqs + __traceiter_android_vh_blk_rq_ctx_init __traceiter_android_vh_cpu_idle_enter __traceiter_android_vh_cpu_idle_exit __traceiter_android_vh_filemap_fault_cache_page @@ -1728,6 +1733,7 @@ __traceiter_android_vh_mmc_blk_mq_rw_recovery __traceiter_android_vh_mmc_blk_reset __traceiter_android_vh_mmc_gpio_cd_irqt + __traceiter_android_vh_mm_dirty_limits __traceiter_android_vh_printk_hotplug __traceiter_android_vh_scheduler_tick __traceiter_android_vh_sdhci_get_cd @@ -1806,6 +1812,8 @@ __tracepoint_android_vh_binder_set_priority __tracepoint_android_vh_binder_trans __tracepoint_android_vh_binder_wakeup_ilocked + __tracepoint_android_vh_blk_alloc_rqs + __tracepoint_android_vh_blk_rq_ctx_init __tracepoint_android_vh_cpu_idle_enter __tracepoint_android_vh_cpu_idle_exit __tracepoint_android_vh_dup_task_struct @@ -1825,6 +1833,7 @@ __tracepoint_android_vh_mmc_blk_mq_rw_recovery __tracepoint_android_vh_mmc_blk_reset __tracepoint_android_vh_mmc_gpio_cd_irqt + __tracepoint_android_vh_mm_dirty_limits __tracepoint_android_vh_printk_hotplug __tracepoint_android_vh_scheduler_tick __tracepoint_android_vh_sdhci_get_cd