├── .clang-format ├── .gitignore ├── Kbuild ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── dkms.conf.in ├── fsstat.c ├── fsstat.h ├── la_ow_syscall_main.c ├── signal.c └── signal.h /.clang-format: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | # 3 | # clang-format configuration file. Intended for clang-format >= 11. 4 | # 5 | # For more information, see: 6 | # 7 | # Documentation/process/clang-format.rst 8 | # https://clang.llvm.org/docs/ClangFormat.html 9 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 10 | # 11 | --- 12 | AccessModifierOffset: -4 13 | AlignAfterOpenBracket: Align 14 | AlignConsecutiveAssignments: false 15 | AlignConsecutiveDeclarations: false 16 | AlignEscapedNewlines: Left 17 | AlignOperands: true 18 | AlignTrailingComments: false 19 | AllowAllParametersOfDeclarationOnNextLine: false 20 | AllowShortBlocksOnASingleLine: false 21 | AllowShortCaseLabelsOnASingleLine: false 22 | AllowShortFunctionsOnASingleLine: None 23 | AllowShortIfStatementsOnASingleLine: false 24 | AllowShortLoopsOnASingleLine: false 25 | AlwaysBreakAfterDefinitionReturnType: None 26 | AlwaysBreakAfterReturnType: None 27 | AlwaysBreakBeforeMultilineStrings: false 28 | AlwaysBreakTemplateDeclarations: false 29 | BinPackArguments: true 30 | BinPackParameters: true 31 | BraceWrapping: 32 | AfterClass: false 33 | AfterControlStatement: false 34 | AfterEnum: false 35 | AfterFunction: true 36 | AfterNamespace: true 37 | AfterObjCDeclaration: false 38 | AfterStruct: false 39 | AfterUnion: false 40 | AfterExternBlock: false 41 | BeforeCatch: false 42 | BeforeElse: false 43 | IndentBraces: false 44 | SplitEmptyFunction: true 45 | SplitEmptyRecord: true 46 | SplitEmptyNamespace: true 47 | BreakBeforeBinaryOperators: None 48 | BreakBeforeBraces: Custom 49 | BreakBeforeInheritanceComma: false 50 | BreakBeforeTernaryOperators: false 51 | BreakConstructorInitializersBeforeComma: false 52 | BreakConstructorInitializers: BeforeComma 53 | BreakAfterJavaFieldAnnotations: false 54 | BreakStringLiterals: false 55 | ColumnLimit: 80 56 | CommentPragmas: '^ IWYU pragma:' 57 | CompactNamespaces: false 58 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 59 | ConstructorInitializerIndentWidth: 8 60 | ContinuationIndentWidth: 8 61 | Cpp11BracedListStyle: false 62 | DerivePointerAlignment: false 63 | DisableFormat: false 64 | ExperimentalAutoDetectBinPacking: false 65 | FixNamespaceComments: false 66 | 67 | # Taken from: 68 | # git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \ 69 | # | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ 70 | # | LC_ALL=C sort -u 71 | ForEachMacros: 72 | - '__ata_qc_for_each' 73 | - '__bio_for_each_bvec' 74 | - '__bio_for_each_segment' 75 | - '__evlist__for_each_entry' 76 | - '__evlist__for_each_entry_continue' 77 | - '__evlist__for_each_entry_from' 78 | - '__evlist__for_each_entry_reverse' 79 | - '__evlist__for_each_entry_safe' 80 | - '__for_each_mem_range' 81 | - '__for_each_mem_range_rev' 82 | - '__for_each_thread' 83 | - '__hlist_for_each_rcu' 84 | - '__map__for_each_symbol_by_name' 85 | - '__perf_evlist__for_each_entry' 86 | - '__perf_evlist__for_each_entry_reverse' 87 | - '__perf_evlist__for_each_entry_safe' 88 | - '__rq_for_each_bio' 89 | - '__shost_for_each_device' 90 | - 'apei_estatus_for_each_section' 91 | - 'ata_for_each_dev' 92 | - 'ata_for_each_link' 93 | - 'ata_qc_for_each' 94 | - 'ata_qc_for_each_raw' 95 | - 'ata_qc_for_each_with_internal' 96 | - 'ax25_for_each' 97 | - 'ax25_uid_for_each' 98 | - 'bio_for_each_bvec' 99 | - 'bio_for_each_bvec_all' 100 | - 'bio_for_each_folio_all' 101 | - 'bio_for_each_integrity_vec' 102 | - 'bio_for_each_segment' 103 | - 'bio_for_each_segment_all' 104 | - 'bio_list_for_each' 105 | - 'bip_for_each_vec' 106 | - 'bond_for_each_slave' 107 | - 'bond_for_each_slave_rcu' 108 | - 'bpf__perf_for_each_map' 109 | - 'bpf__perf_for_each_map_named' 110 | - 'bpf_for_each_spilled_reg' 111 | - 'bpf_object__for_each_map' 112 | - 'bpf_object__for_each_program' 113 | - 'bpf_object__for_each_safe' 114 | - 'bpf_perf_object__for_each' 115 | - 'btree_for_each_safe128' 116 | - 'btree_for_each_safe32' 117 | - 'btree_for_each_safe64' 118 | - 'btree_for_each_safel' 119 | - 'card_for_each_dev' 120 | - 'cgroup_taskset_for_each' 121 | - 'cgroup_taskset_for_each_leader' 122 | - 'cpufreq_for_each_efficient_entry_idx' 123 | - 'cpufreq_for_each_entry' 124 | - 'cpufreq_for_each_entry_idx' 125 | - 'cpufreq_for_each_valid_entry' 126 | - 'cpufreq_for_each_valid_entry_idx' 127 | - 'css_for_each_child' 128 | - 'css_for_each_descendant_post' 129 | - 'css_for_each_descendant_pre' 130 | - 'damon_for_each_region' 131 | - 'damon_for_each_region_safe' 132 | - 'damon_for_each_scheme' 133 | - 'damon_for_each_scheme_safe' 134 | - 'damon_for_each_target' 135 | - 'damon_for_each_target_safe' 136 | - 'data__for_each_file' 137 | - 'data__for_each_file_new' 138 | - 'data__for_each_file_start' 139 | - 'device_for_each_child_node' 140 | - 'displayid_iter_for_each' 141 | - 'dma_fence_array_for_each' 142 | - 'dma_fence_chain_for_each' 143 | - 'dma_fence_unwrap_for_each' 144 | - 'dma_resv_for_each_fence' 145 | - 'dma_resv_for_each_fence_unlocked' 146 | - 'do_for_each_ftrace_op' 147 | - 'drm_atomic_crtc_for_each_plane' 148 | - 'drm_atomic_crtc_state_for_each_plane' 149 | - 'drm_atomic_crtc_state_for_each_plane_state' 150 | - 'drm_atomic_for_each_plane_damage' 151 | - 'drm_client_for_each_connector_iter' 152 | - 'drm_client_for_each_modeset' 153 | - 'drm_connector_for_each_possible_encoder' 154 | - 'drm_for_each_bridge_in_chain' 155 | - 'drm_for_each_connector_iter' 156 | - 'drm_for_each_crtc' 157 | - 'drm_for_each_crtc_reverse' 158 | - 'drm_for_each_encoder' 159 | - 'drm_for_each_encoder_mask' 160 | - 'drm_for_each_fb' 161 | - 'drm_for_each_legacy_plane' 162 | - 'drm_for_each_plane' 163 | - 'drm_for_each_plane_mask' 164 | - 'drm_for_each_privobj' 165 | - 'drm_mm_for_each_hole' 166 | - 'drm_mm_for_each_node' 167 | - 'drm_mm_for_each_node_in_range' 168 | - 'drm_mm_for_each_node_safe' 169 | - 'dsa_switch_for_each_available_port' 170 | - 'dsa_switch_for_each_cpu_port' 171 | - 'dsa_switch_for_each_port' 172 | - 'dsa_switch_for_each_port_continue_reverse' 173 | - 'dsa_switch_for_each_port_safe' 174 | - 'dsa_switch_for_each_user_port' 175 | - 'dsa_tree_for_each_user_port' 176 | - 'dso__for_each_symbol' 177 | - 'dsos__for_each_with_build_id' 178 | - 'elf_hash_for_each_possible' 179 | - 'elf_section__for_each_rel' 180 | - 'elf_section__for_each_rela' 181 | - 'elf_symtab__for_each_symbol' 182 | - 'evlist__for_each_cpu' 183 | - 'evlist__for_each_entry' 184 | - 'evlist__for_each_entry_continue' 185 | - 'evlist__for_each_entry_from' 186 | - 'evlist__for_each_entry_reverse' 187 | - 'evlist__for_each_entry_safe' 188 | - 'flow_action_for_each' 189 | - 'for_each_acpi_dev_match' 190 | - 'for_each_active_dev_scope' 191 | - 'for_each_active_drhd_unit' 192 | - 'for_each_active_iommu' 193 | - 'for_each_active_route' 194 | - 'for_each_aggr_pgid' 195 | - 'for_each_available_child_of_node' 196 | - 'for_each_bench' 197 | - 'for_each_bio' 198 | - 'for_each_board_func_rsrc' 199 | - 'for_each_btf_ext_rec' 200 | - 'for_each_btf_ext_sec' 201 | - 'for_each_bvec' 202 | - 'for_each_card_auxs' 203 | - 'for_each_card_auxs_safe' 204 | - 'for_each_card_components' 205 | - 'for_each_card_dapms' 206 | - 'for_each_card_pre_auxs' 207 | - 'for_each_card_prelinks' 208 | - 'for_each_card_rtds' 209 | - 'for_each_card_rtds_safe' 210 | - 'for_each_card_widgets' 211 | - 'for_each_card_widgets_safe' 212 | - 'for_each_cgroup_storage_type' 213 | - 'for_each_child_of_node' 214 | - 'for_each_clear_bit' 215 | - 'for_each_clear_bit_from' 216 | - 'for_each_clear_bitrange' 217 | - 'for_each_clear_bitrange_from' 218 | - 'for_each_cmd' 219 | - 'for_each_cmsghdr' 220 | - 'for_each_collection' 221 | - 'for_each_comp_order' 222 | - 'for_each_compatible_node' 223 | - 'for_each_component_dais' 224 | - 'for_each_component_dais_safe' 225 | - 'for_each_console' 226 | - 'for_each_console_srcu' 227 | - 'for_each_cpu' 228 | - 'for_each_cpu_and' 229 | - 'for_each_cpu_wrap' 230 | - 'for_each_dapm_widgets' 231 | - 'for_each_dedup_cand' 232 | - 'for_each_dev_addr' 233 | - 'for_each_dev_scope' 234 | - 'for_each_dma_cap_mask' 235 | - 'for_each_dpcm_be' 236 | - 'for_each_dpcm_be_rollback' 237 | - 'for_each_dpcm_be_safe' 238 | - 'for_each_dpcm_fe' 239 | - 'for_each_drhd_unit' 240 | - 'for_each_dss_dev' 241 | - 'for_each_efi_memory_desc' 242 | - 'for_each_efi_memory_desc_in_map' 243 | - 'for_each_element' 244 | - 'for_each_element_extid' 245 | - 'for_each_element_id' 246 | - 'for_each_endpoint_of_node' 247 | - 'for_each_event' 248 | - 'for_each_event_tps' 249 | - 'for_each_evictable_lru' 250 | - 'for_each_fib6_node_rt_rcu' 251 | - 'for_each_fib6_walker_rt' 252 | - 'for_each_free_mem_pfn_range_in_zone' 253 | - 'for_each_free_mem_pfn_range_in_zone_from' 254 | - 'for_each_free_mem_range' 255 | - 'for_each_free_mem_range_reverse' 256 | - 'for_each_func_rsrc' 257 | - 'for_each_group_device' 258 | - 'for_each_group_evsel' 259 | - 'for_each_group_member' 260 | - 'for_each_hstate' 261 | - 'for_each_if' 262 | - 'for_each_inject_fn' 263 | - 'for_each_insn' 264 | - 'for_each_insn_prefix' 265 | - 'for_each_intid' 266 | - 'for_each_iommu' 267 | - 'for_each_ip_tunnel_rcu' 268 | - 'for_each_irq_nr' 269 | - 'for_each_lang' 270 | - 'for_each_link_codecs' 271 | - 'for_each_link_cpus' 272 | - 'for_each_link_platforms' 273 | - 'for_each_lru' 274 | - 'for_each_matching_node' 275 | - 'for_each_matching_node_and_match' 276 | - 'for_each_mem_pfn_range' 277 | - 'for_each_mem_range' 278 | - 'for_each_mem_range_rev' 279 | - 'for_each_mem_region' 280 | - 'for_each_member' 281 | - 'for_each_memory' 282 | - 'for_each_migratetype_order' 283 | - 'for_each_missing_reg' 284 | - 'for_each_net' 285 | - 'for_each_net_continue_reverse' 286 | - 'for_each_net_rcu' 287 | - 'for_each_netdev' 288 | - 'for_each_netdev_continue' 289 | - 'for_each_netdev_continue_rcu' 290 | - 'for_each_netdev_continue_reverse' 291 | - 'for_each_netdev_feature' 292 | - 'for_each_netdev_in_bond_rcu' 293 | - 'for_each_netdev_rcu' 294 | - 'for_each_netdev_reverse' 295 | - 'for_each_netdev_safe' 296 | - 'for_each_new_connector_in_state' 297 | - 'for_each_new_crtc_in_state' 298 | - 'for_each_new_mst_mgr_in_state' 299 | - 'for_each_new_plane_in_state' 300 | - 'for_each_new_plane_in_state_reverse' 301 | - 'for_each_new_private_obj_in_state' 302 | - 'for_each_new_reg' 303 | - 'for_each_node' 304 | - 'for_each_node_by_name' 305 | - 'for_each_node_by_type' 306 | - 'for_each_node_mask' 307 | - 'for_each_node_state' 308 | - 'for_each_node_with_cpus' 309 | - 'for_each_node_with_property' 310 | - 'for_each_nonreserved_multicast_dest_pgid' 311 | - 'for_each_of_allnodes' 312 | - 'for_each_of_allnodes_from' 313 | - 'for_each_of_cpu_node' 314 | - 'for_each_of_pci_range' 315 | - 'for_each_old_connector_in_state' 316 | - 'for_each_old_crtc_in_state' 317 | - 'for_each_old_mst_mgr_in_state' 318 | - 'for_each_old_plane_in_state' 319 | - 'for_each_old_private_obj_in_state' 320 | - 'for_each_oldnew_connector_in_state' 321 | - 'for_each_oldnew_crtc_in_state' 322 | - 'for_each_oldnew_mst_mgr_in_state' 323 | - 'for_each_oldnew_plane_in_state' 324 | - 'for_each_oldnew_plane_in_state_reverse' 325 | - 'for_each_oldnew_private_obj_in_state' 326 | - 'for_each_online_cpu' 327 | - 'for_each_online_node' 328 | - 'for_each_online_pgdat' 329 | - 'for_each_path' 330 | - 'for_each_pci_bridge' 331 | - 'for_each_pci_dev' 332 | - 'for_each_pcm_streams' 333 | - 'for_each_physmem_range' 334 | - 'for_each_populated_zone' 335 | - 'for_each_possible_cpu' 336 | - 'for_each_present_cpu' 337 | - 'for_each_prime_number' 338 | - 'for_each_prime_number_from' 339 | - 'for_each_probe_cache_entry' 340 | - 'for_each_process' 341 | - 'for_each_process_thread' 342 | - 'for_each_prop_codec_conf' 343 | - 'for_each_prop_dai_codec' 344 | - 'for_each_prop_dai_cpu' 345 | - 'for_each_prop_dlc_codecs' 346 | - 'for_each_prop_dlc_cpus' 347 | - 'for_each_prop_dlc_platforms' 348 | - 'for_each_property_of_node' 349 | - 'for_each_reg' 350 | - 'for_each_reg_filtered' 351 | - 'for_each_registered_fb' 352 | - 'for_each_requested_gpio' 353 | - 'for_each_requested_gpio_in_range' 354 | - 'for_each_reserved_mem_range' 355 | - 'for_each_reserved_mem_region' 356 | - 'for_each_rtd_codec_dais' 357 | - 'for_each_rtd_components' 358 | - 'for_each_rtd_cpu_dais' 359 | - 'for_each_rtd_dais' 360 | - 'for_each_script' 361 | - 'for_each_sec' 362 | - 'for_each_set_bit' 363 | - 'for_each_set_bit_from' 364 | - 'for_each_set_bitrange' 365 | - 'for_each_set_bitrange_from' 366 | - 'for_each_set_clump8' 367 | - 'for_each_sg' 368 | - 'for_each_sg_dma_page' 369 | - 'for_each_sg_page' 370 | - 'for_each_sgtable_dma_page' 371 | - 'for_each_sgtable_dma_sg' 372 | - 'for_each_sgtable_page' 373 | - 'for_each_sgtable_sg' 374 | - 'for_each_shell_test' 375 | - 'for_each_sibling_event' 376 | - 'for_each_subelement' 377 | - 'for_each_subelement_extid' 378 | - 'for_each_subelement_id' 379 | - 'for_each_sublist' 380 | - 'for_each_subsystem' 381 | - 'for_each_supported_activate_fn' 382 | - 'for_each_supported_inject_fn' 383 | - 'for_each_test' 384 | - 'for_each_thread' 385 | - 'for_each_token' 386 | - 'for_each_unicast_dest_pgid' 387 | - 'for_each_vsi' 388 | - 'for_each_wakeup_source' 389 | - 'for_each_zone' 390 | - 'for_each_zone_zonelist' 391 | - 'for_each_zone_zonelist_nodemask' 392 | - 'func_for_each_insn' 393 | - 'fwnode_for_each_available_child_node' 394 | - 'fwnode_for_each_child_node' 395 | - 'fwnode_graph_for_each_endpoint' 396 | - 'gadget_for_each_ep' 397 | - 'genradix_for_each' 398 | - 'genradix_for_each_from' 399 | - 'hash_for_each' 400 | - 'hash_for_each_possible' 401 | - 'hash_for_each_possible_rcu' 402 | - 'hash_for_each_possible_rcu_notrace' 403 | - 'hash_for_each_possible_safe' 404 | - 'hash_for_each_rcu' 405 | - 'hash_for_each_safe' 406 | - 'hashmap__for_each_entry' 407 | - 'hashmap__for_each_entry_safe' 408 | - 'hashmap__for_each_key_entry' 409 | - 'hashmap__for_each_key_entry_safe' 410 | - 'hctx_for_each_ctx' 411 | - 'hists__for_each_format' 412 | - 'hists__for_each_sort_list' 413 | - 'hlist_bl_for_each_entry' 414 | - 'hlist_bl_for_each_entry_rcu' 415 | - 'hlist_bl_for_each_entry_safe' 416 | - 'hlist_for_each' 417 | - 'hlist_for_each_entry' 418 | - 'hlist_for_each_entry_continue' 419 | - 'hlist_for_each_entry_continue_rcu' 420 | - 'hlist_for_each_entry_continue_rcu_bh' 421 | - 'hlist_for_each_entry_from' 422 | - 'hlist_for_each_entry_from_rcu' 423 | - 'hlist_for_each_entry_rcu' 424 | - 'hlist_for_each_entry_rcu_bh' 425 | - 'hlist_for_each_entry_rcu_notrace' 426 | - 'hlist_for_each_entry_safe' 427 | - 'hlist_for_each_entry_srcu' 428 | - 'hlist_for_each_safe' 429 | - 'hlist_nulls_for_each_entry' 430 | - 'hlist_nulls_for_each_entry_from' 431 | - 'hlist_nulls_for_each_entry_rcu' 432 | - 'hlist_nulls_for_each_entry_safe' 433 | - 'i3c_bus_for_each_i2cdev' 434 | - 'i3c_bus_for_each_i3cdev' 435 | - 'idr_for_each_entry' 436 | - 'idr_for_each_entry_continue' 437 | - 'idr_for_each_entry_continue_ul' 438 | - 'idr_for_each_entry_ul' 439 | - 'in_dev_for_each_ifa_rcu' 440 | - 'in_dev_for_each_ifa_rtnl' 441 | - 'inet_bind_bucket_for_each' 442 | - 'inet_lhash2_for_each_icsk' 443 | - 'inet_lhash2_for_each_icsk_continue' 444 | - 'inet_lhash2_for_each_icsk_rcu' 445 | - 'interval_tree_for_each_double_span' 446 | - 'interval_tree_for_each_span' 447 | - 'intlist__for_each_entry' 448 | - 'intlist__for_each_entry_safe' 449 | - 'iopt_for_each_contig_area' 450 | - 'kcore_copy__for_each_phdr' 451 | - 'key_for_each' 452 | - 'key_for_each_safe' 453 | - 'klp_for_each_func' 454 | - 'klp_for_each_func_safe' 455 | - 'klp_for_each_func_static' 456 | - 'klp_for_each_object' 457 | - 'klp_for_each_object_safe' 458 | - 'klp_for_each_object_static' 459 | - 'kunit_suite_for_each_test_case' 460 | - 'kvm_for_each_memslot' 461 | - 'kvm_for_each_memslot_in_gfn_range' 462 | - 'kvm_for_each_vcpu' 463 | - 'libbpf_nla_for_each_attr' 464 | - 'list_for_each' 465 | - 'list_for_each_codec' 466 | - 'list_for_each_codec_safe' 467 | - 'list_for_each_continue' 468 | - 'list_for_each_entry' 469 | - 'list_for_each_entry_continue' 470 | - 'list_for_each_entry_continue_rcu' 471 | - 'list_for_each_entry_continue_reverse' 472 | - 'list_for_each_entry_from' 473 | - 'list_for_each_entry_from_rcu' 474 | - 'list_for_each_entry_from_reverse' 475 | - 'list_for_each_entry_lockless' 476 | - 'list_for_each_entry_rcu' 477 | - 'list_for_each_entry_reverse' 478 | - 'list_for_each_entry_safe' 479 | - 'list_for_each_entry_safe_continue' 480 | - 'list_for_each_entry_safe_from' 481 | - 'list_for_each_entry_safe_reverse' 482 | - 'list_for_each_entry_srcu' 483 | - 'list_for_each_from' 484 | - 'list_for_each_prev' 485 | - 'list_for_each_prev_safe' 486 | - 'list_for_each_safe' 487 | - 'llist_for_each' 488 | - 'llist_for_each_entry' 489 | - 'llist_for_each_entry_safe' 490 | - 'llist_for_each_safe' 491 | - 'map__for_each_symbol' 492 | - 'map__for_each_symbol_by_name' 493 | - 'map_for_each_event' 494 | - 'map_for_each_metric' 495 | - 'maps__for_each_entry' 496 | - 'maps__for_each_entry_safe' 497 | - 'mci_for_each_dimm' 498 | - 'media_device_for_each_entity' 499 | - 'media_device_for_each_intf' 500 | - 'media_device_for_each_link' 501 | - 'media_device_for_each_pad' 502 | - 'msi_for_each_desc' 503 | - 'nanddev_io_for_each_page' 504 | - 'netdev_for_each_lower_dev' 505 | - 'netdev_for_each_lower_private' 506 | - 'netdev_for_each_lower_private_rcu' 507 | - 'netdev_for_each_mc_addr' 508 | - 'netdev_for_each_uc_addr' 509 | - 'netdev_for_each_upper_dev_rcu' 510 | - 'netdev_hw_addr_list_for_each' 511 | - 'nft_rule_for_each_expr' 512 | - 'nla_for_each_attr' 513 | - 'nla_for_each_nested' 514 | - 'nlmsg_for_each_attr' 515 | - 'nlmsg_for_each_msg' 516 | - 'nr_neigh_for_each' 517 | - 'nr_neigh_for_each_safe' 518 | - 'nr_node_for_each' 519 | - 'nr_node_for_each_safe' 520 | - 'of_for_each_phandle' 521 | - 'of_property_for_each_string' 522 | - 'of_property_for_each_u32' 523 | - 'pci_bus_for_each_resource' 524 | - 'pci_dev_for_each_resource' 525 | - 'pcl_for_each_chunk' 526 | - 'pcl_for_each_segment' 527 | - 'pcm_for_each_format' 528 | - 'perf_config_items__for_each_entry' 529 | - 'perf_config_sections__for_each_entry' 530 | - 'perf_config_set__for_each_entry' 531 | - 'perf_cpu_map__for_each_cpu' 532 | - 'perf_evlist__for_each_entry' 533 | - 'perf_evlist__for_each_entry_reverse' 534 | - 'perf_evlist__for_each_entry_safe' 535 | - 'perf_evlist__for_each_evsel' 536 | - 'perf_evlist__for_each_mmap' 537 | - 'perf_hpp_list__for_each_format' 538 | - 'perf_hpp_list__for_each_format_safe' 539 | - 'perf_hpp_list__for_each_sort_list' 540 | - 'perf_hpp_list__for_each_sort_list_safe' 541 | - 'perf_pmu__for_each_hybrid_pmu' 542 | - 'ping_portaddr_for_each_entry' 543 | - 'ping_portaddr_for_each_entry_rcu' 544 | - 'plist_for_each' 545 | - 'plist_for_each_continue' 546 | - 'plist_for_each_entry' 547 | - 'plist_for_each_entry_continue' 548 | - 'plist_for_each_entry_safe' 549 | - 'plist_for_each_safe' 550 | - 'pnp_for_each_card' 551 | - 'pnp_for_each_dev' 552 | - 'protocol_for_each_card' 553 | - 'protocol_for_each_dev' 554 | - 'queue_for_each_hw_ctx' 555 | - 'radix_tree_for_each_slot' 556 | - 'radix_tree_for_each_tagged' 557 | - 'rb_for_each' 558 | - 'rbtree_postorder_for_each_entry_safe' 559 | - 'rdma_for_each_block' 560 | - 'rdma_for_each_port' 561 | - 'rdma_umem_for_each_dma_block' 562 | - 'resort_rb__for_each_entry' 563 | - 'resource_list_for_each_entry' 564 | - 'resource_list_for_each_entry_safe' 565 | - 'rhl_for_each_entry_rcu' 566 | - 'rhl_for_each_rcu' 567 | - 'rht_for_each' 568 | - 'rht_for_each_entry' 569 | - 'rht_for_each_entry_from' 570 | - 'rht_for_each_entry_rcu' 571 | - 'rht_for_each_entry_rcu_from' 572 | - 'rht_for_each_entry_safe' 573 | - 'rht_for_each_from' 574 | - 'rht_for_each_rcu' 575 | - 'rht_for_each_rcu_from' 576 | - 'rq_for_each_bvec' 577 | - 'rq_for_each_segment' 578 | - 'rq_list_for_each' 579 | - 'rq_list_for_each_safe' 580 | - 'scsi_for_each_prot_sg' 581 | - 'scsi_for_each_sg' 582 | - 'sctp_for_each_hentry' 583 | - 'sctp_skb_for_each' 584 | - 'sec_for_each_insn' 585 | - 'sec_for_each_insn_continue' 586 | - 'sec_for_each_insn_from' 587 | - 'shdma_for_each_chan' 588 | - 'shost_for_each_device' 589 | - 'sk_for_each' 590 | - 'sk_for_each_bound' 591 | - 'sk_for_each_entry_offset_rcu' 592 | - 'sk_for_each_from' 593 | - 'sk_for_each_rcu' 594 | - 'sk_for_each_safe' 595 | - 'sk_nulls_for_each' 596 | - 'sk_nulls_for_each_from' 597 | - 'sk_nulls_for_each_rcu' 598 | - 'snd_array_for_each' 599 | - 'snd_pcm_group_for_each_entry' 600 | - 'snd_soc_dapm_widget_for_each_path' 601 | - 'snd_soc_dapm_widget_for_each_path_safe' 602 | - 'snd_soc_dapm_widget_for_each_sink_path' 603 | - 'snd_soc_dapm_widget_for_each_source_path' 604 | - 'strlist__for_each_entry' 605 | - 'strlist__for_each_entry_safe' 606 | - 'sym_for_each_insn' 607 | - 'sym_for_each_insn_continue_reverse' 608 | - 'symbols__for_each_entry' 609 | - 'tb_property_for_each' 610 | - 'tcf_act_for_each_action' 611 | - 'tcf_exts_for_each_action' 612 | - 'udp_portaddr_for_each_entry' 613 | - 'udp_portaddr_for_each_entry_rcu' 614 | - 'usb_hub_for_each_child' 615 | - 'v4l2_device_for_each_subdev' 616 | - 'v4l2_m2m_for_each_dst_buf' 617 | - 'v4l2_m2m_for_each_dst_buf_safe' 618 | - 'v4l2_m2m_for_each_src_buf' 619 | - 'v4l2_m2m_for_each_src_buf_safe' 620 | - 'virtio_device_for_each_vq' 621 | - 'while_for_each_ftrace_op' 622 | - 'xa_for_each' 623 | - 'xa_for_each_marked' 624 | - 'xa_for_each_range' 625 | - 'xa_for_each_start' 626 | - 'xas_for_each' 627 | - 'xas_for_each_conflict' 628 | - 'xas_for_each_marked' 629 | - 'xbc_array_for_each_value' 630 | - 'xbc_for_each_key_value' 631 | - 'xbc_node_for_each_array_value' 632 | - 'xbc_node_for_each_child' 633 | - 'xbc_node_for_each_key_value' 634 | - 'xbc_node_for_each_subkey' 635 | - 'zorro_for_each_dev' 636 | 637 | IncludeBlocks: Preserve 638 | IncludeCategories: 639 | - Regex: '.*' 640 | Priority: 1 641 | IncludeIsMainRegex: '(Test)?$' 642 | IndentCaseLabels: false 643 | IndentGotoLabels: false 644 | IndentPPDirectives: None 645 | IndentWidth: 8 646 | IndentWrappedFunctionNames: false 647 | JavaScriptQuotes: Leave 648 | JavaScriptWrapImports: true 649 | KeepEmptyLinesAtTheStartOfBlocks: false 650 | MacroBlockBegin: '' 651 | MacroBlockEnd: '' 652 | MaxEmptyLinesToKeep: 1 653 | NamespaceIndentation: None 654 | ObjCBinPackProtocolList: Auto 655 | ObjCBlockIndentWidth: 8 656 | ObjCSpaceAfterProperty: true 657 | ObjCSpaceBeforeProtocolList: true 658 | 659 | # Taken from git's rules 660 | PenaltyBreakAssignment: 10 661 | PenaltyBreakBeforeFirstCallParameter: 30 662 | PenaltyBreakComment: 10 663 | PenaltyBreakFirstLessLess: 0 664 | PenaltyBreakString: 10 665 | PenaltyExcessCharacter: 100 666 | PenaltyReturnTypeOnItsOwnLine: 60 667 | 668 | PointerAlignment: Right 669 | ReflowComments: false 670 | SortIncludes: false 671 | SortUsingDeclarations: false 672 | SpaceAfterCStyleCast: false 673 | SpaceAfterTemplateKeyword: true 674 | SpaceBeforeAssignmentOperators: true 675 | SpaceBeforeCtorInitializerColon: true 676 | SpaceBeforeInheritanceColon: true 677 | SpaceBeforeParens: ControlStatementsExceptForEachMacros 678 | SpaceBeforeRangeBasedForLoopColon: true 679 | SpaceInEmptyParentheses: false 680 | SpacesBeforeTrailingComments: 1 681 | SpacesInAngles: false 682 | SpacesInContainerLiterals: false 683 | SpacesInCStyleCastParentheses: false 684 | SpacesInParentheses: false 685 | SpacesInSquareBrackets: false 686 | Standard: Cpp03 687 | TabWidth: 8 688 | UseTab: Always 689 | ... 690 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.ko 3 | *.mod.* 4 | *.cmd 5 | Module.symvers 6 | *.mod 7 | modules.order 8 | -------------------------------------------------------------------------------- /Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | # 3 | # Makefile for LoongArch old-world syscall compatible layer. 4 | # 5 | 6 | ifdef KBUILD_EXTMOD 7 | CONFIG_LOONGARCH_OW_SYSCALL := m 8 | endif 9 | 10 | obj-$(CONFIG_LOONGARCH_OW_SYSCALL) += la_ow_syscall.o 11 | la_ow_syscall-y += fsstat.o la_ow_syscall_main.o signal.o 12 | 13 | ifndef KBUILD_EXTMOD 14 | ifdef CONFIG_KALLSYMS 15 | ifndef CONFIG_RANDOMIZE_BASE 16 | $(obj)/ksym_addr.h: System.map 17 | @$(kecho) ' GEN $@' 18 | $(Q)grep ' sys_call_table$$' $< >/dev/null 19 | $(Q)grep ' kallsyms_lookup_name$$' $< >/dev/null 20 | $(Q)echo "#define LAOWSYS_SYS_CALL_TABLE_ADDR 0x$$(grep ' sys_call_table$$' $< | cut -d ' ' -f 1)" > $@ 21 | $(Q)echo "#define LAOWSYS_KALLSYMS_LOOKUP_NAME_ADDR 0x$$(grep ' kallsyms_lookup_name$$' $< | cut -d ' ' -f 1)" >> $@ 22 | ccflags-y += -DHAVE_KSYM_ADDR 23 | $(obj)/$(la_ow_syscall-y): $(obj)/ksym_addr.h 24 | endif 25 | endif 26 | endif 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | obj-m += la_ow_syscall.o fsstat.o la_ow_syscall_main.o signal.o 2 | 3 | KVER ?= $(shell uname -r) 4 | KDIR ?= /lib/modules/$(KVER)/build 5 | VERSION ?= $(shell cat VERSION) 6 | 7 | default: 8 | $(MAKE) -C $(KDIR) M=$(CURDIR) modules 9 | 10 | clean: 11 | $(MAKE) -C $(KDIR) M=$(CURDIR) clean 12 | 13 | install: 14 | $(MAKE) -C $(KDIR) M=$(CURDIR) modules_install 15 | 16 | dkms.conf: dkms.conf.in 17 | m4 -DVERSION=$(VERSION) $^ > $@ 18 | 19 | dkms-add: dkms.conf 20 | /usr/sbin/dkms add $(CURDIR) 21 | 22 | dkms-build: dkms.conf 23 | /usr/sbin/dkms build la_ow_syscall/$(VERSION) 24 | 25 | dkms-install: dkms.conf 26 | /usr/sbin/dkms install la_ow_syscall/$(VERSION) 27 | 28 | dkms-remove: dkms.conf 29 | /usr/sbin/dkms remove la_ow_syscall/$(VERSION) --all 30 | 31 | modprobe-install: 32 | modprobe la_ow_syscall 33 | 34 | modprobe-remove: 35 | modprobe -r la_ow_syscall 36 | 37 | dev: modprobe-remove dkms-remove dkms-add dkms-build dkms-install modprobe-install 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | la\_ow\_syscall 2 | ==== 3 | 4 | This kernel modules provides compatibility with LoongArch's old-world ABI, 5 | making it possible to run old-world applications (such as Kingsoft's WPS Office 6 | and Tencent QQ) transparently on new-world (ABI 2.0) kernels and userspaces. 7 | 8 | Requirements 9 | ---- 10 | 11 | Linux Kernel >= 6.1.0 for `loongarch64` with the following option(s) set: 12 | 13 | - `CONFIG_KALLSYMS=y` (for reading kernel symbol addresses). 14 | - `CONFIG_KPROBES=y` (for probing kernel symbol addresses using kernels where 15 | base address randomisation - `CONFIG_RANDOMIZE_BASE` - is enabled). 16 | 17 | Installation 18 | ---- 19 | 20 | You may install this kernel both as an in-tree module, an out-of-tree DKMS 21 | dynamic module, or a version-specific module. You may pick any option that best 22 | suits your needs. 23 | 24 | ### In-tree module 25 | 26 | Copy this source tree as `arch/loongarch/ow_syscall` in your kernel tree and 27 | append the following to `arch/loongarch/Kbuild`: 28 | 29 | ``` 30 | obj-y += ow_syscall/ 31 | ``` 32 | 33 | After building the kernel with `make`, run the following command to build the 34 | kernel module: 35 | 36 | ``` 37 | # $PWD is containing built objects 38 | # /path/to/source_dir is containing Linux source code 39 | make \ 40 | -C /path/to/source_dir \ 41 | ARCH=loongarch \ 42 | O="$PWD" \ 43 | arch/loongarch/ow_syscall/la_ow_syscall.ko \ 44 | CONFIG_LOONGARCH_OW_SYSCALL=m 45 | ``` 46 | 47 | Upon completion, copy the kernel module in place 48 | (`/lib/modules/.../arch/loongarch/ow_syscall/la_ow_syscall.ko`) and 49 | re-generate modules.dep and map files: 50 | 51 | ``` 52 | depmod 53 | ``` 54 | 55 | ### DKMS dynamic module 56 | 57 | Generate a `dkms.conf`: 58 | 59 | ``` 60 | make dkms.conf 61 | ``` 62 | 63 | For installation and version management, refer to dkms(8) for details. 64 | 65 | ### Version-specific module 66 | 67 | Build the kernel module: 68 | 69 | ``` 70 | make 71 | ``` 72 | 73 | Load the module with super user or root privilege: 74 | 75 | ``` 76 | insmod la_ow_syscall.ko 77 | ``` 78 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.1.0 -------------------------------------------------------------------------------- /dkms.conf.in: -------------------------------------------------------------------------------- 1 | PACKAGE_NAME="la_ow_syscall" 2 | PACKAGE_VERSION="VERSION" 3 | 4 | BUILD_EXCLUSIVE_KERNEL_MIN="5.19" 5 | BUILD_EXCLUSIVE_CONFIG="CONFIG_KALLSYMS" 6 | 7 | MAKE="KDIR=/lib/modules/${kernelver}/build make" 8 | CLEAN="make clean" 9 | BUILT_MODULE_NAME[0]="$PACKAGE_NAME" 10 | AUTOINSTALL="yes" 11 | DEST_MODULE_LOCATION[0]="/extra" 12 | -------------------------------------------------------------------------------- /fsstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "fsstat.h" 7 | 8 | #define INIT_STRUCT_STAT_PADDING(st) memset(&st, 0, sizeof(st)) 9 | 10 | struct __old_kernel_stat { 11 | unsigned short st_dev; 12 | unsigned short st_ino; 13 | unsigned short st_mode; 14 | unsigned short st_nlink; 15 | unsigned short st_uid; 16 | unsigned short st_gid; 17 | unsigned short st_rdev; 18 | unsigned int st_size; 19 | unsigned int st_atime; 20 | unsigned int st_mtime; 21 | unsigned int st_ctime; 22 | }; 23 | 24 | static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf) 25 | { 26 | struct stat tmp; 27 | 28 | if (sizeof(tmp.st_dev) < 4 && !old_valid_dev(stat->dev)) 29 | return -EOVERFLOW; 30 | if (sizeof(tmp.st_rdev) < 4 && !old_valid_dev(stat->rdev)) 31 | return -EOVERFLOW; 32 | #if BITS_PER_LONG == 32 33 | if (stat->size > MAX_NON_LFS) 34 | return -EOVERFLOW; 35 | #endif 36 | 37 | INIT_STRUCT_STAT_PADDING(tmp); 38 | tmp.st_dev = new_encode_dev(stat->dev); 39 | tmp.st_ino = stat->ino; 40 | if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) 41 | return -EOVERFLOW; 42 | tmp.st_mode = stat->mode; 43 | tmp.st_nlink = stat->nlink; 44 | if (tmp.st_nlink != stat->nlink) 45 | return -EOVERFLOW; 46 | SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid)); 47 | SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid)); 48 | tmp.st_rdev = new_encode_dev(stat->rdev); 49 | tmp.st_size = stat->size; 50 | tmp.st_atime = stat->atime.tv_sec; 51 | tmp.st_mtime = stat->mtime.tv_sec; 52 | tmp.st_ctime = stat->ctime.tv_sec; 53 | #ifdef STAT_HAVE_NSEC 54 | tmp.st_atime_nsec = stat->atime.tv_nsec; 55 | tmp.st_mtime_nsec = stat->mtime.tv_nsec; 56 | tmp.st_ctime_nsec = stat->ctime.tv_nsec; 57 | #endif 58 | tmp.st_blocks = stat->blocks; 59 | tmp.st_blksize = stat->blksize; 60 | return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; 61 | } 62 | 63 | __SYSCALL_DEFINEx(2, _newfstat, unsigned int, fd, struct stat __user *, statbuf) 64 | { 65 | struct kstat stat; 66 | int error = p_vfs_fstat(fd, &stat); 67 | 68 | if (!error) 69 | error = cp_new_stat(&stat, statbuf); 70 | 71 | return error; 72 | } 73 | 74 | __SYSCALL_DEFINEx(4, _newfstatat, int, dfd, const char __user *, filename, 75 | struct stat __user *, statbuf, int, flag) 76 | { 77 | struct kstat stat; 78 | int error; 79 | 80 | error = p_vfs_fstatat(dfd, filename, &stat, flag); 81 | if (error) 82 | return error; 83 | return cp_new_stat(&stat, statbuf); 84 | } 85 | -------------------------------------------------------------------------------- /fsstat.h: -------------------------------------------------------------------------------- 1 | extern int (*p_vfs_fstatat)(int dfd, const char __user *filename, 2 | struct kstat *stat, int flags); 3 | extern int (*p_vfs_fstat)(int fd, struct kstat *stat); 4 | -------------------------------------------------------------------------------- /la_ow_syscall_main.c: -------------------------------------------------------------------------------- 1 | #include /* Needed by all modules */ 2 | #include /* Needed for KERN_INFO */ 3 | #include /* Needed for the macros */ 4 | #include /* Needed for kprobe calls */ 5 | 6 | ///< The license type -- this affects runtime behavior 7 | MODULE_LICENSE("GPL"); 8 | 9 | ///< The author -- visible when you use modinfo 10 | MODULE_AUTHOR("Miao Wang"); 11 | 12 | ///< The description -- see modinfo 13 | MODULE_DESCRIPTION("LoongArch old-world syscall compatibility module"); 14 | 15 | ///< The version of the module 16 | MODULE_VERSION("0.1.0"); 17 | 18 | #include 19 | #include 20 | 21 | #define __EXTERN 22 | #include "fsstat.h" 23 | #include "signal.h" 24 | 25 | #define __ARCH_WANT_SET_GET_RLIMIT 26 | #define __ARCH_WANT_NEW_STAT 27 | #undef __SYSCALL 28 | #define __SYSCALL(nr, call) [nr] = (#call), 29 | 30 | const char *sys_call_table_name[__NR_syscalls] = { 31 | [0 ... __NR_syscalls - 1] = "sys_ni_syscall", 32 | #include 33 | }; 34 | 35 | #ifndef __loongarch64 36 | #error This Linux kernel module is only supported on LoongArch 37 | #endif 38 | 39 | #ifdef HAVE_KSYM_ADDR 40 | #include "ksym_addr.h" 41 | #endif 42 | 43 | static struct { 44 | long syscall_num; 45 | void *symbol_addr; 46 | void *orig; 47 | } syscall_to_replace[] = { 48 | { __NR_fstat, sys_newfstat }, 49 | { __NR_newfstatat, sys_newfstatat }, 50 | { __NR_getrlimit, NULL }, 51 | { __NR_setrlimit, NULL }, 52 | { __NR_rt_sigprocmask, sys_rt_sigprocmask }, 53 | { __NR_rt_sigpending, sys_rt_sigpending }, 54 | { __NR_rt_sigtimedwait, sys_rt_sigtimedwait }, 55 | { __NR_rt_sigaction, sys_rt_sigaction }, 56 | { __NR_rt_sigsuspend, sys_rt_sigsuspend }, 57 | { __NR_pselect6, sys_pselect6 }, 58 | { __NR_ppoll, sys_ppoll }, 59 | #ifdef CONFIG_SIGNALFD 60 | { __NR_signalfd4, sys_signalfd4 }, 61 | #endif 62 | #ifdef CONFIG_EPOLL 63 | { __NR_epoll_pwait, sys_epoll_pwait }, 64 | { __NR_epoll_pwait2, sys_epoll_pwait2 }, 65 | #endif 66 | }; 67 | 68 | #define nr_syscalls_to_replace \ 69 | (sizeof(syscall_to_replace) / sizeof(syscall_to_replace[0])) 70 | 71 | static unsigned long kallsyms_lookup_name_addr = 72 | #ifdef HAVE_KSYM_ADDR 73 | LAOWSYS_KALLSYMS_LOOKUP_NAME_ADDR 74 | #else 75 | 0 76 | #endif 77 | ; 78 | static unsigned int allow_mod_unreg = 0; 79 | 80 | #include 81 | 82 | #ifdef HAVE_KSYM_ADDR 83 | static int __init find_kallsyms_lookup_name(void){ return 0; } 84 | #else 85 | // Taken from https://github.com/zizzu0/LinuxKernelModules/blob/main/FindKallsymsLookupName.c 86 | #define KPROBE_PRE_HANDLER(fname) \ 87 | static int __kprobes fname(struct kprobe *p, struct pt_regs *regs) 88 | 89 | static struct kprobe kp0, kp1; 90 | 91 | KPROBE_PRE_HANDLER(handler_pre0) 92 | { 93 | kallsyms_lookup_name_addr = regs->csr_era; 94 | 95 | return 0; 96 | } 97 | 98 | KPROBE_PRE_HANDLER(handler_pre1) 99 | { 100 | return 0; 101 | } 102 | 103 | #undef KPROBE_PRE_HANDLER 104 | 105 | static int do_register_kprobe(struct kprobe *kp, char *symbol_name, 106 | void *handler) 107 | { 108 | int ret = 0; 109 | 110 | kp->symbol_name = symbol_name; 111 | kp->pre_handler = handler; 112 | 113 | ret = register_kprobe(kp); 114 | if (ret < 0) { 115 | pr_err("register_probe() for symbol %s failed, returned %d\n", 116 | symbol_name, ret); 117 | return ret; 118 | } 119 | 120 | pr_debug("planted kprobe for symbol %s at %p\n", symbol_name, kp->addr); 121 | 122 | return ret; 123 | } 124 | 125 | static int __init kprobe_kallsyms_lookup_name(void) 126 | { 127 | int ret = 0; 128 | 129 | ret = do_register_kprobe(&kp0, "kallsyms_lookup_name", handler_pre0); 130 | if (ret < 0) 131 | return ret; 132 | 133 | ret = do_register_kprobe(&kp1, "kallsyms_lookup_name", handler_pre1); 134 | if (ret < 0) { 135 | unregister_kprobe(&kp0); 136 | return ret; 137 | } 138 | 139 | unregister_kprobe(&kp0); 140 | unregister_kprobe(&kp1); 141 | 142 | return ret; 143 | } 144 | 145 | 146 | static int __init find_kallsyms_lookup_name(void) 147 | { 148 | char fn_name[KSYM_SYMBOL_LEN]; 149 | 150 | int ret = 0; 151 | 152 | if (kallsyms_lookup_name_addr == 0 || 153 | kallsyms_lookup_name_addr == (unsigned long)-1) { 154 | ret = kprobe_kallsyms_lookup_name(); 155 | if ( ret < 0 ) { 156 | return ret; 157 | } 158 | if (kallsyms_lookup_name_addr == 0 || 159 | kallsyms_lookup_name_addr == (unsigned long)-1) { 160 | return -EINVAL; 161 | } 162 | } 163 | sprint_symbol(fn_name, kallsyms_lookup_name_addr); 164 | if (strncmp(fn_name, "kallsyms_lookup_name+0x0", 165 | strlen("kallsyms_lookup_name+0x0")) == 0) { 166 | pr_debug("got kallsyms_lookup_name = %lx\n", 167 | kallsyms_lookup_name_addr); 168 | return 0; 169 | } else { 170 | pr_debug("got %s at %lx, not kallsyms_lookup_name\n", fn_name, 171 | kallsyms_lookup_name_addr); 172 | return -EINVAL; 173 | } 174 | } 175 | #endif 176 | 177 | 178 | int (*p_vfs_fstatat)(int dfd, const char __user *filename, struct kstat *stat, 179 | int flags); 180 | int (*p_vfs_fstat)(int fd, struct kstat *stat); 181 | 182 | void *p_sys_setxattr, *p_sys_close, *p_sys_clone; 183 | 184 | static struct { 185 | const char *func_name; 186 | void **stor; 187 | } relocation_table[] = { 188 | #define __rel(func) \ 189 | { \ 190 | (#func), ((void **)&(p_##func)) \ 191 | } 192 | __rel(vfs_fstatat), __rel(vfs_fstat), 193 | __rel(sys_setxattr), __rel(sys_close), 194 | __rel(sys_clone), __rel(sys_rt_sigprocmask), 195 | __rel(sys_rt_sigpending), __rel(sys_rt_sigtimedwait), 196 | __rel(sys_rt_sigaction), __rel(sys_rt_sigsuspend), 197 | __rel(sys_pselect6), __rel(sys_ppoll), 198 | #ifdef CONFIG_SIGNALFD 199 | __rel(sys_signalfd4), 200 | #endif 201 | #ifdef CONFIG_EPOLL 202 | __rel(sys_epoll_pwait), __rel(sys_epoll_pwait2), 203 | #endif 204 | }; 205 | #define nr_rel_tab (sizeof(relocation_table) / sizeof(relocation_table[0])) 206 | 207 | #ifdef HAVE_KSYM_ADDR 208 | static void **p_sys_call_table = (void **)LAOWSYS_SYS_CALL_TABLE_ADDR; 209 | static int __init find_sys_call_table(void){ return 0; }; 210 | #else 211 | 212 | static void **p_sys_call_table; 213 | 214 | #include 215 | #include 216 | static int __init find_sys_call_table(void) 217 | { 218 | unsigned long (*p_kallsyms_lookup_name)(const char *name) = 219 | (void *)kallsyms_lookup_name_addr; 220 | unsigned long *sys_table; 221 | 222 | if (kallsyms_lookup_name_addr == 0) { 223 | return -ENOSYS; 224 | } 225 | 226 | if ((sys_table = (unsigned long *)p_kallsyms_lookup_name( 227 | "sys_call_table"))) { 228 | p_sys_call_table = (void **)sys_table; 229 | pr_debug("found sys_call_table=%px\n", p_sys_call_table); 230 | return 0; 231 | } 232 | 233 | pr_info("failed to find sys_call_table using kallsyms_lookup_name()\n"); 234 | pr_info("trying to find sys_call_table using memory scanning\n"); 235 | 236 | for (sys_table = (void *)&jiffies; 237 | (void *)sys_table < (void *)&reboot_mode; sys_table++) { 238 | if (sys_table[__NR_setxattr] == (unsigned long)p_sys_setxattr && 239 | sys_table[__NR_close] == (unsigned long)p_sys_close && 240 | sys_table[__NR_clone] == (unsigned long)p_sys_clone) { 241 | p_sys_call_table = (void **)sys_table; 242 | pr_debug("found sys_call_table=%px\n", 243 | p_sys_call_table); 244 | return 0; 245 | } 246 | } 247 | 248 | return -ENOSYS; 249 | } 250 | #endif 251 | 252 | static int __init oldsyscall_start(void) 253 | { 254 | unsigned long (*p_kallsyms_lookup_name)(const char *name); 255 | int rc = find_kallsyms_lookup_name(); 256 | if (rc < 0) { 257 | return rc; 258 | } 259 | p_kallsyms_lookup_name = (void *)kallsyms_lookup_name_addr; 260 | 261 | for (int i = 0; i < nr_rel_tab; i++) { 262 | unsigned long p = 263 | p_kallsyms_lookup_name(relocation_table[i].func_name); 264 | if (p == 0) { 265 | pr_warn("cannot find symbol %s\n", 266 | relocation_table[i].func_name); 267 | return -EINVAL; 268 | } 269 | pr_debug("found symbol %s at %px\n", 270 | relocation_table[i].func_name, (void *)p); 271 | *relocation_table[i].stor = (void *)p; 272 | } 273 | rc = find_sys_call_table(); 274 | if (rc < 0) { 275 | return rc; 276 | } 277 | for (int i = 0; i < nr_syscalls_to_replace; i++) { 278 | if (syscall_to_replace[i].symbol_addr) { 279 | continue; 280 | } 281 | const char *symbol_name = 282 | sys_call_table_name[syscall_to_replace[i].syscall_num]; 283 | unsigned long symbol_addr = p_kallsyms_lookup_name(symbol_name); 284 | if (symbol_addr) { 285 | pr_debug("found %s at %px\n", symbol_name, 286 | (void *)symbol_addr); 287 | } else { 288 | pr_warn("cannot find symbol %s\n", symbol_name); 289 | return -EINVAL; 290 | } 291 | syscall_to_replace[i].symbol_addr = (void *)symbol_addr; 292 | } 293 | if (!allow_mod_unreg) { 294 | bool succ = try_module_get(THIS_MODULE); 295 | if (!succ) { 296 | return -EINVAL; 297 | } 298 | } 299 | for (int i = 0; i < nr_syscalls_to_replace; i++) { 300 | pr_debug("will replace syscall_%ld with %px, orig %px\n", 301 | syscall_to_replace[i].syscall_num, 302 | syscall_to_replace[i].symbol_addr, 303 | p_sys_call_table[syscall_to_replace[i].syscall_num]); 304 | syscall_to_replace[i].orig = 305 | p_sys_call_table[syscall_to_replace[i].syscall_num]; 306 | p_sys_call_table[syscall_to_replace[i].syscall_num] = 307 | syscall_to_replace[i].symbol_addr; 308 | } 309 | pr_info("la_ow_syscall module successfully initialized\n"); 310 | return 0; 311 | } 312 | 313 | static void __exit oldsyscall_end(void) 314 | { 315 | for (int i = 0; i < nr_syscalls_to_replace; i++) { 316 | pr_debug("will restore syscall_%ld to %px\n", 317 | syscall_to_replace[i].syscall_num, 318 | syscall_to_replace[i].orig); 319 | p_sys_call_table[syscall_to_replace[i].syscall_num] = 320 | syscall_to_replace[i].orig; 321 | } 322 | } 323 | 324 | module_init(oldsyscall_start); 325 | module_exit(oldsyscall_end); 326 | module_param(allow_mod_unreg, uint, 0000); 327 | MODULE_PARM_DESC(allow_mod_unreg, 328 | "Allow this module to be unload (Danger! Debug use only)"); 329 | #ifndef HAVE_KSYM_ADDR 330 | module_param(kallsyms_lookup_name_addr, ulong, 0000); 331 | MODULE_PARM_DESC(kallsyms_lookup_name_addr, "Address for kallsyms_lookup_name, provide this when unable to find using kprobe"); 332 | #endif 333 | -------------------------------------------------------------------------------- /signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "signal.h" 6 | 7 | #define _LA_OW_NSIG 128 8 | #define _LA_OW_NSIG_WORDS (_LA_OW_NSIG / _NSIG_BPW) 9 | 10 | typedef struct { 11 | unsigned long sig[_LA_OW_NSIG_WORDS]; 12 | } _la_ow_sigset_t; 13 | 14 | static inline int clear_user_sigset_extension(sigset_t __user *to) 15 | { 16 | char __user *expansion = (char __user *)to + sizeof(sigset_t); 17 | int rc = clear_user(expansion, 18 | sizeof(_la_ow_sigset_t) - sizeof(sigset_t)); 19 | if (rc < 0) { 20 | return -EFAULT; 21 | } 22 | return 0; 23 | } 24 | 25 | __SYSCALL_DEFINEx(4, _rt_sigprocmask, int, how, sigset_t __user *, nset, 26 | sigset_t __user *, oset, size_t, sigsetsize) 27 | { 28 | if (sigsetsize == sizeof(sigset_t)) { 29 | return p_sys_rt_sigprocmask(how, nset, oset, sigsetsize); 30 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 31 | int rc = 32 | p_sys_rt_sigprocmask(how, nset, oset, sizeof(sigset_t)); 33 | if (rc < 0) { 34 | return rc; 35 | } 36 | if (oset) { 37 | int rc2 = clear_user_sigset_extension(oset); 38 | if (rc2 < 0) { 39 | return rc2; 40 | } 41 | } 42 | return 0; 43 | } else { 44 | return -EINVAL; 45 | } 46 | } 47 | 48 | __SYSCALL_DEFINEx(2, _rt_sigpending, sigset_t __user *, uset, size_t, 49 | sigsetsize) 50 | { 51 | if (sigsetsize == sizeof(sigset_t)) { 52 | return p_sys_rt_sigpending(uset, sigsetsize); 53 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 54 | int rc = p_sys_rt_sigpending(uset, sizeof(sigset_t)); 55 | if (rc < 0) { 56 | return rc; 57 | } 58 | int rc2 = clear_user_sigset_extension(uset); 59 | if (rc2 < 0) { 60 | return rc2; 61 | } 62 | return 0; 63 | } else { 64 | return -EINVAL; 65 | } 66 | } 67 | 68 | __SYSCALL_DEFINEx(4, _rt_sigtimedwait, const sigset_t __user *, uthese, 69 | siginfo_t __user *, uinfo, 70 | const struct __kernel_timespec __user *, uts, size_t, 71 | sigsetsize) 72 | { 73 | if (sigsetsize == sizeof(sigset_t)) { 74 | return p_sys_rt_sigtimedwait(uthese, uinfo, uts, sigsetsize); 75 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 76 | int rc = p_sys_rt_sigtimedwait(uthese, uinfo, uts, 77 | sizeof(sigset_t)); 78 | if (rc < 0) { 79 | return rc; 80 | } 81 | return rc; 82 | } else { 83 | return -EINVAL; 84 | } 85 | } 86 | 87 | __SYSCALL_DEFINEx(4, _rt_sigaction, int, sig, const struct sigaction __user *, 88 | act, struct sigaction __user *, oact, size_t, sigsetsize) 89 | { 90 | if (sigsetsize == sizeof(sigset_t)) { 91 | return p_sys_rt_sigaction(sig, act, oact, sigsetsize); 92 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 93 | int rc = p_sys_rt_sigaction(sig, act, oact, sizeof(sigset_t)); 94 | if (rc < 0) { 95 | return rc; 96 | } 97 | if (oact) { 98 | int rc2 = clear_user_sigset_extension(&oact->sa_mask); 99 | if (rc2 < 0) { 100 | return rc2; 101 | } 102 | } 103 | return rc; 104 | } else { 105 | return -EINVAL; 106 | } 107 | } 108 | 109 | __SYSCALL_DEFINEx(2, _rt_sigsuspend, sigset_t __user *, unewset, size_t, 110 | sigsetsize) 111 | { 112 | if (sigsetsize == sizeof(sigset_t)) { 113 | return p_sys_rt_sigsuspend(unewset, sigsetsize); 114 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 115 | int rc = p_sys_rt_sigsuspend(unewset, sizeof(sigset_t)); 116 | if (rc < 0) { 117 | return rc; 118 | } 119 | return rc; 120 | } else { 121 | return -EINVAL; 122 | } 123 | } 124 | 125 | __SYSCALL_DEFINEx(6, _pselect6, int, n, fd_set __user *, inp, fd_set __user *, 126 | outp, fd_set __user *, exp, struct __kernel_timespec __user *, 127 | tsp, void __user *, sig) 128 | { 129 | struct sigset_argpack { 130 | sigset_t __user *p; 131 | size_t size; 132 | } x = { NULL, 0 }; 133 | struct sigset_argpack __user *siginfo = 134 | (struct sigset_argpack __user *)sig; 135 | 136 | if (siginfo) { 137 | int rc = get_user(x.size, &siginfo->size); 138 | if (rc < 0) { 139 | return -EFAULT; 140 | } 141 | } 142 | if (siginfo == NULL || x.size == sizeof(sigset_t)) { 143 | return p_sys_pselect6(n, inp, outp, exp, tsp, sig); 144 | } else if (x.size == sizeof(_la_ow_sigset_t)) { 145 | int rc = put_user(sizeof(sigset_t), &siginfo->size); 146 | if (rc < 0) { 147 | return -EFAULT; 148 | } 149 | rc = p_sys_pselect6(n, inp, outp, exp, tsp, sig); 150 | int rc2 = put_user(sizeof(_la_ow_sigset_t), &siginfo->size); 151 | if (rc2 < 0) { 152 | return -EFAULT; 153 | } 154 | return rc; 155 | } else { 156 | return -EINVAL; 157 | } 158 | } 159 | 160 | __SYSCALL_DEFINEx(5, _ppoll, struct pollfd __user *, ufds, unsigned int, nfds, 161 | struct __kernel_timespec __user *, tsp, const sigset_t __user *, sigmask, 162 | size_t, sigsetsize) 163 | { 164 | if (sigmask == NULL || sigsetsize == sizeof(sigset_t)) { 165 | return p_sys_ppoll(ufds, nfds, tsp, sigmask, sigsetsize); 166 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 167 | int rc = p_sys_ppoll(ufds, nfds, tsp, sigmask, sizeof(sigset_t)); 168 | if (rc < 0) { 169 | return rc; 170 | } 171 | return rc; 172 | } else { 173 | return -EINVAL; 174 | } 175 | } 176 | 177 | #ifdef CONFIG_EPOLL 178 | 179 | __SYSCALL_DEFINEx(6, _epoll_pwait, int, epfd, struct epoll_event __user *, 180 | events, int, maxevents, int, timeout, const sigset_t __user *, 181 | sigmask, size_t, sigsetsize) 182 | { 183 | if (sigmask == NULL || sigsetsize == sizeof(sigset_t)) { 184 | return p_sys_epoll_pwait(epfd, events, maxevents, timeout, 185 | sigmask, sigsetsize); 186 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 187 | int rc = p_sys_epoll_pwait(epfd, events, maxevents, timeout, 188 | sigmask, sizeof(sigset_t)); 189 | if (rc < 0) { 190 | return rc; 191 | } 192 | return rc; 193 | } else { 194 | return -EINVAL; 195 | } 196 | } 197 | 198 | __SYSCALL_DEFINEx(6, _epoll_pwait2, int, epfd, struct epoll_event __user *, 199 | events, int, maxevents, 200 | const struct __kernel_timespec __user *, timeout, 201 | const sigset_t __user *, sigmask, size_t, sigsetsize) 202 | { 203 | if (sigmask == NULL || sigsetsize == sizeof(sigset_t)) { 204 | return p_sys_epoll_pwait2(epfd, events, maxevents, timeout, 205 | sigmask, sigsetsize); 206 | } else if (sigsetsize == sizeof(_la_ow_sigset_t)) { 207 | int rc = p_sys_epoll_pwait2(epfd, events, maxevents, timeout, 208 | sigmask, sizeof(sigset_t)); 209 | if (rc < 0) { 210 | return rc; 211 | } 212 | return rc; 213 | } else { 214 | return -EINVAL; 215 | } 216 | } 217 | 218 | #endif 219 | 220 | #ifdef CONFIG_SIGNALFD 221 | 222 | __SYSCALL_DEFINEx(4, _signalfd4, int, ufd, sigset_t __user *, user_mask, size_t, 223 | sizemask, int, flags) 224 | { 225 | if (sizemask == sizeof(sigset_t)) { 226 | return p_sys_signalfd4(ufd, user_mask, sizemask, flags); 227 | } else if (sizemask == sizeof(_la_ow_sigset_t)) { 228 | int rc = p_sys_signalfd4(ufd, user_mask, sizeof(sigset_t), 229 | flags); 230 | if (rc < 0) { 231 | return rc; 232 | } 233 | return rc; 234 | } else { 235 | return -EINVAL; 236 | } 237 | } 238 | 239 | #endif 240 | -------------------------------------------------------------------------------- /signal.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef __EXTERN 4 | #define __EXTERN extern 5 | #endif 6 | #define P__SYSCALL_DEFINEx(x, name, ...) \ 7 | __EXTERN int (*p_sys##name)(__MAP(x, __SC_DECL, __VA_ARGS__)) 8 | 9 | P__SYSCALL_DEFINEx(4, _rt_sigprocmask, int, how, sigset_t __user *, nset, 10 | sigset_t __user *, oset, size_t, sigsetsize); 11 | 12 | P__SYSCALL_DEFINEx(2, _rt_sigpending, sigset_t __user *, uset, size_t, 13 | sigsetsize); 14 | 15 | P__SYSCALL_DEFINEx(4, _rt_sigtimedwait, const sigset_t __user *, uthese, 16 | siginfo_t __user *, uinfo, 17 | const struct __kernel_timespec __user *, uts, size_t, 18 | sigsetsize); 19 | 20 | P__SYSCALL_DEFINEx(4, _rt_sigaction, int, sig, const struct sigaction __user *, 21 | act, struct sigaction __user *, oact, size_t, sigsetsize); 22 | 23 | P__SYSCALL_DEFINEx(2, _rt_sigsuspend, sigset_t __user *, unewset, size_t, 24 | sigsetsize); 25 | P__SYSCALL_DEFINEx(6, _pselect6, int, n, fd_set __user *, inp, fd_set __user *, 26 | outp, fd_set __user *, exp, 27 | struct __kernel_timespec __user *, tsp, void __user *, sig); 28 | P__SYSCALL_DEFINEx(5, _ppoll, struct pollfd __user *, ufds, unsigned int, nfds, 29 | struct __kernel_timespec __user *, tsp, const sigset_t __user *, sigmask, 30 | size_t, sigsetsize); 31 | #ifdef CONFIG_SIGNALFD 32 | P__SYSCALL_DEFINEx(4, _signalfd4, int, ufd, sigset_t __user *, user_mask, 33 | size_t, sizemask, int, flags); 34 | #endif 35 | #ifdef CONFIG_EPOLL 36 | P__SYSCALL_DEFINEx(6, _epoll_pwait, int, epfd, struct epoll_event __user *, 37 | events, int, maxevents, int, timeout, 38 | const sigset_t __user *, sigmask, size_t, sigsetsize); 39 | P__SYSCALL_DEFINEx(6, _epoll_pwait2, int, epfd, struct epoll_event __user *, 40 | events, int, maxevents, 41 | const struct __kernel_timespec __user *, timeout, 42 | const sigset_t __user *, sigmask, size_t, sigsetsize); 43 | #undef P__SYSCALL_DEFINEx 44 | #endif 45 | --------------------------------------------------------------------------------