Commit Graph

973796 Commits

Author SHA1 Message Date
Suren Baghdasaryan
b9b4582292 ANDROID: mm, oom: Prevent extra put_task when oom_evaluate_task is aborted
The previous fix for the oom_evaluate_task abort case leads to an extra
put_task_struct call on oc->chosen_non_negative_adj. Fix this by
resetting oc->chosen_non_negative_adj and avoiding the whole negative
ADJ logic altogether.
Fixes: aef918d19a ("ANDROID: mm, oom: Fix select_bad_process customization")

Bug: 180947519
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I5d649baac17daf1778a198be354823aa0b6a55b4
2021-02-24 22:21:44 +00:00
Will McVicker
7ccd5a5389 ANDROID: Update the ABI
Leaf changes summary: 2617 artifacts changed
Changed leaf types summary: 19 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 2242 Changed, 301 Added functions
Removed/Changed/Added variables summary: 0 Removed, 47 Changed, 8 Added variables
Function symbols changes summary: 0 Removed, 1 Added function symbol not referenced by debug info
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info

301 Added functions:

  [A] 'function void __blk_mq_end_request(request*, blk_status_t)'
  [A] 'function int __blkdev_issue_discard(block_device*, sector_t, sector_t, gfp_t, int, bio**)'
  [A] 'function int __blkdev_issue_zeroout(block_device*, sector_t, sector_t, gfp_t, bio**, unsigned int)'
  [A] 'function void __do_once_done(bool*, static_key_true*, unsigned long int*)'
  [A] 'function bool __do_once_start(bool*, unsigned long int*)'
  [A] 'function int __mmc_claim_host(mmc_host*, mmc_ctx*, atomic_t*)'
  [A] 'function int __mmc_send_status(mmc_card*, u32*, unsigned int)'
  [A] 'function void __mmdrop(mm_struct*)'
  [A] 'function int __platform_driver_probe(platform_driver*, int (platform_device*)*, module*)'
  [A] 'function void __serio_register_port(serio*, module*)'
  [A] 'function int __xa_insert(xarray*, unsigned long int, void*, gfp_t)'
  [A] 'function void _dev_crit(const device*, const char*, ...)'
  [A] 'function int anon_inode_getfd(const char*, const file_operations*, void*, int)'
  [A] 'function async_cookie_t async_schedule_node(async_func_t, void*, int)'
  [A] 'function void bd_set_nr_sectors(block_device*, sector_t)'
  [A] 'function char* bin2hex(char*, void*, unsigned long int)'
  [A] 'function void bio_init(bio*, bio_vec*, unsigned short int)'
  [A] 'function void blk_freeze_queue_start(request_queue*)'
  [A] 'function bool blk_get_queue(request_queue*)'
  [A] 'function request* blk_mq_alloc_request(request_queue*, unsigned int, unsigned int)'
  [A] 'function request* blk_mq_alloc_request_hctx(request_queue*, unsigned int, blk_mq_req_flags_t, unsigned int)'
  [A] 'function bool blk_mq_complete_request_remote(request*)'
  [A] 'function void blk_mq_delay_kick_requeue_list(request_queue*, unsigned long int)'
  [A] 'function void blk_mq_free_request(request*)'
  [A] 'function void blk_mq_freeze_queue(request_queue*)'
  [A] 'function void blk_mq_freeze_queue_wait(request_queue*)'
  [A] 'function int blk_mq_freeze_queue_wait_timeout(request_queue*, unsigned long int)'
  [A] 'function int blk_mq_map_queues(blk_mq_queue_map*)'
  [A] 'function int blk_mq_pci_map_queues(blk_mq_queue_map*, pci_dev*, int)'
  [A] 'function void blk_mq_requeue_request(request*, bool)'
  [A] 'function void blk_mq_run_hw_queues(request_queue*, bool)'
  [A] 'function request* blk_mq_tag_to_rq(blk_mq_tags*, unsigned int)'
  [A] 'function void blk_mq_tagset_busy_iter(blk_mq_tag_set*, busy_tag_iter_fn*, void*)'
  [A] 'function void blk_mq_tagset_wait_completed_request(blk_mq_tag_set*)'
  [A] 'function void blk_mq_unfreeze_queue(request_queue*)'
  [A] 'function u32 blk_mq_unique_tag(request*)'
  [A] 'function void blk_mq_update_nr_hw_queues(blk_mq_tag_set*, int)'
  [A] 'function int blk_poll(request_queue*, unsigned int, bool)'
  [A] 'function void blk_put_queue(request_queue*)'
  [A] 'function void blk_queue_bounce_limit(request_queue*, u64)'
  [A] 'function bool blk_queue_can_use_dma_map_merging(request_queue*, device*)'
  [A] 'function void blk_queue_chunk_sectors(request_queue*, unsigned int)'
  [A] 'function void blk_queue_dma_alignment(request_queue*, int)'
  [A] 'function bool blk_queue_flag_test_and_set(unsigned int, request_queue*)'
  [A] 'function void blk_queue_rq_timeout(request_queue*, unsigned int)'
  [A] 'function void blk_queue_virt_boundary(request_queue*, unsigned long int)'
  [A] 'function void blk_set_queue_dying(request_queue*)'
  [A] 'function bool blk_update_request(request*, blk_status_t, unsigned int)'
  [A] 'function block_device* blkdev_get_by_path(const char*, unsigned int, void*)'
  [A] 'function int blkdev_issue_flush(block_device*, unsigned int)'
  [A] 'function int cache_line_size()'
  [A] 'function void cec_s_phys_addr_from_edid(cec_adapter*, const edid*)'
  [A] 'function void cec_transmit_done_ts(cec_adapter*, u8, u8, u8, u8, u8, ktime_t)'
  [A] 'function int cpufreq_enable_boost_support()'
  [A] 'function unsigned int cpufreq_generic_get(unsigned int)'
  [A] 'function int cpufreq_generic_suspend(cpufreq_policy*)'
  [A] 'function timespec64 current_time(inode*)'
  [A] 'function void d_add(dentry*, inode*)'
  [A] 'function dentry* d_alloc_name(dentry*, const char*)'
  [A] 'function void d_delete(dentry*)'
  [A] 'function dentry* d_make_root(inode*)'
  [A] 'function void debugfs_create_size_t(const char*, umode_t, dentry*, size_t*)'
  [A] 'function void debugfs_create_x64(const char*, umode_t, dentry*, u64*)'
  [A] 'function void dev_pm_opp_free_cpufreq_table(device*, cpufreq_frequency_table**)'
  [A] 'function unsigned long int dev_pm_opp_get_max_transition_latency(device*)'
  [A] 'function opp_table* dev_pm_opp_get_opp_table(device*)'
  [A] 'function int dev_pm_opp_get_sharing_cpus(device*, cpumask*)'
  [A] 'function unsigned long int dev_pm_opp_get_suspend_opp_freq(device*)'
  [A] 'function int dev_pm_opp_init_cpufreq_table(device*, cpufreq_frequency_table**)'
  [A] 'function int dev_pm_opp_of_cpumask_add_table(const cpumask*)'
  [A] 'function int dev_pm_opp_of_get_sharing_cpus(device*, cpumask*)'
  [A] 'function void dev_pm_opp_put_opp_table(opp_table*)'
  [A] 'function void dev_pm_opp_put_regulators(opp_table*)'
  [A] 'function opp_table* dev_pm_opp_set_regulators(device*, const char* const*, unsigned int)'
  [A] 'function int dev_pm_qos_expose_latency_tolerance(device*)'
  [A] 'function void dev_pm_qos_hide_latency_tolerance(device*)'
  [A] 'function int dev_pm_qos_update_user_latency_tolerance(device*, int)'
  [A] 'function devfreq* devfreq_add_device(device*, devfreq_dev_profile*, const char*, void*)'
  [A] 'function void devfreq_cooling_unregister(thermal_cooling_device*)'
  [A] 'function int devfreq_register_opp_notifier(device*, devfreq*)'
  [A] 'function int devfreq_remove_device(devfreq*)'
  [A] 'function int devfreq_unregister_opp_notifier(device*, devfreq*)'
  [A] 'function int device_create_bin_file(device*, const bin_attribute*)'
  [A] 'function int device_property_read_string_array(device*, const char*, const char**, unsigned long int)'
  [A] 'function void device_remove_bin_file(device*, const bin_attribute*)'
  [A] 'function bool device_remove_file_self(device*, const device_attribute*)'
  [A] 'function clk* devm_get_clk_from_child(device*, device_node*, const char*)'
  [A] 'function char* devm_kvasprintf(device*, gfp_t, const char*, va_list)'
  [A] 'function int devm_mfd_add_devices(device*, int, const mfd_cell*, int, resource*, int, irq_domain*)'
  [A] 'function void* devm_of_iomap(device*, device_node*, int, resource_size_t*)'
  [A] 'function rtc_device* devm_rtc_device_register(device*, const char*, const rtc_class_ops*, module*)'
  [A] 'function int devm_snd_dmaengine_pcm_register(device*, const snd_dmaengine_pcm_config*, unsigned int)'
  [A] 'function int dma_buf_mmap(dma_buf*, vm_area_struct*, unsigned long int)'
  [A] 'function unsigned long int dma_get_merge_boundary(device*)'
  [A] 'function const char* dma_heap_get_name(dma_heap*)'
  [A] 'function size_t dma_max_mapping_size(device*)'
  [A] 'function dma_pool* dmam_pool_create(const char*, device*, size_t, size_t, size_t)'
  [A] 'function int down_trylock(semaphore*)'
  [A] 'function void downgrade_write(rw_semaphore*)'
  [A] 'function void drm_bridge_hpd_notify(drm_bridge*, drm_connector_status)'
  [A] 'function void drm_crtc_arm_vblank_event(drm_crtc*, drm_pending_vblank_event*)'
  [A] 'function drm_gem_cma_object* drm_fb_cma_get_gem_obj(drm_framebuffer*, unsigned int)'
  [A] 'function int drm_gem_cma_dumb_create_internal(drm_file*, drm_device*, drm_mode_create_dumb*)'
  [A] 'function void drm_gem_cma_free_object(drm_gem_object*)'
  [A] 'function int drm_gem_cma_mmap(file*, vm_area_struct*)'
  [A] 'function sg_table* drm_gem_cma_prime_get_sg_table(drm_gem_object*)'
  [A] 'function drm_gem_object* drm_gem_cma_prime_import_sg_table(drm_device*, dma_buf_attachment*, sg_table*)'
  [A] 'function int drm_gem_cma_prime_mmap(drm_gem_object*, vm_area_struct*)'
  [A] 'function void* drm_gem_cma_prime_vmap(drm_gem_object*)'
  [A] 'function void drm_gem_cma_prime_vunmap(drm_gem_object*, void*)'
  [A] 'function drm_framebuffer* drm_gem_fb_create(drm_device*, drm_file*, const drm_mode_fb_cmd2*)'
  [A] 'function uint32_t drm_of_find_possible_crtcs(drm_device*, device_node*)'
  [A] 'function void drm_sysfs_hotplug_event(drm_device*)'
  [A] 'function void* dup_iter(iov_iter*, iov_iter*, gfp_t)'
  [A] 'function file* filp_open(const char*, int, unsigned short int)'
  [A] 'function int generic_delete_inode(inode*)'
  [A] 'function unsigned int get_next_ino()'
  [A] 'function unsigned int get_random_u32()'
  [A] 'function int get_tree_single(fs_context*, int (super_block*, fs_context*)*)'
  [A] 'function long int get_user_pages(unsigned long int, unsigned long int, unsigned int, page**, vm_area_struct**)'
  [A] 'function long int get_user_pages_remote(mm_struct*, unsigned long int, unsigned long int, unsigned int, page**, vm_area_struct**, int*)'
  [A] 'function void hdmi_avi_infoframe_init(hdmi_avi_infoframe*)'
  [A] 'function ssize_t hdmi_avi_infoframe_pack(hdmi_avi_infoframe*, void*, size_t)'
  [A] 'function i2c_client* i2c_new_ancillary_device(i2c_client*, const char*, u16)'
  [A] 'function int i2c_smbus_read_word_data(const i2c_client*, unsigned char)'
  [A] 'function void i2c_unregister_device(i2c_client*)'
  [A] 'function void ida_destroy(ida*)'
  [A] 'function sk_buff* ieee80211_ap_probereq_get(ieee80211_hw*, ieee80211_vif*)'
  [A] 'function void ieee80211_chswitch_done(ieee80211_vif*, bool)'
  [A] 'function void ieee80211_cqm_beacon_loss_notify(ieee80211_vif*, gfp_t)'
  [A] 'function void ieee80211_cqm_rssi_notify(ieee80211_vif*, nl80211_cqm_rssi_threshold_event, s32, gfp_t)'
  [A] 'function unsigned int ieee80211_get_hdrlen_from_skb(const sk_buff*)'
  [A] 'function void ieee80211_iterate_interfaces(ieee80211_hw*, u32, void (void*, u8*, ieee80211_vif*)*, void*)'
  [A] 'function sk_buff* ieee80211_nullfunc_get(ieee80211_hw*, ieee80211_vif*, bool)'
  [A] 'function sk_buff* ieee80211_pspoll_get(ieee80211_hw*, ieee80211_vif*)'
  [A] 'function void ieee80211_sched_scan_results(ieee80211_hw*)'
  [A] 'function void ieee80211_sched_scan_stopped(ieee80211_hw*)'
  [A] 'function int ieee80211_sta_ps_transition(ieee80211_sta*, bool)'
  [A] 'function void ieee80211_stop_rx_ba_session(ieee80211_vif*, u16, const u8*)'
  [A] 'function void iov_iter_bvec(iov_iter*, unsigned int, const bio_vec*, unsigned long int, unsigned long int)'
  [A] 'function void kill_litter_super(super_block*)'
  [A] 'function void kiocb_set_cancel_fn(kiocb*, kiocb_cancel_fn*)'
  [A] 'function int kstrtobool_from_user(const char*, unsigned long int, bool*)'
  [A] 'function void kthread_unuse_mm(mm_struct*)'
  [A] 'function void kthread_use_mm(mm_struct*)'
  [A] 'function ktime_t ktime_add_safe(const ktime_t, const ktime_t)'
  [A] 'function void kvfree_call_rcu(callback_head*, rcu_callback_t)'
  [A] 'function void* mempool_alloc_slab(gfp_t, void*)'
  [A] 'function mempool_t* mempool_create_node(int, mempool_alloc_t*, mempool_free_t*, void*, gfp_t, int)'
  [A] 'function void mempool_free_slab(void*, void*)'
  [A] 'function int mipi_dsi_driver_register_full(mipi_dsi_driver*, module*)'
  [A] 'function void mipi_dsi_driver_unregister(mipi_dsi_driver*)'
  [A] 'function void mm_trace_rss_stat(mm_struct*, int, long int, long int)'
  [A] 'function int mmc_add_host(mmc_host*)'
  [A] 'function mmc_host* mmc_alloc_host(int, device*)'
  [A] 'function int mmc_app_cmd(mmc_host*, mmc_card*)'
  [A] 'function unsigned int mmc_calc_max_discard(mmc_card*)'
  [A] 'function int mmc_can_erase(mmc_card*)'
  [A] 'function bool mmc_can_gpio_cd(mmc_host*)'
  [A] 'function int mmc_can_secure_erase_trim(mmc_card*)'
  [A] 'function int mmc_can_trim(mmc_card*)'
  [A] 'function int mmc_cmdq_disable(mmc_card*)'
  [A] 'function int mmc_cmdq_enable(mmc_card*)'
  [A] 'function void mmc_cqe_post_req(mmc_host*, mmc_request*)'
  [A] 'function int mmc_cqe_recovery(mmc_host*)'
  [A] 'function int mmc_cqe_start_req(mmc_host*, mmc_request*)'
  [A] 'function int mmc_detect_card_removed(mmc_host*)'
  [A] 'function void mmc_detect_change(mmc_host*, unsigned long int)'
  [A] 'function int mmc_erase(mmc_card*, unsigned int, unsigned int, unsigned int)'
  [A] 'function int mmc_erase_group_aligned(mmc_card*, unsigned int, unsigned int)'
  [A] 'function int mmc_flush_cache(mmc_card*)'
  [A] 'function void mmc_free_host(mmc_host*)'
  [A] 'function void mmc_get_card(mmc_card*, mmc_ctx*)'
  [A] 'function int mmc_get_ext_csd(mmc_card*, unsigned char**)'
  [A] 'function int mmc_gpio_get_cd(mmc_host*)'
  [A] 'function int mmc_gpio_get_ro(mmc_host*)'
  [A] 'function int mmc_gpiod_request_cd(mmc_host*, const char*, unsigned int, bool, unsigned int)'
  [A] 'function void mmc_gpiod_request_cd_irq(mmc_host*)'
  [A] 'function int mmc_gpiod_request_ro(mmc_host*, const char*, unsigned int, unsigned int)'
  [A] 'function int mmc_hw_reset(mmc_host*)'
  [A] 'function int mmc_of_parse_voltage(device_node*, u32*)'
  [A] 'function void mmc_put_card(mmc_card*, mmc_ctx*)'
  [A] 'function int mmc_register_driver(mmc_driver*)'
  [A] 'function void mmc_release_host(mmc_host*)'
  [A] 'function void mmc_remove_host(mmc_host*)'
  [A] 'function void mmc_request_done(mmc_host*, mmc_request*)'
  [A] 'function void mmc_retune_pause(mmc_host*)'
  [A] 'function void mmc_retune_release(mmc_host*)'
  [A] 'function void mmc_retune_unpause(mmc_host*)'
  [A] 'function void mmc_run_bkops(mmc_card*)'
  [A] 'function int mmc_sanitize(mmc_card*)'
  [A] 'function int mmc_send_status(mmc_card*, unsigned int*)'
  [A] 'function void mmc_set_data_timeout(mmc_data*, const mmc_card*)'
  [A] 'function int mmc_start_request(mmc_host*, mmc_request*)'
  [A] 'function int mmc_switch(mmc_card*, unsigned char, unsigned char, unsigned char, unsigned int)'
  [A] 'function void mmc_unregister_driver(mmc_driver*)'
  [A] 'function int mmc_wait_for_cmd(mmc_host*, mmc_command*, int)'
  [A] 'function void mmc_wait_for_req(mmc_host*, mmc_request*)'
  [A] 'function int netlink_has_listeners(sock*, unsigned int)'
  [A] 'function inode* new_inode(super_block*)'
  [A] 'function loff_t no_seek_end_llseek(file*, loff_t, int)'
  [A] 'function thermal_cooling_device* of_devfreq_cooling_register_power(device_node*, devfreq*, devfreq_cooling_power*)'
  [A] 'function int param_get_uint(char*, const kernel_param*)'
  [A] 'function int param_set_uint(const char*, const kernel_param*)'
  [A] 'function bool pci_device_is_present(pci_dev*)'
  [A] 'function int pci_enable_device_mem(pci_dev*)'
  [A] 'function void pci_free_irq(pci_dev*, unsigned int, void*)'
  [A] 'function int pci_request_irq(pci_dev*, unsigned int, irq_handler_t, irq_handler_t, void*, const char*, ...)'
  [A] 'function int pci_select_bars(pci_dev*, unsigned long int)'
  [A] 'function void pcibios_resource_to_bus(pci_bus*, pci_bus_region*, resource*)'
  [A] 'function bool pcie_aspm_enabled(pci_dev*)'
  [A] 'function void percpu_ref_kill_and_confirm(percpu_ref*, void (percpu_ref*)*)'
  [A] 'function int pinctrl_select_default_state(device*)'
  [A] 'function bool policy_has_boost_freq(cpufreq_policy*)'
  [A] 'function proc_dir_entry* proc_create_single_data(const char*, unsigned short int, proc_dir_entry*, int (seq_file*, void*)*, void*)'
  [A] 'function rb_node* rb_prev(const rb_node*)'
  [A] 'function void rb_replace_node(rb_node*, rb_node*, rb_root*)'
  [A] 'function int regmap_add_irq_chip(regmap*, int, int, int, const regmap_irq_chip*, regmap_irq_chip_data**)'
  [A] 'function void regmap_del_irq_chip(int, regmap_irq_chip_data*)'
  [A] 'function irq_domain* regmap_irq_get_domain(regmap_irq_chip_data*)'
  [A] 'function int regmap_raw_read(regmap*, unsigned int, void*, size_t)'
  [A] 'function int regmap_raw_write(regmap*, unsigned int, void*, size_t)'
  [A] 'function regulator* regulator_get_optional(device*, const char*)'
  [A] 'function int regulator_get_voltage_sel_regmap(regulator_dev*)'
  [A] 'function int regulator_list_voltage_table(regulator_dev*, unsigned int)'
  [A] 'function int regulator_map_voltage_ascend(regulator_dev*, int, int)'
  [A] 'function int regulator_set_voltage_sel_regmap(regulator_dev*, unsigned int)'
  [A] 'function int remap_vmalloc_range(vm_area_struct*, void*, unsigned long int)'
  [A] 'function rfkill_type rfkill_find_type(const char*)'
  [A] 'function int rtc_valid_tm(rtc_time*)'
  [A] 'function int rtc_year_days(unsigned int, unsigned int, unsigned int)'
  [A] 'function void sdio_claim_host(sdio_func*)'
  [A] 'function int sdio_disable_func(sdio_func*)'
  [A] 'function int sdio_enable_func(sdio_func*)'
  [A] 'function unsigned char sdio_f0_readb(sdio_func*, unsigned int, int*)'
  [A] 'function void sdio_f0_writeb(sdio_func*, unsigned char, unsigned int, int*)'
  [A] 'function mmc_pm_flag_t sdio_get_host_pm_caps(sdio_func*)'
  [A] 'function int sdio_memcpy_fromio(sdio_func*, void*, unsigned int, int)'
  [A] 'function int sdio_memcpy_toio(sdio_func*, unsigned int, void*, int)'
  [A] 'function int sdio_readsb(sdio_func*, void*, unsigned int, int)'
  [A] 'function int sdio_register_driver(sdio_driver*)'
  [A] 'function void sdio_release_host(sdio_func*)'
  [A] 'function int sdio_set_block_size(sdio_func*, unsigned int)'
  [A] 'function int sdio_set_host_pm_flags(sdio_func*, mmc_pm_flag_t)'
  [A] 'function void sdio_signal_irq(mmc_host*)'
  [A] 'function void sdio_unregister_driver(sdio_driver*)'
  [A] 'function int sdio_writesb(sdio_func*, unsigned int, void*, int)'
  [A] 'function irqreturn_t serio_interrupt(serio*, unsigned char, unsigned int)'
  [A] 'function void serio_reconnect(serio*)'
  [A] 'function void serio_unregister_port(serio*)'
  [A] 'function int set_page_dirty_lock(page*)'
  [A] 'function size_t sg_zero_buffer(scatterlist*, unsigned int, size_t, off_t)'
  [A] 'function scatterlist* sgl_alloc(long long unsigned int, unsigned int, unsigned int*)'
  [A] 'function void sgl_free(scatterlist*)'
  [A] 'function int simple_statfs(dentry*, kstatfs*)'
  [A] 'function int snd_dmaengine_pcm_prepare_slave_config(snd_pcm_substream*, snd_pcm_hw_params*, dma_slave_config*)'
  [A] 'function int snd_soc_dapm_get_pin_switch(snd_kcontrol*, snd_ctl_elem_value*)'
  [A] 'function int snd_soc_dapm_info_pin_switch(snd_kcontrol*, snd_ctl_elem_info*)'
  [A] 'function int snd_soc_dapm_put_pin_switch(snd_kcontrol*, snd_ctl_elem_value*)'
  [A] 'function int snd_soc_jack_add_gpios(snd_soc_jack*, int, snd_soc_jack_gpio*)'
  [A] 'function int snd_soc_of_parse_audio_simple_widgets(snd_soc_card*, const char*)'
  [A] 'function unsigned int snd_soc_of_parse_daifmt(device_node*, const char*, device_node**, device_node**)'
  [A] 'function void snd_soc_of_parse_node_prefix(device_node*, snd_soc_codec_conf*, device_node*, const char*)'
  [A] 'function int snd_soc_of_parse_tdm_slot(device_node*, unsigned int*, unsigned int*, unsigned int*, unsigned int*)'
  [A] 'function int snd_soc_runtime_calc_hw(snd_soc_pcm_runtime*, snd_pcm_hardware*, int)'
  [A] 'function int spi_bus_lock(spi_controller*)'
  [A] 'function int spi_bus_unlock(spi_controller*)'
  [A] 'function int spi_sync_locked(spi_device*, spi_message*)'
  [A] 'function __kernel_size_t strcspn(const char*, const char*)'
  [A] 'function int stream_open(inode*, file*)'
  [A] 'function irqreturn_t tcpci_irq(tcpci*)'
  [A] 'function tcpci* tcpci_register_port(device*, tcpci_data*)'
  [A] 'function void tcpci_unregister_port(tcpci*)'
  [A] 'function int thermal_zone_device_disable(thermal_zone_device*)'
  [A] 'function int thermal_zone_device_enable(thermal_zone_device*)'
  [A] 'function int thermal_zone_get_temp(thermal_zone_device*, int*)'
  [A] 'function thermal_zone_device* thermal_zone_get_zone_by_name(const char*)'
  [A] 'function int usb_add_hcd(usb_hcd*, unsigned int, unsigned long int)'
  [A] 'function int usb_ep_clear_halt(usb_ep*)'
  [A] 'function void usb_ep_fifo_flush(usb_ep*)'
  [A] 'function int usb_ep_fifo_status(usb_ep*)'
  [A] 'function int usb_gadget_probe_driver(usb_gadget_driver*)'
  [A] 'function int usb_gadget_unregister_driver(usb_gadget_driver*)'
  [A] 'function char* usb_get_gadget_udc_name()'
  [A] 'function int usb_hcd_check_unlink_urb(usb_hcd*, urb*, int)'
  [A] 'function void usb_hcd_giveback_urb(usb_hcd*, urb*, int)'
  [A] 'function int usb_hcd_link_urb_to_ep(usb_hcd*, urb*)'
  [A] 'function void usb_hcd_poll_rh_status(usb_hcd*)'
  [A] 'function void usb_hcd_resume_root_hub(usb_hcd*)'
  [A] 'function void usb_hcd_unlink_urb_from_ep(usb_hcd*, urb*)'
  [A] 'function void usb_put_hcd(usb_hcd*)'
  [A] 'function void usb_remove_hcd(usb_hcd*)'
  [A] 'function usb_role_switch* usb_role_switch_get(device*)'
  [A] 'function void usb_role_switch_put(usb_role_switch*)'
  [A] 'function void uuid_gen(__anonymous_struct__61*)'
  [A] 'function int uuid_parse(const char*, uuid_t*)'
  [A] 'function int vfs_fallocate(file*, int, long long int, long long int)'
  [A] 'function int vfs_getattr(const path*, kstat*, u32, unsigned int)'
  [A] 'function void* vmalloc_user(unsigned long int)'
  [A] 'function unsigned int vmf_insert_pfn(vm_area_struct*, unsigned long int, unsigned long int)'
  [A] 'function unsigned long int wait_for_completion_io_timeout(completion*, unsigned long int)'

2242 functions with some sub-type change:

  [C] 'function void* PDE_DATA(const inode*)' at proc_fs.h:112:1 has some sub-type changes:
    CRC (modversions) changed from 0xca6841d to 0x7aae1df7

  [C] 'function void __ClearPageMovable(page*)' at compaction.c:138:1 has some sub-type changes:
    CRC (modversions) changed from 0x6ddde37 to 0x10923ef0

  [C] 'function void __SetPageMovable(page*, address_space*)' at compaction.c:130:1 has some sub-type changes:
    CRC (modversions) changed from 0x75ba553a to 0x78273bab

  ... 2239 omitted; 2242 symbols have only CRC changes

8 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_iommu_setup_dma_ops'
  [A] 'cma* dma_contiguous_default_area'
  [A] 'const vm_operations_struct drm_gem_cma_vm_ops'
  [A] 'static_key_false kasan_flag_enabled'
  [A] 'const unsigned char rfc1042_header[6]'
  [A] 'const inode_operations simple_dir_inode_operations'
  [A] 'const file_operations simple_dir_operations'
  [A] 'const uuid_t uuid_null'

47 Changed variables:

  [C] 'pglist_data contig_page_data' was changed at memblock.c:96:1:
    size of symbol changed from 7168 to 7296
    CRC (modversions) changed from 0xd65ceba4 to 0xdeb74410
    type of variable changed:
      type size changed from 57344 to 58368 (in bits)
      1 data member insertion:
        'task_struct* pglist_data::mkswapd[16]', at offset 52608 (in bits) at mmzone.h:774:1
      there are data member changes:
        15 ('int pglist_data::kswapd_order' .. 'atomic_long_t pglist_data::vm_stat[38]') offsets changed (by +1024 bits)
      2302 impacted interfaces

  [C] 'net init_net' was changed at net_namespace.c:47:1:
    size of symbol changed from 4224 to 4288
    CRC (modversions) changed from 0xa31a2902 to 0x787ff561
    type of variable changed:
      type size changed from 33792 to 34304 (in bits)
      1 data member insertion:
        'netns_ieee802154_lowpan net::ieee802154_lowpan', at offset 18944 (in bits) at net_namespace.h:131:1
      there are data member changes:
        type 'struct netns_ipv4' of 'net::ipv4' changed:
          type size hasn't changed
          1 data member insertion:
            'unsigned long int* netns_ipv4::sysctl_local_unbindable_ports', at offset 6976 (in bits) at ipv4.h:206:1
          there are data member changes:
            7 ('int netns_ipv4::sysctl_ip_prot_sock' .. 'siphash_key_t netns_ipv4::ip_id_key') offsets changed (by +64 bits)
          281 impacted interfaces
        10 ('netns_nf net::nf' .. 'netns_bpf net::bpf') offsets changed (by +128 bits)
        4 ('netns_xfrm net::xfrm' .. 'sock* net::diag_nlsk') offsets changed (by +512 bits)
      281 impacted interfaces

  [C] 'task_struct init_task' was changed at init_task.c:64:1:
    size of symbol changed from 4160 to 4224
    CRC (modversions) changed from 0xacdeb771 to 0x4763faa0
    type of variable changed:
      type size changed from 33280 to 33792 (in bits)
      1 data member deletion:
        'wake_q_head* task_struct::wake_q_head', at offset 15808 (in bits) at sched.h:1011:1
      1 data member insertion:
        'int task_struct::wake_q_count', at offset 16320 (in bits) at sched.h:1011:1
      there are data member changes:
        type 'struct sched_entity' of 'task_struct::se' changed:
          type size changed from 3072 to 3584 (in bits)
          5 data member insertions:
            'int sched_entity::depth', at offset 2560 (in bits) at sched.h:469:1
            'sched_entity* sched_entity::parent', at offset 2624 (in bits) at sched.h:470:1
            'cfs_rq* sched_entity::cfs_rq', at offset 2688 (in bits) at sched.h:472:1
            'cfs_rq* sched_entity::my_q', at offset 2752 (in bits) at sched.h:474:1
            'unsigned long int sched_entity::runnable_weight', at offset 2816 (in bits) at sched.h:476:1
          there are data member changes:
            'sched_avg sched_entity::avg' offset changed (by +512 bits)
          2302 impacted interfaces
        133 ('sched_rt_entity task_struct::rt' .. 'tlbflush_unmap_batch task_struct::tlb_ubc') offsets changed (by +512 bits)
        anonymous data member 'union {refcount_t rcu_users; callback_head rcu;}' offset changed from 19008 to 19520 (in bits) (by +512 bits)
        21 ('pipe_inode_info* task_struct::splice_pipe' .. 'thread_struct task_struct::thread') offsets changed (by +512 bits)
      2302 impacted interfaces

  [C] 'task_group root_task_group' was changed at core.c:7331:1:
    size of symbol changed from 336 to 448
    CRC (modversions) changed from 0x577959a6 to 0xe51acd56
    type of variable changed:
      type size changed from 2688 to 3584 (in bits)
      4 data member insertions:
        'sched_entity** task_group::se', at offset 1600 (in bits) at sched.h:384:1
        'cfs_rq** task_group::cfs_rq', at offset 1664 (in bits) at sched.h:386:1
        'unsigned long int task_group::shares', at offset 1728 (in bits) at sched.h:387:1
        'atomic_long_t task_group::load_avg', at offset 2048 (in bits) at sched.h:395:1
      there are data member changes:
        11 ('callback_head task_group::rcu' .. 'u64 task_group::android_vendor_data1[4]') offsets changed (by +512 bits)
      2302 impacted interfaces

  [C] 'rq runqueues' was changed at core.c:51:1:
    size of symbol changed from 3968 to 4096
    CRC (modversions) changed from 0x590425db to 0x7d8ddb7c
    type of variable changed:
      type size changed from 31744 to 32768 (in bits)
      2 data member insertions:
        'list_head rq::leaf_cfs_rq_list', at offset 19584 (in bits) at sched.h:939:1
        'list_head* rq::tmp_alone_branch', at offset 19712 (in bits) at sched.h:940:1
      there are data member changes:
        type 'struct cfs_rq' of 'rq::cfs' changed:
          type size changed from 2048 to 3072 (in bits)
          10 data member insertions:
            'unsigned long int cfs_rq::tg_load_avg_contrib', at offset 2048 (in bits) at sched.h:562:1
            'long int cfs_rq::propagate', at offset 2112 (in bits) at sched.h:563:1
            'long int cfs_rq::prop_runnable_sum', at offset 2176 (in bits) at sched.h:564:1
            'unsigned long int cfs_rq::h_load', at offset 2240 (in bits) at sched.h:572:1
            'u64 cfs_rq::last_h_load_update', at offset 2304 (in bits) at sched.h:573:1
            'sched_entity* cfs_rq::h_load_next', at offset 2368 (in bits) at sched.h:574:1
            'rq* cfs_rq::rq', at offset 2432 (in bits) at sched.h:579:1
            'int cfs_rq::on_list', at offset 2496 (in bits) at sched.h:589:1
            'list_head cfs_rq::leaf_cfs_rq_list', at offset 2560 (in bits) at sched.h:590:1
            'task_group* cfs_rq::tg', at offset 2688 (in bits) at sched.h:591:1
          2302 impacted interfaces
        2 ('rt_rq rq::rt' .. 'dl_rq rq::dl') offsets changed (by +1024 bits)
        8 ('unsigned long int rq::nr_uninterruptible' .. 'u64 rq::clock') offsets changed (by +1216 bits)
        43 ('u64 rq::clock_task' .. 'u64 rq::android_vendor_data1[96]') offsets changed (by +1024 bits)
      2302 impacted interfaces

  [C] 'bus_type amba_bustype' was changed at bus.c:215:1:
    CRC (modversions) changed from 0x3a27bef1 to 0xa38da620

  [C] 'const clk_ops clk_fixed_factor_ops' was changed at clk-fixed-factor.c:60:1:
    CRC (modversions) changed from 0xf66fcfb6 to 0x6d350258

  [C] 'const clk_ops clk_fixed_rate_ops' was changed at clk-fixed-rate.c:46:1:
    CRC (modversions) changed from 0xa301d63c to 0x6a810889

  ... 39 omitted; 42 symbols have only CRC changes

1 Added function symbol not referenced by debug info:

  [A] clear_page

'struct cfs_rq at sched.h:518:1' changed:
  details were reported earlier

'struct cma at cma.h:7:1' changed:
  type size changed from 1024 to 1280 (in bits)
  3 data member insertions:
    'hlist_head cma::mem_head', at offset 512 (in bits) at cma.h:14:1
    'spinlock_t cma::mem_head_lock', at offset 576 (in bits) at cma.h:15:1
    'debugfs_u32_array cma::dfs_bitmap', at offset 640 (in bits) at cma.h:16:1
  there are data member changes:
    'char cma::name[64]' offset changed (by +256 bits)
  2303 impacted interfaces

'struct dma_buf at dma-buf.h:394:1' changed:
  type size changed from 2112 to 3072 (in bits)
  3 data member insertions:
    'int dma_buf::mmap_count', at offset 2112 (in bits) at dma-buf.h:430:1
    'const vm_operations_struct* dma_buf::exp_vm_ops', at offset 2176 (in bits) at dma-buf.h:431:1
    'vm_operations_struct dma_buf::vm_ops', at offset 2240 (in bits) at dma-buf.h:432:1
  68 impacted interfaces

'struct kmem_cache at slub_def.h:84:1' changed:
  type size changed from 1728 to 1856 (in bits)
  1 data member insertion:
    'kasan_cache kmem_cache::kasan_info', at offset 1600 (in bits) at slub_def.h:129:1
  there are data member changes:
    2 ('unsigned int kmem_cache::useroffset' .. 'unsigned int kmem_cache::usersize') offsets changed (by +96 bits)
    'kmem_cache_node* kmem_cache::node[1]' offset changed (by +128 bits)
  2302 impacted interfaces

'struct mmc_host at host.h:275:1' changed:
  type size changed from 11264 to 12800 (in bits)
  1 data member insertion:
    'blk_keyslot_manager mmc_host::ksm', at offset 11008 (in bits) at host.h:482:1
  there are data member changes:
    'bool mmc_host::hsq_enabled' offset changed (by +1488 bits)
    'unsigned long int mmc_host::private[]' offset changed (by +1536 bits)
  19 impacted interfaces

'struct mmc_request at core.h:144:1' changed:
  type size changed from 1024 to 1152 (in bits)
  3 data member insertions:
    'bool mmc_request::crypto_enabled', at offset 1024 (in bits) at core.h:167:1
    'int mmc_request::crypto_key_slot', at offset 1056 (in bits) at core.h:168:1
    'u32 mmc_request::data_unit_num', at offset 1088 (in bits) at core.h:169:1
  19 impacted interfaces

'struct module at module.h:366:1' changed:
  type size hasn't changed
  1 data member insertion:
    'const char* module::scmversion', at offset 1600 (in bits) at module.h:380:1
  there are data member changes:
    19 ('kobject* module::holders_dir' .. 'int ()* module::init') offsets changed (by +64 bits)
  2302 impacted interfaces

'struct ndisc_options at ndisc.h:111:1' changed:
  type size changed from 1216 to 1408 (in bits)
  1 data member insertion:
    'nd_opt_hdr* ndisc_options::nd_802154_opt_array[3]', at offset 1216 (in bits) at ndisc.h:120:1
  281 impacted interfaces

'struct net at net_namespace.h:56:1' changed:
  details were reported earlier

'struct netns_ipv4 at ipv4.h:43:1' changed:
  details were reported earlier

'struct pglist_data at mmzone.h:726:1' changed:
  details were reported earlier

'struct rproc_ops at remoteproc.h:379:1' changed:
  type size changed from 896 to 960 (in bits)
  1 data member insertion:
    'void (rproc*)* rproc_ops::coredump', at offset 896 (in bits) at remoteproc.h:397:1
  16 impacted interfaces

'struct rq at sched.h:897:1' changed:
  details were reported earlier

'struct sched_class at sched.h:1790:1' changed:
  type size changed from 1536 to 1792 (in bits)
  1 data member insertion:
    'void (task_struct*, int)* sched_class::task_change_group', at offset 1536 (in bits) at sched.h:1845:1
  2302 impacted interfaces

'struct sched_entity at sched.h:452:1' changed:
  details were reported earlier

'struct task_group at sched.h:379:1' changed:
  details were reported earlier

'struct task_struct at sched.h:641:1' changed:
  details were reported earlier

'struct vm_fault at mm.h:519:1' changed:
  type size changed from 1024 to 1088 (in bits)
  3 data member deletions:
    'vm_area_struct* vm_fault::vma', at offset 0 (in bits) at mm.h:520:1
    'gfp_t vm_fault::gfp_mask', at offset 96 (in bits) at mm.h:522:1
    'unsigned long int vm_fault::address', at offset 192 (in bits) at mm.h:524:1
  there are data member changes:
    data member unsigned long int vm_fault::pgoff at offset 128 (in bits) became anonymous data member 'struct {vm_area_struct* vma; gfp_t gfp_mask; unsigned long int pgoff; unsigned long int address;}'
    and size changed from 64 to 256 (in bits) (by +192 bits)
    'unsigned int vm_fault::flags' offset changed (by +320 bits)
    2 ('unsigned int vm_fault::sequence' .. 'pmd_t vm_fault::orig_pmd') offsets changed (by -256 bits)
    7 ('pmd_t* vm_fault::pmd' .. 'spinlock_t* vm_fault::ptl') offsets changed (by +64 bits)
    type 'typedef pgtable_t' of 'vm_fault::prealloc_pte' changed:
      underlying type 'page*' changed:
    and offset changed from 832 to 896 (in bits) (by +64 bits)
    2 ('unsigned long int vm_fault::vma_flags' .. 'pgprot_t vm_fault::vma_page_prot') offsets changed (by +64 bits)
  2302 impacted interfaces

'struct vm_operations_struct at mm.h:578:1' changed:
  type size hasn't changed
  there are data member changes:
    type 'void (vm_fault*, unsigned long int, unsigned long int)*' of 'vm_operations_struct::map_pages' changed:
      pointer type changed from: 'void (vm_fault*, unsigned long int, unsigned long int)*' to: 'typedef vm_fault_t (vm_fault*, unsigned long int, unsigned long int)*'
  2302 impacted interfaces

Bug: 180027765
Change-Id: I9d713d57f26b05e4c91ad21b8ba345f9de3538cf
Signed-off-by: Will McVicker <willmcvicker@google.com>
2021-02-23 16:42:22 -08:00
Will McVicker
adc53e1fd0 ANDROID: modpost: update nits from late review
Updates the documentation and comments for the MODULE_SCMVERSION feature.

Bug: 180027765
Fixes: 4b9c11a373 ("ANDROID: modules: introduce the MODULE_SCMVERSION config")
Change-Id: I648b31c4810c777ec3d2cb141b61f5924559c76f
Signed-off-by: Will McVicker <willmcvicker@google.com>
2021-02-23 16:42:22 -08:00
Will McVicker
49121c77df ANDROID: GKI: Enable CONFIG_MODULE_SCMVERSION=y
This config enables the module attribute `scmversion` to allow
identifying the SCM versions of kernel modules. In particular, this can
be used to identity the SCM version of vendor kernel modules and
external modules which will vary from the GKI kernel's SCM version.

Bug: 180027765
Change-Id: I7ef84228e5cf0b1c792d022ae4bf8e5302c2dc5e
Signed-off-by: Will McVicker <willmcvicker@google.com>
2021-02-23 16:42:22 -08:00
Will McVicker
cca2b40a78 ANDROID: modpost: Support relative paths for module_srcpath
If a relative path is used for EXT_MODULES and -O is defined, then we
need to set the module_srcpath as relative to $(srctree) vs $(objtree).
Refer to [1] for more details.

[1] https://lore.kernel.org/lkml/20210120193100.3414664-1-masahiroy@kernel.org/

Bug: 180027765
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I17065f2dc7d5c3297f88500390a6f45aceea7229
2021-02-23 16:42:21 -08:00
Will McVicker
da2089a28a ANDROID: modules: introduce the MODULE_SCMVERSION config
Config MODULE_SCMVERSION introduces a new module attribute --
`scmversion` -- which can be used to identify a given module's SCM
version.  This is very useful for developers that update their kernel
independently from their kernel modules or vice-versa since the SCM
version provided by UTS_RELEASE (`uname -r`) will now differ from the
module's vermagic attribute.

For example, we have a CI setup that tests new kernel changes on the
hikey960 and db845c devices without updating their kernel modules. When
these tests fail, we need to be able to identify the exact device
configuration the test was using. By including MODULE_SCMVERSION, we can
identify the exact kernel and modules' SCM versions for debugging the
failures.

Additionally, by exposing the SCM version via the sysfs node
/sys/module/MODULENAME/scmversion, one can also verify the SCM versions
of the modules loaded from the initramfs. Currently, modinfo can only
retrieve module attributes from the module's ko on disk and not from the
actual module that is loaded in RAM.

You can retrieve the SCM version in two ways,

1) By using modinfo:
    > modinfo -F scmversion MODULENAME
2) By module sysfs node:
    > cat /sys/module/MODULENAME/scmversion

Bug: 180027765
Link: https://lore.kernel.org/lkml/20210121213641.3477522-1-willmcvicker@google.com
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Ib7c72c72f95c4545adb7cd4e842729557039ce3a
2021-02-23 16:42:21 -08:00
Will McVicker
8c7a2fec34 ANDROID: scripts/setlocalversion: allow running in a subdir
Getting the scmversion using scripts/setlocalversion currently only
works when run at the root of a git or mecurial project. This was
introduced in commit 8558f59edf ("setlocalversion: Ignote SCMs above
the linux source tree") so that if one is building within a subdir of
a git tree that isn't the kernel git project, then the vermagic wouldn't
include that git sha1.

For Android purposes, this isn't a concern. So let's bring back this
functionality so that we can use scripts/setlocalversion to capture the SCM
version of external modules that reside within subdirectories of an SCM
project.

Bug: 180027765
Link: https://lore.kernel.org/lkml/20201125010541.309848-2-willmcvicker@google.com
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: If12ea75c6be0c0167f29f69b7cf13d1d85b7331c
2021-02-23 16:42:21 -08:00
Elliot Berman
e146d4c5bd ANDROID: abi_gki_aarch64_qcom: Update symbol list
Synchronize QCOM symbol list in android/abi_gki_aarch644_qcom.

Bug: 180592352
Change-Id: I61cd760763140f170462751625d1fbec7cb0daf5
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
2021-02-24 00:27:45 +00:00
Isaac J. Manjarres
c21b86d573 ANDROID: GKI: Add iommu_get_msi_cookie() to the symbol list
iommu_get_msi_cookie() is useful for IOMMU drivers that need
to support MSI and manage their own IOVA space, so add it
to the symbol list.

Bug: 180947264
Change-Id: I32b4cb536b7bcb1e69e43a811489da7cc3d28412
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-02-24 00:00:12 +00:00
Minchan Kim
8e2bcbe741 UPSTREAM: zram: support page writeback
There is demand to writeback specific process pages to backing store
instead of all idles pages in the system due to storage wear out concerns
and to launching latency of apps which are most of the time idle but are
critical for resume latency.

This patch extends the writeback knob to support a specific page
writeback.

Link: https://lkml.kernel.org/r/20201020190506.3758660-1-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 0d8359620d)

Bug: 181035934
Signed-off-by: Amos Bianchi <amosbianchi@google.com>
Change-Id: I2c2ef973f66c9d780244d39a1833c4246fb28bc2
2021-02-23 23:00:10 +00:00
Stephen Dickey
9d1a51d1b9 ANDROID: sched/pause: migrate_tasks crash
With DEQUEUE_SAVE and ENQUEUE_RESTORE set when calling deactivate_task
and activate_task, the rt class scheduler will not dequeue/enqueue
the task respectively - move_entity() returns false. This results in
the same task being picked multiple times by __pick_migrate_task,
which results in the same task getting a second initialization of
next->percpu_kthread_node, corrupting the list and causing a crash
with __list_add_valid.

Remove DEQUEUE_SAVE and ENQUEUE_RESTORE when holding back kthreads from
being migrated, for the calls to activate/deactivate task,
preventing the crash.

Bug: 180893027
Change-Id: I3171c26a4f9415287feb5acfe933b4442ca05937
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-02-23 09:53:46 -08:00
Pavankumar Kondeti
7dddba0c69 ANDROID: sched: Exempt paused CPU from nohz idle balance
A CPU can be paused while it is idle with it's tick stopped.
nohz_balance_exit_idle() should be called from the local CPU,
so it can't be called during pause which can happen remotely.
This results in paused CPU participating in the nohz idle balance,
which should be avoided. This can be done by calling

Fix this issue by calling nohz_balance_exit_idle() from the paused
CPU when it exits and enters idle again. This lazy approach avoids
waking the CPU from idle during pause.

Bug: 180530906
Change-Id: Ia2dfd9c9cac9b0f37c55a9256b9d5f3141ca0421
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
2021-02-23 09:58:52 +00:00
Patrick Daly
9b0d5fb824 ANDROID: Update QCOM symbol list
Add iommu vendor tracepoint hook to the symbol list.

Bug: 179291683
Change-Id: I096fad1c8e822dc4c4f7e52544505b1ddf2a3aca
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-02-23 09:35:31 +00:00
Eric Biggers
018ad7e673 ANDROID: gki_defconfig: enable CONFIG_MMC_CRYPTO
This is needed to support eMMC inline encryption hardware.

Bug: 161256007
Change-Id: Ib8a40363a77f787111632348ec3662c6f7550241
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
14d98d667c ANDROID: mmc: cqhci: set blk_keyslot_manager::features
This is needed due to "ANDROID: block: add hardware-wrapped key
support", which isn't upstream yet.

Bug: 160883801
Change-Id: I053a1de8d8c600f8eaba60cd338e07b778d017b3
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
b489f0324e UPSTREAM: mmc: sdhci-msm: add Inline Crypto Engine support
Add support for Qualcomm Inline Crypto Engine (ICE) to sdhci-msm.

The standard-compliant parts, such as querying the crypto capabilities
and enabling crypto for individual MMC requests, are already handled by
cqhci-crypto.c, which itself is wired into the blk-crypto framework.
However, ICE requires vendor-specific init, enable, and resume logic,
and it requires that keys be programmed and evicted by vendor-specific
SMC calls.  Make the sdhci-msm driver handle these details.

This is heavily inspired by the similar changes made for UFS, since the
UFS and eMMC ICE instances are very similar.  See commit df4ec2fa7a
("scsi: ufs-qcom: Add Inline Crypto Engine support").

I tested this on a Sony Xperia 10, which uses the Snapdragon 630 SoC,
which has basic upstream support.  Mainly, I used android-xfstests
(https://github.com/tytso/xfstests-bld/blob/master/Documentation/android-xfstests.md)
to run the ext4 and f2fs encryption tests in a Debian chroot:

	android-xfstests -c ext4,f2fs -g encrypt -m inlinecrypt

These tests included tests which verify that the on-disk ciphertext is
identical to that produced by a software implementation.  I also
verified that ICE was actually being used.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-9-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit c93767cf64)
Bug: 161256007
Change-Id: I4cdd2eca67419940181d55c690b7308ae7433096
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
23957f08ca UPSTREAM: dt-bindings: mmc: sdhci-msm: add ICE registers and clock
Document the bindings for the registers and clock for the MMC instance
of the Inline Crypto Engine (ICE) on Snapdragon SoCs.  These bindings
are needed in order for sdhci-msm to support inline encryption.

Reviewed-by: Satya Tangirala <satyat@google.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-8-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 5cc046eb13)
Bug: 161256007
Change-Id: Id64d6d66046ea4316cc4caca1fb9553ed71b6722
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
05a22bd588 UPSTREAM: firmware: qcom_scm: update comment for ICE-related functions
The SCM calls QCOM_SCM_ES_INVALIDATE_ICE_KEY and
QCOM_SCM_ES_CONFIG_SET_ICE_KEY are also needed for eMMC inline
encryption support, not just for UFS.  Update the comments accordingly.

Reviewed-by: Satya Tangirala <satyat@google.com>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210125183810.198008-7-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 433611ea8d)
Bug: 161256007
Change-Id: Ifd479558a27393f398e5097f5a7dfbbbc38919db
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
d43a24006d UPSTREAM: mmc: cqhci: add cqhci_host_ops::program_key
On Snapdragon SoCs, the Linux kernel isn't permitted to directly access
the standard CQHCI crypto configuration registers.  Instead, programming
and evicting keys must be done through vendor-specific SMC calls.

To support this hardware, add a ->program_key() method to
'struct cqhci_host_ops'.  This allows overriding the standard CQHCI
crypto key programming / eviction procedure.

This is inspired by the corresponding UFS crypto support, which uses
these same SMC calls.  See commit 1bc726e26e ("scsi: ufs: Add
program_key() variant op").

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Reviewed-and-tested-by: Peng Zhou <peng.zhou@mediatek.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-6-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 0a0c866f37)
Bug: 161256007
Change-Id: Id0a988c769f1ec71c192a634635fdddd5fa66896
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
6a3217913c UPSTREAM: mmc: cqhci: add support for inline encryption
Add support for eMMC inline encryption using the blk-crypto framework
(Documentation/block/inline-encryption.rst).

eMMC inline encryption support is specified by the upcoming JEDEC eMMC
v5.2 specification.  It is only specified for the CQ interface, not the
non-CQ interface.  Although the eMMC v5.2 specification hasn't been
officially released yet, the crypto support was already agreed on
several years ago, and it was already implemented by at least two major
hardware vendors.  Lots of hardware in the field already supports and
uses it, e.g. Snapdragon 630 to give one example.

eMMC inline encryption support is very similar to the UFS inline
encryption support which was standardized in the UFS v2.1 specification
and was already upstreamed.  The only major difference is that eMMC
limits data unit numbers to 32 bits, unlike UFS's 64 bits.

Like we did with UFS, make the crypto support opt-in by individual
drivers; don't enable it automatically whenever the hardware declares
crypto support.  This is necessary because in every case we've seen,
some extra vendor-specific logic is needed to use the crypto support.

Co-developed-by: Satya Tangirala <satyat@google.com>
Signed-off-by: Satya Tangirala <satyat@google.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Reviewed-and-tested-by: Peng Zhou <peng.zhou@mediatek.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210125183810.198008-5-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 1e80709bdb)
Bug: 161256007
Change-Id: I37e62b68e601a50cc4b577ca7386d5a2badf96e4
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
a41cb40e4d UPSTREAM: mmc: cqhci: initialize upper 64 bits of 128-bit task descriptors
Move the task descriptor initialization into cqhci_prep_task_desc().
In addition, make it explicitly initialize all 128 bits of the task
descriptor if the host controller is using 128-bit task descriptors,
rather than relying on the implicit zeroing from dmam_alloc_coherent().

This is needed to prepare for CQHCI inline encryption support, which
requires 128-bit task descriptors and uses the upper 64 bits.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Reviewed-and-tested-by: Peng Zhou <peng.zhou@mediatek.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-4-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit ee49d0321f)
Bug: 161256007
Change-Id: I86b162281c1565dabcf57526c3d7c3f43806be52
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:57 +01:00
Eric Biggers
879803f951 UPSTREAM: mmc: cqhci: rename cqhci.c to cqhci-core.c
Rename cqhci.c to cqhci-core.c so that another source file can be added
to the cqhci module without having to rename the module.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-and-tested-by: Peng Zhou <peng.zhou@mediatek.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-3-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 0653300224)
Bug: 161256007
Change-Id: I22e8eacaf1194272eb3e6124f8e2becf3cc535a9
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:56 +01:00
Eric Biggers
cf3293b65b UPSTREAM: mmc: core: Add basic support for inline encryption
In preparation for adding CQHCI crypto engine (inline encryption)
support, add the code required to make mmc_core and mmc_block aware of
inline encryption.  Specifically:

- Add a capability flag MMC_CAP2_CRYPTO to struct mmc_host.  Drivers
  will set this if the host and driver support inline encryption.

- Embed a blk_keyslot_manager in struct mmc_host.  Drivers will
  initialize this (as a device-managed resource) if the host and driver
  support inline encryption.  mmc_block registers this keyslot manager
  with the request_queue of any MMC card attached to the host.

- Make mmc_block copy the crypto keyslot and crypto data unit number
  from struct request to struct mmc_request, so that drivers will have
  access to them.

- If the MMC host is reset, reprogram all the keyslots to ensure that
  the software state stays in sync with the hardware state.

Co-developed-by: Satya Tangirala <satyat@google.com>
Signed-off-by: Satya Tangirala <satyat@google.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Reviewed-and-tested-by: Peng Zhou <peng.zhou@mediatek.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210126001456.382989-2-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 93f1c150cb)
Bug: 161256007
Change-Id: I30095dcaab9e5e929657190ac5744b4f3676a990
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:56 +01:00
Eric Biggers
d205aa02f6 UPSTREAM: scsi: ufs: use devm_blk_ksm_init()
Use the new resource-managed variant of blk_ksm_init() so that the UFS
driver doesn't have to manually call blk_ksm_destroy().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Link: https://lore.kernel.org/r/20210121082155.111333-3-ebiggers@kernel.org
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit d76d9d7d10)
Bug: 161256007
Change-Id: If9c5ba188d8fa45becd8393822f104017a61637d
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:56 +01:00
Eric Biggers
25b3bc709c UPSTREAM: block/keyslot-manager: introduce devm_blk_ksm_init()
Add a resource-managed variant of blk_ksm_init() so that drivers don't
have to worry about calling blk_ksm_destroy().

Note that the implementation uses a custom devres action to call
blk_ksm_destroy() rather than switching the two allocations to be
directly devres-managed, e.g. with devm_kmalloc().  This is because we
need to keep zeroing the memory containing the keyslots when it is
freed, and also because we want to continue using kvmalloc() (and there
is no devm_kvmalloc()).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20210121082155.111333-2-ebiggers@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

(cherry picked from commit 5851d3b042)
Bug: 161256007
Change-Id: I3cda7fc5f7509f8d967882a88ca30ddc6f6a0426
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:10:56 +01:00
Eric Biggers
ffdad4351e ANDROID: gki_defconfig: enable BLAKE2b support
Bug: 178411248
Change-Id: Iec497954d29adcf7193da9ca4b27d61eac7615d9
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:20 +01:00
Eric Biggers
15023db7dc UPSTREAM: crypto: arm/blake2b - add NEON-accelerated BLAKE2b
Add a NEON-accelerated implementation of BLAKE2b.

On Cortex-A7 (which these days is the most common ARM processor that
doesn't have the ARMv8 Crypto Extensions), this is over twice as fast as
SHA-256, and slightly faster than SHA-1.  It is also almost three times
as fast as the generic implementation of BLAKE2b:

	Algorithm            Cycles per byte (on 4096-byte messages)
	===================  =======================================
	blake2b-256-neon     14.0
	sha1-neon            16.3
	blake2s-256-arm      18.8
	sha1-asm             20.8
	blake2s-256-generic  26.0
	sha256-neon	     28.9
	sha256-asm	     32.0
	blake2b-256-generic  38.9

This implementation isn't directly based on any other implementation,
but it borrows some ideas from previous NEON code I've written as well
as from chacha-neon-core.S.  At least on Cortex-A7, it is faster than
the other NEON implementations of BLAKE2b I'm aware of (the
implementation in the BLAKE2 official repository using intrinsics, and
Andrew Moon's implementation which can be found in SUPERCOP).  It does
only one block at a time, so it performs well on short messages too.

NEON-accelerated BLAKE2b is useful because there is interest in using
BLAKE2b-256 for dm-verity on low-end Android devices (specifically,
devices that lack the ARMv8 Crypto Extensions) to replace SHA-1.  On
these devices, the performance cost of upgrading to SHA-256 may be
unacceptable, whereas BLAKE2b-256 would actually improve performance.

Although BLAKE2b is intended for 64-bit platforms (unlike BLAKE2s which
is intended for 32-bit platforms), on 32-bit ARM processors with NEON,
BLAKE2b is actually faster than BLAKE2s.  This is because NEON supports
64-bit operations, and because BLAKE2s's block size is too small for
NEON to be helpful for it.  The best I've been able to do with BLAKE2s
on Cortex-A7 is 18.8 cpb with an optimized scalar implementation.

(I didn't try BLAKE2sp and BLAKE3, which in theory would be faster, but
they're more complex as they require running multiple hashes at once.
Note that BLAKE2b already uses all the NEON bandwidth on the Cortex-A7,
so I expect that any speedup from BLAKE2sp or BLAKE3 would come only
from the smaller number of rounds, not from the extra parallelism.)

For now this BLAKE2b implementation is only wired up to the shash API,
since there is no library API for BLAKE2b yet.  However, I've tried to
keep things consistent with BLAKE2s, e.g. by defining
blake2b_compress_arch() which is analogous to blake2s_compress_arch()
and could be exported for use by the library API later if needed.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 1862eb0073)
Bug: 178411248
Change-Id: I01557f0a63db0eb21778d0cc7b582ad89898d44a
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:20 +01:00
Eric Biggers
53f83e3aae UPSTREAM: crypto: blake2b - update file comment
The file comment for blake2b_generic.c makes it sound like it's the
reference implementation of BLAKE2b with only minor changes.  But it's
actually been changed a lot.  Update the comment to make this clearer.

Reviewed-by: David Sterba <dsterba@suse.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 0cdc438e6e)
Bug: 178411248
Change-Id: I8b58cd0e2892a873866ead52fa4dba3edabdeeb3
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:20 +01:00
Eric Biggers
8bde3e29cb UPSTREAM: crypto: blake2b - sync with blake2s implementation
Sync the BLAKE2b code with the BLAKE2s code as much as possible:

- Move a lot of code into new headers <crypto/blake2b.h> and
  <crypto/internal/blake2b.h>, and adjust it to be like the
  corresponding BLAKE2s code, i.e. like <crypto/blake2s.h> and
  <crypto/internal/blake2s.h>.

- Rename constants, e.g. BLAKE2B_*_DIGEST_SIZE => BLAKE2B_*_HASH_SIZE.

- Use a macro BLAKE2B_ALG() to define the shash_alg structs.

- Export blake2b_compress_generic() for use as a fallback.

This makes it much easier to add optimized implementations of BLAKE2b,
as optimized implementations can use the helper functions
crypto_blake2b_{setkey,init,update,final}() and
blake2b_compress_generic().  The ARM implementation will use these.

But this change is also helpful because it eliminates unnecessary
differences between the BLAKE2b and BLAKE2s code, so that the same
improvements can easily be made to both.  (The two algorithms are
basically identical, except for the word size and constants.)  It also
makes it straightforward to add a library API for BLAKE2b in the future
if/when it's needed.

This change does make the BLAKE2b code slightly more complicated than it
needs to be, as it doesn't actually provide a library API yet.  For
example, __blake2b_update() doesn't really need to exist yet; it could
just be inlined into crypto_blake2b_update().  But I believe this is
outweighed by the benefits of keeping the code in sync.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 28dcca4cc0)
Bug: 178411248
Change-Id: I755c64fefe1209b54d1417d91e8a4c207382a620
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:20 +01:00
Eric Biggers
f1cc7b47d8 UPSTREAM: wireguard: Kconfig: select CRYPTO_BLAKE2S_ARM
When available, select the new implementation of BLAKE2s for 32-bit ARM.
This is faster than the generic C implementation.

Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit a64bfe7ad4)
Bug: 152722841
Bug: 178411248
Change-Id: I27b0d049b689c8ef5d44e01151aa8c78af1bdd0e
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:20 +01:00
Eric Biggers
8cc1fdb8ac UPSTREAM: crypto: arm/blake2s - add ARM scalar optimized BLAKE2s
Add an ARM scalar optimized implementation of BLAKE2s.

NEON isn't very useful for BLAKE2s because the BLAKE2s block size is too
small for NEON to help.  Each NEON instruction would depend on the
previous one, resulting in poor performance.

With scalar instructions, on the other hand, we can take advantage of
ARM's "free" rotations (like I did in chacha-scalar-core.S) to get an
implementation get runs much faster than the C implementation.

Performance results on Cortex-A7 in cycles per byte using the shash API:

	4096-byte messages:
		blake2s-256-arm:     18.8
		blake2s-256-generic: 26.0

	500-byte messages:
		blake2s-256-arm:     20.3
		blake2s-256-generic: 27.9

	100-byte messages:
		blake2s-256-arm:     29.7
		blake2s-256-generic: 39.2

	32-byte messages:
		blake2s-256-arm:     50.6
		blake2s-256-generic: 66.2

Except on very short messages, this is still slower than the NEON
implementation of BLAKE2b which I've written; that is 14.0, 16.4, 25.8,
and 76.1 cpb on 4096, 500, 100, and 32-byte messages, respectively.
However, optimized BLAKE2s is useful for cases where BLAKE2s is used
instead of BLAKE2b, such as WireGuard.

This new implementation is added in the form of a new module
blake2s-arm.ko, which is analogous to blake2s-x86_64.ko in that it
provides blake2s_compress_arch() for use by the library API as well as
optionally register the algorithms with the shash API.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 5172d322d3)
Bug: 152722841
Bug: 178411248
Change-Id: I0ba7a0ea53518d512ccbe54a56970d6bbe2a32e0
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
290d0e42bc UPSTREAM: crypto: blake2s - include <linux/bug.h> instead of <asm/bug.h>
Address the following checkpatch warning:

	WARNING: Use #include <linux/bug.h> instead of <asm/bug.h>

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit bbda6e0f13)
Bug: 152722841
Bug: 178411248
Change-Id: Ib12103873c97387ba59ff897c44a18e4f1e6da3d
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
f006426a4f UPSTREAM: crypto: blake2s - adjust include guard naming
Use the full path in the include guards for the BLAKE2s headers to avoid
ambiguity and to match the convention for most files in include/crypto/.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 8786841bc2)
Bug: 152722841
Bug: 178411248
Change-Id: Iea57edbe14c9083ce3d7a77b2c3bd63cd6650e56
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
c42fac6d71 UPSTREAM: crypto: blake2s - add comment for blake2s_state fields
The first three fields of 'struct blake2s_state' are used in assembly
code, which isn't immediately obvious, so add a comment to this effect.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 7d87131fad)
Bug: 152722841
Bug: 178411248
Change-Id: Iab85ddd350a2db917b247ba8f6e224eba905b747
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
46c4d1ccb0 UPSTREAM: crypto: blake2s - optimize blake2s initialization
If no key was provided, then don't waste time initializing the block
buffer, as its initial contents won't be used.

Also, make crypto_blake2s_init() and blake2s() call a single internal
function __blake2s_init() which treats the key as optional, rather than
conditionally calling blake2s_init() or blake2s_init_key().  This
reduces the compiled code size, as previously both blake2s_init() and
blake2s_init_key() were being inlined into these two callers, except
when the key size passed to blake2s() was a compile-time constant.

These optimizations aren't that significant for BLAKE2s.  However, the
equivalent optimizations will be more significant for BLAKE2b, as
everything is twice as big in BLAKE2b.  And it's good to keep things
consistent rather than making optimizations for BLAKE2b but not BLAKE2s.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 42ad8cf821)
Bug: 152722841
Bug: 178411248
Change-Id: Id057e0c8a5f0e432f227dc3deaa8997a7cbc0577
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
669d2197fc UPSTREAM: crypto: blake2s - share the "shash" API boilerplate code
Add helper functions for shash implementations of BLAKE2s to
include/crypto/internal/blake2s.h, taking advantage of
__blake2s_update() and __blake2s_final() that were added by the previous
patch to share more code between the library and shash implementations.

crypto_blake2s_setkey() and crypto_blake2s_init() are usable as
shash_alg::setkey and shash_alg::init directly, while
crypto_blake2s_update() and crypto_blake2s_final() take an extra
'blake2s_compress_t' function pointer parameter.  This allows the
implementation of the compression function to be overridden, which is
the only part that optimized implementations really care about.

The new functions are inline functions (similar to those in sha1_base.h,
sha256_base.h, and sm3_base.h) because this avoids needing to add a new
module blake2s_helpers.ko, they aren't *too* long, and this avoids
indirect calls which are expensive these days.  Note that they can't go
in blake2s_generic.ko, as that would require selecting CRYPTO_BLAKE2S
from CRYPTO_BLAKE2S_X86, which would cause a recursive dependency.

Finally, use these new helper functions in the x86 implementation of
BLAKE2s.  (This part should be a separate patch, but unfortunately the
x86 implementation used the exact same function names like
"crypto_blake2s_update()", so it had to be updated at the same time.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 8c4a93a127)
Bug: 152722841
Bug: 178411248
Change-Id: I9d23b1897cee81fb1704b6eea14d3dc9b1c80fe0
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
f411897ead UPSTREAM: crypto: blake2s - move update and final logic to internal/blake2s.h
Move most of blake2s_update() and blake2s_final() into new inline
functions __blake2s_update() and __blake2s_final() in
include/crypto/internal/blake2s.h so that this logic can be shared by
the shash helper functions.  This will avoid duplicating this logic
between the library and shash implementations.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 057edc9c8b)
Bug: 152722841
Bug: 178411248
Change-Id: Idedf8147914839d5280e5d8eec9013264fbb45f9
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
27aee704d0 UPSTREAM: crypto: blake2s - remove unneeded includes
It doesn't make sense for the generic implementation of BLAKE2s to
include <crypto/internal/simd.h> and <linux/jump_label.h>, as these are
things that would only be useful in an architecture-specific
implementation.  Remove these unnecessary includes.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit df412e7efd)
Bug: 152722841
Bug: 178411248
Change-Id: I8bccb9506d235c2b184b9899ee375fdc12d6b10f
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
6c2952c3cd UPSTREAM: crypto: x86/blake2s - define shash_alg structs using macros
The shash_alg structs for the four variants of BLAKE2s are identical
except for the algorithm name, driver name, and digest size.  So, avoid
code duplication by using a macro to define these structs.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 1aa90f4cf0)
Bug: 152722841
Bug: 178411248
Change-Id: Ibba710056182a609defca0a53133387153f0f63d
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Eric Biggers
2ccec4b7bf UPSTREAM: crypto: blake2s - define shash_alg structs using macros
The shash_alg structs for the four variants of BLAKE2s are identical
except for the algorithm name, driver name, and digest size.  So, avoid
code duplication by using a macro to define these structs.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 0d396058f9)
Bug: 152722841
Bug: 178411248
Change-Id: I32b3a6c035b18f063ad0e03c43171091ca1490a8
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Herbert Xu
d0a59f9532 UPSTREAM: crypto: lib/blake2s - Move selftest prototype into header file
This patch fixes a missing prototype warning on blake2s_selftest.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit ce0d5d63e8)
Bug: 152722841
Change-Id: Ieb19048d60f6c9dc36cefda8b09b3d5c95e9118e
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-02-23 08:06:19 +01:00
Suren Baghdasaryan
aa8f690d71 ANDROID: vmscan: Fix sparse warnings for kswapd_threads
Fix the following warning by declaring kswapd_threads as static:
mm/vmscan.c:175:5: sparse: symbol 'kswapd_threads' was not declared.

Fixes: 0d61a651e4 ("ANDROID: vmscan: Support multiple kswapd threads per node")
Bug: 171351667
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I6ccb1e0e0f597fda27ed6893d254a77341139084
2021-02-22 18:13:47 -08:00
Suren Baghdasaryan
6a0a705473 ANDROID: mm: hide get_each_object_track declaration when CONFIG_SLUB=n
struct track and enum track_item are undefined when CONFIG_SLUB=n.
get_each_object_track which uses these types should not be compiled
in this configuration. Add missing ifdefs to prevent compilation errors.

Fixes: ee8d2c7884 ("ANDROID: mm: add get_each_object_track function")
Bug: 177377077
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9ad15e6ef1572ba8f69b746ab837f051614c017c
2021-02-22 17:40:01 -08:00
Vlastimil Babka
10aaa1d5c7 FROMGIT: mm, compaction: make fast_isolate_freepages() stay within zone
Compaction always operates on pages from a single given zone when
isolating both pages to migrate and freepages.  Pageblock boundaries are
intersected with zone boundaries to be safe in case zone starts or ends in
the middle of pageblock.  The use of pageblock_pfn_to_page() protects
against non-contiguous pageblocks.

The functions fast_isolate_freepages() and fast_isolate_around() don't
currently protect the fast freepage isolation thoroughly enough against
these corner cases, and can result in freepage isolation operate outside
of zone boundaries:

- in fast_isolate_freepages() if we get a pfn from the first pageblock
  of a zone that starts in the middle of that pageblock, 'highest' can be
  a pfn outside of the zone.  If we fail to isolate anything in this
  function, we may then call fast_isolate_around() on a pfn outside of the
  zone and there effectively do a set_pageblock_skip(page_to_pfn(highest))
  which may currently hit a VM_BUG_ON() in some configurations

- fast_isolate_around() checks only the zone end boundary and not
  beginning, nor that the pageblock is contiguous (with
  pageblock_pfn_to_page()) so it's possible that we end up calling
  isolate_freepages_block() on a range of pfn's from two different zones
  and end up e.g.  isolating freepages under the wrong zone's lock.

This patch should fix the above issues.

Link: https://lkml.kernel.org/r/20210217173300.6394-1-vbabka@suse.cz
Fixes: 5a811889de ("mm, compaction: use free lists to quickly locate a migration target")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Minchan Kim <minchan@google.com>
Bug: 180548389
Change-Id: I97c31374640255219de3b852097501e3d935c8ce
(cherry picked from https://lore.kernel.org/mm-commits/20210217191436.shTJB%25akpm@linux-foundation.org/)
2021-02-22 22:51:57 +00:00
Quentin Perret
d498075b65 ANDROID: sched: time: Export symbols needed for schedutil module
Export symbols needed to allow building a schedutil-based vendor module
with GKI.

This is a small price to pay to give vendors the flexibility they need,
and avoids littering cpufreq_schedutil.c with many vendor hooks.

Bug: 170511085
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I8ff8bdb32df5d47124236819efba881c1a2a538d
(cherry picked from commit 34cd6916744b8b2d2107d2d5f10cbacb181e4f6c)
(cherry picked from commit 7587bc9dcf)
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-02-22 11:58:23 -08:00
Charan Teja Reddy
0d61a651e4 ANDROID: vmscan: Support multiple kswapd threads per node
Page replacement is handled in the Linux Kernel in one of two ways:

1) Asynchronously via kswapd
2) Synchronously, via direct reclaim

At page allocation time the allocating task is immediately given a page
from the zone free list allowing it to go right back to work doing
whatever it was doing; Probably directly or indirectly executing business
logic.

Just prior to satisfying the allocation, free pages is checked to see if
it has reached the zone low watermark and if so, kswapd is awakened.
Kswapd will start scanning pages looking for inactive pages to evict to
make room for new page allocations. The work of kswapd allows tasks to
continue allocating memory from their respective zone free list without
incurring any delay.

When the demand for free pages exceeds the rate that kswapd tasks can
supply them, page allocation works differently. Once the allocating task
finds that the number of free pages is at or below the zone min watermark,
the task will no longer pull pages from the free list. Instead, the task
will run the same CPU-bound routines as kswapd to satisfy its own
allocation by scanning and evicting pages. This is called a direct reclaim.

The time spent performing a direct reclaim can be substantial, often
taking tens to hundreds of milliseconds for small order0 allocations to
half a second or more for order9 huge-page allocations. In fact, kswapd is
not actually required on a linux system. It exists for the sole purpose of
optimizing performance by preventing direct reclaims.

When memory shortfall is sufficient to trigger direct reclaims, they can
occur in any task that is running on the system. A single aggressive
memory allocating task can set the stage for collateral damage to occur in
small tasks that rarely allocate additional memory. Consider the impact of
injecting an additional 100ms of latency when nscd allocates memory to
facilitate caching of a DNS query.

The presence of direct reclaims 10 years ago was a fairly reliable
indicator that too much was being asked of a Linux system. Kswapd was
likely wasting time scanning pages that were ineligible for eviction.
Adding RAM or reducing the working set size would usually make the problem
go away. Since then hardware has evolved to bring a new struggle for
kswapd. Storage speeds have increased by orders of magnitude while CPU
clock speeds stayed the same or even slowed down in exchange for more
cores per package. This presents a throughput problem for a single
threaded kswapd that will get worse with each generation of new hardware.

Test Details

NOTE: The tests below were run with shadow entries disabled. See the
associated patch and cover letter for details

The tests below were designed with the assumption that a kswapd bottleneck
is best demonstrated using filesystem reads. This way, the inactive list
will be full of clean pages, simplifying the analysis and allowing kswapd
to achieve the highest possible steal rate. Maximum steal rates for kswapd
are likely to be the same or lower for any other mix of page types on the
system.

Tests were run on a 2U Oracle X7-2L with 52 Intel Xeon Skylake 2GHz cores,
756GB of RAM and 8 x 3.6 TB NVMe Solid State Disk drives. Each drive has
an XFS file system mounted separately as /d0 through /d7. SSD drives
require multiple concurrent streams to show their potential, so I created
eleven 250GB zero-filled files on each drive so that I could test with
parallel reads.

The test script runs in multiple stages. At each stage, the number of dd
tasks run concurrently is increased by 2. I did not include all of the
test output for brevity.

During each stage dd tasks are launched to read from each drive in a round
robin fashion until the specified number of tasks for the stage has been
reached. Then iostat, vmstat and top are started in the background with 10
second intervals. After five minutes, all of the dd tasks are killed and
the iostat, vmstat and top output is parsed in order to report the
following:

CPU consumption
- sy - aggregate kernel mode CPU consumption from vmstat output. The value
       doesn't tend to fluctuate much so I just grab the highest value.
       Each sample is averaged over 10 seconds
- dd_cpu - for all of the dd tasks averaged across the top samples since
           there is a lot of variation.

Throughput
- in Kbytes
- Command is iostat -x -d 10 -g total

This first test performs reads using O_DIRECT in order to show the maximum
throughput that can be obtained using these drives. It also demonstrates
how rapidly throughput scales as the number of dd tasks are increased.

The dd command for this test looks like this:

Command Used: dd iflag=direct if=/d${i}/$n of=/dev/null bs=4M

Test #1: Direct IO
dd sy dd_cpu throughput
6  0  2.33   14726026.40
10 1  2.95   19954974.80
16 1  2.63   24419689.30
22 1  2.63   25430303.20
28 1  2.91   26026513.20
34 1  2.53   26178618.00
40 1  2.18   26239229.20
46 1  1.91   26250550.40
52 1  1.69   26251845.60
58 1  1.54   26253205.60
64 1  1.43   26253780.80
70 1  1.31   26254154.80
76 1  1.21   26253660.80
82 1  1.12   26254214.80
88 1  1.07   26253770.00
90 1  1.04   26252406.40

Throughput was close to peak with only 22 dd tasks. Very little system CPU
was consumed as expected as the drives DMA directly into the user address
space when using direct IO.

In this next test, the iflag=direct option is removed and we only run the
test until the pgscan_kswapd from /proc/vmstat starts to increment. At
that point metrics are parsed and reported and the pagecache contents are
dropped prior to the next test. Lather, rinse, repeat.

Test #2: standard file system IO, no page replacement
dd sy dd_cpu throughput
6  2  28.78  5134316.40
10 3  31.40  8051218.40
16 5  34.73  11438106.80
22 7  33.65  14140596.40
28 8  31.24  16393455.20
34 10 29.88  18219463.60
40 11 28.33  19644159.60
46 11 25.05  20802497.60
52 13 26.92  22092370.00
58 13 23.29  22884881.20
64 14 23.12  23452248.80
70 15 22.40  23916468.00
76 16 22.06  24328737.20
82 17 20.97  24718693.20
88 16 18.57  25149404.40
90 16 18.31  25245565.60

Each read has to pause after the buffer in kernel space is populated while
those pages are added to the pagecache and copied into the user address
space. For this reason, more parallel streams are required to achieve peak
throughput. The copy operation consumes substantially more CPU than direct
IO as expected.

The next test measures throughput after kswapd starts running. This is the
same test only we wait for kswapd to wake up before we start collecting
metrics. The script actually keeps track of a few things that were not
mentioned earlier. It tracks direct reclaims and page scans by watching
the metrics in /proc/vmstat. CPU consumption for kswapd is tracked the
same way it is tracked for dd.

Since the test is 100% reads, you can assume that the page steal rate for
kswapd and direct reclaims is almost identical to the scan rate.

Test #3: 1 kswapd thread per node
dd sy dd_cpu kswapd0 kswapd1 throughput  dr    pgscan_kswapd pgscan_direct
10 4  26.07  28.56   27.03   7355924.40  0     459316976     0
16 7  34.94  69.33   69.66   10867895.20 0     872661643     0
22 10 36.03  93.99   99.33   13130613.60 489   1037654473    11268334
28 10 30.34  95.90   98.60   14601509.60 671   1182591373    15429142
34 14 34.77  97.50   99.23   16468012.00 10850 1069005644    249839515
40 17 36.32  91.49   97.11   17335987.60 18903 975417728     434467710
46 19 38.40  90.54   91.61   17705394.40 25369 855737040     582427973
52 22 40.88  83.97   83.70   17607680.40 31250 709532935     724282458
58 25 40.89  82.19   80.14   17976905.60 35060 657796473     804117540
64 28 41.77  73.49   75.20   18001910.00 39073 561813658     895289337
70 33 45.51  63.78   64.39   17061897.20 44523 379465571     1020726436
76 36 46.95  57.96   60.32   16964459.60 47717 291299464     1093172384
82 39 47.16  55.43   56.16   16949956.00 49479 247071062     1134163008
88 42 47.41  53.75   47.62   16930911.20 51521 195449924     1180442208
90 43 47.18  51.40   50.59   16864428.00 51618 190758156     1183203901

In the previous test where kswapd was not involved, the system-wide kernel
mode CPU consumption with 90 dd tasks was 16%. In this test CPU consumption
with 90 tasks is at 43%. With 52 cores, and two kswapd tasks (one per NUMA
node), kswapd can only be responsible for a little over 4% of the increase.
The rest is likely caused by 51,618 direct reclaims that scanned 1.2
billion pages over the five minute time period of the test.

Same test, more kswapd tasks:

Test #4: 4 kswapd threads per node
dd sy dd_cpu kswapd0 kswapd1 throughput  dr    pgscan_kswapd pgscan_direct
10 5  27.09  16.65   14.17   7842605.60  0     459105291     0
16 10 37.12  26.02   24.85   11352920.40 15    920527796     358515
22 11 36.94  37.13   35.82   13771869.60 0     1132169011     0
28 13 35.23  48.43   46.86   16089746.00 0     1312902070     0
34 15 33.37  53.02   55.69   18314856.40 0     1476169080     0
40 19 35.90  69.60   64.41   19836126.80 0     1629999149     0
46 22 36.82  88.55   57.20   20740216.40 0     1708478106     0
52 24 34.38  93.76   68.34   21758352.00 0     1794055559     0
58 24 30.51  79.20   82.33   22735594.00 0     1872794397     0
64 26 30.21  97.12   76.73   23302203.60 176   1916593721     4206821
70 33 32.92  92.91   92.87   23776588.00 3575  1817685086     85574159
76 37 31.62  91.20   89.83   24308196.80 4752  1812262569     113981763
82 29 25.53  93.23   92.33   24802791.20 306   2032093122     7350704
88 43 37.12  76.18   77.01   25145694.40 20310 1253204719     487048202
90 42 38.56  73.90   74.57   22516787.60 22774 1193637495     545463615

By increasing the number of kswapd threads, throughput increased by ~50%
while kernel mode CPU utilization decreased or stayed the same, likely due
to a decrease in the number of parallel tasks at any given time doing page
replacement.

Signed-off-by: Buddy Lumpkin <buddy.lumpkin@oracle.com>
Bug: 171351667
Link: https://lore.kernel.org/lkml/1522661062-39745-1-git-send-email-buddy.lumpkin@oracle.com
[charante@codeaurora.org]: Changes made to select number of kswapds through uapi
Change-Id: I8425cab7f40cbeaf65af0ea118c1a9ac7da0930e
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2021-02-22 19:47:44 +00:00
Vijayanand Jitta
ee8d2c7884 ANDROID: mm: add get_each_object_track function
Add and export get_each_object_track which helps in
looping through all the slab objects of a page
and gets the track structure of each object, also
make track_item and track structure public, these
will be used by the minidump module to get slab
owner info.

Bug: 177377077
Change-Id: Ic207fd26a122a5f1b014f4929760d064f7af0225
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
2021-02-22 19:26:26 +00:00
Chiawei Wang
db158b4ae0 ANDROID: mm: Add vendor hook in pagecache_get_page()
Add a vendor hook for pagecache hit/miss and other
vendor specific functions.

Bug: 174088128
Bug: 172987241
Signed-off-by: Chiawei Wang <chiaweiwang@google.com>
Change-Id: Ie9f14a69a86b8ed81de766e44e30f2eba1d9bd84
2021-02-19 17:59:52 +00:00
Chiawei Wang
369de37804 ANDROID: mm: Add vendor hook in rmqueue()
Add a vendor hook for costly order page counting
and other vendor specific functions.

Bug: 174521902
Bug: 172987241
Signed-off-by: Chiawei Wang <chiaweiwang@google.com>
Change-Id: I89206727a462548cc3500b695d85c83ff003eec7
2021-02-19 17:59:30 +00:00
Alistair Delva
ea15862d66 ANDROID: GKI: Build in VIRTIO_FS
This allows us to keep filesystem symbols non-exported, without bringing
much into GKI.

Bug: 180710829
Change-Id: If3a4a87448be94826390fa23b0e241e2239d9550
Signed-off-by: Alistair Delva <adelva@google.com>
2021-02-19 15:34:47 +00:00