pax_global_header 0000666 0000000 0000000 00000000064 14715043267 0014523 g ustar 00root root 0000000 0000000 52 comment=6008f1ecc3d0482d5c6bd466b6fd217a74b3a31a
crac-criu-1.5.0/ 0000775 0000000 0000000 00000000000 14715043267 0013376 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/.circleci/ 0000775 0000000 0000000 00000000000 14715043267 0015231 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/.circleci/config.yml 0000664 0000000 0000000 00000001102 14715043267 0017213 0 ustar 00root root 0000000 0000000 version: 2.1
jobs:
test-local-gcc:
machine:
image: ubuntu-2004:202010-01
working_directory: ~/criu
steps:
- checkout
- run:
name: "Test local with GCC"
command: sudo -E make -C scripts/ci local
test-local-clang:
machine:
image: ubuntu-2004:202010-01
working_directory: ~/criu
steps:
- checkout
- run:
name: "Test local with CLANG"
command: sudo -E make -C scripts/ci local CLANG=1
workflows:
version: 2
builds:
jobs:
- test-local-gcc
- test-local-clang
crac-criu-1.5.0/.cirrus.yml 0000664 0000000 0000000 00000012741 14715043267 0015513 0 ustar 00root root 0000000 0000000 task:
name: Vagrant Fedora based test (no VDSO)
environment:
HOME: "/root"
CIRRUS_WORKING_DIR: "/tmp/criu"
compute_engine_instance:
image_project: cirrus-images
image: family/docker-kvm
platform: linux
cpu: 4
memory: 16G
nested_virtualization: true
setup_script: |
scripts/ci/apt-install make gcc pkg-config git perl-modules iproute2 kmod wget cpu-checker
sudo kvm-ok
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
build_script: |
make -C scripts/ci vagrant-fedora-no-vdso
task:
name: CentOS Stream 9 based test
environment:
HOME: "/root"
CIRRUS_WORKING_DIR: "/tmp/criu"
compute_engine_instance:
image_project: centos-cloud
image: family/centos-stream-9
platform: linux
cpu: 4
memory: 8G
setup_script: |
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
dnf config-manager --set-enabled crb # Same as CentOS 8 powertools
dnf -y install epel-release epel-next-release
dnf -y install --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python-devel python-PyYAML python-protobuf python-junit_xml python3-importlib-metadata python-flake8 xmlto libdrm-devel
systemctl stop sssd
# Even with selinux in permissive mode the selinux tests will be executed.
# The Cirrus CI user runs as a service from selinux point of view and is
# much more restricted than a normal shell (system_u:system_r:unconfined_service_t:s0).
# The test case above (vagrant-fedora-no-vdso) should run selinux tests in enforcing mode.
setenforce 0
build_script: |
make -C scripts/ci local SKIP_CI_PREP=1 CC=gcc CD_TO_TOP=1 ZDTM_OPTS="-x zdtm/static/socket-raw"
task:
name: Vagrant Fedora Rawhide based test
environment:
HOME: "/root"
CIRRUS_WORKING_DIR: "/tmp/criu"
compute_engine_instance:
image_project: cirrus-images
image: family/docker-kvm
platform: linux
cpu: 4
memory: 16G
nested_virtualization: true
setup_script: |
scripts/ci/apt-install make gcc pkg-config git perl-modules iproute2 kmod wget cpu-checker
sudo kvm-ok
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
build_script: |
make -C scripts/ci vagrant-fedora-rawhide
task:
name: Vagrant Fedora based test (non-root)
environment:
HOME: "/root"
CIRRUS_WORKING_DIR: "/tmp/criu"
compute_engine_instance:
image_project: cirrus-images
image: family/docker-kvm
platform: linux
cpu: 4
memory: 16G
nested_virtualization: true
setup_script: |
scripts/ci/apt-install make gcc pkg-config git perl-modules iproute2 kmod wget cpu-checker
sudo kvm-ok
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
build_script: |
make -C scripts/ci vagrant-fedora-non-root
task:
name: CentOS Stream 8 based test
environment:
HOME: "/root"
CIRRUS_WORKING_DIR: "/tmp/criu"
compute_engine_instance:
image_project: centos-cloud
image: family/centos-stream-8
platform: linux
cpu: 4
memory: 8G
setup_script: |
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
# Do not fail if latest epel repository definition is already installed
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm || :
yum install -y dnf-plugins-core
yum config-manager --set-enabled powertools
yum install -y --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python3-devel python3-flake8 python3-PyYAML python3-protobuf python3-importlib-metadata python3-junit_xml xmlto libdrm-devel
alternatives --set python /usr/bin/python3
systemctl stop sssd
# Even with selinux in permissive mode the selinux tests will be executed
# The Cirrus CI user runs as a service from selinux point of view and is
# much more restricted than a normal shell (system_u:system_r:unconfined_service_t:s0)
# The test case above (vagrant-fedora-no-vdso) should run selinux tests in enforcing mode
setenforce 0
build_script: |
make -C scripts/ci local SKIP_CI_PREP=1 CC=gcc CD_TO_TOP=1 ZDTM_OPTS="-x zdtm/static/socket-raw"
task:
name: aarch64 build GCC (native)
arm_container:
image: docker.io/library/ubuntu:jammy
cpu: 4
memory: 4G
script: uname -a
build_script: |
scripts/ci/apt-install make
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
make -C scripts/ci local
task:
name: aarch64 build CLANG (native)
arm_container:
image: docker.io/library/ubuntu:jammy
cpu: 4
memory: 4G
script: uname -a
build_script: |
scripts/ci/apt-install make
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
make -C scripts/ci local CLANG=1
task:
name: aarch64 Fedora Rawhide
arm_container:
image: registry.fedoraproject.org/fedora:rawhide
cpu: 4
memory: 4G
script: uname -a
build_script: |
scripts/ci/prepare-for-fedora-rawhide.sh
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
make -C scripts/ci/ local CC=gcc SKIP_CI_PREP=1 SKIP_CI_TEST=1 CD_TO_TOP=1
make -C test/zdtm -j 4
crac-criu-1.5.0/.clang-format 0000664 0000000 0000000 00000041337 14715043267 0015761 0 ustar 00root root 0000000 0000000 # SPDX-License-Identifier: GPL-2.0
#
# clang-format configuration file. Intended for clang-format >= 11.
#
# For more information, see:
#
# Documentation/process/clang-format.rst
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left # Unknown to clang-format-4.0
AlignOperands: true
AlignTrailingComments: true
AlignConsecutiveMacros: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false # Unknown to clang-format-5.0
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true # Unknown to clang-format-4.0
SplitEmptyRecord: true # Unknown to clang-format-4.0
SplitEmptyNamespace: true # Unknown to clang-format-4.0
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false # Unknown to clang-format-4.0
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false # Unknown to clang-format-4.0
# Taken from:
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
# | sort | uniq
ForEachMacros:
- 'for_each_pstree_item'
- 'for_each_bit'
- 'apei_estatus_for_each_section'
- 'ata_for_each_dev'
- 'ata_for_each_link'
- '__ata_qc_for_each'
- 'ata_qc_for_each'
- 'ata_qc_for_each_raw'
- 'ata_qc_for_each_with_internal'
- 'ax25_for_each'
- 'ax25_uid_for_each'
- '__bio_for_each_bvec'
- 'bio_for_each_bvec'
- 'bio_for_each_bvec_all'
- 'bio_for_each_integrity_vec'
- '__bio_for_each_segment'
- 'bio_for_each_segment'
- 'bio_for_each_segment_all'
- 'bio_list_for_each'
- 'bip_for_each_vec'
- 'bitmap_for_each_clear_region'
- 'bitmap_for_each_set_region'
- 'blkg_for_each_descendant_post'
- 'blkg_for_each_descendant_pre'
- 'blk_queue_for_each_rl'
- 'bond_for_each_slave'
- 'bond_for_each_slave_rcu'
- 'bpf_for_each_spilled_reg'
- 'btree_for_each_safe128'
- 'btree_for_each_safe32'
- 'btree_for_each_safe64'
- 'btree_for_each_safel'
- 'card_for_each_dev'
- 'cgroup_taskset_for_each'
- 'cgroup_taskset_for_each_leader'
- 'cpufreq_for_each_entry'
- 'cpufreq_for_each_entry_idx'
- 'cpufreq_for_each_valid_entry'
- 'cpufreq_for_each_valid_entry_idx'
- 'css_for_each_child'
- 'css_for_each_descendant_post'
- 'css_for_each_descendant_pre'
- 'device_for_each_child_node'
- 'displayid_iter_for_each'
- 'dma_fence_chain_for_each'
- 'do_for_each_ftrace_op'
- 'drm_atomic_crtc_for_each_plane'
- 'drm_atomic_crtc_state_for_each_plane'
- 'drm_atomic_crtc_state_for_each_plane_state'
- 'drm_atomic_for_each_plane_damage'
- 'drm_client_for_each_connector_iter'
- 'drm_client_for_each_modeset'
- 'drm_connector_for_each_possible_encoder'
- 'drm_for_each_bridge_in_chain'
- 'drm_for_each_connector_iter'
- 'drm_for_each_crtc'
- 'drm_for_each_crtc_reverse'
- 'drm_for_each_encoder'
- 'drm_for_each_encoder_mask'
- 'drm_for_each_fb'
- 'drm_for_each_legacy_plane'
- 'drm_for_each_plane'
- 'drm_for_each_plane_mask'
- 'drm_for_each_privobj'
- 'drm_mm_for_each_hole'
- 'drm_mm_for_each_node'
- 'drm_mm_for_each_node_in_range'
- 'drm_mm_for_each_node_safe'
- 'flow_action_for_each'
- 'for_each_acpi_dev_match'
- 'for_each_active_dev_scope'
- 'for_each_active_drhd_unit'
- 'for_each_active_iommu'
- 'for_each_aggr_pgid'
- 'for_each_available_child_of_node'
- 'for_each_bio'
- 'for_each_board_func_rsrc'
- 'for_each_bvec'
- 'for_each_card_auxs'
- 'for_each_card_auxs_safe'
- 'for_each_card_components'
- 'for_each_card_dapms'
- 'for_each_card_pre_auxs'
- 'for_each_card_prelinks'
- 'for_each_card_rtds'
- 'for_each_card_rtds_safe'
- 'for_each_card_widgets'
- 'for_each_card_widgets_safe'
- 'for_each_cgroup_storage_type'
- 'for_each_child_of_node'
- 'for_each_clear_bit'
- 'for_each_clear_bit_from'
- 'for_each_cmsghdr'
- 'for_each_compatible_node'
- 'for_each_component_dais'
- 'for_each_component_dais_safe'
- 'for_each_comp_order'
- 'for_each_console'
- 'for_each_cpu'
- 'for_each_cpu_and'
- 'for_each_cpu_not'
- 'for_each_cpu_wrap'
- 'for_each_dapm_widgets'
- 'for_each_dev_addr'
- 'for_each_dev_scope'
- 'for_each_dma_cap_mask'
- 'for_each_dpcm_be'
- 'for_each_dpcm_be_rollback'
- 'for_each_dpcm_be_safe'
- 'for_each_dpcm_fe'
- 'for_each_drhd_unit'
- 'for_each_dss_dev'
- 'for_each_dtpm_table'
- 'for_each_efi_memory_desc'
- 'for_each_efi_memory_desc_in_map'
- 'for_each_element'
- 'for_each_element_extid'
- 'for_each_element_id'
- 'for_each_endpoint_of_node'
- 'for_each_evictable_lru'
- 'for_each_fib6_node_rt_rcu'
- 'for_each_fib6_walker_rt'
- 'for_each_free_mem_pfn_range_in_zone'
- 'for_each_free_mem_pfn_range_in_zone_from'
- 'for_each_free_mem_range'
- 'for_each_free_mem_range_reverse'
- 'for_each_func_rsrc'
- 'for_each_hstate'
- 'for_each_if'
- 'for_each_iommu'
- 'for_each_ip_tunnel_rcu'
- 'for_each_irq_nr'
- 'for_each_link_codecs'
- 'for_each_link_cpus'
- 'for_each_link_platforms'
- 'for_each_lru'
- 'for_each_matching_node'
- 'for_each_matching_node_and_match'
- 'for_each_member'
- 'for_each_memcg_cache_index'
- 'for_each_mem_pfn_range'
- '__for_each_mem_range'
- 'for_each_mem_range'
- '__for_each_mem_range_rev'
- 'for_each_mem_range_rev'
- 'for_each_mem_region'
- 'for_each_migratetype_order'
- 'for_each_msi_entry'
- 'for_each_msi_entry_safe'
- 'for_each_msi_vector'
- 'for_each_net'
- 'for_each_net_continue_reverse'
- 'for_each_netdev'
- 'for_each_netdev_continue'
- 'for_each_netdev_continue_rcu'
- 'for_each_netdev_continue_reverse'
- 'for_each_netdev_feature'
- 'for_each_netdev_in_bond_rcu'
- 'for_each_netdev_rcu'
- 'for_each_netdev_reverse'
- 'for_each_netdev_safe'
- 'for_each_net_rcu'
- 'for_each_new_connector_in_state'
- 'for_each_new_crtc_in_state'
- 'for_each_new_mst_mgr_in_state'
- 'for_each_new_plane_in_state'
- 'for_each_new_private_obj_in_state'
- 'for_each_node'
- 'for_each_node_by_name'
- 'for_each_node_by_type'
- 'for_each_node_mask'
- 'for_each_node_state'
- 'for_each_node_with_cpus'
- 'for_each_node_with_property'
- 'for_each_nonreserved_multicast_dest_pgid'
- 'for_each_of_allnodes'
- 'for_each_of_allnodes_from'
- 'for_each_of_cpu_node'
- 'for_each_of_pci_range'
- 'for_each_old_connector_in_state'
- 'for_each_old_crtc_in_state'
- 'for_each_old_mst_mgr_in_state'
- 'for_each_oldnew_connector_in_state'
- 'for_each_oldnew_crtc_in_state'
- 'for_each_oldnew_mst_mgr_in_state'
- 'for_each_oldnew_plane_in_state'
- 'for_each_oldnew_plane_in_state_reverse'
- 'for_each_oldnew_private_obj_in_state'
- 'for_each_old_plane_in_state'
- 'for_each_old_private_obj_in_state'
- 'for_each_online_cpu'
- 'for_each_online_node'
- 'for_each_online_pgdat'
- 'for_each_pci_bridge'
- 'for_each_pci_dev'
- 'for_each_pci_msi_entry'
- 'for_each_pcm_streams'
- 'for_each_physmem_range'
- 'for_each_populated_zone'
- 'for_each_possible_cpu'
- 'for_each_present_cpu'
- 'for_each_prime_number'
- 'for_each_prime_number_from'
- 'for_each_process'
- 'for_each_process_thread'
- 'for_each_prop_codec_conf'
- 'for_each_prop_dai_codec'
- 'for_each_prop_dai_cpu'
- 'for_each_prop_dlc_codecs'
- 'for_each_prop_dlc_cpus'
- 'for_each_prop_dlc_platforms'
- 'for_each_property_of_node'
- 'for_each_registered_fb'
- 'for_each_requested_gpio'
- 'for_each_requested_gpio_in_range'
- 'for_each_reserved_mem_range'
- 'for_each_reserved_mem_region'
- 'for_each_rtd_codec_dais'
- 'for_each_rtd_components'
- 'for_each_rtd_cpu_dais'
- 'for_each_rtd_dais'
- 'for_each_set_bit'
- 'for_each_set_bit_from'
- 'for_each_set_clump8'
- 'for_each_sg'
- 'for_each_sg_dma_page'
- 'for_each_sg_page'
- 'for_each_sgtable_dma_page'
- 'for_each_sgtable_dma_sg'
- 'for_each_sgtable_page'
- 'for_each_sgtable_sg'
- 'for_each_sibling_event'
- 'for_each_subelement'
- 'for_each_subelement_extid'
- 'for_each_subelement_id'
- '__for_each_thread'
- 'for_each_thread'
- 'for_each_unicast_dest_pgid'
- 'for_each_vsi'
- 'for_each_wakeup_source'
- 'for_each_zone'
- 'for_each_zone_zonelist'
- 'for_each_zone_zonelist_nodemask'
- 'fwnode_for_each_available_child_node'
- 'fwnode_for_each_child_node'
- 'fwnode_graph_for_each_endpoint'
- 'gadget_for_each_ep'
- 'genradix_for_each'
- 'genradix_for_each_from'
- 'hash_for_each'
- 'hash_for_each_possible'
- 'hash_for_each_possible_rcu'
- 'hash_for_each_possible_rcu_notrace'
- 'hash_for_each_possible_safe'
- 'hash_for_each_rcu'
- 'hash_for_each_safe'
- 'hctx_for_each_ctx'
- 'hlist_bl_for_each_entry'
- 'hlist_bl_for_each_entry_rcu'
- 'hlist_bl_for_each_entry_safe'
- 'hlist_for_each'
- 'hlist_for_each_entry'
- 'hlist_for_each_entry_continue'
- 'hlist_for_each_entry_continue_rcu'
- 'hlist_for_each_entry_continue_rcu_bh'
- 'hlist_for_each_entry_from'
- 'hlist_for_each_entry_from_rcu'
- 'hlist_for_each_entry_rcu'
- 'hlist_for_each_entry_rcu_bh'
- 'hlist_for_each_entry_rcu_notrace'
- 'hlist_for_each_entry_safe'
- 'hlist_for_each_entry_srcu'
- '__hlist_for_each_rcu'
- 'hlist_for_each_safe'
- 'hlist_nulls_for_each_entry'
- 'hlist_nulls_for_each_entry_from'
- 'hlist_nulls_for_each_entry_rcu'
- 'hlist_nulls_for_each_entry_safe'
- 'i3c_bus_for_each_i2cdev'
- 'i3c_bus_for_each_i3cdev'
- 'ide_host_for_each_port'
- 'ide_port_for_each_dev'
- 'ide_port_for_each_present_dev'
- 'idr_for_each_entry'
- 'idr_for_each_entry_continue'
- 'idr_for_each_entry_continue_ul'
- 'idr_for_each_entry_ul'
- 'in_dev_for_each_ifa_rcu'
- 'in_dev_for_each_ifa_rtnl'
- 'inet_bind_bucket_for_each'
- 'inet_lhash2_for_each_icsk_rcu'
- 'key_for_each'
- 'key_for_each_safe'
- 'klp_for_each_func'
- 'klp_for_each_func_safe'
- 'klp_for_each_func_static'
- 'klp_for_each_object'
- 'klp_for_each_object_safe'
- 'klp_for_each_object_static'
- 'kunit_suite_for_each_test_case'
- 'kvm_for_each_memslot'
- 'kvm_for_each_vcpu'
- 'list_for_each'
- 'list_for_each_codec'
- 'list_for_each_codec_safe'
- 'list_for_each_continue'
- 'list_for_each_entry'
- 'list_for_each_entry_continue'
- 'list_for_each_entry_continue_rcu'
- 'list_for_each_entry_continue_reverse'
- 'list_for_each_entry_from'
- 'list_for_each_entry_from_rcu'
- 'list_for_each_entry_from_reverse'
- 'list_for_each_entry_lockless'
- 'list_for_each_entry_rcu'
- 'list_for_each_entry_reverse'
- 'list_for_each_entry_safe'
- 'list_for_each_entry_safe_continue'
- 'list_for_each_entry_safe_from'
- 'list_for_each_entry_safe_reverse'
- 'list_for_each_entry_srcu'
- 'list_for_each_prev'
- 'list_for_each_prev_safe'
- 'list_for_each_safe'
- 'llist_for_each'
- 'llist_for_each_entry'
- 'llist_for_each_entry_safe'
- 'llist_for_each_safe'
- 'mci_for_each_dimm'
- 'media_device_for_each_entity'
- 'media_device_for_each_intf'
- 'media_device_for_each_link'
- 'media_device_for_each_pad'
- 'nanddev_io_for_each_page'
- 'netdev_for_each_lower_dev'
- 'netdev_for_each_lower_private'
- 'netdev_for_each_lower_private_rcu'
- 'netdev_for_each_mc_addr'
- 'netdev_for_each_uc_addr'
- 'netdev_for_each_upper_dev_rcu'
- 'netdev_hw_addr_list_for_each'
- 'nft_rule_for_each_expr'
- 'nla_for_each_attr'
- 'nla_for_each_nested'
- 'nlmsg_for_each_attr'
- 'nlmsg_for_each_msg'
- 'nr_neigh_for_each'
- 'nr_neigh_for_each_safe'
- 'nr_node_for_each'
- 'nr_node_for_each_safe'
- 'of_for_each_phandle'
- 'of_property_for_each_string'
- 'of_property_for_each_u32'
- 'pci_bus_for_each_resource'
- 'pcl_for_each_chunk'
- 'pcl_for_each_segment'
- 'pcm_for_each_format'
- 'ping_portaddr_for_each_entry'
- 'plist_for_each'
- 'plist_for_each_continue'
- 'plist_for_each_entry'
- 'plist_for_each_entry_continue'
- 'plist_for_each_entry_safe'
- 'plist_for_each_safe'
- 'pnp_for_each_card'
- 'pnp_for_each_dev'
- 'protocol_for_each_card'
- 'protocol_for_each_dev'
- 'queue_for_each_hw_ctx'
- 'radix_tree_for_each_slot'
- 'radix_tree_for_each_tagged'
- 'rb_for_each'
- 'rbtree_postorder_for_each_entry_safe'
- 'rdma_for_each_block'
- 'rdma_for_each_port'
- 'rdma_umem_for_each_dma_block'
- 'resource_list_for_each_entry'
- 'resource_list_for_each_entry_safe'
- 'rhl_for_each_entry_rcu'
- 'rhl_for_each_rcu'
- 'rht_for_each'
- 'rht_for_each_entry'
- 'rht_for_each_entry_from'
- 'rht_for_each_entry_rcu'
- 'rht_for_each_entry_rcu_from'
- 'rht_for_each_entry_safe'
- 'rht_for_each_from'
- 'rht_for_each_rcu'
- 'rht_for_each_rcu_from'
- '__rq_for_each_bio'
- 'rq_for_each_bvec'
- 'rq_for_each_segment'
- 'scsi_for_each_prot_sg'
- 'scsi_for_each_sg'
- 'sctp_for_each_hentry'
- 'sctp_skb_for_each'
- 'shdma_for_each_chan'
- '__shost_for_each_device'
- 'shost_for_each_device'
- 'sk_for_each'
- 'sk_for_each_bound'
- 'sk_for_each_entry_offset_rcu'
- 'sk_for_each_from'
- 'sk_for_each_rcu'
- 'sk_for_each_safe'
- 'sk_nulls_for_each'
- 'sk_nulls_for_each_from'
- 'sk_nulls_for_each_rcu'
- 'snd_array_for_each'
- 'snd_pcm_group_for_each_entry'
- 'snd_soc_dapm_widget_for_each_path'
- 'snd_soc_dapm_widget_for_each_path_safe'
- 'snd_soc_dapm_widget_for_each_sink_path'
- 'snd_soc_dapm_widget_for_each_source_path'
- 'tb_property_for_each'
- 'tcf_exts_for_each_action'
- 'udp_portaddr_for_each_entry'
- 'udp_portaddr_for_each_entry_rcu'
- 'usb_hub_for_each_child'
- 'v4l2_device_for_each_subdev'
- 'v4l2_m2m_for_each_dst_buf'
- 'v4l2_m2m_for_each_dst_buf_safe'
- 'v4l2_m2m_for_each_src_buf'
- 'v4l2_m2m_for_each_src_buf_safe'
- 'virtio_device_for_each_vq'
- 'while_for_each_ftrace_op'
- 'xa_for_each'
- 'xa_for_each_marked'
- 'xa_for_each_range'
- 'xa_for_each_start'
- 'xas_for_each'
- 'xas_for_each_conflict'
- 'xas_for_each_marked'
- 'xbc_array_for_each_value'
- 'xbc_for_each_key_value'
- 'xbc_node_for_each_array_value'
- 'xbc_node_for_each_child'
- 'xbc_node_for_each_key_value'
- 'zorro_for_each_dev'
IncludeBlocks: Preserve # Unknown to clang-format-5.0
IncludeCategories:
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None # Unknown to clang-format-5.0
IndentWidth: 8
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
# Taken from git's rules
PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false # Unknown to clang-format-4.0
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: Always
...
crac-criu-1.5.0/.codespellrc 0000664 0000000 0000000 00000000176 14715043267 0015702 0 ustar 00root root 0000000 0000000 [codespell]
skip = ./.git,./test/pki
ignore-words-list = creat,fpr,fle,ue,bord,parms,nd,te,testng,inh,wronly,renderd,bui,clen
crac-criu-1.5.0/.github/ 0000775 0000000 0000000 00000000000 14715043267 0014736 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000002020 14715043267 0017435 0 ustar 00root root 0000000 0000000
**Description**
**Steps to reproduce the issue:**
1.
2.
3.
**Describe the results you received:**
**Describe the results you expected:**
**Additional information you deem important (e.g. issue happens only occasionally):**
**CRIU logs and information:**
CRIU full dump/restore logs:
```
(paste your output here)
```
Output of `criu --version`:
```
(paste your output here)
```
Output of `criu check --all`:
```
(paste your output here)
```
**Additional environment details:**
crac-criu-1.5.0/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000001435 14715043267 0020542 0 ustar 00root root 0000000 0000000
crac-criu-1.5.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14715043267 0016773 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/.github/workflows/ccpp.yml 0000664 0000000 0000000 00000004006 14715043267 0020443 0 ustar 00root root 0000000 0000000 name: Build
on:
push:
branches:
- "*"
tags:
- 'release-*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
BUNDLENAME: ${{ steps.compute.outputs.BUNDLENAME }}
steps:
- name: Compute parameters
id: compute
run: |
if [ ${{ startsWith(github.ref, 'refs/tags/') }} = true ]; then
TAG=${GITHUB_REF##refs/tags/}
BUNDLENAME=crac-criu-${TAG}
else
TAG=notag
BUNDLENAME=crac-criu-build-${{ github.run_number }}
fi
for i in TAG BUNDLENAME; do
echo "::set-output name=${i}::${!i}"
done
- name: Start build container
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com;
docker run -d --name build
-w $PWD
-v /home/runner:/home/runner
-u $(id -u):$(id -g)
--entrypoint tail
docker.pkg.github.com/crac/docker-build/image:ubuntu-16.04
-f /dev/null
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Submodule init
run: |
git submodule init
git submodule update
- run: make DESTDIR=. PREFIX=/${{ steps.compute.outputs.BUNDLENAME }} install-criu V=1
shell: docker exec build bash -e {0}
- run: tar -zcf ${{ steps.compute.outputs.BUNDLENAME }}.tar.gz ${{ steps.compute.outputs.BUNDLENAME }}
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.compute.outputs.BUNDLENAME }}
path: ${{ steps.compute.outputs.BUNDLENAME }}.tar.gz
release:
runs-on: ubuntu-latest
needs: build
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.BUNDLENAME }}
- uses: softprops/action-gh-release@v1
with:
files: |
${{ needs.build.outputs.BUNDLENAME }}.tar.gz
crac-criu-1.5.0/.github/workflows/check-commits.yml 0000664 0000000 0000000 00000002363 14715043267 0022250 0 ustar 00root root 0000000 0000000 name: Verify self-contained commits
on: pull_request
# Cancel any preceding run on the pull request
concurrency:
group: commit-test-${{ github.event.pull_request.number }}
jobs:
build:
runs-on: ubuntu-latest
# Check if pull request does not have label "not-selfcontained-ok"
if: "!contains(github.event.pull_request.labels.*.name, 'not-selfcontained-ok')"
steps:
- uses: actions/checkout@v3
with:
# Needed to rebase against the base branch
fetch-depth: 0
# Checkout pull request HEAD commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
run: sudo apt-get install -y libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev
- name: Configure git user details
run: |
git config --global user.email "checkpoint-restore@users.noreply.github.com"
git config --global user.name "checkpoint-restore"
- name: Configure base branch without switching current branch
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Build each commit
run: git rebase ${{ github.base_ref }} -x "make -C scripts/ci check-commit"
crac-criu-1.5.0/.github/workflows/codeql.yml 0000664 0000000 0000000 00000002720 14715043267 0020766 0 ustar 00root root 0000000 0000000 name: "CodeQL"
on:
push:
branches: [ "criu-dev", "master" ]
pull_request:
branches: [ "criu-dev" ]
schedule:
- cron: "11 6 * * 3"
# Cancel any preceding run on the pull request.
concurrency:
group: codeql-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ python, cpp ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Packages (cpp)
if: ${{ matrix.language == 'cpp' }}
run: |
sudo scripts/ci/apt-install protobuf-c-compiler libprotobuf-c-dev libprotobuf-dev build-essential libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnet-dev pkg-config libnl-3-dev libbsd0 libbsd-dev iproute2 libcap-dev libaio-dev libbsd-dev python3-yaml libnl-route-3-dev gnutls-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
crac-criu-1.5.0/.github/workflows/java-test.yml 0000664 0000000 0000000 00000000616 14715043267 0021417 0 ustar 00root root 0000000 0000000 name: Java Test
on: [push, pull_request]
# Cancel any preceding run on the pull request.
concurrency:
group: java-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Run Java Test
run: sudo make -C scripts/ci java-test
crac-criu-1.5.0/.github/workflows/lint.yml 0000664 0000000 0000000 00000002227 14715043267 0020467 0 ustar 00root root 0000000 0000000 name: Run code linter
on: [push, pull_request]
# Cancel any preceding run on the pull request.
concurrency:
group: lint-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}
jobs:
build:
runs-on: ubuntu-latest
container:
image: registry.fedoraproject.org/fedora:latest
steps:
- name: Install tools
run: sudo dnf -y install git make python3-flake8 xz clang-tools-extra which codespell git-clang-format ShellCheck
- uses: actions/checkout@v2
- name: Set git safe directory
# https://github.com/actions/checkout/issues/760
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Run make lint
run: make lint
- name: Run make indent
continue-on-error: true
run: |
if [ -z "${{github.base_ref}}" ]; then
git fetch --deepen=1
make indent
else
git fetch origin ${{github.base_ref}}
make indent BASE=origin/${{github.base_ref}}
fi
- name: Raise in-line make indent warnings
run: |
git diff | ./scripts/github-indent-warnings.py
crac-criu-1.5.0/.github/workflows/loongarch64-qemu-test.yml 0000664 0000000 0000000 00000000635 14715043267 0023572 0 ustar 00root root 0000000 0000000 name: LoongArch64 Qemu Test
on: [push, pull_request]
# Cancel any preceding run on the pull request.
concurrency:
group: loongarch64-qemu-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- run: sudo make -C scripts/ci loongarch64-qemu-test
crac-criu-1.5.0/.github/workflows/manage-labels.yml 0000664 0000000 0000000 00000000630 14715043267 0022205 0 ustar 00root root 0000000 0000000 name: Remove labels
on: [issue_comment, pull_request_review_comment]
jobs:
remove-labels-on-comments:
name: Remove labels on comments
if: github.event_name == 'issue_comment'
runs-on: ubuntu-latest
steps:
- uses: mondeja/remove-labels-gh-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
changes requested
awaiting reply
crac-criu-1.5.0/.gitignore 0000664 0000000 0000000 00000001201 14715043267 0015360 0 ustar 00root root 0000000 0000000 .config
*.o
*.d
*.a
*.img
*.bin
*.elf
*.out
*.swp
*.swo
*.so
.git-ignore
*.patch
*.pyc
cscope*
tags
TAGS
Makefile.local
compel/compel
compel/compel-host-bin
images/*.c
images/*.h
images/google/protobuf/*.c
images/google/protobuf/*.h
.gitid
criu/criu
criu/unittest/unittest
criu/arch/*/sys-exec-tbl*.c
# x86 syscalls-table is not generated
!criu/arch/x86/sys-exec-tbl.c
criu/arch/*/syscalls*.S
criu/include/syscall-codes*.h
criu/include/syscall*.h
criu/include/version.h
criu/pie/restorer-blob.h
criu/pie/parasite-blob.h
criu/protobuf-desc-gen.h
lib/build/
lib/c/criu.pc
compel/include/asm
include/common/asm
include/common/config.h
build/**
crac-criu-1.5.0/.gitmodules 0000664 0000000 0000000 00000000101 14715043267 0015543 0 ustar 00root root 0000000 0000000 [submodule "lz4"]
path = lz4
url = https://github.com/lz4/lz4/
crac-criu-1.5.0/.lgtm.yml 0000664 0000000 0000000 00000001356 14715043267 0015147 0 ustar 00root root 0000000 0000000 extraction:
cpp:
prepare:
packages:
- "protobuf-c-compiler"
- "libprotobuf-c-dev"
- "libprotobuf-dev"
- "build-essential"
- "libprotobuf-dev"
- "libprotobuf-c-dev"
- "protobuf-c-compiler"
- "protobuf-compiler"
- "python3-protobuf"
- "libnet-dev"
- "pkg-config"
- "libnl-3-dev"
- "libbsd0"
- "libbsd-dev"
- "iproute2"
- "libcap-dev"
- "libaio-dev"
- "libbsd-dev"
- "python3-yaml"
- "libnl-route-3-dev"
- "gnutls-dev"
configure:
command:
- "ls -laR images/google"
- "ln -s /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto"
- "ls -laR images/google"
crac-criu-1.5.0/.mailmap 0000664 0000000 0000000 00000001162 14715043267 0015017 0 ustar 00root root 0000000 0000000 Stanislav Kinsbursky
Pavel Emelyanov
Andrei Vagin
Andrei Vagin
Andrei Vagin
Andrei Vagin
Andrei Vagin
Cyrill Gorcunov
Alexander Mikhalitsyn
Alexander Mikhalitsyn
crac-criu-1.5.0/.travis.yml 0000664 0000000 0000000 00000001261 14715043267 0015507 0 ustar 00root root 0000000 0000000 language: c
os: linux
dist: bionic
services:
- docker
jobs:
include:
- os: linux
arch: ppc64le
env: TR_ARCH=local
dist: bionic
- os: linux
arch: ppc64le
env: TR_ARCH=local CLANG=1
dist: bionic
- os: linux
arch: s390x
env: TR_ARCH=local
dist: bionic
- os: linux
arch: arm64-graviton2
env: TR_ARCH=local RUN_TESTS=1
dist: focal
group: edge
virt: vm
- os: linux
arch: arm64-graviton2
env: TR_ARCH=local CLANG=1 RUN_TESTS=1
group: edge
virt: vm
dist: bionic
script:
- sudo make -C scripts/ci $TR_ARCH
after_success:
- make -C scripts/ci after_success
crac-criu-1.5.0/CONTRIBUTING.md 0000664 0000000 0000000 00000042647 14715043267 0015644 0 ustar 00root root 0000000 0000000 ## How to contribute to CRIU
CRIU project is (almost) the never-ending story, because we have to always keep up with the
Linux kernel supporting checkpoint and restore for all the features it provides. Thus we're
looking for contributors of all kinds -- feedback, bug reports, testing, coding, writing, etc.
Here are some useful hints to get involved.
* We have both -- [very simple](https://github.com/checkpoint-restore/criu/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) and [more sophisticated](https://github.com/checkpoint-restore/criu/issues?q=is%3Aissue+is%3Aopen+label%3A%22new+feature%22) coding tasks;
* CRIU does need [extensive testing](https://github.com/checkpoint-restore/criu/issues?q=is%3Aissue+is%3Aopen+label%3Atesting);
* Documentation is always hard, we have [some information](https://criu.org/Category:Empty_articles) that is to be extracted from people's heads into wiki pages as well as [some texts](https://criu.org/Category:Editor_help_needed) that all need to be converted into useful articles;
* Feedback is expected on the GitHub issues page and on the [mailing list](https://lists.openvz.org/mailman/listinfo/criu);
* We accept GitHub pull requests and this is the preferred way to contribute to CRIU. If you prefer to send patches by email, you are welcome to send them to [CRIU development mailing list](https://lists.openvz.org/mailman/listinfo/criu).
Below we describe in more detail recommend practices for CRIU development.
* Spread the word about CRIU in [social networks](http://criu.org/Contacts);
* If you're giving a talk about CRIU -- let us know, we'll mention it on the [wiki main page](https://criu.org/News/events);
### Setting up the development environment
Although `criu` could be run as non-root (see [Security](https://criu.org/Security)), development is better to be done as root. For example, some tests require root. So, it would be a good idea to set up some recent Linux distro on a virtual machine.
### Get the source code
The CRIU sources are tracked by Git. Official CRIU repo is at https://github.com/checkpoint-restore/criu.
The repository may contain multiple branches. Development happens in the **criu-dev** branch.
To clone CRIU repo and switch to the proper branch, run:
```
git clone https://github.com/checkpoint-restore/criu criu
cd criu
git checkout criu-dev
```
### Compile
First, you need to install compile-time dependencies. Check [Installation dependencies](https://criu.org/Installation#Dependencies) for more info.
To compile CRIU, run:
```
make
```
This should create the `./criu/criu` executable.
## Edit the source code
When you change the source code, please keep in mind the following code conventions:
* code is written to be read, so the code readability is the most important thing you need to have in mind when preparing patches
* we prefer tabs and indentations to be 8 characters width
* we prefer line length of 80 characters or less, more is allowed if it helps with code readability
* CRIU mostly follows [Linux kernel coding style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but we are less strict than the kernel community
Other conventions can be learned from the source code itself. In short, make sure your new code looks similar to what is already there.
## Automatic tools to fix coding-style
Important: These tools are there to advise you, but should not be considered as a "source of truth", as tools also make nasty mistakes from time to time which can completely break code readability.
The following command can be used to automatically run a code linter for Python files (flake8), Shell scripts (shellcheck),
text spelling (codespell), and a number of CRIU-specific checks (usage of print macros and EOL whitespace for C files).
```
make lint
```
In addition, we have adopted a [clang-format configuration file](https://www.kernel.org/doc/Documentation/process/clang-format.rst)
based on the kernel source tree. However, compliance with the clang-format autoformat rules is optional. If the automatic code formatting
results in decreased readability, we may choose to ignore these errors.
Run the following command to check if your changes are compliant with the clang-format rules:
```
make indent
```
This command is built upon the `git-clang-format` tool and supports two options `BASE` and `OPTS`. The `BASE` option allows you to
specify a range of commits to check for coding style issues. By default, it is set to `HEAD~1`, so that only the last commit is checked.
If you are developing on top of the criu-dev branch and want to check all your commits for compliance with the clang-format rules, you
can use `BASE=origin/criu-dev`. The `OPTS` option can be used to pass additional options to `git-clang-format`. For example, if you want
to check the last *N* commits for formatting errors, without applying the changes to the codebase you can use the following command.
```
make indent OPTS=--diff BASE=HEAD~N
```
Note that for pull requests, the "Run code linter" workflow runs these checks for all commits. If a clang-format error is detected
we need to review the suggested changes and decide if they should be fixed before merging.
Here are some bad examples of clang-format-ing:
* if clang-format tries to force 120 characters and breaks readability - it is wrong:
```
@@ -58,8 +59,7 @@ static int register_membarriers(void)
}
if (!all_ok) {
- fail("can't register membarrier()s - tried %#x, kernel %#x",
- barriers_registered, barriers_supported);
+ fail("can't register membarrier()s - tried %#x, kernel %#x", barriers_registered, barriers_supported);
return -1;
}
```
* if clang-format breaks your beautiful readability friendly alignment in structures, comments or defines - it is wrong:
```
--- a/test/zdtm/static/membarrier.c
+++ b/test/zdtm/static/membarrier.c
@@ -27,9 +27,10 @@ static const struct {
int register_cmd;
int execute_cmd;
} membarrier_cmds[] = {
- { "", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, MEMBARRIER_CMD_PRIVATE_EXPEDITED },
- { "_SYNC_CORE", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE, MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE },
- { "_RSEQ", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ, MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ },
+ { "", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, MEMBARRIER_CMD_PRIVATE_EXPEDITED },
+ { "_SYNC_CORE", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE,
+ MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE },
+ { "_RSEQ", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ, MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ },
};
```
## Test your changes
CRIU comes with an extensive test suite. To check whether your changes introduce any regressions, run
```
make test
```
The command runs [ZDTM Test Suite](https://criu.org/ZDTM_Test_Suite). Check for any error messages produced by it.
In case you'd rather have someone else run the tests, you can use travis-ci for your
own GitHub fork of CRIU. It will check the compilation for various supported platforms,
as well as run most of the tests from the suite. See https://travis-ci.org/checkpoint-restore/criu
for more details.
## Describe your changes
Describe your problem. Whether your change is a one-line bug fix or
5000 lines of a new feature, there must be an underlying problem that
motivated you to do this work. Convince the reviewer that there is a
problem worth fixing and that it makes sense for them to read past the
first paragraph.
Once the problem is established, describe what you are actually doing
about it in technical detail. It's important to describe the change
in plain English for the reviewer to verify that the code is behaving
as you intend it to.
Solve only one problem per commit. If your description starts to get
long, that's a sign that you probably need to split up your commit.
See [Separate your changes](#separate-your-changes).
Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
instead of "[This commit] makes xyzzy do frotz" or "[I] changed xyzzy
to do frotz", as if you are giving orders to the codebase to change
its behaviour.
If your change fixes a bug in a specific commit, e.g. you found an issue using
`git bisect`, please use the `Fixes:` tag with the abbreviation of
the SHA-1 ID, and the one line summary. For example:
```
Fixes: 9433b7b9db3e ("make: use cflags/ldflags for config.h detection mechanism")
```
The following `git config` settings can be used to add a pretty format for
outputting the above style in the `git log` or `git show` commands:
```
[pretty]
fixes = Fixes: %h (\"%s\")
```
If your change address an issue listed in GitHub, please use `Fixes:` tag with the number of the issue. For instance:
```
Fixes: #339
```
The `Fixes:` tags should be put at the end of the detailed description.
Please add a prefix to your commit subject line describing the part of the
project your change is related to. This can be either the name of the file or
directory you changed, or just a general word. If your patch is touching
multiple components you may separate prefixes with "/"-es. Here are some good
examples of subject lines from git log:
```
criu-ns: Convert to python3 style print() syntax
compel: Calculate sh_addr if not provided by linker
style: Enforce kernel style -Wstrict-prototypes
rpc/libcriu: Add lsm-profile option
```
You may refer to [How to Write a Git Commit
Message](https://chris.beams.io/posts/git-commit/) article for
recommendations for good commit message.
## Separate your changes
Separate each **logical change** into a separate commit.
For example, if your changes include both bug fixes and performance
enhancements for a single driver, separate those changes into two
or more commits. If your changes include an API update, and a new
driver which uses that new API, separate those into two commits.
On the other hand, if you make a single change to numerous files,
group those changes into a single commit. Thus a single logical change
is contained within a single commit.
The point to remember is that each commit should make an easily understood
change that can be verified by reviewers. Each commit should be justifiable
on its own merits.
When dividing your change into a series of commits, take special care to
ensure that CRIU builds and runs properly after each commit in the
series. Developers using `git bisect` to track down a problem can end up
splitting your patch series at any point; they will not thank you if you
introduce bugs in the middle.
## Sign your work
To improve tracking of who did what, we ask you to sign off the commits in
your fork of CRIU or the patches that are to be emailed.
The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to
pass it on as an open-source patch. The rules are pretty simple: if you
can certify the below:
### Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
then you just add a line saying
```
Signed-off-by: Random J Developer
```
using your real name (please, no pseudonyms or anonymous contributions if
it possible).
Hint: you can use `git commit -s` to add Signed-off-by line to your
commit message. To append such line to a commit you already made, use
`git commit --amend -s`.
```
From: Random J Developer
Subject: [PATCH] component: Short patch description
Long patch description (could be skipped if patch
is trivial enough)
Signed-off-by: Random J Developer
---
Patch body here
```
## Submit your work upstream
We accept GitHub pull requests and this is the preferred way to contribute to CRIU.
For that you should push your work to your fork of CRIU at [GitHub](https://github.com) and create a [pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
### Pull request guidelines
Pull request comment should contain description of the problem your changes
solve and a brief outline of the changes included in the pull request.
Please avoid pushing fixup commits to an existent pull request. Each commit
should be self contained and there should not be fixup commits in a patch
series. Pull requests that contain one commit which breaks something
and another commit which fixes it, will be rejected.
Please merge the fixup commits into the commits that has introduced the
problem before creating a pull request.
It may happen that the reviewers were not completely happy with your
changes and requested changes to your patches. After you updated your
changes please close the old pull request and create a new one that
contains the following:
* Description of the problem your changes solve and a brief outline of the
changes
* Link to the previous version of the pull request
* Brief description of the changes between old and new versions of the pull
request. If there were more than one previous pull request, all the
revisions should be listed. For example:
```
v3: rebase on the current criu-dev
v2: add commit to foo() and update bar() coding style
```
If there are only minor updates to the commits in a pull request, it is
possible to force-push them into an existing pull request. This only applies
to small changes and should be used with care. If you update an existing
pull request, remember to add the description of the changes from the
previous version.
### Mailing list submission
Historically, CRIU worked with mailing lists and patches so if you still prefer this way continue reading till the end of this section.
### Make a patch
To create a patch, run
```
git format-patch --signoff origin/criu-dev
```
You might need to read GIT documentation on how to prepare patches
for mail submission. Take a look at http://book.git-scm.com/ and/or
http://git-scm.com/documentation for details. It should not be hard
at all.
We recommend to post patches using `git send-email`
```
git send-email --cover-letter --no-chain-reply-to --annotate \
--confirm=always --to=criu@openvz.org criu-dev
```
Note that the `git send-email` subcommand may not be in
the main git package and using it may require installation of a
separate package, for example the "git-email" package in Fedora and
Debian.
If this is your first time using git send-email, you might need to
configure it to point it to your SMTP server with something like:
```
git config --global sendemail.smtpServer stmp.example.net
```
If you get tired of typing `--to=criu@openvz.org` all the time,
you can configure that to be automatically handled as well:
```
git config sendemail.to criu@openvz.org
```
If a developer is sending another version of the patch (e.g. to address
review comments), they are advised to note differences to previous versions
after the `---` line in the patch so that it helps reviewers but
doesn't become part of git history. Moreover, such patch needs to be prefixed
correctly with `--subject-prefix=PATCHv2` appended to
`git send-email` (substitute `v2` with the correct
version if needed though).
### Mail patches
The patches should be sent to CRIU development mailing list, `criu AT openvz.org`. Note that you need to be subscribed first in order to post. The list web interface is available at https://openvz.org/mailman/listinfo/criu; you can also use standard mailman aliases to work with it.
Please make sure the email client you're using doesn't screw your patch (line wrapping and so on).
> **Note:** When sending a patch set that consists of more than one patch, please, push your changes in your local repo and provide the URL of the branch in the cover-letter
### Wait for response
Be patient. Most CRIU developers are pretty busy people so if
there is no immediate response on your patch — don't be surprised,
sometimes a patch may fly around a week before it gets reviewed.
## Continuous integration
Wiki article: [Continuous integration](https://criu.org/Continuous_integration)
CRIU tests are run for each series sent to the mailing list. If you get a message from our patchwork that patches failed to pass the tests, you have to investigate what is wrong.
We also recommend you to [enable Travis CI for your repo](https://criu.org/Continuous_integration#Enable_Travis_CI_for_your_repo) to check patches in your git branch, before sending them to the mailing list.
crac-criu-1.5.0/COPYING 0000664 0000000 0000000 00000130542 14715043267 0014436 0 ustar 00root root 0000000 0000000 This software is licensed under the GNU GENERAL PUBLIC LICENCE Version
2. Except that any software in the lib/ directory is for the creation of a
linkable library to the tools and is licensed under the GNU LESSER GENERAL
PUBLIC LICENCE Version 2.1. Contributing Authors agree that their code is
submitted under the licence appropriate for its location within the source
tree (GPL except for LGPL in lib/) and agree that any future patches, provided
they are accepted into the project, may change the licence of their code from
GPL to LGPL by moving pieces of it into lib/ or LGPL to GPL by moving pieces
of it out of lib/
Note that the only valid version of the GPL is THIS particular version
of the license (ie v2, not v2.2 or v3.x or whatever), unless explicitly
otherwise stated.
----------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
---------------------------------------
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
crac-criu-1.5.0/CREDITS 0000664 0000000 0000000 00000000470 14715043267 0014417 0 ustar 00root root 0000000 0000000 The following people provided invaluable help to CRIU project
(in alphabetical order)
-------------------------------------------------------------------
Andrew Morton
David Miller
Eric Dumazet
Eric W. Biederman
H. Peter Anvin
Kees Cook
KOSAKI Motohiro
Li Yu
Linus Torvalds
Oleg Nesterov
Serge Hallyn
Tejun Heo
crac-criu-1.5.0/Documentation/ 0000775 0000000 0000000 00000000000 14715043267 0016207 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/Documentation/.gitattributes 0000664 0000000 0000000 00000000021 14715043267 0021073 0 ustar 00root root 0000000 0000000 *.txt whitespace
crac-criu-1.5.0/Documentation/.gitignore 0000664 0000000 0000000 00000000053 14715043267 0020175 0 ustar 00root root 0000000 0000000 *.xml
*.html
*.[1-8]
*.pdf
*.ps
footer.txt
crac-criu-1.5.0/Documentation/HOWTO.cross-compile 0000664 0000000 0000000 00000003656 14715043267 0021622 0 ustar 00root root 0000000 0000000 How to cross-compile CRIU on x86:
Use the Dockerfile provided:
scripts/build/Dockerfile.armv7-cross
Historical guide how-to do it without docker container:
[Unsupported, may not work anymore!]
1. Download the protobuf sources.
2. Apply the patch http://16918.selcdn.ru/crtools/aarch64/0001-protobuf-added-the-support-for-the-acrchitecture-AAr.patch
3. Configure protobuf to be compiled for the target architecture:
./configure --prefix=$X86_PREFIX --disable-shared --enable-static
4. Compile protobuf.
5. Download protobuf-c sources.
6. Configure protobuf-c for the architecture x86:
export PATH=$PATH:$X86_PREFIX/bin
export PKG_CONFIG_PATH=$X86_PREFIX/lib/pkgconfig
CPPFLAGS=`pkg-config --cflags protobuf` LDFLAGS=`pkg-config --libs protobuf` ./configure --prefix=$X86_PREFIX --disable-shared --enable-static
7. Compile and install protobuf-c.
8. Configure protobuf to be compiled for the target architecture:
./configure --prefix=$ARCH_PREFIX --disable-shared --enable-static --with-protoc=protoc --host=$TARGET
9. Compile and install protobuf.
10. Let PKG_CONFIG_PATH=$ARCH_PREFIX/lib/pkgconfig.
11. Configure protobuf-c to be compiled for the target architecture:
CPPFLAGS=`pkg-config --cflags protobuf` LDFLAGS=`pkg-config --libs protobuf` ./configure --prefix=$ARCH_PREFIX --disable-shared --enable-static --disable-protoc --host=$TARGET
12. Compile and install protobuf-c.
13. Compile CRIU:
ARCH= CROSS_COMPILE=$TARGET- CFLAGS=`pkg-config --cflags libprotobuf-c` LDFLAGS="`pkg-config --libs libprotobuf-c`" make
Special notes for Android NDK cross compile:
1, Android NDK doesn't have some headers required by CRIU build, they are ,
2, Android NDK doesn't have some function required by CRIU build, they are aio*, fanotify_init, fanotify_mark, povit_root, index.
3, in order to pass build with Android NDK, you implement them yourself, and link them to CRIU.
crac-criu-1.5.0/Documentation/Makefile 0000664 0000000 0000000 00000005016 14715043267 0017651 0 ustar 00root root 0000000 0000000 __nmk_dir ?= ../scripts/nmk/scripts/
include $(__nmk_dir)include.mk
include $(__nmk_dir)macro.mk
ifneq ($(USE_ASCIIDOCTOR),)
ASCIIDOC := asciidoctor
XMLTO :=
else
ASCIIDOC := asciidoc
XMLTO := xmlto
endif
FOOTER := footer.txt
SRC1 += crit.txt
SRC1 += criu-ns.txt
SRC1 += compel.txt
SRC1 += criu-amdgpu-plugin.txt
SRC8 += criu.txt
SRC := $(SRC1) $(SRC8)
XMLS := $(patsubst %.txt,%.xml,$(SRC))
MAN1S := $(patsubst %.txt,%.1,$(SRC1))
MAN8S := $(patsubst %.txt,%.8,$(SRC8))
MANS := $(MAN1S) $(MAN8S)
MAN1DIR := $(MANDIR)/man1
MAN8DIR := $(MANDIR)/man8
GROFF :=groff
PAPER :=$(shell paperconf 2>/dev/null || echo letter)
GROFF_OPTS := -Tps -t -dpaper=$(PAPER) -P-p$(PAPER) -man -msafer -rC1 -rD1 -rS11
PSS := $(patsubst %,%.ps,$(basename $(MANS)))
PDFS := $(patsubst %,%.pdf,$(basename $(MANS)))
all: check $(MANS)
ps: $(PSS)
pdf: $(PDFS)
.PHONY: all ps pdf check
check:
$(Q) for B in $(ASCIIDOC) $(XMLTO); do \
$$B --version > /dev/null || exit 1; \
done
ifeq ($(CRIU_VERSION),)
include ../Makefile.versions
endif
$(FOOTER): ../Makefile.versions
$(call msg-gen, $@)
$(Q) echo ":doctype: manpage" > $@
$(Q) echo ":man source: criu" >> $@
$(Q) echo ":man version: $(CRIU_VERSION)" >> $@
$(Q) echo ":man manual: CRIU Manual" >> $@
%.1: %.txt $(FOOTER) custom.xsl
$(call msg-gen, $@)
ifneq ($(USE_ASCIIDOCTOR),)
$(Q) $(ASCIIDOC) -b manpage -d manpage -o $@ $<
else
$(Q) $(ASCIIDOC) -b docbook -d manpage -o $(patsubst %.1,%.xml,$@) $<
$(Q) $(XMLTO) man -m custom.xsl $(patsubst %.1,%.xml,$@)
endif
%.8: %.txt $(FOOTER) custom.xsl
$(call msg-gen, $@)
ifneq ($(USE_ASCIIDOCTOR),)
$(Q) $(ASCIIDOC) -b manpage -d manpage -o $@ $<
else
$(Q) $(ASCIIDOC) -b docbook -d manpage -o $(patsubst %.8,%.xml,$@) $<
$(Q) $(XMLTO) man -m custom.xsl $(patsubst %.8,%.xml,$@)
endif
%.ps: %.1
$(call msg-gen, $@)
$(Q) $(GROFF) $(GROFF_OPTS) $^ > $@
%.ps: %.8
$(call msg-gen, $@)
$(Q) $(GROFF) $(GROFF_OPTS) $^ > $@
%.pdf: %.ps
$(call msg-gen, $@)
$(Q) ps2pdf $< $@
clean:
$(call msg-clean, "Documentation")
$(Q) rm -f $(XMLS) $(MANS) $(PSS) $(PDFS) $(FOOTER)
install: check $(MANS)
$(E) " INSTALL " $(MAN8S)
$(Q) mkdir -p $(DESTDIR)$(MAN8DIR)
$(Q) install -m 644 $(MAN8S) $(DESTDIR)$(MAN8DIR)
$(E) " INSTALL " $(MAN1S)
$(Q) mkdir -p $(DESTDIR)$(MAN1DIR)
$(Q) install -m 644 $(MAN1S) $(DESTDIR)$(MAN1DIR)
uninstall:
$(E) " UNINSTALL" $(MAN1S)
$(Q) $(RM) $(addprefix $(DESTDIR)$(MAN1DIR)/,$(MAN1S))
$(E) " UNINSTALL" $(MAN8S)
$(Q) $(RM) $(addprefix $(DESTDIR)$(MAN8DIR)/,$(MAN8S))
.PHONY: clean install uninstall
crac-criu-1.5.0/Documentation/asciidoc.conf 0000664 0000000 0000000 00000000001 14715043267 0020623 0 ustar 00root root 0000000 0000000
crac-criu-1.5.0/Documentation/compel.txt 0000664 0000000 0000000 00000006574 14715043267 0020243 0 ustar 00root root 0000000 0000000 COMPEL(1)
==========
include::footer.txt[]
NAME
----
compel - Execute parasitic code within another process.
SYNOPSIS
--------
*compel* 'hgen' ['option' ...]
*compel* 'plugins' ['PLUGIN_NAME' ...]
*compel* ['--compat'] 'includes' | 'cflags' | 'ldflags'
*compel* ['--compat'] ['--static'] 'libs'
DESCRIPTION
------------
*compel* is a utility to execute arbitrary code, also called parasite code,
in the context of a foreign process. The parasitic code, once compiled with
compel flags and packed, can be executed in the context of other tasks. Currently
there is only one way to load the parasitic blob into victim task using libcompel.a,
called c-header.
ARGUMENTS
----------
Positional Arguments
~~~~~~~~~~~~~~~~~~~~
*hgen*::
create a header from the .po file, which is the parasite binary.
*plugins*::
prints the plugins available.
*ldflags*::
prints the ldflags available to compel during linking of parasite code.
*cflags*::
prints the compel cflags to be used during compilation of parasitic code.
*includes*::
prints list of standard include directories.
*libs*::
prints list of static or dynamic libraries that compel can link with.
OPTIONS
--------
*-f*, *--file* 'FILE'::
Path to the binary file, 'FILE', which *compel* must turn into a header
*-o*, *--output* 'FILE'::
Path to the header file, 'FILE', where compel must write the resulting header.
*-p*, *--prefix* 'NAME'::
Specify prefix for var names
*-l*, *--log-level* 'NUM'::
Default log level of compel.
*-h*, *--help*::
Prints usage and exits.
*-V*, *--version*::
Prints version number of compel.
SOURCE EXAMPLES
----------------
Parasitic Code
~~~~~~~~~~~~~~
*#include *
*int parasite_trap_cmd(int cmd, void *args);* //gets called by compel_run_in_thread()
*int parasite_daemon_cmd(int cmd, void *arg);* // gets called by compel_rpc_call() and compel_rpc_call_sync()
*void parasite_cleanup(void);* //gets called on parasite unload by compel_cure()
Infecting code
~~~~~~~~~~~~~~
The parasitic code is compiled and converted to a header using *compel*, and included here.
*#include *
*#include "parasite.h"*
Following steps are performed to infect the victim process:
- stop the task: *int compel_stop_task(int pid);*
- prepare infection handler: *struct parasite_ctl *compel_prepare(int pid);*
- execute system call: *int compel_syscall(ctl, int syscall_nr, long *ret, int arg ...);*
- infect victim: *int compel_infect(ctl, nr_thread, size_of_args_area);*
- cure the victim: *int compel_cure(ctl);* //ctl pointer is freed by this call
- Resume victim: *int compel_resume_task(pid, orig_state, state)* or
*int compel_resume_task_sig(pid, orig_state, state, stop_signo).*
//compel_resume_task_sig() could be used in case when victim is in stopped state.
stop_signo could be read by calling compel_parse_stop_signo().
*ctl* must be configured with blob information by calling *PREFIX_setup_c_header()*, with ctl as its argument.
*PREFIX* is the argument given to *-p* when calling hgen, else it is deduced from file name.
EXAMPLES
---------
To generate a header file(.h) from a parasite binary file(.po) use:
----------
compel hgen -f parasite.po -o parasite.h
----------
'parasite.po' file is obtained by compiling the parasite source with compel flags and
linking it with the compel plugins.
AUTHOR
------
The CRIU team.
crac-criu-1.5.0/Documentation/crit.txt 0000664 0000000 0000000 00000001460 14715043267 0017712 0 ustar 00root root 0000000 0000000 CRIT(1)
=======
include::footer.txt[]
NAME
----
crit - CRiu Image Tool
SYNOPSIS
--------
*crit* 'decode' [-h] [-i IN] [-o OUT] [--pretty]
*crit* 'encode' [-h] [-i IN] [-o OUT]
*crit* 'info' [-h] in
*crit* 'x' [-h] dir {ps,fds,mems}
*crit* 'show' [-h] in
DESCRIPTION
-----------
*crit* is a feature-rich replacement for existing *criu* show.
ARGUMENTS
---------
Positional Arguments
~~~~~~~~~~~~~~~~~~~~
*decode*::
convert *criu* image from binary type JSON
*encode*::
convert *criu* image from JSON type to binary
*info*::
show info about image
*x*::
explore image directory
*show*::
convert *criu* image from binary to human-readable JSON
Optional Arguments
~~~~~~~~~~~~~~~~~~
*-h*, *--help*::
Print some help and exit
SEE ALSO
--------
criu(8)
AUTHOR
------
The CRIU team
crac-criu-1.5.0/Documentation/criu-amdgpu-plugin.txt 0000664 0000000 0000000 00000006334 14715043267 0022467 0 ustar 00root root 0000000 0000000 ROCM Support(1)
===============
NAME
----
criu-amdgpu-plugin - A plugin extension to CRIU to support checkpoint/restore in
userspace for AMD GPUs.
CURRENT SUPPORT
---------------
Single and Multi GPU systems (Gfx9)
Checkpoint / Restore on different system
Checkpoint / Restore inside a docker container
Pytorch
Tensorflow
Using CRIU Image Streamer
DESCRIPTION
-----------
Though *criu* is a great tool for checkpointing and restoring running
applications, it has certain limitations such as it cannot handle
applications that have device files open. In order to support *ROCm* based
workloads with *criu* we need to augment criu's core functionality with a
plugin based extension mechanism. *criu-amdgpu-plugin* provides the necessary support
to criu to allow Checkpoint / Restore with ROCm.
Dependencies
~~~~~~~~~~~~~~
*amdkfd support*::
In order to snapshot the *VRAM* and other *GPU* device states, we require
an updated version of amdkfd(amdgpu) driver. The kernel patches are under
review currently.
*criu 3.16*::
This work is rebased on latest criu release available at this time.
OPTIONS
-------
Optional parameters can be passed in as environment variables before
executing criu command.
*KFD_FW_VER_CHECK*::
Enable or disable firmware version check.
If enabled, firmware version on restored gpu needs to be greater than or
equal firmware version on checkpointed GPU. Default:Enabled
E.g:
KFD_FW_VER_CHECK=0
*KFD_SDMA_FW_VER_CHECK*::
Enable or disable SDMA firmware version check.
If enabled, SDMA firmware version on restored gpu needs to be greater than or
equal firmware version on checkpointed GPU. Default:Enabled
E.g:
KFD_SDMA_FW_VER_CHECK=0
*KFD_CACHES_COUNT_CHECK*::
Enable or disable caches count check. If enabled, the caches count on
restored GPU needs to be greater than or equal caches count on checkpointed
GPU. Default:Enabled
E.g:
KFD_CACHES_COUNT_CHECK=0
*KFD_NUM_GWS_CHECK*::
Enable or disable num_gws check. If enabled, the num_gws on
restored GPU needs to be greater than or equal num_gws on checkpointed
GPU. Default:Enabled
E.g:
KFD_NUM_GWS_CHECK=0
*KFD_VRAM_SIZE_CHECK*::
Enable or disable VRAM size check. If enabled, the VRAM size on
restored GPU needs to be greater than or equal VRAM size on checkpointed
GPU. Default:Enabled
E.g:
KFD_VRAM_SIZE_CHECK=0
*KFD_NUMA_CHECK*::
Enable or disable NUMA CPU region check. If enabled, the plugin will restore
GPUs that belong to one CPU NUMA region to the same CPU NUMA region.
Default:Enabled
E.g:
KFD_NUMA_CHECK=1
*KFD_CAPABILITY_CHECK*::
Enable or disable capability check. If enabled, the capability on
restored GPU needs to be equal to the capability on the checkpointed GPU.
Default:Enabled
E.g:
KFD_CAPABILITY_CHECK=1
*KFD_MAX_BUFFER_SIZE*::
On some systems, VRAM sizes may exceed RAM sizes, and so buffers for dumping
and restoring VRAM may be unable to fit. Set to a nonzero value (in bytes)
to set a limit on the plugin's memory usage.
Default:0 (Disabled)
E.g:
KFD_MAX_BUFFER_SIZE="2G"
AUTHOR
------
The AMDKFD team.
COPYRIGHT
---------
Copyright \(C) 2020-2021, Advanced Micro Devices, Inc. (AMD)
crac-criu-1.5.0/Documentation/criu-ns.txt 0000664 0000000 0000000 00000001145 14715043267 0020331 0 ustar 00root root 0000000 0000000 CRIU-NS(1)
==========
include::footer.txt[]
NAME
----
criu-ns - run criu in different namespaces
SYNOPSIS
--------
*criu-ns* 'dump' -t PID []
*criu-ns* 'pre-dump' -t PID []
*criu-ns* 'restore' []
*criu-ns* 'check' []
DESCRIPTION
-----------
The *criu-ns* command executes 'criu' in a new PID and mount namespace.
The purpose of this wrapper script is to enable restoring a process tree
that might require a specific PID that is already used on the system;
so called "PID mismatch" problem.
SEE ALSO
--------
nsenter(1) namespaces(7) criu(8)
AUTHOR
------
The CRIU team
crac-criu-1.5.0/Documentation/criu.txt 0000664 0000000 0000000 00000110616 14715043267 0017717 0 ustar 00root root 0000000 0000000 CRIU(8)
=======
include::footer.txt[]
NAME
----
criu - checkpoint/restore in userspace
SYNOPSIS
--------
*criu* 'command' ['option' ...]
DESCRIPTION
-----------
*criu* is a tool for checkpointing and restoring running applications.
It does this by saving their state as a collection of files (see the *dump*
command) and creating equivalent processes from those files (see the *restore*
command). The restore operation can be performed at a later time,
on a different system, or both.
OPTIONS
-------
Most of the long flags can be
prefixed with *no-* to negate the option (example: *--display-stats*
and *--no-display-stats*).
Common options
~~~~~~~~~~~~~~
Common options are applicable to any 'command'.
*-v*[*v*...], *--verbosity*::
Increase verbosity up from the default level. In case of short option,
multiple *v* can be used, each increasing verbosity by one.
**-v**__num__, **--verbosity=**__num__::
Set verbosity level to _num_. The higher the level, the more output
is produced.
+
The following levels are available:
* *-v0*
no output;
* *-v1*
only errors;
* *-v2*
above plus warnings (this is the default level);
* *-v3*
above plus information messages and timestamps;
* *-v4*
above plus lots of debug.
*--config* 'file'::
Pass a specific configuration file to criu.
*--no-default-config*::
Disable parsing of default configuration files.
*--pidfile* 'file'::
Write root task, service or page-server pid into a 'file'.
*-o*, *--log-file* 'file'::
Write logging messages to a 'file'.
*--display-stats*::
During dump, as well as during restore, *criu* collects some statistics,
like the time required to dump or restore the process, or the
number of pages dumped or restored. This information is always
saved to the *stats-dump* and *stats-restore* files, and can
be shown using *crit*(1). The option *--display-stats*
prints out this information on the console at the end
of a dump or restore operation.
*-D*, *--images-dir* 'path'::
Use 'path' as a base directory where to look for sets of image files.
*--stream*::
dump/restore images using criu-image-streamer.
See https://github.com/checkpoint-restore/criu-image-streamer for detailed
usage.
*--prev-images-dir* 'path'::
Use 'path' as a parent directory where to look for sets of image files.
This option makes sense in case of incremental dumps.
*-W*, *--work-dir* 'dir'::
Use directory 'dir' for putting logs, pidfiles and statistics. If not
specified, 'path' from *-D* option is taken.
*--close* 'fd'::
Close file descriptor 'fd' before performing any actions.
*-L*, *--libdir* 'path'::
Path to plugins directory.
*--enable-fs* ['fs'[,'fs'...]]::
Specify a comma-separated list of filesystem names that should
be auto-detected. The value 'all' enables auto-detection for
all filesystems.
+
Note: This option is not safe, use at your own risk.
Auto-detecting a filesystem mount assumes that the mountpoint can
be restored with *mount(src, mountpoint, flags, options)*. When used,
*dump* is expected to always succeed if a mountpoint is to be
auto-detected, however *restore* may fail (or do something wrong)
if the assumption for restore logic is incorrect. This option is
not compatible with *--external* *dev*.
*--action-script* 'script'::
Add an external action script to be executed at certain stages.
The environment variable *CRTOOLS_SCRIPT_ACTION* is available
to the script to find out which action is being executed, and
its value can be one of the following:
*pre-dump*:::
run prior to beginning a *dump*
*post-dump*:::
run upon *dump* completion
*pre-restore*:::
run prior to beginning a *restore*
*post-restore*:::
run upon *restore* completion
*pre-resume*:::
run when all processes and resources are
restored but tasks are stopped waiting for
final kick to run. Must not fail.
*post-resume*:::
called at the very end, when everything is
restored and processes were resumed
*network-lock*:::
run to lock network in a target network namespace
*network-unlock*:::
run to unlock network in a target network namespace
*setup-namespaces*:::
run once root task has just been created
with required namespaces. Note it is an early stage
of restore, when nothing is restored yet, except for
namespaces themselves
*post-setup-namespaces*:::
called after the namespaces are configured
*orphan-pts-master*:::
called after master pty is opened and unlocked. This
hook can be used only in the RPC mode, and the
notification message contains a file descriptor for
the master pty
*query-ext-files*:::
called after the process tree is stopped and network is locked.
This hook is used only in the RPC mode. The notification reply
contains file ids to be added to external file list (may be empty).
*--unprivileged*::
This option tells *criu* to accept the limitations when running
as non-root. Running as non-root requires *criu* at least to have
*CAP_SYS_ADMIN* or *CAP_CHECKPOINT_RESTORE*. For details about running
*criu* as non-root please consult the *NON-ROOT* section.
*-V*, *--version*::
Print program version and exit.
*-h*, *--help*::
Print some help and exit.
*pre-dump*
~~~~~~~~~~
Performs the pre-dump procedure, during which *criu* creates a snapshot of
memory changes since the previous *pre-dump*. Note that during this
*criu* also creates the fsnotify cache which speeds up the *restore*
procedure. *pre-dump* requires at least *-t* option (see *dump* below).
In addition, *page-server* options may be specified.
*--track-mem*::
Turn on memory changes tracker in the kernel. If the option is
not passed the memory tracker get turned on implicitly.
*--pre-dump-mode*='mode'::
There are two 'mode' to operate pre-dump algorithm. The 'splice' mode
is parasite based, whereas 'read' mode is based on process_vm_readv
syscall. The 'read' mode incurs reduced frozen time and reduced
memory pressure as compared to 'splice' mode. Default is 'splice' mode.
*dump*
~~~~~~
Performs a checkpoint procedure.
*-t*, *--tree* 'pid'::
Checkpoint the whole process tree starting from 'pid'.
*-R*, *--leave-running*::
Leave tasks in running state after checkpoint, instead of killing. This
option is pretty dangerous and should be used only if you understand
what you are doing.
+
Note if task is about to run after been checkpointed, it can modify
TCP connections, delete files and do other dangerous actions. Therefore,
*criu* can not guarantee that the next *restore* action will succeed.
Most likely if this option is used, at least the file system snapshot
must be made with the help of *post-dump* action script.
+
In other words, do not use it unless really needed.
*-s*, *--leave-stopped*::
Leave tasks in stopped state after checkpoint, instead of killing.
*--external* __type__**[**__id__**]:**__value__::
Dump an instance of an external resource. The generic syntax is
'type' of resource, followed by resource 'id' (enclosed in literal
square brackets), and optional 'value' (prepended by a literal colon).
The following resource types are currently supported: *mnt*, *dev*,
*file*, *tty*, *unix*. Syntax depends on type.
Note to restore external resources, either *--external* or *--inherit-fd*
is used, depending on resource type.
*--external* **mnt[**__mountpoint__**]:**__name__::
Dump an external bind mount referenced by 'mountpoint', saving it
to image under the identifier 'name'.
*--external* **mnt[]:**__flags__::
Dump all external bind mounts, autodetecting those. Optional 'flags'
can contain *m* to also dump external master mounts, *s* to also
dump external shared mounts (default behavior is to abort dumping
if such mounts are found). If 'flags' are not provided, colon
is optional.
*--external* **dev[**__major__**/**__minor__**]:**__name__::
Allow to dump a mount namespace having a real block device mounted.
A block device is identified by its 'major' and 'minor' numbers,
and *criu* saves its information to image under the identifier 'name'.
*--external* **file[**__mnt_id__**:**__inode__**]**::
Dump an external file, i.e. an opened file that is can not be resolved
from the current mount namespace, which can not be dumped without using
this option. The file is identified by 'mnt_id' (a field obtained from
**/proc/**__pid__**/fdinfo/**__N__) and 'inode' (as returned by
*stat*(2)).
*--external* **tty[**__rdev__**:**__dev__**]**::
Dump an external TTY, identified by *st_rdev* and *st_dev* fields
returned by *stat*(2).
*--external* **unix[**__id__**]**::
Tell *criu* that one end of a pair of UNIX sockets (created by
*socketpair*(2)) with the given _id_ is OK to be disconnected.
*--external* **net[**__inode__**]:**__name__::
Mark a network namespace as external and do not include it in the
checkpoint. The label 'name' can be used with *--inherit-fd* during
restore to specify a file descriptor to a preconfigured network
namespace.
*--external* **pid[**__inode__**]:**__name__::
Mark a PID namespace as external. This can be later used to restore
a process into an existing PID namespace. The label 'name' can be
used to assign another PID namespace during restore with the help
of *--inherit-fd*.
*--freeze-cgroup*::
Use cgroup freezer to collect processes.
*--manage-cgroups*::
Collect cgroups into the image thus they gonna be restored then.
Without this option, *criu* will not save cgroups configuration
associated with a task.
*--cgroup-props* 'spec'::
Specify controllers and their properties to be saved into the
image file. *criu* predefines specifications for common controllers,
but since the kernel can add new controllers and modify their
properties, there should be a way to specify ones matched the kernel.
+
'spec' argument describes the controller and properties specification in
a simplified YAML form:
+
----------
"c1":
- "strategy": "merge"
- "properties": ["a", "b"]
"c2":
- "strategy": "replace"
- "properties": ["c", "d"]
----------
+
where 'c1' and 'c2' are controllers names, and 'a', 'b', 'c', 'd' are
their properties.
+
Note the format: double quotes, spaces and new lines are required.
The 'strategy' specifies what to do if a controller specified already
exists as a built-in one: *criu* can either *merge* or *replace* such.
+
For example, the command line for the above example should look like this:
+
----------
--cgroup-props "\"c1\":\n - \"strategy\": \"merge\"\n - \"properties\": [\"a\", \"b\"]\n \"c2\":\n - \"strategy\": \"replace\"\n - \"properties\": [\"c\", \"d\"]"
----------
*--cgroup-props-file* 'file'::
Same as *--cgroup-props*, except the specification is read from
the 'file'.
*--cgroup-dump-controller* 'name'::
Dump a controller with 'name' only, skipping anything else that was
discovered automatically (usually via */proc*). This option is
useful when one needs *criu* to skip some controllers.
*--cgroup-yard* 'path'::
Instead of trying to mount cgroups in CRIU, provide a path to a directory
with already created cgroup yard. Useful if you don't want to grant
CAP_SYS_ADMIN to CRIU. For every cgroup mount there should be exactly one
directory. If there is only one controller in this mount, the dir's name
should be just the name of the controller. If there are multiple controllers
comounted, the directory name should have them be separated by a comma.
+
For example, if */proc/cgroups* looks like this:
+
----------
#subsys_name hierarchy num_cgroups enabled
cpu 1 1 1
devices 2 2 1
freezer 2 2 1
----------
+
then you can create the cgroup yard by the following commands:
+
----------
mkdir private_yard
cd private_yard
mkdir cpu
mount -t cgroup -o cpu none cpu
mkdir devices,freezer
mount -t cgroup -o devices,freezer none devices,freezer
----------
*--tcp-established*::
Checkpoint established TCP connections.
*--tcp-close*::
Don't dump the state of, or block, established tcp connections
(including the connection is once established but now closed).
This is useful when tcp connections are not going to be restored.
*--skip-in-flight*::
This option skips in-flight TCP connections. If any TCP connections
that are not yet completely established are found, *criu* ignores
these connections, rather than errors out.
The TCP stack on the client side is expected to handle the
re-connect gracefully.
*--evasive-devices*::
Use any path to a device file if the original one is inaccessible.
*--page-server*::
Send pages to a page server (see the *page-server* command).
*--force-irmap*::
Force resolving names for inotify and fsnotify watches.
*--auto-dedup*::
Deduplicate "old" data in pages images of previous *dump*. This option
implies incremental *dump* mode (see the *pre-dump* command).
*-l*, *--file-locks*::
Dump file locks. It is necessary to make sure that all file lock users
are taken into dump, so it is only safe to use this for enclosed containers
where locks are not held by any processes outside of dumped process tree.
*--link-remap*::
Allows to link unlinked files back, if possible (modifies filesystem
during *restore*).
*--timeout* 'number'::
Set a time limit in seconds for collecting tasks during the
dump operation. The timeout is 10 seconds by default.
*--ghost-limit* 'size'::
Set the maximum size of deleted file to be carried inside image.
By default, up to 1M file is allowed. Using this
option allows to not put big deleted files inside images. Argument
'size' may be postfixed with a *K*, *M* or *G*, which stands for kilo-,
mega, and gigabytes, accordingly.
*--ghost-fiemap*::
Enable an optimization based on fiemap ioctl that can reduce the
number of system calls used when checkpointing highly sparse ghost
files. This option is enabled by default, and it can be disabled
with *--no-ghost-fiemap*. An automatic fallback to SEEK_HOLE/SEEK_DATA
is used when fiemap is not supported.
*-j*, *--shell-job*::
Allow one to dump shell jobs. This implies the restored task will
inherit session and process group ID from the *criu* itself.
This option also allows to migrate a single external tty connection,
to migrate applications like *top*. If used with *dump* command,
it must be specified with *restore* as well.
*--cpu-cap* ['cap'[,'cap'...]]::
Specify CPU capabilities to write to an image file. The argument is a
comma-separated list of:
+
- *none* to ignore capabilities at all; the image will not be produced
on dump, neither any check performed on restore;
- *fpu* to check if FPU module is compatible;
- *ins* to check if CPU supports all instructions required;
- *cpu* to check if CPU capabilities are exactly matching;
- *all* for all above set.
+
By default the option is set to *fpu* and *ins*.
*--cgroup-root* ['controller':]/'newroot'::
Change the root for the controller that will be dumped. By default, *criu*
simply dumps everything below where any of the tasks live. However, if a
container moves all of its tasks into a cgroup directory below the container
engine's default directory for tasks, permissions will not be preserved on
the upper directories with no tasks in them, which may cause problems.
*--lazy-pages*::
Perform the dump procedure without writing memory pages into the
image files and prepare to service page requests over the
network. When *dump* runs in this mode it presumes that
*lazy-pages* daemon will connect to it and fetch memory pages to
lazily inject them into the restored process address space. This
option is intended for post-copy (lazy) migration and should be
used in conjunction with *restore* with appropriate options.
*--file-validation* ['mode']::
Set the method to be used to validate open files. Validation is done
to ensure that the version of the file being restored is the same
version when it was dumped.
+
The 'mode' may be one of the following:
*filesize*:::
To explicitly use only the file size check all the time.
This is the fastest and least intensive check.
*buildid*:::
To validate ELF files with their build-ID. If the
build-ID cannot be obtained, 'chksm-first' method will be
used. This is the default if mode is unspecified.
*--network-lock* ['mode']::
Set the method to be used for network locking/unlocking. Locking is done
to ensure that tcp packets are dropped between dump and restore. This is
done to avoid the kernel sending RST when a packet arrives destined for
the dumped process.
+
The 'mode' may be one of the following:
*iptables*::: Use iptables rules to drop the packets.
This is the default if 'mode' is not specified.
*nftables*::: Use nftables rules to drop the packets.
*skip*::: Don't lock the network. If *--tcp-close* is not used, the network
must be locked externally to allow CRIU to dump TCP connections.
*restore*
~~~~~~~~~
Restores previously checkpointed processes.
*--inherit-fd* **fd[**__N__**]:**__resource__::
Inherit a file descriptor. This option lets *criu* use an already opened
file descriptor 'N' for restoring a file identified by 'resource'.
This option can be used to restore an external resource dumped
with the help of *--external* *file*, *tty*, *pid* and *unix* options.
+
The 'resource' argument can be one of the following:
+
- **tty[**__rdev__**:**__dev__**]**
- **pipe[**__inode__**]**
- **socket[**__inode__*]*
- **file[**__mnt_id__**:**__inode__**]**
- 'path/to/file'
+
Note that square brackets used in this option arguments are literals and
usually need to be escaped from shell.
*-d*, *--restore-detached*::
Detach *criu* itself once restore is complete.
*-s*, *--leave-stopped*::
Leave tasks in stopped state after restore (rather than resuming
their execution).
*-S*, *--restore-sibling*::
Restore root task as a sibling (makes sense only with
*--restore-detached*).
*--log-pid*::
Write separate logging files per each pid.
*-r*, *--root* 'path'::
Change the root filesystem to 'path' (when run in a mount namespace).
This option is required to restore a mount namespace. The directory
'path' must be a mount point and its parent must not be overmounted.
*--external* __type__**[**__id__**]:**__value__::
Restore an instance of an external resource. The generic syntax is
'type' of resource, followed by resource 'id' (enclosed in literal
square brackets), and optional 'value' (prepended by a literal colon).
The following resource types are currently supported: *mnt*, *dev*,
*veth*, *macvlan*. Syntax depends on type. Note to restore external
resources dealing with opened file descriptors (such as dumped with
the help of *--external* *file*, *tty*, and *unix* options), option
*--inherit-fd* should be used.
*--external* **mnt[**__name__**]:**__mountpoint__::
Restore an external bind mount referenced in the image by 'name',
bind-mounting it from the host 'mountpoint' to a proper mount point.
*--external mnt[]*::
Restore all external bind mounts (dumped with the help of
*--external mnt[]* auto-detection).
*--external* **dev[**__name__**]:**__/dev/path__::
Restore an external mount device, identified in the image by 'name',
using the existing block device '/dev/path'.
*--external* **veth[**__inner_dev__**]:**__outer_dev__**@**__bridge__::
Set the outer VETH device name (corresponding to 'inner_dev' being
restored) to 'outer_dev'. If optional **@**_bridge_ is specified,
'outer_dev' is added to that bridge. If the option is not used,
'outer_dev' will be autogenerated by the kernel.
*--external* **macvlan[**__inner_dev__**]:**__outer_dev__::
When restoring an image that have a MacVLAN device in it, this option
must be used to specify to which 'outer_dev' (an existing network device
in CRIU namespace) the restored 'inner_dev' should be bound to.
*-J*, *--join-ns* **NS**:{**PID**|**NS_FILE**}[,**EXTRA_OPTS**]::
Restore process tree inside an existing namespace. The namespace can
be specified in 'PID' or 'NS_FILE' path format (example:
*--join-ns net:12345* or *--join-ns net:/foo/bar*). Currently supported
values for **NS** are: *ipc*, *net*, *time*, *user*, and *uts*.
This option doesn't support joining a PID namespace, however, this is
possible using *--external* and *--inheritfd*. 'EXTRA_OPTS' is optional
and can be used to specify UID and GID for user namespace (e.g.,
*--join-ns user:PID,UID,GID*).
*--manage-cgroups* ['mode']::
Restore cgroups configuration associated with a task from the image.
Controllers are always restored in an optimistic way -- if already present
in system, *criu* reuses it, otherwise it will be created.
+
The 'mode' may be one of the following:
*none*::: Do not restore cgroup properties but require cgroup to
pre-exist at the moment of *restore* procedure.
*props*::: Restore cgroup properties and require cgroup to pre-exist.
*soft*::: Restore cgroup properties if only cgroup has been created
by *criu*, otherwise do not restore properties. This is the
default if mode is unspecified.
*full*::: Always restore all cgroups and their properties.
*strict*::: Restore all cgroups and their properties from the scratch,
requiring them to not present in the system.
*ignore*::: Don't deal with cgroups and pretend that they don't exist.
*--cgroup-yard* 'path'::
Instead of trying to mount cgroups in CRIU, provide a path to a directory
with already created cgroup yard. For more information look in the *dump*
section.
*--cgroup-root* ['controller'*:*]/'newroot'::
Change the root cgroup the controller will be installed into. No controller
means that root is the default for all controllers not specified.
*--tcp-established*::
Restore previously dumped established TCP connections. This implies that
the network has been locked between *dump* and *restore* phases so other
side of a connection simply notice a kind of lag.
*--tcp-close*::
Restore connected TCP sockets in closed state.
*--veth-pair* __IN__**=**__OUT__::
Correspondence between outside and inside names of veth devices.
*-l*, *--file-locks*::
Restore file locks from the image.
*--lsm-profile* __type__**:**__name__::
Specify an LSM profile to be used during restore. The _type_ can be
either *apparmor* or *selinux*.
*--lsm-mount-context* 'context'::
Specify a new mount context to be used during restore.
+
This option will only replace existing mount context information
with the one specified with this option. Mounts without the
'context=' option will not be changed.
+
If a mountpoint has been checkpointed with an option like
context="system_u:object_r:container_file_t:s0:c82,c137"
+
it is possible to change this option using
--lsm-mount-context "system_u:object_r:container_file_t:s0:c204,c495"
+
which will result that the mountpoint will be restored
with the new 'context='.
+
This option is useful if using *selinux* and if the *selinux*
labels need to be changed on restore like if a container is
restored into an existing Pod.
*--auto-dedup*::
As soon as a page is restored it get punched out from image.
*-j*, *--shell-job*::
Restore shell jobs, in other words inherit session and process group
ID from the criu itself.
*--cpu-cap* ['cap'[,'cap'...]]::
Specify CPU capabilities to be present on the CPU the process is
restoring. To inverse a capability, prefix it with *^*. This option implies
that *--cpu-cap* has been passed on *dump* as well, except *fpu* option
case. The 'cap' argument can be the following (or a set of comma-separated
values):
*all*::: Require all capabilities. This is *default* mode if *--cpu-cap*
is passed without arguments. Most safe mode.
*cpu*::: Require the CPU to have all capabilities in image to match
runtime CPU.
*fpu*::: Require the CPU to have compatible FPU. For example the process
might be dumped with xsave capability but attempted to restore
without it present on target CPU. In such case we refuse to
proceed. This is *default* mode if *--cpu-cap* is not present
in command line. Note this argument might be passed even if
on the *dump* no *--cpu-cap* have been specified because FPU
frames are always encoded into images.
*ins*::: Require CPU compatibility on instructions level.
*none*::: Ignore capabilities. Most dangerous mode. The behaviour is
implementation dependent. Try to not use it until really
required.
+
For example, this option can be used in case *--cpu-cap=cpu* was used
during *dump*, and images are migrated to a less capable CPU and are
to be restored. By default, *criu* shows an error that CPU capabilities
are not adequate, but this can be suppressed by using *--cpu-cap=none*.
*--weak-sysctls*::
Silently skip restoring sysctls that are not available. This allows
to restore on an older kernel, or a kernel configured without some
options.
*--lazy-pages*::
Restore the processes without filling out the entire memory
contents. When this option is used, *restore* sets up the
infrastructure required to fill memory pages either on demand when
the process accesses them or in the background without stopping the
restored process.
This option requires running *lazy-pages* daemon.
*--file-validation* ['mode']::
Set the method to be used to validate open files. Validation is done
to ensure that the version of the file being restored is the same
version when it was dumped.
+
The 'mode' may be one of the following:
*filesize*:::
To explicitly use only the file size check all the time.
This is the fastest and least intensive check.
*buildid*:::
To validate ELF files with their build-ID. If the
build-ID cannot be obtained, 'chksm-first' method will be
used. This is the default if mode is unspecified.
*--skip-file-rwx-check*::
Skip checking file permissions (r/w/x for u/g/o) on restore.
*check*
~~~~~~~
Checks whether the kernel supports the features needed by *criu* to
dump and restore a process tree.
There are three categories of kernel support, as described below. *criu
check* always checks Category 1 features unless *--feature* is specified
which only checks a specified feature.
*Category 1*::: Absolutely required. These are features like support for
*/proc/PID/map_files*, *NETLINK_SOCK_DIAG* socket
monitoring, */proc/sys/kernel/ns_last_pid* etc.
*Category 2*::: Required only for specific cases. These are features
like AIO remap, */dev/net/tun* and others that are only
required if a process being dumped or restored
is using those.
*Category 3*::: Experimental. These are features like *task-diag* that
are used for experimental purposes (mostly
during development).
If there are no errors or warnings, *criu* prints "Looks good." and its
exit code is 0.
A missing Category 1 feature causes *criu* to print "Does not look good."
and its exit code is non-zero.
Missing Category 2 and 3 features cause *criu* to print "Looks good but
..." and its exit code is be non-zero.
Without any options, *criu check* checks Category 1 features. This
behavior can be changed by using the following options:
*--extra*::
Check kernel support for Category 2 features.
*--experimental*::
Check kernel support for Category 3 features.
*--all*::
Check kernel support for Category 1, 2, and 3 features.
*--feature* 'name'::
Check a specific feature. If 'name' is *list*, a list of valid
kernel feature names that can be checked will be printed.
*page-server*
~~~~~~~~~~~~~
Launches *criu* in page server mode.
*--daemon*::
Runs page server as a daemon (background process).
*--status-fd*::
Write \0 to the FD and close it once page-server is ready to handle
requests. The status-fd allows to not daemonize a process and get its
exit code at the end.
It isn't supposed to use --daemon and --status-fd together.
*--address* 'address'::
Page server IP address or hostname.
*--port* 'number'::
Page server port number.
*--ps-socket* 'fd'::
Use provided file descriptor as socket for incoming connection.
In this case --address and --port are ignored.
Useful for intercepting page-server traffic e.g. to add encryption
or authentication.
*--lazy-pages*::
Serve local memory dump to a remote *lazy-pages* daemon. In this
mode the *page-server* reads local memory dump and allows the
remote *lazy-pages* daemon to request memory pages in random
order.
*--tls-cacert* 'file'::
Specifies the path to a trusted Certificate Authority (CA) certificate
file to be used for verification of a client or server certificate.
The 'file' must be in PEM format. When this option is used only the
specified CA is used for verification. Otherwise, the system's trusted CAs
and, if present, '/etc/pki/CA/cacert.pem' will be used.
*--tls-cacrl* 'file'::
Specifies a path to a Certificate Revocation List (CRL) 'file' which
contains a list of revoked certificates that should no longer be trusted.
The 'file' must be in PEM format. When this option is not specified, the
file, if present, '/etc/pki/CA/cacrl.pem' will be used.
*--tls-cert* 'file'::
Specifies a path to a file that contains a X.509 certificate to present
to the remote entity. The 'file' must be in PEM format. When this option
is not specified, the default location ('/etc/pki/criu/cert.pem') will be
used.
*--tls-key* 'file'::
Specifies a path to a file that contains TLS private key. The 'file' must
be in PEM format. When this option is not the default location
('/etc/pki/criu/private/key.pem') will be used.
*--tls*::
Use TLS to secure remote connections.
*lazy-pages*
~~~~~~~~~~~~
Launches *criu* in lazy-pages daemon mode.
The *lazy-pages* daemon is responsible for managing user-level demand
paging for the restored processes. It gets information required to
fill the process memory pages from the *restore* and from the
checkpoint directory. When a restored process access certain memory
page for the first time, the *lazy-pages* daemon injects its contents
into the process address space. The memory pages that are not yet
requested by the restored processes are injected in the background.
*exec*
~~~~~~
Executes a system call inside a destination task\'s context. This functionality
is deprecated; please use *Compel* instead.
*service*
~~~~~~~~~
Launches *criu* in RPC daemon mode, where *criu* is listening for
RPC commands over socket to perform. This is convenient for a
case where daemon itself is running in a privileged (superuser) mode
but clients are not.
dedup
~~~~~
Starts pagemap data deduplication procedure, where *criu* scans over all
pagemap files and tries to minimize the number of pagemap entries by
obtaining the references from a parent pagemap image.
cpuinfo dump
~~~~~~~~~~~~
Fetches current CPU features and write them into an image file.
cpuinfo check
~~~~~~~~~~~~~
Fetches current CPU features (i.e. CPU the *criu* is running on) and test if
they are compatible with the ones present in an image file.
CONFIGURATION FILES
-------------------
*Criu* supports usage of configuration files to avoid the need of writing every
option on command line, which is useful especially with repeated usage of
same options. A specific configuration file can be passed with
the "*--config* 'file'" option. If no file is passed, the default configuration
files '/etc/criu/default.conf' and '$HOME/.criu/default.conf' are parsed (if
present on the system). If the environment variable CRIU_CONFIG_FILE is set,
it will also be parsed.
The options passed to CRIU via CLI, RPC or configuration file are evaluated
in the following order:
- apply_config(/etc/criu/default.conf)
- apply_config($HOME/.criu/default.conf)
- apply_config(CRIU_CONFIG_FILE)
- apply_config(*--config* 'file')
- apply_config(CLI) or apply_config(RPC)
- apply_config(RPC configuration file) (only for RPC mode)
Default configuration file parsing can be deactivated
with "*--no-default-config*" if needed. Parsed configuration files are merged
with command line options, which allows overriding boolean options.
Configuration file syntax
~~~~~~~~~~~~~~~~~~~~~~~~~
Comments are supported using \'#' sign. The rest of the line is ignored.
Options are the same as command line options without the \'--' prefix, use
one option per line (with corresponding argument if applicable, divided by
whitespaces). If needed, the argument can be provided in double quotes (this
should be needed only if the argument contains whitespaces). In case this type
of argument contains a literal double quote as well, it can be escaped using
the \'\' sign. Usage of commands is disallowed and all other escape sequences
are interpreted literally.
Example of configuration file to illustrate syntax:
---------------
$ cat ~/.criu/default.conf
tcp-established
work-dir "/home/USERNAME/criu/my \"work\" directory"
#this is a comment
no-restore-sibling # this is another comment
---------------
Configuration files in RPC mode
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Not only does *criu* evaluate configuration files in CLI mode, it also
evaluates configuration files in RPC mode. Just as in CLI mode the
configuration file values are evaluated first. This means that any option
set via RPC will overwrite the configuration file setting. The user can
thus change *criu*'s default behavior but it is not possible to change
settings which are explicitly set by the RPC client.
The RPC client can, however, specify an additional configuration file
which will be evaluated after the RPC options (see above for option evaluation
order). The RPC client can specify this additional configuration file
via "req.opts.config_file = '/path/to/file'". The values from this
configuration file will overwrite all other configuration file settings
or RPC options. *This can lead to undesired behavior of criu and
should only be used carefully.*
NON-ROOT
--------
*criu* can be used as non-root with either the *CAP_SYS_ADMIN* capability
or with the *CAP_CHECKPOINT_RESTORE* capability introduces in Linux kernel 5.9.
*CAP_CHECKPOINT_RESTORE* is the minimum that is required.
*criu* also needs either *CAP_SYS_PTRACE* or a value of 0 in
*/proc/sys/kernel/yama/ptrace_scope* (see *ptrace*(2)) to be able to interrupt
the process for dumping.
Running *criu* as non-root has many limitations and depending on the process
to checkpoint and restore it may not be possible.
In addition to *CAP_CHECKPOINT_RESTORE* it is possible to give *criu* additional
capabilities to enable additional features in non-root mode.
Currently *criu* can benefit from the following additional capabilities:
- *CAP_NET_ADMIN*
- *CAP_SYS_CHROOT*
- *CAP_SETUID*
- *CAP_SYS_RESOURCE*
Note that for some operations, having a capability in a namespace other than
the init namespace (i.e. the default/root namespace) is not sufficient. For
example, in order to read symlinks in proc/[pid]/map_files CRIU requires
CAP_CHECKPOINT_RESTORE in the init namespace; having CAP_CHECKPOINT_RESTORE
while running in another user namespace (e.g. in a container) does not allow
CRIU to read symlinks in /proc/[pid]/map_files.
Without access to /proc/[pid]/map_files checkpointing/restoring processes
that have mapped deleted files may not be possible.
Independent of the capabilities it is always necessary to use "*--unprivileged*" to
accept *criu*'s limitation in non-root mode.
EXAMPLES
--------
To checkpoint a program with pid of *1234* and write all image files into
directory *checkpoint*:
----------
criu dump -D checkpoint -t 1234
----------
To restore this program detaching criu itself:
----------
criu restore -d -D checkpoint
----------
AUTHOR
------
The CRIU team.
COPYRIGHT
---------
Copyright \(C) 2011-2016, Parallels Holdings, Inc.
crac-criu-1.5.0/Documentation/custom.xsl 0000664 0000000 0000000 00000000424 14715043267 0020251 0 ustar 00root root 0000000 0000000
1
1
1
crac-criu-1.5.0/INSTALL.md 0000664 0000000 0000000 00000002323 14715043267 0015026 0 ustar 00root root 0000000 0000000 ## Installing CRIU from source code
Once CRIU is built one can easily setup the complete CRIU package
(which includes executable itself, CRIT tool, libraries, manual
and etc) simply typing
make install
this command accepts the following variables:
* **DESTDIR**, to specify global root where all components will be placed under (empty by default);
* **PREFIX**, to specify additional prefix for path of every component installed (`/usr/local` by default);
* **BINDIR**, to specify where to put CRIT tool (`$(PREFIX)/bin` by default);
* **SBINDIR**, to specify where to put CRIU executable (`$(PREFIX)/sbin` by default);
* **MANDIR**, to specify directory for manual pages (`$(PREFIX)/share/man` by default);
* **LIBDIR**, to specify directory where to put libraries (guess the correct path by default).
Thus one can type
make DESTDIR=/some/new/place install
and get everything installed under `/some/new/place`.
## Uninstalling CRIU
To clean up previously installed CRIU instance one can type
make uninstall
and everything should be removed. Note though that if some variable (**DESTDIR**, **BINDIR**
and such) has been used during installation procedure, the same *must* be passed with
uninstall action.
crac-criu-1.5.0/MAINTAINERS 0000664 0000000 0000000 00000000501 14715043267 0015067 0 ustar 00root root 0000000 0000000 Pavel Emelyanov (chief)
Andrey Vagin
Mike Rapoport
Dmitry Safonov <0x7f454c46@gmail.com>
Adrian Reber
Pavel Tikhomirov
Radostin Stoyanov
Alexander Mikhalitsyn
crac-criu-1.5.0/MAINTAINERS_GUIDE.md 0000664 0000000 0000000 00000014407 14715043267 0016415 0 ustar 00root root 0000000 0000000 ## Introduction
Dear maintainer. Thank you for investing the time and energy to help
make CRIU as useful as possible. Maintaining a project is difficult,
sometimes unrewarding work. Sure, you will contribute cool features
to the project, but most of your time will be spent reviewing patches,
cleaning things up, documenting, answering questions, justifying design
decisions - while everyone else will just have fun! But remember -- the
quality of the maintainers work is what distinguishes the good projects
from the great. So please be proud of your work, even the unglamorous
parts, and encourage a culture of appreciation and respect for *every*
aspect of improving the project -- not just the hot new features.
Being a maintainer is a time consuming commitment and should not be
taken lightly. This document is a manual for maintainers old and new.
It explains what is expected of maintainers, how they should work, and
what tools are available to them.
This is a living document - if you see something out of date or missing,
speak up!
## What are a maintainer's responsibility?
Part of a healthy project is to have active maintainers to support the
community in contributions and perform tasks to keep the project running.
It is every maintainer's responsibility to:
* Keep the community a friendly place
* Deliver prompt feedback and decisions on pull requests and mailing
list threads
* Encourage other members to help each other, especially in cases the
maintainer is overloaded or feels the lack of needed expertise
* Make sure the changes made respects the philosophy, design and
roadmap of the project
## How are decisions made?
CRIU is an open-source project with an open design philosophy. This
means that the repository is the source of truth for EVERY aspect of the
project. *If it's part of the project, it's in the repo. It's in the
repo, it's part of the project.*
All decisions affecting CRIU, big and small, follow the same 3 steps:
* Submit a change. Anyone can do this
* Discuss it. Anyone can and is encouraged to do this
* Accept or decline it. Only maintainers do this
*I'm a maintainer, should I make pull requests / send patches too?*
Yes. Nobody should ever push to the repository directly. All changes
should be made through submitting (and accepting) the change.
### Two-steps decision making ###
Since CRIU is extremely complex piece of software we try double hard
not to make mistakes, that would be hard to fix in the future. In order
to facilitate this, the "final" decision is made in two stages:
* We definitely want to try something out
* We think that the attempt was successful
Respectively, new features get accepted first into the *criu-dev* branch and
after they have been validated they are merged into the *master* branch. Yet,
urgent bug fixes may land directly in the master branch. If a change in
the criu-dev branch is considered to be bad (whatever it means), then it
can be reverted without propagation to the master branch. Reverting from
the master branch is expected not to happen at all, but if such an
extraordinary case occurs, the impact of this step, especially the question
of backward compatibility, should be considered in the most careful manner.
## Who decides what?
All decisions can be expressed as changes to the repository (either in the
form of pull requests, or patches sent to the mailing list), and maintainers
make decisions by merging or rejecting them. Review and approval or
disagreement can be done by anyone and is denoted by adding a respective
comment in the pull request. However, merging the change into either branch
only happens after approvals from maintainers.
In order for a patch to be merged into the criu-dev branch at least two
maintainers should accept it. In order for a patch to be merged into the
master branch the majority of maintainers should decide that (then prepare
a pull request, submit it, etc.).
Overall the maintainer system works because of mutual respect across the
maintainers of the project. The maintainers trust one another to make
decisions in the best interests of the project. Sometimes maintainers
can disagree and this is part of a healthy project to represent the point
of views of various people. In the case where maintainers cannot find
agreement on a specific change the role of a Chief Maintainer comes into
play.
### Chief maintainer
The chief maintainer for the project is responsible for overall architecture
of the project to maintain conceptual integrity. Large decisions and
architecture changes should be reviewed by the chief maintainer.
Also the chief maintainer has the veto power on any change submitted
to any branch. Naturally, a change in the criu-dev branch can be reverted
after a chief maintainer veto, a change in the master branch must be
carefully reviewed by the chief maintainer and vetoed in advance.
### How are maintainers added (and removed)?
The best maintainers have a vested interest in the project. Maintainers
are first and foremost contributors that have shown they are committed to
the long term success of the project. Contributors wanting to become
maintainers are expected to be deeply involved in contributing code,
patches review, and paying needed attention to the issues in the project.
Just contributing does not make you a maintainer, it is about building trust
with the current maintainers of the project and being a person that they can
rely on and trust to make decisions in the best interest of the project.
When a contributor wants to become a maintainer or nominate someone as a
maintainer, one can submit a "nomination", which technically is the
respective modification to the `MAINTAINERS` file. When a maintainer feels
they is unable to perform the required duties, or someone else wants to draw
the community attention to this fact, one can submit a "(self-)removing"
change.
The final vote to add or to remove a maintainer is to be approved by the
majority of current maintainers (with the chief maintainer having veto power
on that too).
One might have noticed, that the chief maintainer (re-)assignment is not
regulated by this document. That's true :) However, this can be done. If
the community decides that the chief maintainer needs to be changed the
respective "decision making rules" are to be prepared, submitted and
accepted into this file first.
Good luck!
crac-criu-1.5.0/Makefile 0000664 0000000 0000000 00000033340 14715043267 0015041 0 ustar 00root root 0000000 0000000 __nmk_dir=$(CURDIR)/scripts/nmk/scripts/
export __nmk_dir
#
# No need to try to remake our Makefiles
Makefile: ;
Makefile.%: ;
scripts/%.mak: ;
$(__nmk_dir)%.mk: ;
#
# Import the build engine
include $(__nmk_dir)include.mk
include $(__nmk_dir)macro.mk
ifeq ($(origin HOSTCFLAGS), undefined)
HOSTCFLAGS := $(CFLAGS) $(USERCFLAGS)
endif
#
# Supported Architectures
ifneq ($(filter-out x86 arm aarch64 ppc64 s390 mips loongarch64,$(ARCH)),)
$(error "The architecture $(ARCH) isn't supported")
endif
# The PowerPC 64 bits architecture could be big or little endian.
# They are handled in the same way.
ifeq ($(SUBARCH),ppc64)
error := $(error ppc64 big endian is not yet supported)
endif
#
# Architecture specific options.
ifeq ($(ARCH),arm)
ARMV := $(shell echo $(SUBARCH) | sed -nr 's/armv([[:digit:]]).*/\1/p; t; i7')
ifeq ($(ARMV),6)
ARCHCFLAGS += -march=armv6
endif
ifeq ($(ARMV),7)
ARCHCFLAGS += -march=armv7-a+fp
endif
ifeq ($(ARMV),8)
# Running 'setarch linux32 uname -m' returns armv8l on travis aarch64.
# This tells CRIU to handle armv8l just as armv7hf. Right now this is
# only used for compile testing. No further verification of armv8l exists.
ARCHCFLAGS += -march=armv7-a
ARMV := 7
endif
DEFINES := -DCONFIG_ARMV$(ARMV) -DCONFIG_VDSO_32
PROTOUFIX := y
# For simplicity - compile code in Arm mode without interwork.
# We could choose Thumb mode as default instead - but a dirty
# experiment shows that with 90Kb PIEs Thumb code doesn't save
# even one page. So, let's stick so far to Arm mode as it's more
# universal around all different Arm variations, until someone
# will find any use for Thumb mode. -dima
CFLAGS_PIE := -marm
endif
ifeq ($(ARCH),aarch64)
DEFINES := -DCONFIG_AARCH64
endif
ifeq ($(ARCH),ppc64)
LDARCH := powerpc:common64
DEFINES := -DCONFIG_PPC64 -D__SANE_USERSPACE_TYPES__
endif
ifeq ($(ARCH),x86)
LDARCH := i386:x86-64
DEFINES := -DCONFIG_X86_64
endif
ifeq ($(ARCH),mips)
DEFINES := -DCONFIG_MIPS
endif
ifeq ($(ARCH),loongarch64)
DEFINES := -DCONFIG_LOONGARCH64
endif
#
# CFLAGS_PIE:
#
# Ensure with -fno-optimize-sibling-calls that we don't create GOT
# (Global Offset Table) relocations with gcc compilers that don't have
# commit "S/390: Fix 64 bit sibcall".
ifeq ($(ARCH),s390)
ARCH := s390
DEFINES := -DCONFIG_S390
CFLAGS_PIE := -fno-optimize-sibling-calls
endif
CFLAGS_PIE += -DCR_NOGLIBC
export CFLAGS_PIE
LDARCH ?= $(ARCH)
export LDARCH
export PROTOUFIX DEFINES
#
# Independent options for all tools.
DEFINES += -D_FILE_OFFSET_BITS=64
DEFINES += -D_GNU_SOURCE
WARNINGS := -Wall -Wformat-security -Wdeclaration-after-statement -Wstrict-prototypes
# -Wdangling-pointer results in false warning when we add a list element to
# local list head variable. It is false positive because before leaving the
# function we always check that local list head variable is empty, thus
# insuring that pointer to it is not dangling anywhere, but gcc can't
# understand it.
# Note: There is similar problem with kernel list, where this warning is also
# disabled: https://github.com/torvalds/linux/commit/49beadbd47c2
WARNINGS += -Wno-dangling-pointer -Wno-unknown-warning-option
CFLAGS-GCOV := --coverage -fno-exceptions -fno-inline -fprofile-update=atomic
export CFLAGS-GCOV
ifeq ($(ARCH),mips)
WARNINGS := -rdynamic
endif
ifeq ($(ARCH),loongarch64)
WARNINGS := -Wno-implicit-function-declaration
endif
ifneq ($(GCOV),)
LDFLAGS += -lgcov
CFLAGS += $(CFLAGS-GCOV)
endif
ifeq ($(ASAN),1)
CFLAGS-ASAN := -fsanitize=address
export CFLAGS-ASAN
CFLAGS += $(CFLAGS-ASAN)
endif
ifneq ($(WERROR),0)
WARNINGS += -Werror
endif
ifeq ($(DEBUG),1)
DEFINES += -DCR_DEBUG
CFLAGS += -O0 -ggdb3
else
CFLAGS += -O2 -g
endif
ifeq ($(GMON),1)
CFLAGS += -pg
GMONLDOPT += -pg
export GMON GMONLDOPT
endif
AFLAGS += -D__ASSEMBLY__
CFLAGS += $(USERCFLAGS) $(ARCHCFLAGS) $(WARNINGS) $(DEFINES) -iquote include/
HOSTCFLAGS += $(WARNINGS) $(DEFINES) -iquote include/
export AFLAGS CFLAGS USERCLFAGS HOSTCFLAGS
# Default target
all: criu lib crit
.PHONY: all
#
# Version headers.
include Makefile.versions
VERSION_HEADER := criu/include/version.h
GITID_FILE := .gitid
GITID := $(shell if [ -d ".git" ]; then git describe --always; fi)
# Git repository wasn't inited in CRIU folder
ifeq ($(GITID),)
GITID := 0
else
GITID_FILE_VALUE := $(shell if [ -f '$(GITID_FILE)' ]; then if [ `cat '$(GITID_FILE)'` = $(GITID) ]; then echo y; fi; fi)
ifneq ($(GITID_FILE_VALUE),y)
.PHONY: $(GITID_FILE)
endif
endif
$(GITID_FILE):
$(call msg-gen, $@)
$(Q) echo "$(GITID)" > $(GITID_FILE)
$(VERSION_HEADER): Makefile.versions $(GITID_FILE)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, do not edit */" > $@
$(Q) echo "#ifndef __CR_VERSION_H__" >> $@
$(Q) echo "#define __CR_VERSION_H__" >> $@
$(Q) echo "#define CRIU_VERSION \"$(CRIU_VERSION)\"" >> $@
$(Q) echo "#define CRIU_VERSION_MAJOR " $(CRIU_VERSION_MAJOR) >> $@
$(Q) echo "#define CRIU_VERSION_MINOR " $(CRIU_VERSION_MINOR) >> $@
ifneq ($(CRIU_VERSION_SUBLEVEL),)
$(Q) echo "#define CRIU_VERSION_SUBLEVEL " $(CRIU_VERSION_SUBLEVEL) >> $@
endif
ifneq ($(CRIU_VERSION_EXTRA),)
$(Q) echo "#define CRIU_VERSION_EXTRA " $(CRIU_VERSION_EXTRA) >> $@
endif
$(Q) echo "#define CRIU_GITID \"$(GITID)\"" >> $@
$(Q) echo "#endif /* __CR_VERSION_H__ */" >> $@
criu-deps += $(VERSION_HEADER)
#
# Setup proper link for asm headers in common code.
include/common/asm: include/common/arch/$(ARCH)/asm
$(call msg-gen, $@)
$(Q) ln -s ./arch/$(ARCH)/asm $@
criu-deps += include/common/asm
#
# Configure variables.
export CONFIG_HEADER := include/common/config.h
ifeq ($(filter tags etags cscope clean lint indent fetch-clang-format help mrproper,$(MAKECMDGOALS)),)
include Makefile.config
else
# To clean all files, enable make/build options here
export CONFIG_COMPAT := y
export CONFIG_GNUTLS := y
export CONFIG_HAS_LIBBPF := y
endif
#
# Protobuf images first, they are not depending
# on anything else.
$(eval $(call gen-built-in,images))
criu-deps += images/built-in.o
#
# Compel get used by CRIU, build it earlier
include Makefile.compel
#
# Next the socket CR library
#
SOCCR_A := soccr/libsoccr.a
soccr/Makefile: ;
soccr/%: $(CONFIG_HEADER) .FORCE
$(Q) $(MAKE) $(build)=soccr $@
soccr/built-in.o: $(CONFIG_HEADER) .FORCE
$(Q) $(MAKE) $(build)=soccr all
$(SOCCR_A): |soccr/built-in.o
criu-deps += $(SOCCR_A)
#
# LZ4 library
#
LZ4_OBJS = lz4/lib/liblz4.a criu/liblz4io.a
$(LZ4_OBJS) :
git submodule init
git submodule update
$(Q) env -i PATH="$$PATH" make CC=$(CC) CFLAGS="$(CFLAGS)" -C lz4 lib lz4
$(Q) $(AR) rcs criu/liblz4io.a lz4/programs/lz4io.o
criu-deps += $(LZ4_OBJS)
CFLAGS += -I.
#
# CRIU building done in own directory
# with slightly different rules so we
# can't use nmk engine directly (we
# build syscalls library and such).
#
# But note that we're already included
# the nmk so we can reuse it there.
criu/Makefile: ;
criu/Makefile.packages: ;
criu/Makefile.crtools: ;
criu/%: $(criu-deps) .FORCE
$(Q) $(MAKE) $(build)=criu $@
criu: $(criu-deps)
$(Q) $(MAKE) $(build)=criu all
.PHONY: criu
unittest: $(criu-deps)
$(Q) $(MAKE) $(build)=criu unittest
.PHONY: unittest
#
# Libraries next once criu is ready
# (we might generate headers and such
# when building criu itself).
lib/Makefile: ;
lib/%: criu .FORCE
$(Q) $(MAKE) $(build)=lib $@
lib: criu
$(Q) $(MAKE) $(build)=lib all
.PHONY: lib
clean mrproper:
$(Q) $(MAKE) $(build)=images $@
$(Q) $(MAKE) $(build)=criu $@
$(Q) $(MAKE) $(build)=soccr $@
$(Q) $(MAKE) $(build)=lib $@
$(Q) $(MAKE) $(build)=crit $@
$(Q) $(MAKE) $(build)=compel $@
$(Q) $(MAKE) $(build)=compel/plugins $@
$(Q) $(MAKE) -C lz4 clean
rm -rf $(LZ4_OBJS)
.PHONY: clean mrproper
clean-amdgpu_plugin:
$(Q) $(MAKE) -C plugins/amdgpu clean
.PHONY: clean-amdgpu_plugin
clean-top:
$(Q) $(MAKE) -C Documentation clean
$(Q) $(MAKE) $(build)=test/compel clean
$(Q) $(RM) .gitid
.PHONY: clean-top
clean: clean-top clean-amdgpu_plugin
mrproper-top: clean-top clean-amdgpu_plugin
$(Q) $(RM) $(CONFIG_HEADER)
$(Q) $(RM) $(VERSION_HEADER)
$(Q) $(RM) $(COMPEL_VERSION_HEADER)
$(Q) $(RM) include/common/asm
$(Q) $(RM) compel/include/asm
$(Q) $(RM) cscope.*
$(Q) $(RM) tags TAGS
.PHONY: mrproper-top
mrproper: mrproper-top
#
# Non-CRIU stuff.
#
docs:
$(Q) $(MAKE) -s -C Documentation all
.PHONY: docs
zdtm: all
$(Q) $(MAKE) -C test/zdtm all
.PHONY: zdtm
test: zdtm
$(Q) $(MAKE) -C test
.PHONY: test
amdgpu_plugin: criu
$(Q) $(MAKE) -C plugins/amdgpu all
.PHONY: amdgpu_plugin
crit: lib
$(Q) $(MAKE) -C crit
.PHONY: crit
#
# Generating tar requires tag matched CRIU_VERSION.
# If not found then simply use GIT's describe with
# "v" prefix stripped.
head-name := $(shell git tag -l v$(CRIU_VERSION))
ifeq ($(head-name),)
head-name := $(shell git describe 2>/dev/null)
endif
# If no git tag could describe current commit,
# use pre-defined CRIU_VERSION with GITID (if any).
ifeq ($(head-name),)
ifneq ($(GITID),)
head-name := $(CRIU_VERSION)-$(GITID)
else
head-name := $(CRIU_VERSION)
endif
endif
tar-name := $(shell echo $(head-name) | sed -e 's/^v//g')
criu-$(tar-name).tar.bz2:
git archive --format tar --prefix 'criu-$(tar-name)/' $(head-name) | bzip2 > $@
dist tar: criu-$(tar-name).tar.bz2 ;
.PHONY: dist tar
TAGS_FILES_REGEXP := . -name '*.[hcS]' ! -path './.*' \( ! -path './test/*' -o -path './test/zdtm/lib/*' \)
tags:
$(call msg-gen, $@)
$(Q) $(RM) tags
$(Q) $(FIND) $(TAGS_FILES_REGEXP) -print | xargs $(CTAGS) -a
.PHONY: tags
etags:
$(call msg-gen, $@)
$(Q) $(RM) TAGS
$(Q) $(FIND) $(TAGS_FILES_REGEXP) -print | xargs $(ETAGS) -a
.PHONY: etags
cscope:
$(call msg-gen, $@)
$(Q) $(FIND) $(TAGS_FILES_REGEXP) ! -type l -print > cscope.files
$(Q) $(CSCOPE) -bkqu
.PHONY: cscope
gcov:
$(E) " GCOV"
$(Q) test -d gcov || mkdir gcov && \
geninfo --output-filename gcov/criu.info --no-recursion criu/ && \
cd gcov && \
genhtml --rc lcov_branch_coverage=1 --output-directory html criu.info
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
.PHONY: gcov
docker-build:
$(MAKE) -C scripts/build/ x86_64
.PHONY: docker-build
docker-test:
docker run --rm --privileged -v /lib/modules:/lib/modules --network=host --cgroupns=host criu-x86_64 \
./test/zdtm.py run -a --keep-going --ignore-taint
.PHONY: docker-test
help:
@echo ' Targets:'
@echo ' all - Build all [*] targets'
@echo ' * criu - Build criu'
@echo ' * crit - Build crit'
@echo ' zdtm - Build zdtm test-suite'
@echo ' docs - Build documentation'
@echo ' install - Install CRIU (see INSTALL.md)'
@echo ' uninstall - Uninstall CRIU'
@echo ' dist - Create a source tarball'
@echo ' clean - Clean most, but leave enough to navigate'
@echo ' mrproper - Delete all compiled/generated files'
@echo ' tags - Generate tags file (ctags)'
@echo ' etags - Generate TAGS file (etags)'
@echo ' cscope - Generate cscope database'
@echo ' test - Run zdtm test-suite'
@echo ' gcov - Make code coverage report'
@echo ' unittest - Run unit tests'
@echo ' lint - Run code linters'
@echo ' indent - Indent C code'
@echo ' amdgpu_plugin - Make AMD GPU plugin'
.PHONY: help
lint:
flake8 --version
flake8 --config=scripts/flake8.cfg test/zdtm.py
flake8 --config=scripts/flake8.cfg test/inhfd/*.py
flake8 --config=scripts/flake8.cfg test/others/rpc/config_file.py
flake8 --config=scripts/flake8.cfg lib/pycriu/images/pb2dict.py
flake8 --config=scripts/flake8.cfg lib/pycriu/images/images.py
flake8 --config=scripts/flake8.cfg scripts/criu-ns
flake8 --config=scripts/flake8.cfg test/others/criu-ns/run.py
flake8 --config=scripts/flake8.cfg crit/*.py
flake8 --config=scripts/flake8.cfg crit/crit/*.py
flake8 --config=scripts/flake8.cfg scripts/uninstall_module.py
flake8 --config=scripts/flake8.cfg coredump/ coredump/coredump
flake8 --config=scripts/flake8.cfg scripts/github-indent-warnings.py
shellcheck --version
shellcheck scripts/*.sh
shellcheck scripts/ci/*.sh scripts/ci/apt-install
shellcheck -x test/others/crit/*.sh
shellcheck -x test/others/libcriu/*.sh
shellcheck -x test/others/crit/*.sh test/others/criu-coredump/*.sh
shellcheck -x test/others/config-file/*.sh
shellcheck -x test/others/action-script/*.sh
codespell -S tags
# Do not append \n to pr_perror, pr_pwarn or fail
! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>.*\\n"'
# Do not use %m with pr_* or fail
! git --no-pager grep -E '^\s*\<(pr_(err|perror|warn|pwarn|debug|info|msg)|fail)\>.*%m'
# Do not use errno with pr_perror, pr_pwarn or fail
! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>\(".*".*errno'
# End pr_(err|warn|msg|info|debug) with \n
! git --no-pager grep -En '^\s*\.*);$$' | grep -v '\\n'
# No EOL whitespace for C files
! git --no-pager grep -E '\s+$$' \*.c \*.h
.PHONY: lint
codecov: SHELL := $(shell which bash)
codecov:
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov
.PHONY: codecov
fetch-clang-format: .FORCE
$(E) ".clang-format"
$(Q) scripts/fetch-clang-format.sh
BASE ?= "HEAD~1"
OPTS ?= "--quiet"
indent:
git clang-format --style file --extensions c,h $(OPTS) $(BASE)
.PHONY: indent
include Makefile.install
.DEFAULT_GOAL := all
# Disable implicit rules in _this_ Makefile.
.SUFFIXES:
#
# Optional local include.
-include Makefile.local
crac-criu-1.5.0/Makefile.compel 0000664 0000000 0000000 00000005454 14715043267 0016324 0 ustar 00root root 0000000 0000000 COMPEL_BIN := ./compel/compel-host
export COMPEL_BIN
COMPEL_VERSION_HEADER := compel/include/version.h
$(COMPEL_VERSION_HEADER): Makefile.versions
$(call msg-gen, $(COMPEL_VERSION_HEADER))
$(Q) echo "/* Autogenerated, do not edit */" > $(COMPEL_VERSION_HEADER)
$(Q) echo "#ifndef COMPEL_SO_VERSION_H__" >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#define COMPEL_SO_VERSION_H__" >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#define COMPEL_SO_VERSION \"$(COMPEL_SO_VERSION)\"" >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#define COMPEL_SO_VERSION_MAJOR " $(COMPEL_SO_VERSION_MAJOR) >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#define COMPEL_SO_VERSION_MINOR " $(COMPEL_SO_VERSION_MINOR) >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#define COMPEL_SO_VERSION_SUBLEVEL " $(COMPEL_SO_VERSION_SUBLEVEL) >> $(COMPEL_VERSION_HEADER)
$(Q) echo "#endif /* COMPEL_SO_VERSION_H__ */" >> $(COMPEL_VERSION_HEADER)
compel/include/asm:
$(call msg-gen, $@)
$(Q) ln -s ../arch/$(ARCH)/src/lib/include $@
compel-deps += compel/include/asm
compel-deps += $(COMPEL_VERSION_HEADER)
compel-deps += $(CONFIG_HEADER)
compel-deps += include/common/asm
compel-plugins += compel/plugins/std.lib.a compel/plugins/fds.lib.a
LIBCOMPEL_SO := libcrac-compel.so
LIBCOMPEL_A := libcrac-compel.a
export LIBCOMPEL_SO LIBCOMPEL_A
#
# Compel itself.
compel/Makefile: ;
compel/%: $(compel-deps) $(compel-plugins) .FORCE
$(Q) $(MAKE) $(build)=compel $@
criu-deps += compel/compel-host-bin
#
# Make sure the host program is ready after the
# library and plugins are built.
compel/compel-host-bin: | compel/$(LIBCOMPEL_A) $(compel-plugins)
$(COMPEL_BIN): compel/compel-host-bin
#
# Plugins
compel/plugins/Makefile: ;
compel/plugins/%: $(compel-deps) .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@
#
# GNU make 4.x supports targets matching via wide
# match targeting, where GNU make 3.x series (used on
# Travis) is not, so we have to write them here explicitly.
compel/plugins/std.lib.a: $(compel-deps) .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@
compel/plugins/shmem.lib.a: $(compel-deps) compel/plugins/std.lib.a .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@
compel/plugins/fds.lib.a: $(compel-deps) compel/plugins/std.lib.a .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@
compel/compel: compel/built-in.o compel/$(LIBCOMPEL_A) | $(compel-deps)
$(call msg-link, $@)
$(Q) $(CC) $(CFLAGS) $^ $(WRAPFLAGS) $(LDFLAGS) -rdynamic -o $@
#
# And compel library.
LIBCOMPEL_SO_CFLAGS += $(CFLAGS) -rdynamic -Wl,-soname,$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR)
compel/$(LIBCOMPEL_SO): compel/$(LIBCOMPEL_A)
$(call msg-link, $@)
$(Q) $(CC) -shared $(LIBCOMPEL_SO_CFLAGS) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(LDFLAGS)
compel-install-targets += compel/$(LIBCOMPEL_SO)
compel-install-targets += compel/compel
compel-install-targets += $(compel-plugins)
crac-criu-1.5.0/Makefile.config 0000664 0000000 0000000 00000007572 14715043267 0016315 0 ustar 00root root 0000000 0000000 include $(__nmk_dir)utils.mk
include $(__nmk_dir)msg.mk
include scripts/feature-tests.mak
# Make the binary distributable without depending on build system shared libraries availability.
#ifeq ($(call try-cc,$(FEATURE_TEST_LIBBSD_DEV),-lbsd),true)
# LIBS_FEATURES += -lbsd
# FEATURE_DEFINES += -DCONFIG_HAS_LIBBSD
#else
# $(info Note: Building without setproctitle() and strlcpy() support.)
# $(info $(info) To enable these features, please install libbsd-devel (RPM) / libbsd-dev (DEB).)
#endif
ifeq ($(call pkg-config-check,libselinux),y)
LIBS_FEATURES += -lselinux
FEATURE_DEFINES += -DCONFIG_HAS_SELINUX
endif
# Make the binary distributable without depending on build system shared libraries availability.
#ifeq ($(call pkg-config-check,libbpf),y)
# LIBS_FEATURES += -lbpf
# FEATURE_DEFINES += -DCONFIG_HAS_LIBBPF
# export CONFIG_HAS_LIBBPF := y
#endif
ifeq ($(call pkg-config-check,libdrm),y)
export CONFIG_AMDGPU := y
$(info Note: Building criu with amdgpu_plugin.)
else
$(info Note: Building criu without amdgpu_plugin.)
$(info Note: libdrm and libdrm_amdgpu are required to build amdgpu_plugin.)
endif
ifeq ($(NO_GNUTLS)x$(call pkg-config-check,gnutls),xy)
LIBS_FEATURES += -lgnutls
export CONFIG_GNUTLS := y
FEATURE_DEFINES += -DCONFIG_GNUTLS
else
$(info Note: Building without GnuTLS support)
endif
# Make the binary distributable without depending on build system shared libraries availability.
#ifeq ($(call pkg-config-check,libnftables),y)
# LIB_NFTABLES := $(shell $(PKG_CONFIG) --libs libnftables)
# ifeq ($(call try-cc,$(FEATURE_TEST_NFTABLES_LIB_API_0),$(LIB_NFTABLES)),true)
# LIBS_FEATURES += $(LIB_NFTABLES)
# FEATURE_DEFINES += -DCONFIG_HAS_NFTABLES_LIB_API_0
# else ifeq ($(call try-cc,$(FEATURE_TEST_NFTABLES_LIB_API_1),$(LIB_NFTABLES)),true)
# LIBS_FEATURES += $(LIB_NFTABLES)
# FEATURE_DEFINES += -DCONFIG_HAS_NFTABLES_LIB_API_1
# else
# $(warning Warn: you have libnftables installed but it has incompatible API)
# $(warning Warn: Building without nftables support)
# endif
#else
# $(warning Warn: you have no libnftables installed)
# $(warning Warn: Building without nftables support)
#endif
export LIBS += $(LIBS_FEATURES)
CONFIG_FILE = .config
$(CONFIG_FILE):
touch $(CONFIG_FILE)
ifeq ($(ARCH),x86)
# CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
ifeq ($(call try-asm,$(FEATURE_TEST_X86_COMPAT)),true)
export CONFIG_COMPAT := y
FEATURE_DEFINES += -DCONFIG_COMPAT
else
$(info Note: Building without ia32 C/R, missed ia32 support in gcc)
$(info $(info) That may be related to missing gcc-multilib in your)
$(info $(info) distribution or you may have Debian with buggy toolchain)
$(info $(info) (issue https://github.com/checkpoint-restore/criu/issues/315))
endif
endif
export DEFINES += $(FEATURE_DEFINES)
export CFLAGS += $(FEATURE_DEFINES)
FEATURES_LIST := TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
SETPROCTITLE_INIT TCP_REPAIR_WINDOW MEMFD_CREATE \
OPENAT2 NO_LIBC_RSEQ_DEFS
# $1 - config name
define gen-feature-test
ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS_FEATURES),$$(DEFINES)),true)
$(Q) echo '#define CONFIG_HAS_$(1)' >> $$@
else
$(Q) echo '// CONFIG_HAS_$(1) is not set' >> $$@
endif
endef
define config-header-rule
$(CONFIG_HEADER): scripts/feature-tests.mak $(CONFIG_FILE)
$(call msg-gen, $$@)
$(Q) echo '#ifndef __CR_CONFIG_H__' > $$@
$(Q) echo '#define __CR_CONFIG_H__' >> $$@
$(Q) echo '' >> $$@
$(call map,gen-feature-test,$(FEATURES_LIST))
$(Q) cat $(CONFIG_FILE) | sed -n -e '/^[^#]/s/^/#define CONFIG_/p' >> $$@
$(Q) echo '#endif /* __CR_CONFIG_H__ */' >> $$@
endef
$(eval $(config-header-rule))
crac-criu-1.5.0/Makefile.install 0000664 0000000 0000000 00000003263 14715043267 0016507 0 ustar 00root root 0000000 0000000 #
# Installation paths.
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SBINDIR ?= $(PREFIX)/sbin
MANDIR ?= $(PREFIX)/share/man
INCLUDEDIR ?= $(PREFIX)/include
LIBEXECDIR ?= $(PREFIX)/libexec
RUNDIR ?= /run
PLUGINDIR ?= $(PREFIX)/lib/criu
#
# For recent Debian/Ubuntu with multiarch support.
DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
ifneq "$(DEB_HOST_MULTIARCH)" ""
LIBDIR ?= $(PREFIX)/lib/$(DEB_HOST_MULTIARCH)
else
#
# For most other systems
ifeq "$(shell uname -m)" "x86_64"
LIBDIR ?= $(PREFIX)/lib64
endif
endif
#
# LIBDIR falls back to the standard path.
LIBDIR ?= $(PREFIX)/lib
export PREFIX BINDIR SBINDIR MANDIR RUNDIR
export LIBDIR INCLUDEDIR LIBEXECDIR PLUGINDIR
install-man:
$(Q) $(MAKE) -C Documentation install
.PHONY: install-man
install-lib: lib
$(Q) $(MAKE) $(build)=lib install
.PHONY: install-lib
install-crit: lib
$(Q) $(MAKE) $(build)=crit install
.PHONY: install-crit
install-criu: criu
$(Q) $(MAKE) $(build)=criu install
.PHONY: install-criu
install-amdgpu_plugin: amdgpu_plugin
$(Q) $(MAKE) -C plugins/amdgpu install
.PHONY: install-amdgpu_plugin
install-compel: $(compel-install-targets)
$(Q) $(MAKE) $(build)=compel install
$(Q) $(MAKE) $(build)=compel/plugins install
.PHONY: install-compel
install: install-man install-lib install-crit install-criu install-compel install-amdgpu_plugin ;
.PHONY: install
uninstall:
$(Q) $(MAKE) -C Documentation $@
$(Q) $(MAKE) $(build)=lib $@
$(Q) $(MAKE) $(build)=crit $@
$(Q) $(MAKE) $(build)=criu $@
$(Q) $(MAKE) $(build)=compel $@
$(Q) $(MAKE) $(build)=compel/plugins $@
$(Q) $(MAKE) -C plugins/amdgpu $@
.PHONY: uninstall
crac-criu-1.5.0/Makefile.versions 0000664 0000000 0000000 00000001625 14715043267 0016711 0 ustar 00root root 0000000 0000000 #
# CRIU version.
CRIU_VERSION_MAJOR := 3
CRIU_VERSION_MINOR := 19
CRIU_VERSION_SUBLEVEL :=
CRIU_VERSION_EXTRA :=
CRIU_VERSION_NAME := Bronze Peacock
CRIU_VERSION := $(CRIU_VERSION_MAJOR)$(if $(CRIU_VERSION_MINOR),.$(CRIU_VERSION_MINOR))$(if $(CRIU_VERSION_SUBLEVEL),.$(CRIU_VERSION_SUBLEVEL))$(if $(CRIU_VERSION_EXTRA),.$(CRIU_VERSION_EXTRA))-crac
export CRIU_VERSION_MAJOR CRIU_VERSION_MINOR CRIU_VERSION_SUBLEVEL
export CRIU_VERSION_EXTRA CRIU_VERSION_NAME CRIU_VERSION
#
# C library for CRIU.
CRIU_SO_VERSION_MAJOR := 2
CRIU_SO_VERSION_MINOR := 0
export CRIU_SO_VERSION_MAJOR CRIU_SO_VERSION_MINOR
#
# SOCCR library.
SOCCR_SO_VERSION_MAJOR := 1
SOCCR_SO_VERSION_MINOR := 0
export SOCCR_SO_VERSION_MAJOR SOCCR_SO_VERSION_MINOR
COMPEL_SO_VERSION_MAJOR := 1
COMPEL_SO_VERSION_MINOR := 0
COMPEL_SO_VERSION_SUBLEVEL := 0
export COMPEL_SO_VERSION_MAJOR COMPEL_SO_VERSION_MINOR COMPEL_SO_VERSION_SUBLEVEL
crac-criu-1.5.0/README.md 0000664 0000000 0000000 00000010620 14715043267 0014654 0 ustar 00root root 0000000 0000000 [](
https://github.com/checkpoint-restore/criu/actions/workflows/x86-64-gcc-test.yml)
[](
https://github.com/checkpoint-restore/criu/actions/workflows/docker-test.yml)
[](
https://github.com/checkpoint-restore/criu/actions/workflows/podman-test.yml)
[](
https://circleci.com/gh/checkpoint-restore/criu)

## CRIU -- A project to implement checkpoint/restore functionality for Linux
CRIU (stands for Checkpoint and Restore in Userspace) is a utility to checkpoint/restore Linux tasks.
Using this tool, you can freeze a running application (or part of it) and checkpoint
it to a hard drive as a collection of files. You can then use the files to restore and run the
application from the point it was frozen at. The distinctive feature of the CRIU
project is that it is mainly implemented in user space. There are some more projects
doing C/R for Linux, and so far CRIU [appears to be](https://criu.org/Comparison_to_other_CR_projects)
the most feature-rich and up-to-date with the kernel.
CRIU project is (almost) the never-ending story, because we have to always keep up with the
Linux kernel supporting checkpoint and restore for all the features it provides. Thus we're
looking for contributors of all kinds -- feedback, bug reports, testing, coding, writing, etc.
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) if you would like to get involved.
The project [started](https://criu.org/History) as the way to do live migration for OpenVZ
Linux containers, but later grew to more sophisticated and flexible tool. It is currently
used by (integrated into) OpenVZ, LXC/LXD, Docker, and other software, project gets tremendous
help from the community, and its packages are included into many Linux distributions.
The project home is at http://criu.org. This wiki contains all the knowledge base for CRIU we have.
Pages worth starting with are:
- [Installation instructions](http://criu.org/Installation)
- [A simple example of usage](http://criu.org/Simple_loop)
- [Examples of more advanced usage](https://criu.org/Category:HOWTO)
- Troubleshooting can be hard, some help can be found [here](https://criu.org/When_C/R_fails), [here](https://criu.org/What_cannot_be_checkpointed) and [here](https://criu.org/FAQ)
### Checkpoint and restore of simple loop process

## Advanced features
As main usage for CRIU is live migration, there's a library for it called P.Haul. Also the
project exposes two cool core features as standalone libraries. These are libcompel for parasite code
injection and libsoccr for TCP connections checkpoint-restore.
### Live migration
True [live migration](https://criu.org/Live_migration) using CRIU is possible, but doing
all the steps by hands might be complicated. The [phaul sub-project](https://criu.org/P.Haul)
provides a Go library that encapsulates most of the complexity. This library and the Go bindings
for CRIU are stored in the [go-criu](https://github.com/checkpoint-restore/go-criu) repository.
### Parasite code injection
In order to get state of the running process CRIU needs to make this process execute
some code, that would fetch the required information. To make this happen without
killing the application itself, CRIU uses the [parasite code injection](https://criu.org/Parasite_code)
technique, which is also available as a standalone library called [libcompel](https://criu.org/Compel).
### TCP sockets checkpoint-restore
One of the CRIU features is the ability to save and restore state of a TCP socket
without breaking the connection. This functionality is considered to be useful by
itself, and we have it available as the [libsoccr library](https://criu.org/Libsoccr).
## Licence
The project is licensed under GPLv2 (though files sitting in the lib/ directory are LGPLv2.1).
All files in the images/ directory are licensed under the Expat license (so-called MIT).
See the images/LICENSE file.
crac-criu-1.5.0/compel/ 0000775 0000000 0000000 00000000000 14715043267 0014655 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/.gitignore 0000664 0000000 0000000 00000001040 14715043267 0016640 0 ustar 00root root 0000000 0000000 arch/x86/plugins/std/sys-exec-tbl-64.c
arch/x86/plugins/std/syscalls-64.S
arch/arm/plugins/std/syscalls/syscalls.S
arch/aarch64/plugins/std/syscalls/syscalls.S
arch/s390/plugins/std/syscalls/syscalls.S
arch/ppc64/plugins/std/syscalls/syscalls.S
include/version.h
plugins/include/uapi/std/asm/syscall-types.h
plugins/include/uapi/std/syscall-64.h
plugins/include/uapi/std/syscall-codes-64.h
plugins/include/uapi/std/syscall-codes.h
plugins/include/uapi/std/syscall.h
plugins/include/uapi/std/syscall-aux.h
plugins/include/uapi/std/syscall-aux.S
crac-criu-1.5.0/compel/Makefile 0000664 0000000 0000000 00000006761 14715043267 0016327 0 ustar 00root root 0000000 0000000 include Makefile.versions
COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.$(COMPEL_SO_VERSION_MINOR))$(if $(COMPEL_SO_VERSION_SUBLEVEL),.$(COMPEL_SO_VERSION_SUBLEVEL))
COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
ccflags-y += -DINCLUDEDIR=\"$(INCLUDEDIR)\"
ccflags-y += -DLIBEXECDIR=\"$(LIBEXECDIR)\"
ccflags-y += -DLIBDIR=\"$(LIBDIR)\"
ccflags-y += -DSTATIC_LIB=\"$(LIBCOMPEL_A)\"
ccflags-y += -DDYN_LIB=\"$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR)\"
ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include
ccflags-y += -iquote compel/include
ccflags-y += -fno-strict-aliasing
ccflags-y += -fPIC
ldflags-y += -r
#
# UAPI inclusion, referred as
ccflags-y += -I compel/include/uapi
lib-name := $(LIBCOMPEL_A)
lib-y += src/lib/log.o
host-lib-y += src/lib/log.o
lib-y += arch/$(ARCH)/src/lib/cpu.o
lib-y += arch/$(ARCH)/src/lib/infect.o
lib-y += src/lib/infect-rpc.o
lib-y += src/lib/infect-util.o
lib-y += src/lib/infect.o
lib-y += src/lib/ptrace.o
ifeq ($(ARCH),x86)
lib-y += arch/$(ARCH)/src/lib/thread_area.o
endif
# handle_elf() has no support of ELF relocations on ARM (yet?)
ifneq ($(filter arm aarch64 loongarch64,$(ARCH)),)
CFLAGS += -DNO_RELOCS
HOSTCFLAGS += -DNO_RELOCS
endif
obj-y += src/main.o
obj-y += arch/$(ARCH)/src/lib/handle-elf.o
obj-y += src/lib/handle-elf.o
host-ccflags-y += $(ccflags-y)
hostprogs-y += compel-host-bin
compel-host-bin-objs := $(patsubst %.o,%-host.o,$(obj-y) $(host-lib-y))
cleanup-y += compel/compel
cleanup-y += compel/compel-host-bin
cleanup-y += compel/libcompel.so
install: compel/compel compel/$(LIBCOMPEL_SO) compel/$(LIBCOMPEL_A)
$(E) " INSTALL " compel
$(Q) mkdir -p $(DESTDIR)$(BINDIR)
$(Q) install -m 755 compel/compel $(DESTDIR)$(BINDIR)/crac-compel
$(E) " INSTALL " $(LIBCOMPEL_SO)
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)
$(Q) install -m 0644 compel/$(LIBCOMPEL_SO) $(DESTDIR)$(LIBDIR)
$(Q) install -m 755 compel/$(LIBCOMPEL_SO) $(DESTDIR)$(LIBDIR)/$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR)
$(Q) ln -fns $(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR)
$(Q) ln -fns $(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(LIBCOMPEL_SO)
$(E) " INSTALL " $(LIBCOMPEL_A)
$(Q) install -m 0644 compel/$(LIBCOMPEL_A) $(DESTDIR)$(LIBDIR)
$(E) " INSTALL " compel uapi
$(Q) mkdir -p $(DESTDIR)$(INCLUDEDIR)/crac-criu/compel/asm
$(Q) cp compel/include/uapi/*.h $(DESTDIR)$(INCLUDEDIR)/crac-criu/compel/
$(Q) cp compel/include/uapi/asm/*.h $(DESTDIR)$(INCLUDEDIR)/crac-criu/compel/asm/
$(Q) mkdir -p $(DESTDIR)$(INCLUDEDIR)/crac-criu/compel/common/asm
$(Q) cp include/common/compiler.h $(DESTDIR)$(INCLUDEDIR)/crac-criu/compel/common/
.PHONY: install
uninstall:
$(E) " UNINSTALL" compel
$(Q) $(RM) $(addprefix $(DESTDIR)$(BINDIR)/,crac-compel)
$(E) " UNINSTALL" $(LIBCOMPEL_SO)
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(LIBCOMPEL_SO))
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR))
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR))
$(E) " UNINSTALL" $(LIBCOMPEL_A)
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(LIBCOMPEL_A))
$(E) " UNINSTALL" compel uapi
$(Q) $(RM) -rf $(addprefix $(DESTDIR)$(INCLUDEDIR)/,crac-criu/compel/*)
.PHONY: uninstall
crac-criu-1.5.0/compel/arch/ 0000775 0000000 0000000 00000000000 14715043267 0015572 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/ 0000775 0000000 0000000 00000000000 14715043267 0017022 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0020503 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0022126 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022706 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/include/asm/prologue.h 0000777 0000000 0000000 00000000000 14715043267 0035430 2../../../../../arch/x86/plugins/include/asm/prologue.h ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001170 14715043267 0025672 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
#define SA_RESTORER 0x04000000
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define _KNSIG 64
#define _NSIG_BPW 64
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
typedef struct {
unsigned long sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/aarch64/plugins/include/features.h 0000664 0000000 0000000 00000000151 14715043267 0024112 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/aarch64/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0021275 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/std/parasite-head.S 0000664 0000000 0000000 00000000343 14715043267 0024130 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(__export_parasite_head_start)
bl parasite_service
brk #0 // the instruction BRK #0 generates the signal SIGTRAP in Linux
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0023132 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls 0000777 0000000 0000000 00000000000 14715043267 0037660 2../../../../arm/plugins/std/syscalls/Makefile.syscalls ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/gen-sys-exec-tbl.pl 0000777 0000000 0000000 00000000000 14715043267 0040136 2../../../../arm/plugins/std/syscalls/gen-sys-exec-tbl.pl ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl 0000777 0000000 0000000 00000000000 14715043267 0036772 2../../../../arm/plugins/std/syscalls/gen-syscalls.pl ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S 0000664 0000000 0000000 00000001031 14715043267 0025516 0 ustar 00root root 0000000 0000000 /**
* This source contains emulation of syscalls
* that are not implemented in the AArch64 Linux kernel
*/
ENTRY(sys_open)
mov x3, x2
mov x2, x1
mov x1, x0
mov x0, #-100
b sys_openat
END(sys_open)
ENTRY(sys_mkdir)
mov x3, x2
mov x2, x1
mov x1, x0
mov x0, #-100
b sys_mkdirat
END(sys_mkdir)
ENTRY(sys_rmdir)
mov x2, #0x200 // flags = AT_REMOVEDIR
mov x1, x0
mov x0, #-100
b sys_unlinkat
END(sys_rmdir)
ENTRY(sys_unlink)
mov x2, #0 // flags = 0
mov x1, x0
mov x0, #-100
b sys_unlinkat
END(sys_unlink)
crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h 0000664 0000000 0000000 00000000062 14715043267 0025546 0 ustar 00root root 0000000 0000000 #ifndef __NR_openat
#define __NR_openat 56
#endif
crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/syscall-common.S 0000664 0000000 0000000 00000000352 14715043267 0026216 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
syscall_common:
svc #0
ret
.macro syscall name, nr
ENTRY(\name)
mov x8, \nr
b syscall_common
END(\name)
.endm
ENTRY(__cr_restore_rt)
mov x8, __NR_rt_sigreturn
svc #0
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/aarch64/plugins/std/syscalls/syscall.def 0000777 0000000 0000000 00000000000 14715043267 0035354 2../../../../arm/plugins/std/syscalls/syscall.def ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0020511 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000753 14715043267 0023616 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(aarch64)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.crblob 0x0 : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
. = ALIGN(32);
*(.data*)
. = ALIGN(32);
*(.rodata*)
. = ALIGN(32);
*(.bss*)
. = ALIGN(32);
*(.got*)
. = ALIGN(32);
*(.toc*)
. = ALIGN(32);
} =0x00000000,
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
*(*)
}
}
crac-criu-1.5.0/compel/arch/aarch64/src/ 0000775 0000000 0000000 00000000000 14715043267 0017611 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0020357 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/cpu.c 0000664 0000000 0000000 00000002563 14715043267 0021320 0 ustar 00root root 0000000 0000000 #include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "log.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static void fetch_rt_cpuinfo(void)
{
static bool rt_info_done = false;
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
}
void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
}
void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
}
int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
return 0;
}
int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
return 0;
}
int compel_cpuid(compel_cpuinfo_t *info)
{
return 0;
}
bool compel_cpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_cpu_cap(&rt_info, feature);
}
bool compel_fpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_fpu_cap(&rt_info, feature);
}
uint32_t compel_fpu_feature_size(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
uint32_t compel_fpu_feature_offset(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
void compel_cpu_clear_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_clear_cpu_cap(&rt_info, feature);
}
void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
{
fetch_rt_cpuinfo();
memcpy(c, &rt_info, sizeof(rt_info));
}
crac-criu-1.5.0/compel/arch/aarch64/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025633 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/handle-elf.c 0000664 0000000 0000000 00000001477 14715043267 0022533 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char __maybe_unused elf_ident_64_be[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int handle_binary(void *mem, size_t size)
{
const unsigned char *elf_ident =
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
elf_ident_64_le;
#else
elf_ident_64_be;
#endif
if (memcmp(mem, elf_ident, sizeof(elf_ident_64_le)) == 0)
return handle_elf_aarch64(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0022002 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/cpu.h 0000664 0000000 0000000 00000000000 14715043267 0022730 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000451 14715043267 0024152 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define __handle_elf handle_elf_aarch64
#define arch_is_machine_supported(e_machine) (e_machine == EM_AARCH64)
extern int handle_elf_aarch64(void *mem, size_t size);
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/syscall.h 0000664 0000000 0000000 00000000252 14715043267 0023624 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022740 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0023520 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/.gitignore 0000664 0000000 0000000 00000000000 14715043267 0025476 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000001664 14715043267 0026221 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
#include
#include
struct hwbp_cap {
char arch;
char bp_count;
};
/* copied from `linux/arch/arm64/include/asm/hw_breakpoint.h` */
/* Lengths */
#define ARM_BREAKPOINT_LEN_1 0x1
#define ARM_BREAKPOINT_LEN_2 0x3
#define ARM_BREAKPOINT_LEN_3 0x7
#define ARM_BREAKPOINT_LEN_4 0xf
#define ARM_BREAKPOINT_LEN_5 0x1f
#define ARM_BREAKPOINT_LEN_6 0x3f
#define ARM_BREAKPOINT_LEN_7 0x7f
#define ARM_BREAKPOINT_LEN_8 0xff
/* Privilege Levels */
#define AARCH64_BREAKPOINT_EL1 1
#define AARCH64_BREAKPOINT_EL0 2
/* Breakpoint */
#define ARM_BREAKPOINT_EXECUTE 0
/* Watchpoints */
#define ARM_BREAKPOINT_LOAD 1
#define ARM_BREAKPOINT_STORE 2
#define AARCH64_ESR_ACCESS_MASK (1 << 6)
#define DISABLE_HBP 0
#define ENABLE_HBP 1
int ptrace_set_breakpoint(pid_t pid, void *addr);
int ptrace_flush_breakpoints(pid_t pid);
#endif
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000214 14715043267 0024455 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_CPU_H__
#define UAPI_COMPEL_ASM_CPU_H__
typedef struct {
} compel_cpuinfo_t;
#endif /* UAPI_COMPEL_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000121 14715043267 0024455 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000002027 14715043267 0026304 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#include
#include
#include
#define SIGMAX 64
#define SIGMAX_OLD 31
/*
* Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
*
* A thread ARM CPU context
*/
typedef struct user_pt_regs user_regs_struct_t;
typedef struct user_fpsimd_state user_fpregs_struct_t;
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
#define REG_RES(r) ((uint64_t)(r).regs[0])
#define REG_IP(r) ((uint64_t)(r).pc)
#define SET_REG_IP(r, val) ((r).pc = (val))
#define REG_SP(r) ((uint64_t)((r).sp))
#define REG_SYSCALL_NR(r) ((uint64_t)(r).regs[8])
#define user_regs_native(pregs) true
#define ARCH_SI_TRAP TRAP_BRKPT
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/processor-flags.h 0000664 0000000 0000000 00000000212 14715043267 0026775 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__
#define UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__
#endif /* UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000004156 14715043267 0025474 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
#include
#include
/* Copied from the kernel header arch/arm64/include/uapi/asm/sigcontext.h */
#define FPSIMD_MAGIC 0x46508001
typedef struct fpsimd_context fpu_state_t;
struct aux_context {
struct fpsimd_context fpsimd;
/* additional context to be added before "end" */
struct _aarch64_ctx end;
};
// XXX: the identifier rt_sigcontext is expected to be struct by the CRIU code
#define rt_sigcontext sigcontext
#include
/* Copied from the kernel source arch/arm64/kernel/signal.c */
struct rt_sigframe {
siginfo_t info;
ucontext_t uc;
uint64_t fp;
uint64_t lr;
};
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"mov sp, %0 \n" \
"mov x8, #"__stringify(__NR_rt_sigreturn)" \n" \
"svc #0 \n" \
: \
: "r"(new_sp) \
: "x8", "memory")
/* clang-format on */
/* cr_sigcontext is copied from arch/arm64/include/uapi/asm/sigcontext.h */
struct cr_sigcontext {
__u64 fault_address;
/* AArch64 registers */
__u64 regs[31];
__u64 sp;
__u64 pc;
__u64 pstate;
/* 4K reserved for FP/SIMD state and future expansion */
__u8 __reserved[4096] __attribute__((__aligned__(16)));
};
#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc)
#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.pc)
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
#define RT_SIGFRAME_SIGCONTEXT(rt_sigframe) ((struct cr_sigcontext *)&(rt_sigframe)->uc.uc_mcontext)
#define RT_SIGFRAME_AUX_CONTEXT(rt_sigframe) ((struct aux_context *)&(RT_SIGFRAME_SIGCONTEXT(rt_sigframe)->__reserved))
#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_CONTEXT(rt_sigframe)->fpsimd)
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/aarch64/src/lib/infect.c 0000664 0000000 0000000 00000016122 14715043267 0021775 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include "common/page.h"
#include "uapi/compel/asm/infect-types.h"
#include "log.h"
#include "errno.h"
#include "infect.h"
#include "infect-priv.h"
#include "asm/breakpoints.h"
unsigned __page_size = 0;
unsigned __page_shift = 0;
/*
* Injected syscall instruction
*/
const char code_syscall[] = {
0x01, 0x00, 0x00, 0xd4, /* SVC #0 */
0x00, 0x00, 0x20, 0xd4 /* BRK #0 */
};
static const int code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static inline void __always_unused __check_code_syscall(void)
{
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
struct fpsimd_context *fpsimd = RT_SIGFRAME_FPU(sigframe);
memcpy(sigframe->uc.uc_mcontext.regs, regs->regs, sizeof(regs->regs));
sigframe->uc.uc_mcontext.sp = regs->sp;
sigframe->uc.uc_mcontext.pc = regs->pc;
sigframe->uc.uc_mcontext.pstate = regs->pstate;
memcpy(fpsimd->vregs, fpregs->vregs, 32 * sizeof(__uint128_t));
fpsimd->fpsr = fpregs->fpsr;
fpsimd->fpcr = fpregs->fpcr;
fpsimd->head.magic = FPSIMD_MAGIC;
fpsimd->head.size = sizeof(*fpsimd);
return 0;
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpsimd = ext_regs ? ext_regs : &tmp;
struct iovec iov;
int ret;
pr_info("Dumping GP/FPU registers for %d\n", pid);
iov.iov_base = regs;
iov.iov_len = sizeof(user_regs_struct_t);
if ((ret = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov))) {
pr_perror("Failed to obtain CPU registers for %d", pid);
goto err;
}
iov.iov_base = fpsimd;
iov.iov_len = sizeof(*fpsimd);
if ((ret = ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov))) {
pr_perror("Failed to obtain FPU registers for %d", pid);
goto err;
}
ret = save(arg, regs, fpsimd);
err:
return ret;
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
struct iovec iov;
pr_info("Restoring GP/FPU registers for %d\n", pid);
iov.iov_base = ext_regs;
iov.iov_len = sizeof(*ext_regs);
if (ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov)) {
pr_perror("Failed to set FPU registers for %d", pid);
return -1;
}
return 0;
}
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
regs.regs[8] = (unsigned long)nr;
regs.regs[0] = arg1;
regs.regs[1] = arg2;
regs.regs[2] = arg3;
regs.regs[3] = arg4;
regs.regs[4] = arg5;
regs.regs[5] = arg6;
regs.regs[6] = 0;
regs.regs[7] = 0;
err = compel_execute_syscall(ctl, ®s, code_syscall);
*ret = regs.regs[0];
return err;
}
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset);
if (err < 0 || (long)map < 0)
map = 0;
return (void *)map;
}
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->pc = new_ip;
if (stack)
regs->sp = (unsigned long)stack;
}
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
/*
* TODO: Add proper check here
*/
return true;
}
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
/*
* Range for task size calculated from the following Linux kernel files:
* arch/arm64/include/asm/memory.h
* arch/arm64/Kconfig
*
* TODO: handle 32 bit tasks
*/
#define TASK_SIZE_MIN (1UL << 39)
#define TASK_SIZE_MAX (1UL << 48)
unsigned long compel_task_size(void)
{
unsigned long task_size;
for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
if (munmap((void *)task_size, page_size()))
break;
return task_size;
}
static struct hwbp_cap *ptrace_get_hwbp_cap(pid_t pid)
{
static struct hwbp_cap info;
static int available = -1;
if (available == -1) {
unsigned int val;
struct iovec iovec = {
.iov_base = &val,
.iov_len = sizeof(val),
};
if (ptrace(PTRACE_GETREGSET, pid, NT_ARM_HW_BREAK, &iovec) < 0)
available = 0;
else {
info.arch = (char)((val >> 8) & 0xff);
info.bp_count = (char)(val & 0xff);
available = (info.arch != 0);
}
}
return available == 1 ? &info : NULL;
}
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
k_rtsigset_t block;
struct hwbp_cap *info = ptrace_get_hwbp_cap(pid);
struct user_hwdebug_state regs = {};
unsigned int ctrl = 0;
struct iovec iovec;
if (info == NULL || info->bp_count == 0)
return 0;
/*
* The struct is copied from `arch/arm64/include/asm/hw_breakpoint.h` in
* linux kernel:
* struct arch_hw_breakpoint_ctrl {
* __u32 __reserved : 19,
* len : 8,
* type : 2,
* privilege : 2,
* enabled : 1;
* };
*
* The part of `struct arch_hw_breakpoint_ctrl` bits meaning is defined
* in <>,
* D13.3.2 DBGBCR_EL1, Debug Breakpoint Control Registers.
*/
ctrl = ARM_BREAKPOINT_LEN_4;
ctrl = (ctrl << 2) | ARM_BREAKPOINT_EXECUTE;
ctrl = (ctrl << 2) | AARCH64_BREAKPOINT_EL0;
ctrl = (ctrl << 1) | ENABLE_HBP;
regs.dbg_regs[0].addr = (__u64)addr;
regs.dbg_regs[0].ctrl = ctrl;
iovec.iov_base = ®s;
iovec.iov_len = (offsetof(struct user_hwdebug_state, dbg_regs) + sizeof(regs.dbg_regs[0]));
if (ptrace(PTRACE_SETREGSET, pid, NT_ARM_HW_BREAK, &iovec))
return -1;
/*
* FIXME(issues/1429): SIGTRAP can't be blocked, otherwise its handler
* will be reset to the default one.
*/
ksigfillset(&block);
ksigdelset(&block, SIGTRAP);
if (ptrace(PTRACE_SETSIGMASK, pid, sizeof(k_rtsigset_t), &block)) {
pr_perror("Can't block signals for %d", pid);
return -1;
}
if (ptrace(PTRACE_CONT, pid, NULL, NULL) != 0) {
pr_perror("Unable to restart the stopped tracee process %d", pid);
return -1;
}
return 1;
}
int ptrace_flush_breakpoints(pid_t pid)
{
struct hwbp_cap *info = ptrace_get_hwbp_cap(pid);
struct user_hwdebug_state regs = {};
unsigned int ctrl = 0;
struct iovec iovec;
if (info == NULL || info->bp_count == 0)
return 0;
ctrl = ARM_BREAKPOINT_LEN_4;
ctrl = (ctrl << 2) | ARM_BREAKPOINT_EXECUTE;
ctrl = (ctrl << 2) | AARCH64_BREAKPOINT_EL0;
ctrl = (ctrl << 1) | DISABLE_HBP;
regs.dbg_regs[0].addr = 0ul;
regs.dbg_regs[0].ctrl = ctrl;
iovec.iov_base = ®s;
iovec.iov_len = (offsetof(struct user_hwdebug_state, dbg_regs) + sizeof(regs.dbg_regs[0]));
if (ptrace(PTRACE_SETREGSET, pid, NT_ARM_HW_BREAK, &iovec))
return -1;
return 0;
}
crac-criu-1.5.0/compel/arch/arm/ 0000775 0000000 0000000 00000000000 14715043267 0016351 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0020032 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0021455 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022235 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/include/asm/prologue.h 0000777 0000000 0000000 00000000000 14715043267 0034757 2../../../../../arch/x86/plugins/include/asm/prologue.h ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001170 14715043267 0025221 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
#define SA_RESTORER 0x04000000
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define _KNSIG 64
#define _NSIG_BPW 32
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
typedef struct {
unsigned long sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/arm/plugins/include/features.h 0000664 0000000 0000000 00000000151 14715043267 0023441 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/arm/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0020624 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/std/parasite-head.S 0000664 0000000 0000000 00000000371 14715043267 0023460 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(__export_parasite_head_start)
bl parasite_service
.byte 0xf0, 0x01, 0xf0, 0xe7 @ the instruction UDF #32 generates the signal SIGTRAP in Linux
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0022461 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000003672 14715043267 0025765 0 ustar 00root root 0000000 0000000 ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
sys-types := $(obj)/include/uapi/std/syscall-types.h
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
sys-proto := $(obj)/include/uapi/std/syscall.h
sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
sys-asm-common-name := std/syscalls/syscall-common.S
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
sys-gen := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
sys-gen-tbl := $(PLUGIN_ARCH_DIR)/std/syscalls/gen-sys-exec-tbl.pl
sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-lib-y += $(sys-asm:.S=).o
ifeq ($(ARCH),arm)
arch_bits := 32
else
arch_bits := 64
endif
sys-exec-tbl := sys-exec-tbl.c
$(sys-asm) $(sys-types) $(sys-codes) $(sys-proto): $(sys-gen) $(sys-def) $(sys-asm-common) $(sys-asm-types)
$(E) " GEN " $@
$(Q) perl \
$(sys-gen) \
$(sys-def) \
$(sys-codes) \
$(sys-proto) \
$(sys-asm) \
$(sys-asm-common-name) \
$(sys-types) \
$(arch_bits)
$(sys-asm:.S=).o: $(sys-asm)
$(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
$(E) " GEN " $@
$(Q) perl \
$(sys-gen-tbl) \
$(sys-def) \
$(sys-exec-tbl) \
$(arch_bits)
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h
std-headers-deps += $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y += $(std-headers-deps)
mrproper-y += $(obj)/include/uapi/std/syscall-aux.S
mrproper-y += $(obj)/include/uapi/std/syscall-aux.h
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/gen-sys-exec-tbl.pl 0000775 0000000 0000000 00000001574 14715043267 0026116 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use strict;
use warnings;
my $in = $ARGV[0];
my $tblout = $ARGV[1];
my $bits = $ARGV[2];
my $code = "code$bits";
open TBLOUT, ">", $tblout or die $!;
open IN, "<", $in or die $!;
print TBLOUT "/* Autogenerated, don't edit */\n";
print TBLOUT "static struct syscall_exec_desc sc_exec_table[] = {\n";
for () {
if ($_ =~ /\#/) {
next;
}
my $sys_name;
my $sys_num;
if (/(?\S+)\s+(?\S+)\s+(?\d+|\!)\s+(?(?:\d+|\!))\s+\((?.+)\)/) {
$sys_name = $+{alias};
} elsif (/(?\S+)\s+(?\d+|\!)\s+(?(?:\d+|\!))\s+\((?.+)\)/) {
$sys_name = $+{name};
} else {
unlink $tblout;
die "Invalid syscall definition file: invalid entry $_\n";
}
$sys_num = $+{$code};
if ($sys_num ne "!") {
print TBLOUT "SYSCALL($sys_name, $sys_num)\n";
}
}
print TBLOUT " { }, /* terminator */";
print TBLOUT "};"
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl 0000775 0000000 0000000 00000004462 14715043267 0025433 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use strict;
use warnings;
my $in = $ARGV[0];
my $codesout = $ARGV[1];
my $codes = $ARGV[1];
$codes =~ s/.*include\/uapi\//compel\/plugins\//g;
my $protosout = $ARGV[2];
my $protos = $ARGV[2];
$protos =~ s/.*include\/uapi\//compel\/plugins\//g;
my $asmout = $ARGV[3];
my $asmcommon = $ARGV[4];
my $prototypes = $ARGV[5];
$prototypes =~ s/.*include\/uapi\//compel\/plugins\//g;
my $bits = $ARGV[6];
my $codesdef = $codes;
$codesdef =~ tr/.\-\//_/;
my $protosdef = $protos;
$protosdef =~ tr/.\-\//_/;
my $code = "code$bits";
my $need_aux = 0;
unlink $codesout;
unlink $protosout;
unlink $asmout;
open CODESOUT, ">", $codesout or die $!;
open PROTOSOUT, ">", $protosout or die $!;
open ASMOUT, ">", $asmout or die $!;
open IN, "<", $in or die $!;
print CODESOUT <<"END";
/* Autogenerated, don't edit */
#ifndef $codesdef
#define $codesdef
END
print PROTOSOUT <<"END";
/* Autogenerated, don't edit */
#ifndef $protosdef
#define $protosdef
#include <$prototypes>
#include <$codes>
END
print ASMOUT <<"END";
/* Autogenerated, don't edit */
#include <$codes>
#include "$asmcommon"
END
for () {
if ($_ =~ /\#/) {
next;
}
my $code_macro;
my $sys_macro;
my $sys_name;
if (/(?\S+)\s+(?\S+)\s+(?\d+|\!)\s+(?(?:\d+|\!))\s+\((?.+)\)/) {
$code_macro = "__NR_$+{name}";
$sys_macro = "SYS_$+{name}";
$sys_name = "sys_$+{alias}";
} elsif (/(?\S+)\s+(?\d+|\!)\s+(?(?:\d+|\!))\s+\((?.+)\)/) {
$code_macro = "__NR_$+{name}";
$sys_macro = "SYS_$+{name}";
$sys_name = "sys_$+{name}";
} else {
unlink $codesout;
unlink $protosout;
unlink $asmout;
die "Invalid syscall definition file: invalid entry $_\n";
}
if ($+{$code} ne "!") {
print CODESOUT "#ifndef $code_macro\n#define $code_macro $+{$code}\n#endif\n";
print CODESOUT "#ifndef $sys_macro\n#define $sys_macro $code_macro\n#endif\n";
print ASMOUT "syscall $sys_name, $code_macro\n";
} else {
$need_aux = 1;
}
print PROTOSOUT "extern long $sys_name($+{args});\n";
}
if ($need_aux == 1) {
print ASMOUT "#include \n";
print CODESOUT "#include \n";
}
print CODESOUT "#endif /* $codesdef */";
print PROTOSOUT "#endif /* $protosdef */";
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/syscall-aux.S 0000664 0000000 0000000 00000000321 14715043267 0025046 0 ustar 00root root 0000000 0000000 nr_sys_mmap:
.long 192
ENTRY(sys_mmap)
push {r4, r5, r7, lr}
ldr r4, [sp, #16]
ldr r5, [sp, #20]
lsr r5, #12
adr r7, nr_sys_mmap
ldr r7, [r7]
svc 0x00000000
pop {r4, r5, r7, pc}
END(sys_mmap)
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/syscall-aux.h 0000664 0000000 0000000 00000000770 14715043267 0025103 0 ustar 00root root 0000000 0000000 #ifndef __NR_mmap2
#define __NR_mmap2 192
#endif
#ifndef __ARM_NR_BASE
#define __ARM_NR_BASE 0x0f0000
#endif
#ifndef __ARM_NR_breakpoint
#define __ARM_NR_breakpoint (__ARM_NR_BASE + 1)
#endif
#ifndef __ARM_NR_cacheflush
#define __ARM_NR_cacheflush (__ARM_NR_BASE + 2)
#endif
#ifndef __ARM_NR_usr26
#define __ARM_NR_usr26 (__ARM_NR_BASE + 3)
#endif
#ifndef __ARM_NR_usr32
#define __ARM_NR_usr32 (__ARM_NR_BASE + 4)
#endif
#ifndef __ARM_NR_set_tls
#define __ARM_NR_set_tls (__ARM_NR_BASE + 5)
#endif
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/syscall-common.S 0000664 0000000 0000000 00000001312 14715043267 0025542 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
@ We use the register R8 unlike libc that uses R12.
@ This avoids corruption of the register by the stub
@ for the syscall sys_munmap() when syscalls are hooked
@ by ptrace(). However we have to make sure that
@ the compiler doesn't use the register on the route
@ between parasite_service() and sys_munmap().
syscall_common:
ldr r7, [r7]
add r8, sp, #24
ldm r8, {r4, r5, r6}
svc 0x00000000
pop {r4, r5, r6, r7, r8, pc}
.macro syscall name, nr
.nr_\name :
.long \nr
ENTRY(\name)
push {r4, r5, r6, r7, r8, lr}
adr r7, .nr_\name
b syscall_common
END(\name)
.endm
ENTRY(__cr_restore_rt)
adr r7, .nr_sys_rt_sigreturn
ldr r7, [r7]
svc #0
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/arm/plugins/std/syscalls/syscall.def 0000664 0000000 0000000 00000017611 14715043267 0024621 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consists of only the syscalls
# really used somewhere in the project.
#
# The template is (name and arguments are optional if you need only __NR_x
# defined, but no real entry point in syscalls lib).
#
# name/alias code64 code32 arguments
# -----------------------------------------------------------------------
#
read 63 3 (int fd, void *buf, unsigned long count)
write 64 4 (int fd, const void *buf, unsigned long count)
open ! 5 (const char *filename, unsigned long flags, unsigned long mode)
close 57 6 (int fd)
lseek 62 19 (int fd, unsigned long offset, unsigned long origin)
mmap 222 ! (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
mprotect 226 125 (const void *addr, unsigned long len, unsigned long prot)
munmap 215 91 (void *addr, unsigned long len)
brk 214 45 (void *addr)
rt_sigaction sigaction 134 174 (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
rt_sigprocmask sigprocmask 135 175 (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
rt_sigreturn 139 173 (void)
ioctl 29 54 (unsigned int fd, unsigned int cmd, unsigned long arg)
pread64 67 180 (unsigned int fd, char *buf, size_t count, loff_t pos)
ptrace 117 26 (long request, pid_t pid, void *addr, void *data)
mremap 216 163 (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flag, unsigned long new_addr)
mincore 232 219 (void *addr, unsigned long size, unsigned char *vec)
madvise 233 220 (unsigned long start, size_t len, int behavior)
shmat 196 305 (int shmid, void *shmaddr, int shmflag)
pause 1061 29 (void)
nanosleep 101 162 (struct timespec *req, struct timespec *rem)
getitimer 102 105 (int which, const struct itimerval *val)
setitimer 103 104 (int which, const struct itimerval *val, struct itimerval *old)
getpid 172 20 (void)
socket 198 281 (int domain, int type, int protocol)
connect 203 283 (int sockfd, struct sockaddr *addr, int addrlen)
sendto 206 290 (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
recvfrom 207 292 (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
sendmsg 211 296 (int sockfd, const struct msghdr *msg, int flags)
recvmsg 212 297 (int sockfd, struct msghdr *msg, int flags)
shutdown 210 293 (int sockfd, int how)
bind 235 282 (int sockfd, const struct sockaddr *addr, int addrlen)
setsockopt 208 294 (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
getsockopt 209 295 (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
clone 220 120 (unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
exit 93 1 (unsigned long error_code)
wait4 260 114 (int pid, int *status, int options, struct rusage *ru)
waitid 95 280 (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
kill 129 37 (long pid, int sig)
fcntl 25 55 (int fd, int type, long arg)
flock 32 143 (int fd, unsigned long cmd)
mkdir ! 39 (const char *name, int mode)
rmdir ! 40 (const char *name)
unlink ! 10 (char *pathname)
readlinkat 78 332 (int fd, const char *path, char *buf, int bufsize)
umask 166 60 (int mask)
getgroups 158 205 (int gsize, unsigned int *groups)
setgroups 159 206 (int gsize, unsigned int *groups)
setresuid 147 164 (int uid, int euid, int suid)
getresuid 148 165 (int *uid, int *euid, int *suid)
setresgid 149 170 (int gid, int egid, int sgid)
getresgid 150 171 (int *gid, int *egid, int *sgid)
getpgid 155 132 (pid_t pid)
setfsuid 151 138 (int fsuid)
setfsgid 152 139 (int fsgid)
getsid 156 147 (void)
capget 90 184 (struct cap_header *h, struct cap_data *d)
capset 91 185 (struct cap_header *h, struct cap_data *d)
rt_sigqueueinfo 138 178 (pid_t pid, int sig, siginfo_t *info)
setpriority 140 97 (int which, int who, int nice)
sched_setscheduler 119 156 (int pid, int policy, struct sched_param *p)
sigaltstack 132 186 (const void *uss, void *uoss)
personality 92 136 (unsigned int personality)
prctl 167 172 (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
arch_prctl ! 17 (int option, unsigned long addr)
setrlimit 164 75 (int resource, struct krlimit *rlim)
mount 40 21 (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
umount2 39 52 (char *name, int flags)
gettid 178 224 (void)
futex 98 240 (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
set_tid_address 96 256 (int *tid_addr)
restart_syscall 128 0 (void)
timer_create 107 257 (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
timer_settime 110 258 (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
timer_gettime 108 259 (int timer_id, const struct itimerspec *setting)
timer_getoverrun 109 260 (int timer_id)
timer_delete 111 261 (kernel_timer_t timer_id)
clock_gettime 113 263 (const clockid_t which_clock, const struct timespec *tp)
exit_group 94 248 (int error_code)
set_robust_list 99 338 (struct robust_list_head *head, size_t len)
get_robust_list 100 339 (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
signalfd4 74 355 (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
rt_tgsigqueueinfo 240 363 (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
vmsplice 75 343 (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
timerfd_settime 86 353 (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
fanotify_init 262 367 (unsigned int flags, unsigned int event_f_flags)
fanotify_mark 263 368 (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
open_by_handle_at 265 371 (int mountdirfd, struct file_handle *handle, int flags)
setns 268 375 (int fd, int nstype)
kcmp 272 378 (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
openat 56 322 (int dirfd, const char *pathname, int flags, mode_t mode)
mkdirat 34 323 (int dirfd, const char *pathname, mode_t mode)
unlinkat 35 328 (int dirfd, const char *pathname, int flags)
memfd_create 279 385 (const char *name, unsigned int flags)
io_setup 0 243 (unsigned nr_events, aio_context_t *ctx)
io_submit 2 246 (aio_context_t ctx_id, long nr, struct iocb **iocbpp)
io_getevents 4 245 (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
seccomp 277 383 (unsigned int op, unsigned int flags, const char *uargs)
gettimeofday 169 78 (struct timeval *tv, struct timezone *tz)
preadv_raw 69 361 (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
userfaultfd 282 388 (int flags)
fallocate 47 352 (int fd, int mode, loff_t offset, loff_t len)
cacheflush ! 983042 (void *start, void *end, int flags)
ppoll 73 336 (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
open_tree 428 428 (int dirfd, const char *pathname, unsigned int flags)
move_mount 429 429 (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
fsopen 430 430 (char *fsname, unsigned int flags)
fsconfig 431 431 (int fd, unsigned int cmd, const char *key, const char *value, int aux)
fsmount 432 432 (int fd, unsigned int flags, unsigned int attr_flags)
clone3 435 435 (struct clone_args *uargs, size_t size)
pidfd_open 434 434 (pid_t pid, unsigned int flags)
openat2 437 437 (int dirfd, char *pathname, struct open_how *how, size_t size)
pidfd_getfd 438 438 (int pidfd, int targetfd, unsigned int flags)
rseq 293 398 (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
membarrier 283 389 (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/arm/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0020040 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000747 14715043267 0023150 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(arm)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.crblob 0x0 : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
. = ALIGN(32);
*(.data*)
. = ALIGN(32);
*(.rodata*)
. = ALIGN(32);
*(.bss*)
. = ALIGN(32);
*(.got*)
. = ALIGN(32);
*(.toc*)
. = ALIGN(32);
} =0x00000000,
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
*(*)
}
}
crac-criu-1.5.0/compel/arch/arm/src/ 0000775 0000000 0000000 00000000000 14715043267 0017140 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0017706 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/cpu.c 0000777 0000000 0000000 00000000000 14715043267 0025215 2../../../aarch64/src/lib/cpu.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025162 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/handle-elf.c 0000664 0000000 0000000 00000000762 14715043267 0022056 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_32[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_32, sizeof(elf_ident_32)) == 0)
return handle_elf_arm(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/arm/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0021331 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/include/cpu.h 0000664 0000000 0000000 00000000000 14715043267 0022257 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000435 14715043267 0023503 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf32-types.h"
#define __handle_elf handle_elf_arm
#define arch_is_machine_supported(e_machine) (e_machine == EM_ARM)
extern int handle_elf_arm(void *mem, size_t size);
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/arm/src/lib/include/syscall.h 0000664 0000000 0000000 00000000252 14715043267 0023153 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022267 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0023047 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/.gitignore 0000664 0000000 0000000 00000000000 14715043267 0025025 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000377 14715043267 0025550 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
}
static inline int ptrace_flush_breakpoints(pid_t pid)
{
return 0;
}
#endif
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000214 14715043267 0024004 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_CPU_H__
#define UAPI_COMPEL_ASM_CPU_H__
typedef struct {
} compel_cpuinfo_t;
#endif /* UAPI_COMPEL_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000121 14715043267 0024004 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000003311 14715043267 0025630 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#include
#define SIGMAX 64
#define SIGMAX_OLD 31
/*
* Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
*
* A thread ARM CPU context
*/
typedef struct {
long uregs[18];
} user_regs_struct_t;
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
typedef struct user_vfp user_fpregs_struct_t;
#define ARM_cpsr uregs[16]
#define ARM_pc uregs[15]
#define ARM_lr uregs[14]
#define ARM_sp uregs[13]
#define ARM_ip uregs[12]
#define ARM_fp uregs[11]
#define ARM_r10 uregs[10]
#define ARM_r9 uregs[9]
#define ARM_r8 uregs[8]
#define ARM_r7 uregs[7]
#define ARM_r6 uregs[6]
#define ARM_r5 uregs[5]
#define ARM_r4 uregs[4]
#define ARM_r3 uregs[3]
#define ARM_r2 uregs[2]
#define ARM_r1 uregs[1]
#define ARM_r0 uregs[0]
#define ARM_ORIG_r0 uregs[17]
/* Copied from arch/arm/include/asm/user.h */
struct user_vfp {
unsigned long long fpregs[32];
unsigned long fpscr;
};
struct user_vfp_exc {
unsigned long fpexc;
unsigned long fpinst;
unsigned long fpinst2;
};
#define REG_RES(regs) ((regs).ARM_r0)
#define REG_IP(regs) ((regs).ARM_pc)
#define SET_REG_IP(regs, val) ((regs).ARM_pc = (val))
#define REG_SP(regs) ((regs).ARM_sp)
#define REG_SYSCALL_NR(regs) ((regs).ARM_r7)
#define user_regs_native(pregs) true
#define ARCH_SI_TRAP TRAP_BRKPT
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/processor-flags.h 0000664 0000000 0000000 00000002115 14715043267 0026330 0 ustar 00root root 0000000 0000000 #ifndef __CR_PROCESSOR_FLAGS_H__
#define __CR_PROCESSOR_FLAGS_H__
/* Copied from the Linux kernel header arch/arm/include/uapi/asm/ptrace.h */
/*
* PSR bits
*/
#define USR26_MODE 0x00000000
#define FIQ26_MODE 0x00000001
#define IRQ26_MODE 0x00000002
#define SVC26_MODE 0x00000003
#define USR_MODE 0x00000010
#define FIQ_MODE 0x00000011
#define IRQ_MODE 0x00000012
#define SVC_MODE 0x00000013
#define ABT_MODE 0x00000017
#define UND_MODE 0x0000001b
#define SYSTEM_MODE 0x0000001f
#define MODE32_BIT 0x00000010
#define MODE_MASK 0x0000001f
#define PSR_T_BIT 0x00000020
#define PSR_F_BIT 0x00000040
#define PSR_I_BIT 0x00000080
#define PSR_A_BIT 0x00000100
#define PSR_E_BIT 0x00000200
#define PSR_J_BIT 0x01000000
#define PSR_Q_BIT 0x08000000
#define PSR_V_BIT 0x10000000
#define PSR_C_BIT 0x20000000
#define PSR_Z_BIT 0x40000000
#define PSR_N_BIT 0x80000000
/*
* Groups of PSR bits
*/
#define PSR_f 0xff000000 /* Flags */
#define PSR_s 0x00ff0000 /* Status */
#define PSR_x 0x0000ff00 /* Extension */
#define PSR_c 0x000000ff /* Control */
#endif
crac-criu-1.5.0/compel/arch/arm/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000004550 14715043267 0025021 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
/* Copied from the Linux kernel header arch/arm/include/asm/sigcontext.h */
struct rt_sigcontext {
unsigned long trap_no;
unsigned long error_code;
unsigned long oldmask;
unsigned long arm_r0;
unsigned long arm_r1;
unsigned long arm_r2;
unsigned long arm_r3;
unsigned long arm_r4;
unsigned long arm_r5;
unsigned long arm_r6;
unsigned long arm_r7;
unsigned long arm_r8;
unsigned long arm_r9;
unsigned long arm_r10;
unsigned long arm_fp;
unsigned long arm_ip;
unsigned long arm_sp;
unsigned long arm_lr;
unsigned long arm_pc;
unsigned long arm_cpsr;
unsigned long fault_address;
};
/* Copied from the Linux kernel header arch/arm/include/asm/ucontext.h */
#define VFP_MAGIC 0x56465001
#define VFP_STORAGE_SIZE sizeof(struct vfp_sigframe)
struct vfp_sigframe {
unsigned long magic;
unsigned long size;
struct user_vfp ufp;
struct user_vfp_exc ufp_exc;
};
typedef struct vfp_sigframe fpu_state_t;
struct aux_sigframe {
/*
struct crunch_sigframe crunch;
struct iwmmxt_sigframe iwmmxt;
*/
struct vfp_sigframe vfp;
unsigned long end_magic;
} __attribute__((aligned(8)));
#include
struct sigframe {
struct rt_ucontext uc;
unsigned long retcode[2];
};
struct rt_sigframe {
struct rt_siginfo info;
struct sigframe sig;
};
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"mov sp, %0 \n" \
"mov r7, #"__stringify(__NR_rt_sigreturn)" \n" \
"svc #0 \n" \
: \
: "r"(new_sp) \
: "memory")
/* clang-format on */
#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->sig.uc)
#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->sig.uc.uc_mcontext.arm_ip
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1
#define RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe) ((struct aux_sigframe *)&(rt_sigframe)->sig.uc.uc_regspace)
#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe)->vfp)
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->sig.uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->sig.uc.uc_sigmask, from, sizeof(k_rtsigset_t))
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/arm/src/lib/infect.c 0000664 0000000 0000000 00000012316 14715043267 0021325 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include "common/page.h"
#include "uapi/compel/asm/infect-types.h"
#include "log.h"
#include "errno.h"
#include "infect.h"
#include "infect-priv.h"
/*
* Injected syscall instruction
*/
const char code_syscall[] = {
0x00, 0x00, 0x00, 0xef, /* SVC #0 */
0xf0, 0x01, 0xf0, 0xe7 /* UDF #32 */
};
static const int code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static inline __always_unused void __check_code_syscall(void)
{
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
struct aux_sigframe *aux = (struct aux_sigframe *)(void *)&sigframe->sig.uc.uc_regspace;
sigframe->sig.uc.uc_mcontext.arm_r0 = regs->ARM_r0;
sigframe->sig.uc.uc_mcontext.arm_r1 = regs->ARM_r1;
sigframe->sig.uc.uc_mcontext.arm_r2 = regs->ARM_r2;
sigframe->sig.uc.uc_mcontext.arm_r3 = regs->ARM_r3;
sigframe->sig.uc.uc_mcontext.arm_r4 = regs->ARM_r4;
sigframe->sig.uc.uc_mcontext.arm_r5 = regs->ARM_r5;
sigframe->sig.uc.uc_mcontext.arm_r6 = regs->ARM_r6;
sigframe->sig.uc.uc_mcontext.arm_r7 = regs->ARM_r7;
sigframe->sig.uc.uc_mcontext.arm_r8 = regs->ARM_r8;
sigframe->sig.uc.uc_mcontext.arm_r9 = regs->ARM_r9;
sigframe->sig.uc.uc_mcontext.arm_r10 = regs->ARM_r10;
sigframe->sig.uc.uc_mcontext.arm_fp = regs->ARM_fp;
sigframe->sig.uc.uc_mcontext.arm_ip = regs->ARM_ip;
sigframe->sig.uc.uc_mcontext.arm_sp = regs->ARM_sp;
sigframe->sig.uc.uc_mcontext.arm_lr = regs->ARM_lr;
sigframe->sig.uc.uc_mcontext.arm_pc = regs->ARM_pc;
sigframe->sig.uc.uc_mcontext.arm_cpsr = regs->ARM_cpsr;
memcpy(&aux->vfp.ufp.fpregs, &fpregs->fpregs, sizeof(aux->vfp.ufp.fpregs));
aux->vfp.ufp.fpscr = fpregs->fpscr;
aux->vfp.magic = VFP_MAGIC;
aux->vfp.size = VFP_STORAGE_SIZE;
return 0;
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
#define PTRACE_GETVFPREGS 27
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *vfp = ext_regs ? ext_regs : &tmp;
int ret = -1;
pr_info("Dumping GP/FPU registers for %d\n", pid);
if (ptrace(PTRACE_GETVFPREGS, pid, NULL, vfp)) {
pr_perror("Can't obtain FPU registers for %d", pid);
goto err;
}
/* Did we come from a system call? */
if ((int)regs->ARM_ORIG_r0 >= 0) {
/* Restart the system call */
switch ((long)(int)regs->ARM_r0) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
regs->ARM_r0 = regs->ARM_ORIG_r0;
regs->ARM_pc -= 4;
break;
case -ERESTART_RESTARTBLOCK:
pr_warn("Will restore %d with interrupted system call\n", pid);
regs->ARM_r0 = -EINTR;
break;
}
}
ret = save(arg, regs, vfp);
err:
return ret;
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
pr_info("Restoring GP/FPU registers for %d\n", pid);
if (ptrace(PTRACE_SETVFPREGS, pid, NULL, ext_regs)) {
pr_perror("Can't set FPU registers for %d", pid);
return -1;
}
return 0;
}
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
regs.ARM_r7 = (unsigned long)nr;
regs.ARM_r0 = arg1;
regs.ARM_r1 = arg2;
regs.ARM_r2 = arg3;
regs.ARM_r3 = arg4;
regs.ARM_r4 = arg5;
regs.ARM_r5 = arg6;
err = compel_execute_syscall(ctl, ®s, code_syscall);
*ret = regs.ARM_r0;
return err;
}
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
if (offset & ~PAGE_MASK)
return 0;
err = compel_syscall(ctl, __NR_mmap2, &map, (unsigned long)addr, length, prot, flags, fd, offset >> 12);
if (err < 0 || map > ctl->ictx.task_size)
map = 0;
return (void *)map;
}
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->ARM_pc = new_ip;
if (stack)
regs->ARM_sp = (unsigned long)stack;
/* Make sure flags are in known state */
regs->ARM_cpsr &= PSR_f | PSR_s | PSR_x | MODE32_BIT;
}
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
/*
* TODO: Add proper check here
*/
return true;
}
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->sig.uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
/*
* Range for task size calculated from the following Linux kernel files:
* arch/arm/include/asm/memory.h
* arch/arm/Kconfig (PAGE_OFFSET values in Memory split section)
*/
#define TASK_SIZE_MIN 0x3f000000
#define TASK_SIZE_MAX 0xbf000000
#define SZ_1G 0x40000000
unsigned long compel_task_size(void)
{
unsigned long task_size;
for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size += SZ_1G)
if (munmap((void *)task_size, page_size()))
break;
return task_size;
}
crac-criu-1.5.0/compel/arch/loongarch64/ 0000775 0000000 0000000 00000000000 14715043267 0017720 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0021401 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0023024 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0023604 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/include/asm/prologue.h 0000664 0000000 0000000 00000001256 14715043267 0025615 0 ustar 00root root 0000000 0000000 #ifndef __ASM_PROLOGUE_H__
#define __ASM_PROLOGUE_H__
#ifndef __ASSEMBLY__
#include
#include
#include
#include
#define sys_recv(sockfd, ubuf, size, flags) sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL)
typedef struct prologue_init_args {
struct sockaddr_un ctl_sock_addr;
unsigned int ctl_sock_addr_len;
unsigned int arg_s;
void *arg_p;
void *sigframe;
} prologue_init_args_t;
#endif /* __ASSEMBLY__ */
/*
* Reserve enough space for sigframe.
*
* FIXME It is rather should be taken from sigframe header.
*/
#define PROLOGUE_SGFRAME_SIZE 4096
#define PROLOGUE_INIT_ARGS_SIZE 1024
#endif /* __ASM_PROLOGUE_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001417 14715043267 0026574 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
#include
/* Types for sigaction, sigprocmask syscalls */
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
/* refer to arch/loongarch/include/uapi/asm/signal.h */
#define _KNSIG 64
#define _NSIG_BPW BITS_PER_LONG
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
typedef struct {
uint64_t sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
#define SA_RESTORER 0x04000000
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/plugins/include/features.h 0000664 0000000 0000000 00000000151 14715043267 0025010 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0022173 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/parasite-head.S 0000664 0000000 0000000 00000000244 14715043267 0025026 0 ustar 00root root 0000000 0000000
#include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(__export_parasite_head_start)
bl parasite_service;
break 0;
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0024030 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000011345 14715043267 0027330 0 ustar 00root root 0000000 0000000 std-lib-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
sys-proto-types := $(obj)/include/uapi/std/syscall-types.h
sys-proto-generic := $(obj)/include/uapi/std/syscall.h
sys-codes-generic := $(obj)/include/uapi/std/syscall-codes.h
sys-codes = $(obj)/include/uapi/std/syscall-codes-$(1).h
sys-proto = $(obj)/include/uapi/std/syscall-$(1).h
sys-def = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
sys-asm = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
sys-asm-common-name = std/syscalls/syscall-common-loongarch-$(1).S
sys-asm-common = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
sys-bits := 64
AV := $$$$
define gen-rule-sys-codes
$(sys-codes): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1; \
sub("^__NR", "SYS", SYSN); \
print "\n#ifndef ", $(AV)1; \
print "#define", $(AV)1, $(AV)2; \
print "#endif"; \
print "\n#ifndef ", SYSN; \
print "#define ", SYSN, $(AV)1; \
print "#endif";}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-proto
$(sys-proto): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include ' >> $$@
ifeq ($(1),32)
$(Q) echo '#include "asm/syscall32.h"' >> $$@
endif
$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3, \
substr($(AV)0, index($(AV)0,$(AV)4)), ";"}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-asm
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include "$(sys-asm-common-name)"' >> $$@
$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}' >> $$@
endef
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(sys-codes-generic): $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo '#include ' >> $@
$(Q) cat $< | awk '/^__NR/{NR32=$$1; \
sub("^__NR", "__NR32", NR32); \
print "\n#ifndef ", NR32; \
print "#define ", NR32, $$2; \
print "#endif";}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
mrproper-y += $(sys-codes-generic)
$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "" >> $@
$(Q) echo '#include ' >> $@
$(Q) echo "" >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
mrproper-y += $(sys-proto-generic)
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
std-headers-deps += $(call sys-codes,$(sys-bits))
std-headers-deps += $(call sys-proto,$(sys-bits))
std-headers-deps += $(call sys-asm,$(sys-bits))
std-headers-deps += $(call sys-exec-tbl,$(sys-bits))
std-headers-deps += $(sys-codes-generic)
std-headers-deps += $(sys-proto-generic)
std-headers-deps += $(sys-asm-types)
mrproper-y += $(std-headers-deps)
crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/syscalls/syscall-common-loongarch-64.S 0000664 0000000 0000000 00000001406 14715043267 0031316 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
#define SYSCALL(name, opcode) \
ENTRY(name); \
addi.d $a7, $zero, opcode; \
syscall 0; \
jirl $r0, $r1, 0; \
END(name)
#ifndef AT_FDCWD
#define AT_FDCWD -100
#endif
#ifndef AT_REMOVEDIR
#define AT_REMOVEDIR 0x200
#endif
ENTRY(sys_open)
or $a3, $zero, $a2
or $a2, $zero, $a1
or $a1, $zero, $a0
addi.d $a0, $zero, AT_FDCWD
b sys_openat
END(sys_open)
ENTRY(sys_mkdir)
or $a3, $zero, $a2
or $a2, $zero, $a1
or $a1, $zero, $a0
addi.d $a0, $zero, AT_FDCWD
b sys_mkdirat
END(sys_mkdir)
ENTRY(sys_rmdir)
addi.d $a2, $zero, AT_REMOVEDIR
or $a1, $zero, $a0
addi.d $a0, $zero, AT_FDCWD
b sys_unlinkat
END(sys_rmdir)
ENTRY(__cr_restore_rt)
addi.d $a7, $zero, __NR_rt_sigreturn
syscall 0
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/loongarch64/plugins/std/syscalls/syscall_64.tbl 0000664 0000000 0000000 00000023200 14715043267 0026513 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consist only the syscalls
# really used somewhere in project.
# from kernel/linux-3.10.84/arch/mips/include/uapi/asm/unistd.h Linux 64-bit syscalls are in the range from 5000 to 5999.
#
# __NR_name code name arguments
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
__NR_io_setup 0 sys_io_setup (unsigned nr_events, aio_context_t *ctx)
__NR_io_submit 2 sys_io_submit (aio_context_t ctx, long nr, struct iocb **iocbpp)
__NR_io_getevents 4 sys_io_getevents (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
__NR_fcntl 25 sys_fcntl (int fd, int type, long arg)
__NR_ioctl 29 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_flock 32 sys_flock (int fd, unsigned long cmd)
__NR_mkdirat 34 sys_mkdirat (int dfd, const char *pathname, int flag)
__NR_unlinkat 35 sys_unlinkat (int dfd, const char *pathname, int flag)
__NR_umount2 39 sys_umount2 (char *name, int flags)
__NR_mount 40 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_fallocate 47 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_close 57 sys_close (int fd)
__NR_openat 56 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_lseek 62 sys_lseek (int fd, unsigned long offset, unsigned long origin)
__NR_read 63 sys_read (int fd, void *buf, unsigned long count)
__NR_write 64 sys_write (int fd, const void *buf, unsigned long count)
__NR_pread64 67 sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos)
__NR_preadv 69 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_ppoll 73 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_signalfd4 74 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_vmsplice 75 sys_vmsplice (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
__NR_readlinkat 78 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_timerfd_settime 86 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_capget 90 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 91 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_personality 92 sys_personality (unsigned int personality)
__NR_exit 93 sys_exit (unsigned long error_code)
__NR_exit_group 94 sys_exit_group (int error_code)
__NR_waitid 95 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_set_tid_address 96 sys_set_tid_address (int *tid_addr)
__NR_futex 98 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_robust_list 99 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 100 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_nanosleep 101 sys_nanosleep (struct timespec *req, struct timespec *rem)
__NR_getitimer 102 sys_getitimer (int which, const struct itimerval *val)
__NR_setitimer 103 sys_setitimer (int which, const struct itimerval *val, struct itimerval *old)
__NR_sys_timer_create 107 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_sys_timer_gettime 108 sys_timer_gettime (int timer_id, const struct itimerspec *setting)
__NR_sys_timer_getoverrun 109 sys_timer_getoverrun (int timer_id)
__NR_sys_timer_settime 110 sys_timer_settime (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
__NR_sys_timer_delete 111 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 113 sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp)
__NR_sched_setscheduler 119 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_restart_syscall 128 sys_restart_syscall (void)
__NR_kill 129 sys_kill (long pid, int sig)
__NR_sigaltstack 132 sys_sigaltstack (const void *uss, void *uoss)
__NR_rt_sigaction 134 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 135 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
__NR_rt_sigqueueinfo 138 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *info)
__NR_rt_sigreturn 139 sys_rt_sigreturn (void)
__NR_setpriority 140 sys_setpriority (int which, int who, int nice)
__NR_setresuid 147 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid 148 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid 149 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid 150 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_getpgid 155 sys_getpgid (pid_t pid)
__NR_setfsuid 151 sys_setfsuid (int fsuid)
__NR_setfsgid 152 sys_setfsgid (int fsgid)
__NR_getsid 156 sys_getsid (void)
__NR_getgroups 158 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups 159 sys_setgroups (int gsize, unsigned int *groups)
__NR_setrlimit 164 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_umask 166 sys_umask (int mask)
__NR_prctl 167 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_gettimeofday 169 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_getpid 172 sys_getpid (void)
__NR_ptrace 177 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_gettid 178 sys_gettid (void)
__NR_shmat 196 sys_shmat (int shmid, void *shmaddr, int shmflag)
__NR_socket 198 sys_socket (int domain, int type, int protocol)
__NR_bind 200 sys_bind (int sockfd, const struct sockaddr *addr, int addrlen)
__NR_connect 203 sys_connect (int sockfd, struct sockaddr *addr, int addrlen)
__NR_sendto 206 sys_sendto (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
__NR_recvfrom 207 sys_recvfrom (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
__NR_setsockopt 208 sys_setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
__NR_getsockopt 209 sys_getsockopt (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
__NR_shutdown 210 sys_shutdown (int sockfd, int how)
__NR_sendmsg 211 sys_sendmsg (int sockfd, const struct msghdr *msg, int flags)
__NR_recvmsg 212 sys_recvmsg (int sockfd, struct msghdr *msg, int flags)
__NR_brk 214 sys_brk (void *addr)
__NR_munmap 215 sys_munmap (void *addr, unsigned long len)
__NR_mremap 216 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_clone 220 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
__NR_mmap 222 sys_mmap (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
__NR_mprotect 226 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_mincore 232 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 233 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_rt_tgsigqueueinfo 240 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_wait4 260 sys_wait4 (int pid, int *status, int options, struct rusage *ru)
__NR_fanotify_init 262 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 263 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 265 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 268 sys_setns (int fd, int nstype)
__NR_kcmp 272 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_seccomp 277 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_memfd_create 279 sys_memfd_create (const char *name, unsigned int flags)
__NR_userfaultfd 282 sys_userfaultfd (int flags)
__NR_membarrier 283 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
__NR_rseq 293 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_openat2 437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
#__NR_dup2 ! sys_dup2 (int oldfd, int newfd)
#__NR_rmdir ! sys_rmdir (const char *name)
#__NR_unlink ! sys_unlink (char *pathname)
#__NR_cacheflush ! sys_cacheflush (char *addr, int nbytes, int cache)
#__NR_set_thread_area ! sys_set_thread_area (unsigned long *addr)
#__NR_mkdir ! sys_mkdir (const char *name, int mode)
#__NR_open ! sys_open (const char *filename, unsigned long flags, unsigned long mode)
crac-criu-1.5.0/compel/arch/loongarch64/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0021407 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000755 14715043267 0024516 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(loongarch)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.crblob 0x0 : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
. = ALIGN(32);
*(.data*)
. = ALIGN(32);
*(.rodata*)
. = ALIGN(32);
*(.bss*)
. = ALIGN(32);
*(.got*)
. = ALIGN(32);
*(.toc*)
. = ALIGN(32);
} =0x00000000,
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
*(*)
}
}
crac-criu-1.5.0/compel/arch/loongarch64/src/ 0000775 0000000 0000000 00000000000 14715043267 0020507 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0021255 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/src/lib/cpu.c 0000664 0000000 0000000 00000001312 14715043267 0022205 0 ustar 00root root 0000000 0000000 #include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "common/compiler.h"
#include "log.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static bool rt_info_done = false;
void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
return 0;
}
int compel_cpuid(compel_cpuinfo_t *c)
{
return 0;
}
bool compel_cpu_has_feature(unsigned int feature)
{
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
return compel_test_cpu_cap(&rt_info, feature);
}
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/handle-elf-host.c 0000664 0000000 0000000 00000001053 14715043267 0024372 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
extern int __handle_elf(void *mem, size_t size);
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_64_le, sizeof(elf_ident_64_le)) == 0)
return __handle_elf(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/handle-elf.c 0000664 0000000 0000000 00000001053 14715043267 0023417 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
extern int __handle_elf(void *mem, size_t size);
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_64_le, sizeof(elf_ident_64_le)) == 0)
return __handle_elf(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0022700 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000304 14715043267 0025045 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define arch_is_machine_supported(e_machine) (e_machine == EM_LOONGARCH)
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/syscall.h 0000664 0000000 0000000 00000000161 14715043267 0024521 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#ifndef SIGSTKFLT
#define SIGSTKFLT 16
#endif
#endif
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0023636 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0024416 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000322 14715043267 0027105 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
extern int ptrace_set_breakpoint(pid_t pid, void *addr);
extern int ptrace_flush_breakpoints(pid_t pid);
#endif
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000166 14715043267 0025361 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_CPU_H__
#define __CR_ASM_CPU_H__
typedef struct {
} compel_cpuinfo_t;
#endif /* __CR_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000121 14715043267 0025353 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000002721 14715043267 0027203 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#define SIGMAX 64
#define SIGMAX_OLD 31
/*
* From the Linux kernel header arch/loongarch/include/uapi/asm/ptrace.h
*
* A thread LoongArch CPU context
*
* struct user_fp_state {
* uint64_t fpr[32];
* uint64_t fcc;
* uint32_t fcsr;
* };
*
* struct user_pt_regs {
* unsigned long regs[32];
* unsigned long csr_era;
* unsigned long csr_badv;
* unsigned long reserved[11];
* };
*/
struct user_gp_regs {
uint64_t regs[32];
uint64_t orig_a0;
uint64_t pc;
uint64_t csr_badv;
uint64_t reserved[10];
} __attribute__((aligned(8)));
struct user_fp_regs {
uint64_t regs[32];
uint64_t fcc;
uint32_t fcsr;
};
typedef struct user_gp_regs user_regs_struct_t;
typedef struct user_fp_regs user_fpregs_struct_t;
#define user_regs_native(regs) true
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
#define REG_RES(r) ((uint64_t)(r).regs[4])
#define REG_IP(r) ((uint64_t)(r).pc)
#define REG_SP(r) ((uint64_t)(r).regs[3])
#define REG_SYSCALL_NR(r) ((uint64_t)(r).regs[11])
#define SET_REG_IP(r, val) ((r).pc = (val))
#define GPR_NUM 32
#define FPR_NUM 32
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000005534 14715043267 0026373 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
#include
#include
#include
#include
#include
#define rt_sigcontext sigcontext
/* sigcontext defined in usr/include/uapi/asm/sigcontext.h*/
#include
typedef __u32 u32;
typedef struct sigcontext_t {
__u64 pc;
__u64 regs[32];
__u32 flags;
__u64 extcontext[0] __attribute__((__aligned__(16)));
} sigcontext_t;
typedef struct context_info_t {
__u32 magic;
__u32 size;
__u64 padding;
} context_info_t;
#define FPU_CTX_MAGIC 0x46505501
#define FPU_CTX_ALIGN 8
typedef struct fpu_context_t {
__u64 regs[32];
__u64 fcc;
__u64 fcsr;
} fpu_context_t;
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
__u8 __unused[1024 / 8 - sizeof(sigset_t)];
sigcontext_t uc_mcontext;
} ucontext;
/* Copy from the kernel source arch/loongarch/kernel/signal.c */
struct rt_sigframe {
rt_siginfo_t rs_info;
ucontext rs_uc;
};
#define RT_SIGFRAME_UC(rt_sigframe) (&(rt_sigframe->rs_uc))
#define RT_SIGFRAME_SIGMASK(rt_sigframe) ((k_rtsigset_t *)&RT_SIGFRAME_UC(rt_sigframe)->uc_sigmask)
#define RT_SIGFRAME_SIGCTX(rt_sigframe) (&(RT_SIGFRAME_UC(rt_sigframe)->uc_mcontext))
#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(RT_SIGFRAME_SIGCTX(rt_sigframe)->pc))
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
#define RT_SIGFRAME_FPU(rt_sigframe) \
({ \
context_info_t *ctx = (context_info_t *)RT_SIGFRAME_SIGCTX(rt_sigframe)->extcontext; \
ctx->magic = FPU_CTX_MAGIC; \
ctx->size = sizeof(context_info_t) + sizeof(fpu_context_t); \
(fpu_context_t *)((char *)ctx + sizeof(context_info_t)); \
})
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"addi.d $sp, %0, 0 \n" \
"addi.d $a7, $zero, "__stringify(__NR_rt_sigreturn)" \n" \
"syscall 0" \
: \
:"r"(new_sp) \
: "$a7", "memory")
/* clang-format on */
int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe);
#define rt_sigframe_erase_sigset(sigframe) memset(RT_SIGFRAME_SIGMASK(sigframe), 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(RT_SIGFRAME_SIGMASK(sigframe), from, sizeof(k_rtsigset_t))
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/loongarch64/src/lib/infect.c 0000664 0000000 0000000 00000011336 14715043267 0022675 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include "errno.h"
#include
#include
#include "common/err.h"
#include "common/page.h"
#include "asm/infect-types.h"
#include "ptrace.h"
#include "infect.h"
#include "infect-priv.h"
#include "log.h"
#include "common/bug.h"
/*
* Injected syscall instruction
* loongarch64 is Little Endian
*/
const char code_syscall[] = {
0x00, 0x00, 0x2b, 0x00, /* syscall */
0x00, 0x00, 0x2a, 0x00 /* break */
};
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
sigcontext_t *sc;
fpu_context_t *fpu;
sc = RT_SIGFRAME_SIGCTX(sigframe);
memcpy(sc->regs, regs->regs, sizeof(regs->regs));
sc->pc = regs->pc;
fpu = RT_SIGFRAME_FPU(sigframe);
memcpy(fpu->regs, fpregs->regs, sizeof(fpregs->regs));
fpu->fcc = fpregs->fcc;
fpu->fcsr = fpregs->fcsr;
return 0;
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
struct iovec iov;
int ret;
pr_info("Dumping GP/FPU registers for %d\n", pid);
iov.iov_base = regs;
iov.iov_len = sizeof(user_regs_struct_t);
if ((ret = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov))) {
pr_perror("Failed to obtain CPU registers for %d", pid);
goto err;
}
/*
* Refer to Linux kernel arch/loongarch/kernel/signal.c
*/
if (regs->regs[0]) {
switch (regs->regs[4]) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
regs->regs[4] = regs->orig_a0;
regs->pc -= 4;
break;
case -ERESTART_RESTARTBLOCK:
regs->regs[4] = regs->orig_a0;
regs->regs[11] = __NR_restart_syscall;
regs->pc -= 4;
break;
}
regs->regs[0] = 0; /* Don't deal with this again. */
}
iov.iov_base = fpregs;
iov.iov_len = sizeof(user_fpregs_struct_t);
if ((ret = ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov))) {
pr_perror("Failed to obtain FPU registers for %d", pid);
goto err;
}
ret = save(arg, regs, fpregs);
err:
return 0;
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
struct iovec iov;
pr_info("Restoring GP/FPU registers for %d\n", pid);
iov.iov_base = ext_regs;
iov.iov_len = sizeof(*ext_regs);
if (ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov)) {
pr_perror("Failed to set FPU registers for %d", pid);
return -1;
}
return 0;
}
/*
* Registers $4 ~ $11 represents arguments a0 ~ a7, especially a7 is
* used as syscall number.
*/
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
int err;
user_regs_struct_t regs = ctl->orig.regs;
regs.regs[11] = (unsigned long)nr;
regs.regs[4] = arg1;
regs.regs[5] = arg2;
regs.regs[6] = arg3;
regs.regs[7] = arg4;
regs.regs[8] = arg5;
regs.regs[9] = arg6;
err = compel_execute_syscall(ctl, ®s, code_syscall);
*ret = regs.regs[4];
return err;
}
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset >> PAGE_SHIFT);
if (err < 0 || IS_ERR_VALUE(map)) {
pr_err("remote mmap() failed: %s\n", strerror(-map));
return NULL;
}
return (void *)map;
}
/*
* regs must be inited when calling this function from original context
*/
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->pc = new_ip;
if (stack)
regs->regs[4] = (unsigned long)stack;
}
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
return true;
}
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->rs_uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
/*
* TODO: add feature
*/
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
}
int ptrace_flush_breakpoints(pid_t pid)
{
return 0;
}
/*
* Refer to Linux kernel arch/loongarch/include/asm/processor.h
*/
#define TASK_SIZE32 (1UL) << 31
#define TASK_SIZE64_MIN (1UL) << 40
#define TASK_SIZE64_MAX (1UL) << 48
unsigned long compel_task_size(void)
{
unsigned long task_size;
for (task_size = TASK_SIZE64_MIN; task_size < TASK_SIZE64_MAX; task_size <<= 1)
if (munmap((void *)task_size, page_size()))
break;
return task_size;
}
crac-criu-1.5.0/compel/arch/mips/ 0000775 0000000 0000000 00000000000 14715043267 0016542 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0020223 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0021646 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022426 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/include/asm/prologue.h 0000664 0000000 0000000 00000001256 14715043267 0024437 0 ustar 00root root 0000000 0000000 #ifndef __ASM_PROLOGUE_H__
#define __ASM_PROLOGUE_H__
#ifndef __ASSEMBLY__
#include
#include
#include
#include
#define sys_recv(sockfd, ubuf, size, flags) sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL)
typedef struct prologue_init_args {
struct sockaddr_un ctl_sock_addr;
unsigned int ctl_sock_addr_len;
unsigned int arg_s;
void *arg_p;
void *sigframe;
} prologue_init_args_t;
#endif /* __ASSEMBLY__ */
/*
* Reserve enough space for sigframe.
*
* FIXME It is rather should be taken from sigframe header.
*/
#define PROLOGUE_SGFRAME_SIZE 4096
#define PROLOGUE_INIT_ARGS_SIZE 1024
#endif /* __ASM_PROLOGUE_H__ */
crac-criu-1.5.0/compel/arch/mips/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001656 14715043267 0025423 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
/* Types for sigaction, sigprocmask syscalls */
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define SA_RESTORER 0x04000000
/** refer to linux-3.10/arch/mips/include/uapi/asm/signal.h*/
#define _KNSIG 128
#define _NSIG_BPW 64
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
/*
* Note: as k_rtsigset_t is the same size for 32-bit and 64-bit,
* sig defined as uint64_t rather than (unsigned long) - for the
* purpose if we ever going to support native 32-bit compilation.
*/
typedef struct {
uint64_t sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/mips/plugins/include/features.h 0000664 0000000 0000000 00000000202 14715043267 0023627 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#define ARCH_HAS_MEMCPY
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/mips/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0021015 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/std/memcpy.S 0000664 0000000 0000000 00000000416 14715043267 0022434 0 ustar 00root root 0000000 0000000
#include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(memcpy)
.set noreorder
dadd v0,zero,a0
daddiu t1,zero,0
loop:
beq t1,a2,exit
nop
lb t2,0(a1)
sb t2,0(a0)
daddiu t1,t1,1
daddiu a0,a0,1
daddiu a1,a1,1
j loop
nop
exit:
jr ra
nop
END(memcpy)
crac-criu-1.5.0/compel/arch/mips/plugins/std/parasite-head.S 0000664 0000000 0000000 00000000417 14715043267 0023652 0 ustar 00root root 0000000 0000000
#include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(__export_parasite_head_start)
.set push
.set noreorder
jal parasite_service
nop
.byte 0x0d, 0x00, 0x00, 0x00 //break
.set pop
// .byte 0x40,0x01,0x00,0x00 //pause
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/mips/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0022652 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000011340 14715043267 0026145 0 ustar 00root root 0000000 0000000 std-lib-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
sys-proto-types := $(obj)/include/uapi/std/syscall-types.h
sys-proto-generic := $(obj)/include/uapi/std/syscall.h
sys-codes-generic := $(obj)/include/uapi/std/syscall-codes.h
sys-codes = $(obj)/include/uapi/std/syscall-codes-$(1).h
sys-proto = $(obj)/include/uapi/std/syscall-$(1).h
sys-def = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
sys-asm = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
sys-asm-common-name = std/syscalls/syscall-common-mips-$(1).S
sys-asm-common = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
sys-bits := 64
AV := $$$$
define gen-rule-sys-codes
$(sys-codes): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1; \
sub("^__NR", "SYS", SYSN); \
print "\n#ifndef ", $(AV)1; \
print "#define", $(AV)1, $(AV)2; \
print "#endif"; \
print "\n#ifndef ", SYSN; \
print "#define ", SYSN, $(AV)1; \
print "#endif";}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-proto
$(sys-proto): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include ' >> $$@
ifeq ($(1),32)
$(Q) echo '#include "asm/syscall32.h"' >> $$@
endif
$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3, \
substr($(AV)0, index($(AV)0,$(AV)4)), ";"}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-asm
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include "$(sys-asm-common-name)"' >> $$@
$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}' >> $$@
endef
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(sys-codes-generic): $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo '#include ' >> $@
$(Q) cat $< | awk '/^__NR/{NR32=$$1; \
sub("^__NR", "__NR32", NR32); \
print "\n#ifndef ", NR32; \
print "#define ", NR32, $$2; \
print "#endif";}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
mrproper-y += $(sys-codes-generic)
$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "" >> $@
$(Q) echo '#include ' >> $@
$(Q) echo "" >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
mrproper-y += $(sys-proto-generic)
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
std-headers-deps += $(call sys-codes,$(sys-bits))
std-headers-deps += $(call sys-proto,$(sys-bits))
std-headers-deps += $(call sys-asm,$(sys-bits))
std-headers-deps += $(call sys-exec-tbl,$(sys-bits))
std-headers-deps += $(sys-codes-generic)
std-headers-deps += $(sys-proto-generic)
std-headers-deps += $(sys-asm-types)
mrproper-y += $(std-headers-deps)
crac-criu-1.5.0/compel/arch/mips/plugins/std/syscalls/syscall-common-mips-64.S 0000664 0000000 0000000 00000000305 14715043267 0027131 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
#define SYSCALL(name, opcode) \
ENTRY(name); \
li v0, opcode; \
syscall; \
jr ra; \
nop; \
END(name)
ENTRY(__cr_restore_rt)
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/mips/plugins/std/syscalls/syscall_64.tbl 0000664 0000000 0000000 00000023374 14715043267 0025351 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consist only the syscalls
# really used somewhere in project.
# from kernel/linux-3.10.84/arch/mips/include/uapi/asm/unistd.h Linux 64-bit syscalls are in the range from 5000 to 5999.
#
# __NR_name code name arguments
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
__NR_read 5000 sys_read (int fd, void *buf, unsigned long count)
__NR_write 5001 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 5002 sys_open (const char *filename, unsigned long flags, unsigned long mode)
__NR_close 5003 sys_close (int fd)
__NR_lseek 5008 sys_lseek (int fd, unsigned long offset, unsigned long origin)
__NR_mmap 5009 sys_mmap (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
__NR_mprotect 5010 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_munmap 5011 sys_munmap (void *addr, unsigned long len)
__NR_brk 5012 sys_brk (void *addr)
__NR_rt_sigaction 5013 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 5014 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
__NR_rt_sigreturn 5211 sys_rt_sigreturn (void)
__NR_ioctl 5015 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_pread64 5016 sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos)
__NR_mremap 5024 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_mincore 5026 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 5027 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_shmat 5029 sys_shmat (int shmid, void *shmaddr, int shmflag)
__NR_dup2 5032 sys_dup2 (int oldfd, int newfd)
__NR_nanosleep 5034 sys_nanosleep (struct timespec *req, struct timespec *rem)
__NR_getitimer 5035 sys_getitimer (int which, const struct itimerval *val)
__NR_setitimer 5036 sys_setitimer (int which, const struct itimerval *val, struct itimerval *old)
__NR_getpid 5038 sys_getpid (void)
__NR_socket 5040 sys_socket (int domain, int type, int protocol)
__NR_connect 5041 sys_connect (int sockfd, struct sockaddr *addr, int addrlen)
__NR_sendto 5043 sys_sendto (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
__NR_recvfrom 5044 sys_recvfrom (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
__NR_sendmsg 5045 sys_sendmsg (int sockfd, const struct msghdr *msg, int flags)
__NR_recvmsg 5046 sys_recvmsg (int sockfd, struct msghdr *msg, int flags)
__NR_shutdown 5047 sys_shutdown (int sockfd, int how)
__NR_bind 5048 sys_bind (int sockfd, const struct sockaddr *addr, int addrlen)
__NR_setsockopt 5053 sys_setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
__NR_getsockopt 5054 sys_getsockopt (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
__NR_clone 5055 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
__NR_exit 5058 sys_exit (unsigned long error_code)
__NR_wait4 5059 sys_wait4 (int pid, int *status, int options, struct rusage *ru)
__NR_kill 5060 sys_kill (long pid, int sig)
__NR_fcntl 5070 sys_fcntl (int fd, int type, long arg)
__NR_flock 5071 sys_flock (int fd, unsigned long cmd)
__NR_mkdir 5081 sys_mkdir (const char *name, int mode)
__NR_rmdir 5082 sys_rmdir (const char *name)
__NR_unlink 5085 sys_unlink (char *pathname)
__NR_umask 5093 sys_umask (int mask)
__NR_gettimeofday 5094 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_ptrace 5099 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_getgroups 5113 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups 5114 sys_setgroups (int gsize, unsigned int *groups)
__NR_setresuid 5115 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid 5116 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid 5117 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid 5118 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_getpgid 5119 sys_getpgid (pid_t pid)
__NR_setfsuid 5120 sys_setfsuid (int fsuid)
__NR_setfsgid 5121 sys_setfsgid (int fsgid)
__NR_getsid 5122 sys_getsid (void)
__NR_capget 5123 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 5124 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_rt_sigqueueinfo 5127 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *info)
__NR_sigaltstack 5129 sys_sigaltstack (const void *uss, void *uoss)
__NR_personality 5132 sys_personality (unsigned int personality)
__NR_setpriority 5138 sys_setpriority (int which, int who, int nice)
__NR_sched_setscheduler 5141 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_prctl 5153 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_setrlimit 5155 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 5160 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 5161 sys_umount2 (char *name, int flags)
__NR_gettid 5178 sys_gettid (void)
__NR_futex 5194 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_cacheflush 5197 sys_cacheflush (char *addr, int nbytes, int cache)
__NR_io_setup 5200 sys_io_setup (unsigned nr_events, aio_context_t *ctx)
__NR_io_getevents 5202 sys_io_getevents (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
__NR_io_submit 5203 sys_io_submit (aio_context_t ctx, long nr, struct iocb **iocbpp)
__NR_set_tid_address 5212 sys_set_tid_address (int *tid_addr)
__NR_restart_syscall 5213 sys_restart_syscall (void)
__NR_sys_timer_create 5216 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_sys_timer_settime 5217 sys_timer_settime (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
__NR_sys_timer_gettime 5218 sys_timer_gettime (int timer_id, const struct itimerspec *setting)
__NR_sys_timer_getoverrun 5219 sys_timer_getoverrun (int timer_id)
__NR_sys_timer_delete 5220 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 5222 sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp)
__NR_exit_group 5205 sys_exit_group (int error_code)
__NR_set_thread_area 5242 sys_set_thread_area (unsigned long *addr)
__NR_openat 5247 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_waitid 5237 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_readlinkat 5257 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_ppoll 5261 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_set_robust_list 5268 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 5269 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_fallocate 5279 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_seccomp 5312 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_vmsplice 5266 sys_vmsplice (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
__NR_timerfd_settime 5282 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_signalfd4 5283 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_preadv 5289 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_rt_tgsigqueueinfo 5291 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 5295 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 5296 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 5299 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 5303 sys_setns (int fd, int nstype)
__NR_kcmp 5306 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_memfd_create 5314 sys_memfd_create (const char *name, unsigned int flags)
__NR_userfaultfd 5317 sys_userfaultfd (int flags)
##TODO for kernel
__NR_open_tree 5428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 5429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 5430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 5431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 5432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_clone3 5435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_pidfd_open 5434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_openat2 5437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 5438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
__NR_rseq 5327 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_membarrier 5318 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/mips/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0020231 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/scripts/compel-pack-compat.lds.S 0000664 0000000 0000000 00000000153 14715043267 0024611 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(mips)
EXTERN(__export_parasite_head_start)
ASSERT(0,"Compatible PIEs are unsupported on mips")
crac-criu-1.5.0/compel/arch/mips/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000001025 14715043267 0023327 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(mips)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.text : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
*(.compel.exit)
*(.compel.init)
/* .rodata section*/
*(.rodata*)
*(.got*)
/* .data section */
*(.data*)
*(.bss*)
*(.sbss*)
*(.toc*)
}
/DISCARD/ : { /*segments need to discard */
*(.debug*)
*(.pdr)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
*(.MIPS.options)
*(.gnu.attributes)
}
}
crac-criu-1.5.0/compel/arch/mips/src/ 0000775 0000000 0000000 00000000000 14715043267 0017331 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0020077 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/cpu.c 0000664 0000000 0000000 00000001312 14715043267 0021027 0 ustar 00root root 0000000 0000000 #include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "common/compiler.h"
#include "log.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static bool rt_info_done = false;
void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
return 0;
}
int compel_cpuid(compel_cpuinfo_t *c)
{
return 0;
}
bool compel_cpu_has_feature(unsigned int feature)
{
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
return compel_test_cpu_cap(&rt_info, feature);
}
crac-criu-1.5.0/compel/arch/mips/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025353 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/handle-elf.c 0000664 0000000 0000000 00000001053 14715043267 0022241 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
extern int __handle_elf(void *mem, size_t size);
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_64_le, sizeof(elf_ident_64_le)) == 0)
return __handle_elf(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/mips/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0021522 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000277 14715043267 0023700 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define arch_is_machine_supported(e_machine) (e_machine == EM_MIPS)
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/mips/src/lib/include/ldsodefs.h 0000664 0000000 0000000 00000013267 14715043267 0023507 0 ustar 00root root 0000000 0000000 /*
* Run-time dynamic linker data structures for loaded ELF shared objects.
* Copyright (C) 2000-2014 Free Software Foundation, Inc.
* This file is part of the GNU C Library.
*
* The GNU C Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* The GNU C Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the GNU C Library. If not, see
* .
*/
#ifndef _MIPS_LDSODEFS_H
#define _MIPS_LDSODEFS_H 1
#include
struct La_mips_32_regs;
struct La_mips_32_retval;
struct La_mips_64_regs;
struct La_mips_64_retval;
#define ARCH_PLTENTER_MEMBERS \
Elf32_Addr (*mips_o32_gnu_pltenter)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
struct La_mips_32_regs *, unsigned int *, const char *name, \
long int *framesizep); \
Elf32_Addr (*mips_n32_gnu_pltenter)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
struct La_mips_64_regs *, unsigned int *, const char *name, \
long int *framesizep); \
Elf64_Addr (*mips_n64_gnu_pltenter)(Elf64_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
struct La_mips_64_regs *, unsigned int *, const char *name, \
long int *framesizep);
#define ARCH_PLTEXIT_MEMBERS \
unsigned int (*mips_o32_gnu_pltexit)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
const struct La_mips_32_regs *, struct La_mips_32_retval *, \
const char *); \
unsigned int (*mips_n32_gnu_pltexit)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
const struct La_mips_64_regs *, struct La_mips_64_retval *, \
const char *); \
unsigned int (*mips_n64_gnu_pltexit)(Elf64_Sym *, unsigned int, uintptr_t *, uintptr_t *, \
const struct La_mips_64_regs *, struct La_mips_64_retval *, \
const char *);
/* The MIPS ABI specifies that the dynamic section has to be read-only. */
/*
* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
* relocation entry specifies up to three actual relocations, all at
* the same address. The first relocation which required a symbol
* uses the symbol in the r_sym field. The second relocation which
* requires a symbol uses the symbol in the r_ssym field. If all
* three relocations require a symbol, the third one uses a zero
* value.
*
* We define these structures in internal headers because we're not
* sure we want to make them part of the ABI yet. Eventually, some of
* this may move into elf/elf.h.
*/
/* An entry in a 64 bit SHT_REL section. */
typedef struct {
Elf32_Word r_sym; /* Symbol index */
unsigned char r_ssym; /* Special symbol for 2nd relocation */
unsigned char r_type3; /* 3rd relocation type */
unsigned char r_type2; /* 2nd relocation type */
unsigned char r_type1; /* 1st relocation type */
} _Elf64_Mips_R_Info;
typedef union {
Elf64_Xword r_info_number;
_Elf64_Mips_R_Info r_info_fields;
} _Elf64_Mips_R_Info_union;
typedef struct {
Elf64_Addr r_offset; /* Address */
_Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
} Elf64_Mips_Rel;
typedef struct {
Elf64_Addr r_offset; /* Address */
_Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
Elf64_Sxword r_addend; /* Addend */
} Elf64_Mips_Rela;
#define ELF64_MIPS_R_SYM(i) ((__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
#define ELF64_MIPS_R_TYPE(i) \
(((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 | \
((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type2 << 8) | \
((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type3 << 16) | \
((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_ssym << 24))
#define ELF64_MIPS_R_INFO(sym, type) \
(__extension__(_Elf64_Mips_R_Info_union)( \
__extension__(_Elf64_Mips_R_Info){ (sym), ELF64_MIPS_R_SSYM(type), ELF64_MIPS_R_TYPE3(type), \
ELF64_MIPS_R_TYPE2(type), ELF64_MIPS_R_TYPE1(type) }) \
.r_info_number)
/*
* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
* compose it back into a value that it can be used as an argument to
* ELF64_MIPS_R_INFO.
*/
#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
#define ELF64_MIPS_R_TYPE1(i) ((i)&0xff)
#define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
((type1) | ((Elf32_Word)(type2) << 8) | ((Elf32_Word)(type3) << 16) | ((Elf32_Word)(ssym) << 24))
#undef ELF64_R_SYM
#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM(i)
#undef ELF64_R_TYPE
/*fixme*/
#define ELF64_R_TYPE(i) (ELF64_MIPS_R_TYPE(i) & 0x00ff)
#undef ELF64_R_INFO
#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO((sym), (type))
#endif
crac-criu-1.5.0/compel/arch/mips/src/lib/include/syscall.h 0000664 0000000 0000000 00000000160 14715043267 0023342 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#ifndef SIGSTKFLT
#define SIGSTKFLT 16
#endif
#endif
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022460 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0023240 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000322 14715043267 0025727 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
extern int ptrace_set_breakpoint(pid_t pid, void *addr);
extern int ptrace_flush_breakpoints(pid_t pid);
#endif
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000166 14715043267 0024203 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_CPU_H__
#define __CR_ASM_CPU_H__
typedef struct {
} compel_cpuinfo_t;
#endif /* __CR_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000121 14715043267 0024175 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000003174 14715043267 0026030 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#include
#include
#include
#include
#define SIGMAX 64
#define SIGMAX_OLD 31
/*
* Copied from the Linux kernel header arch/mips/include/asm/ptrace.h
*
* A thread MIPS CPU context
*/
typedef struct {
/* Saved main processor registers. */
__u64 regs[32];
/* Saved special registers. */
__u64 lo;
__u64 hi;
__u64 cp0_epc;
__u64 cp0_badvaddr;
__u64 cp0_status;
__u64 cp0_cause;
} user_regs_struct_t;
/* from linux-3.10/arch/mips/kernel/ptrace.c */
typedef struct {
/* Saved fpu registers. */
__u64 regs[32];
__u32 fpu_fcr31;
__u32 fpu_id;
} user_fpregs_struct_t;
#define MIPS_a0 regs[4] //arguments a0-a3
#define MIPS_t0 regs[8] //temporaries t0-t7
#define MIPS_v0 regs[2]
#define MIPS_v1 regs[3]
#define MIPS_sp regs[29]
#define MIPS_ra regs[31]
#define NATIVE_MAGIC 0x0A
#define COMPAT_MAGIC 0x0C
static inline bool user_regs_native(user_regs_struct_t *pregs)
{
return true;
}
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
#define REG_RES(regs) ((regs).MIPS_v0)
#define REG_IP(regs) ((regs).cp0_epc)
#define SET_REG_IP(regs, val) ((regs).cp0_epc = (val))
#define REG_SP(regs) ((regs).MIPS_sp)
#define REG_SYSCALL_NR(regs) ((regs).MIPS_v0)
//#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall)
#define __NR(syscall, compat) __NR_##syscall
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000003357 14715043267 0025216 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
#include
#include
#include
#include
#define u32 __u32
/* sigcontext defined in /usr/include/asm/sigcontext.h*/
#define rt_sigcontext sigcontext
#include
/* refer to linux-3.10/include/uapi/asm-generic/ucontext.h */
struct k_ucontext {
unsigned long uc_flags;
struct k_ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
k_rtsigset_t uc_sigmask;
};
/* Copy from the kernel source arch/mips/kernel/signal.c */
struct rt_sigframe {
u32 rs_ass[4]; /* argument save space for o32 */
u32 rs_pad[2]; /* Was: signal trampoline */
siginfo_t rs_info;
struct k_ucontext rs_uc;
};
#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->rs_uc)
#define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) ((k_rtsigset_t *)(void *)&rt_sigframe->rs_uc.uc_sigmask)
#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)0x00)
#define RT_SIGFRAME_FPU(rt_sigframe)
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"move $29, %0 \n" \
"li $2, "__stringify(__NR_rt_sigreturn)" \n" \
"syscall \n" \
: \
: "r"(new_sp) \
: "$2","memory")
/* clang-format on */
int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe);
#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->rs_uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->rs_uc.uc_sigmask, from, sizeof(k_rtsigset_t))
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/mips/src/lib/include/uapi/asm/siginfo.h 0000664 0000000 0000000 00000005475 14715043267 0025062 0 ustar 00root root 0000000 0000000 /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1998, 1999, 2001, 2003 Ralf Baechle
* Copyright (C) 2000, 2001 Silicon Graphics, Inc.
*/
#ifndef _UAPI_ASM_SIGINFO_H
#define _UAPI_ASM_SIGINFO_H
#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2 * sizeof(int))
#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
#define HAVE_ARCH_SIGINFO_T
/*
* Careful to keep union _sifields from shifting ...
*/
#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
#define __ARCH_SIGSYS
#define SI_MAX_SIZE 128
#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
#define __ARCH_SI_UID_T __kernel_uid32_t
#ifndef __ARCH_SI_UID_T
#define __ARCH_SI_UID_T __kernel_uid32_t
#endif
#ifndef __ARCH_SI_BAND_T
#define __ARCH_SI_BAND_T long
#endif
#ifndef __ARCH_SI_CLOCK_T
#define __ARCH_SI_CLOCK_T __kernel_clock_t
#endif
#ifndef __ARCH_SI_ATTRIBUTES
#define __ARCH_SI_ATTRIBUTES
#endif
typedef struct siginfo {
int si_signo;
int si_errno;
int si_code;
union {
int _pad[SI_PAD_SIZE];
/* kill() */
struct {
__kernel_pid_t _pid; /* sender's pid */
__ARCH_SI_UID_T _uid; /* sender's uid */
} _kill;
/* POSIX.1b timers */
struct {
__kernel_timer_t _tid; /* timer id */
int _overrun; /* overrun count */
char _pad[sizeof(__ARCH_SI_UID_T) - sizeof(int)];
sigval_t _sigval; /* same as below */
int _sys_private; /* not to be passed to user */
} _timer;
/* POSIX.1b signals */
struct {
__kernel_pid_t _pid; /* sender's pid */
__ARCH_SI_UID_T _uid; /* sender's uid */
sigval_t _sigval;
} _rt;
/* SIGCHLD */
struct {
__kernel_pid_t _pid; /* which child */
__ARCH_SI_UID_T _uid; /* sender's uid */
int _status; /* exit code */
__ARCH_SI_CLOCK_T _utime;
__ARCH_SI_CLOCK_T _stime;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
struct {
void *_addr; /* faulting insn/memory ref. */
#ifdef __ARCH_SI_TRAPNO
int _trapno; /* TRAP # which caused the signal */
#endif
short _addr_lsb; /* LSB of the reported address */
#ifndef __GENKSYMS__
struct {
void *_lower;
void *_upper;
} _addr_bnd;
#endif
} _sigfault;
/* SIGPOLL */
struct {
__ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
int _fd;
} _sigpoll;
/* SIGSYS */
struct {
void *_call_addr; /* calling user insn */
int _syscall; /* triggering system call number */
unsigned int _arch; /* AUDIT_ARCH_* of syscall */
} _sigsys;
} _sifields;
} __ARCH_SI_ATTRIBUTES siginfo_t;
/*
* si_code values
* Again these have been chosen to be IRIX compatible.
*/
#undef SI_ASYNCIO
#undef SI_TIMER
#undef SI_MESGQ
#define SI_ASYNCIO -2 /* sent by AIO completion */
#endif /* _UAPI_ASM_SIGINFO_H */
crac-criu-1.5.0/compel/arch/mips/src/lib/infect.c 0000664 0000000 0000000 00000024460 14715043267 0021521 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include "errno.h"
#include
#include
#include "common/err.h"
#include "common/page.h"
#include "asm/infect-types.h"
#include "ptrace.h"
#include "infect.h"
#include "infect-priv.h"
#include "log.h"
#include "common/bug.h"
/*
* Injected syscall instruction
* mips64el is Little Endian
*/
const char code_syscall[] = {
0x0c, 0x00, 0x00, 0x00, /* syscall */
0x0d, 0x00, 0x00, 0x00 /* break */
};
/* 10-byte legacy floating point register */
struct fpreg {
uint16_t significand[4];
uint16_t exponent;
};
/* 16-byte floating point register */
struct fpxreg {
uint16_t significand[4];
uint16_t exponent;
uint16_t padding[3];
};
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
sigframe->rs_uc.uc_mcontext.sc_regs[0] = regs->regs[0];
sigframe->rs_uc.uc_mcontext.sc_regs[1] = regs->regs[1];
sigframe->rs_uc.uc_mcontext.sc_regs[2] = regs->regs[2];
sigframe->rs_uc.uc_mcontext.sc_regs[3] = regs->regs[3];
sigframe->rs_uc.uc_mcontext.sc_regs[4] = regs->regs[4];
sigframe->rs_uc.uc_mcontext.sc_regs[5] = regs->regs[5];
sigframe->rs_uc.uc_mcontext.sc_regs[6] = regs->regs[6];
sigframe->rs_uc.uc_mcontext.sc_regs[7] = regs->regs[7];
sigframe->rs_uc.uc_mcontext.sc_regs[8] = regs->regs[8];
sigframe->rs_uc.uc_mcontext.sc_regs[9] = regs->regs[9];
sigframe->rs_uc.uc_mcontext.sc_regs[10] = regs->regs[10];
sigframe->rs_uc.uc_mcontext.sc_regs[11] = regs->regs[11];
sigframe->rs_uc.uc_mcontext.sc_regs[12] = regs->regs[12];
sigframe->rs_uc.uc_mcontext.sc_regs[13] = regs->regs[13];
sigframe->rs_uc.uc_mcontext.sc_regs[14] = regs->regs[14];
sigframe->rs_uc.uc_mcontext.sc_regs[15] = regs->regs[15];
sigframe->rs_uc.uc_mcontext.sc_regs[16] = regs->regs[16];
sigframe->rs_uc.uc_mcontext.sc_regs[17] = regs->regs[17];
sigframe->rs_uc.uc_mcontext.sc_regs[18] = regs->regs[18];
sigframe->rs_uc.uc_mcontext.sc_regs[19] = regs->regs[19];
sigframe->rs_uc.uc_mcontext.sc_regs[20] = regs->regs[20];
sigframe->rs_uc.uc_mcontext.sc_regs[21] = regs->regs[21];
sigframe->rs_uc.uc_mcontext.sc_regs[22] = regs->regs[22];
sigframe->rs_uc.uc_mcontext.sc_regs[23] = regs->regs[23];
sigframe->rs_uc.uc_mcontext.sc_regs[24] = regs->regs[24];
sigframe->rs_uc.uc_mcontext.sc_regs[25] = regs->regs[25];
sigframe->rs_uc.uc_mcontext.sc_regs[26] = regs->regs[26];
sigframe->rs_uc.uc_mcontext.sc_regs[27] = regs->regs[27];
sigframe->rs_uc.uc_mcontext.sc_regs[28] = regs->regs[28];
sigframe->rs_uc.uc_mcontext.sc_regs[29] = regs->regs[29];
sigframe->rs_uc.uc_mcontext.sc_regs[30] = regs->regs[30];
sigframe->rs_uc.uc_mcontext.sc_regs[31] = regs->regs[31];
sigframe->rs_uc.uc_mcontext.sc_mdlo = regs->lo;
sigframe->rs_uc.uc_mcontext.sc_mdhi = regs->hi;
sigframe->rs_uc.uc_mcontext.sc_pc = regs->cp0_epc;
sigframe->rs_uc.uc_mcontext.sc_fpregs[0] = fpregs->regs[0];
sigframe->rs_uc.uc_mcontext.sc_fpregs[1] = fpregs->regs[1];
sigframe->rs_uc.uc_mcontext.sc_fpregs[2] = fpregs->regs[2];
sigframe->rs_uc.uc_mcontext.sc_fpregs[3] = fpregs->regs[3];
sigframe->rs_uc.uc_mcontext.sc_fpregs[4] = fpregs->regs[4];
sigframe->rs_uc.uc_mcontext.sc_fpregs[5] = fpregs->regs[5];
sigframe->rs_uc.uc_mcontext.sc_fpregs[6] = fpregs->regs[6];
sigframe->rs_uc.uc_mcontext.sc_fpregs[7] = fpregs->regs[7];
sigframe->rs_uc.uc_mcontext.sc_fpregs[8] = fpregs->regs[8];
sigframe->rs_uc.uc_mcontext.sc_fpregs[9] = fpregs->regs[9];
sigframe->rs_uc.uc_mcontext.sc_fpregs[10] = fpregs->regs[10];
sigframe->rs_uc.uc_mcontext.sc_fpregs[11] = fpregs->regs[11];
sigframe->rs_uc.uc_mcontext.sc_fpregs[12] = fpregs->regs[12];
sigframe->rs_uc.uc_mcontext.sc_fpregs[13] = fpregs->regs[13];
sigframe->rs_uc.uc_mcontext.sc_fpregs[14] = fpregs->regs[14];
sigframe->rs_uc.uc_mcontext.sc_fpregs[15] = fpregs->regs[15];
sigframe->rs_uc.uc_mcontext.sc_fpregs[16] = fpregs->regs[16];
sigframe->rs_uc.uc_mcontext.sc_fpregs[17] = fpregs->regs[17];
sigframe->rs_uc.uc_mcontext.sc_fpregs[18] = fpregs->regs[18];
sigframe->rs_uc.uc_mcontext.sc_fpregs[19] = fpregs->regs[19];
sigframe->rs_uc.uc_mcontext.sc_fpregs[20] = fpregs->regs[20];
sigframe->rs_uc.uc_mcontext.sc_fpregs[21] = fpregs->regs[21];
sigframe->rs_uc.uc_mcontext.sc_fpregs[22] = fpregs->regs[22];
sigframe->rs_uc.uc_mcontext.sc_fpregs[23] = fpregs->regs[23];
sigframe->rs_uc.uc_mcontext.sc_fpregs[24] = fpregs->regs[24];
sigframe->rs_uc.uc_mcontext.sc_fpregs[25] = fpregs->regs[25];
sigframe->rs_uc.uc_mcontext.sc_fpregs[26] = fpregs->regs[26];
sigframe->rs_uc.uc_mcontext.sc_fpregs[27] = fpregs->regs[27];
sigframe->rs_uc.uc_mcontext.sc_fpregs[28] = fpregs->regs[28];
sigframe->rs_uc.uc_mcontext.sc_fpregs[29] = fpregs->regs[29];
sigframe->rs_uc.uc_mcontext.sc_fpregs[30] = fpregs->regs[30];
sigframe->rs_uc.uc_mcontext.sc_fpregs[31] = fpregs->regs[31];
return 0;
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t xsave = {}, *xs = ext_regs ? ext_regs : &xsave;
int ret = -1;
pr_info("Dumping GP/FPU registers for %d\n", pid);
if (ptrace(PTRACE_GETFPREGS, pid, NULL, xs)) {
pr_perror("Can't obtain FPU registers for %d", pid);
return ret;
}
/*Restart the system call*/
if (regs->regs[0]) {
switch ((long)(int)regs->regs[2]) {
case ERESTARTNOHAND:
case ERESTARTSYS:
case ERESTARTNOINTR:
regs->regs[2] = regs->regs[0];
regs->regs[7] = regs->regs[26];
regs->cp0_epc -= 4;
break;
case ERESTART_RESTARTBLOCK:
pr_warn("Will restore %d with interrupted system call\n", pid);
regs->regs[2] = -EINTR;
break;
}
regs->regs[0] = 0;
}
ret = save(arg, regs, xs);
return ret;
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
pr_info("Restoring GP/FPU registers for %d\n", pid);
if (ptrace(PTRACE_SETFPREGS, pid, NULL, ext_regs)) {
pr_perror("Can't set FPU registers for %d", pid);
return -1;
}
return 0;
}
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
/*refer to glibc-2.20/sysdeps/unix/sysv/linux/mips/mips64/syscall.S*/
user_regs_struct_t regs = ctl->orig.regs;
int err;
regs.regs[2] = (unsigned long)nr; //syscall_number will be in v0
regs.regs[4] = arg1;
regs.regs[5] = arg2;
regs.regs[6] = arg3;
regs.regs[7] = arg4;
regs.regs[8] = arg5;
regs.regs[9] = arg6;
err = compel_execute_syscall(ctl, ®s, code_syscall);
*ret = regs.regs[2];
return err;
}
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset >> PAGE_SHIFT);
if (err < 0 || IS_ERR_VALUE(map)) {
pr_err("remote mmap() failed: %s\n", strerror(-map));
return NULL;
}
return (void *)map;
}
/*
* regs must be inited when calling this function from original context
*/
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->cp0_epc = new_ip;
if (stack) {
/* regs[29] is sp */
regs->regs[29] = (unsigned long)stack;
}
}
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
return true;
}
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->rs_uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
}
int ptrace_flush_breakpoints(pid_t pid)
{
return 0;
}
/*refer to kernel linux-3.10/arch/mips/include/asm/processor.h*/
#define TASK_SIZE32 0x7fff8000UL
#define TASK_SIZE64 0x10000000000UL
#define TASK_SIZE TASK_SIZE64
unsigned long compel_task_size(void)
{
return TASK_SIZE;
}
/*
* Get task registers (overwrites weak function)
*
*/
int ptrace_get_regs(int pid, user_regs_struct_t *regs)
{
return ptrace(PTRACE_GETREGS, pid, NULL, regs);
}
/*
* Set task registers (overwrites weak function)
*/
int ptrace_set_regs(int pid, user_regs_struct_t *regs)
{
return ptrace(PTRACE_SETREGS, pid, NULL, regs);
}
void compel_relocs_apply_mips(void *mem, void *vbase, struct parasite_blob_desc *pbd)
{
compel_reloc_t *elf_relocs = pbd->hdr.relocs;
size_t nr_relocs = pbd->hdr.nr_relocs;
size_t i, j;
/*
* mips rebasing :load time relocation
* parasite.built-in.o and restorer.built-in.o is ELF 64-bit LSB relocatable for mips.
* so we have to relocate some type for R_MIPS_26 R_MIPS_HIGHEST R_MIPS_HIGHER R_MIPS_HI16 and R_MIPS_LO16 in there.
* for mips64el .if toload/store data or jump instruct ,need to relocation R_TYPE
*/
for (i = 0, j = 0; i < nr_relocs; i++) {
if (elf_relocs[i].type & COMPEL_TYPE_MIPS_26) {
int *where = (mem + elf_relocs[i].offset);
*where = *where |
((elf_relocs[i].addend + ((unsigned long)vbase & 0x00fffffff) /*low 28 bit*/) >> 2);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_64) {
unsigned long *where = (mem + elf_relocs[i].offset);
*where = elf_relocs[i].addend + (unsigned long)vbase;
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HI16) {
/* refer to binutils mips.cc */
int *where = (mem + elf_relocs[i].offset);
int v_lo16 = (unsigned long)vbase & 0x00ffff;
if ((v_lo16 + elf_relocs[i].value + elf_relocs[i].addend) >= 0x8000) {
*where = *where | ((((unsigned long)vbase >> 16) & 0xffff) + 0x1);
} else {
*where = *where | ((((unsigned long)vbase >> 16) & 0xffff));
}
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_LO16) {
int *where = (mem + elf_relocs[i].offset);
int v_lo16 = (unsigned long)vbase & 0x00ffff;
*where = *where | ((v_lo16 + elf_relocs[i].addend) & 0xffff);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HIGHER) {
int *where = (mem + elf_relocs[i].offset);
*where = *where | ((((unsigned long)vbase + (uint64_t)0x80008000) >> 32) & 0xffff);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HIGHEST) {
int *where = (mem + elf_relocs[i].offset);
*where = *where | ((((unsigned long)vbase + (uint64_t)0x800080008000llu) >> 48) & 0xffff);
} else {
BUG();
}
}
}
crac-criu-1.5.0/compel/arch/ppc64/ 0000775 0000000 0000000 00000000000 14715043267 0016526 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0020207 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0021632 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022412 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/include/asm/prologue.h 0000777 0000000 0000000 00000000000 14715043267 0035134 2../../../../../arch/x86/plugins/include/asm/prologue.h ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001171 14715043267 0025377 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
#define SA_RESTORER 0x04000000U
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define _KNSIG 64
#define _NSIG_BPW 64
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
typedef struct {
unsigned long sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/ppc64/plugins/include/features.h 0000664 0000000 0000000 00000000232 14715043267 0023616 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#define ARCH_HAS_MEMCPY
#define ARCH_HAS_MEMCMP
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0021001 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/std/memcmp.S 0000664 0000000 0000000 00000005656 14715043267 0022417 0 ustar 00root root 0000000 0000000 /*
* Author: Anton Blanchard
* Copyright 2015 IBM Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* --
* Copied form the linux file arch/powerpc/lib/memcmp_64.S
*/
#include "common/asm/linkage.h"
#define off8 r6
#define off16 r7
#define off24 r8
#define rA r9
#define rB r10
#define rC r11
#define rD r27
#define rE r28
#define rF r29
#define rG r30
#define rH r31
#ifdef __LITTLE_ENDIAN__
#define LD ldbrx
#else
#define LD ldx
#endif
ENTRY(memcmp)
cmpdi cr1,r5,0
/* Use the short loop if both strings are not 8B aligned */
or r6,r3,r4
andi. r6,r6,7
/* Use the short loop if length is less than 32B */
cmpdi cr6,r5,31
beq cr1,.Lzero
bne .Lshort
bgt cr6,.Llong
.Lshort:
mtctr r5
1: lbz rA,0(r3)
lbz rB,0(r4)
subf. rC,rB,rA
bne .Lnon_zero
bdz .Lzero
lbz rA,1(r3)
lbz rB,1(r4)
subf. rC,rB,rA
bne .Lnon_zero
bdz .Lzero
lbz rA,2(r3)
lbz rB,2(r4)
subf. rC,rB,rA
bne .Lnon_zero
bdz .Lzero
lbz rA,3(r3)
lbz rB,3(r4)
subf. rC,rB,rA
bne .Lnon_zero
addi r3,r3,4
addi r4,r4,4
bdnz 1b
.Lzero:
li r3,0
blr
.Lnon_zero:
mr r3,rC
blr
.Llong:
li off8,8
li off16,16
li off24,24
std r31,-8(r1)
std r30,-16(r1)
std r29,-24(r1)
std r28,-32(r1)
std r27,-40(r1)
srdi r0,r5,5
mtctr r0
andi. r5,r5,31
LD rA,0,r3
LD rB,0,r4
LD rC,off8,r3
LD rD,off8,r4
LD rE,off16,r3
LD rF,off16,r4
LD rG,off24,r3
LD rH,off24,r4
cmpld cr0,rA,rB
addi r3,r3,32
addi r4,r4,32
bdz .Lfirst32
LD rA,0,r3
LD rB,0,r4
cmpld cr1,rC,rD
LD rC,off8,r3
LD rD,off8,r4
cmpld cr6,rE,rF
LD rE,off16,r3
LD rF,off16,r4
cmpld cr7,rG,rH
bne cr0,.LcmpAB
LD rG,off24,r3
LD rH,off24,r4
cmpld cr0,rA,rB
bne cr1,.LcmpCD
addi r3,r3,32
addi r4,r4,32
bdz .Lsecond32
.balign 16
1: LD rA,0,r3
LD rB,0,r4
cmpld cr1,rC,rD
bne cr6,.LcmpEF
LD rC,off8,r3
LD rD,off8,r4
cmpld cr6,rE,rF
bne cr7,.LcmpGH
LD rE,off16,r3
LD rF,off16,r4
cmpld cr7,rG,rH
bne cr0,.LcmpAB
LD rG,off24,r3
LD rH,off24,r4
cmpld cr0,rA,rB
bne cr1,.LcmpCD
addi r3,r3,32
addi r4,r4,32
bdnz 1b
.Lsecond32:
cmpld cr1,rC,rD
bne cr6,.LcmpEF
cmpld cr6,rE,rF
bne cr7,.LcmpGH
cmpld cr7,rG,rH
bne cr0,.LcmpAB
bne cr1,.LcmpCD
bne cr6,.LcmpEF
bne cr7,.LcmpGH
.Ltail:
ld r31,-8(r1)
ld r30,-16(r1)
ld r29,-24(r1)
ld r28,-32(r1)
ld r27,-40(r1)
cmpdi r5,0
beq .Lzero
b .Lshort
.Lfirst32:
cmpld cr1,rC,rD
cmpld cr6,rE,rF
cmpld cr7,rG,rH
bne cr0,.LcmpAB
bne cr1,.LcmpCD
bne cr6,.LcmpEF
bne cr7,.LcmpGH
b .Ltail
.LcmpAB:
li r3,1
bgt cr0,.Lout
li r3,-1
b .Lout
.LcmpCD:
li r3,1
bgt cr1,.Lout
li r3,-1
b .Lout
.LcmpEF:
li r3,1
bgt cr6,.Lout
li r3,-1
b .Lout
.LcmpGH:
li r3,1
bgt cr7,.Lout
li r3,-1
.Lout:
ld r31,-8(r1)
ld r30,-16(r1)
ld r29,-24(r1)
ld r28,-32(r1)
ld r27,-40(r1)
blr
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/memcpy.S 0000664 0000000 0000000 00000007606 14715043267 0022430 0 ustar 00root root 0000000 0000000 /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) IBM Corporation, 2012
*
* Author: Anton Blanchard
*
* --
* Copied from the kernel file arch/powerpc/lib/memcpy_power7.S
* Altivec support has been removed so we don't taint restored process.
*/
#include "common/asm/linkage.h"
/*
* When building the parasite code, the compiler may rely on the C library
* service memcpy to initialise big local variable in the stack.
*/
ENTRY(memcpy)
cmpldi r5,16
std r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
blt .Lshort_copy
.Lnonvmx_copy:
/* Get the source 8B aligned */
neg r6,r4
mtocrf 0x01,r6
clrldi r6,r6,(64-3)
bf cr7*4+3,1f
lbz r0,0(r4)
addi r4,r4,1
stb r0,0(r3)
addi r3,r3,1
1: bf cr7*4+2,2f
lhz r0,0(r4)
addi r4,r4,2
sth r0,0(r3)
addi r3,r3,2
2: bf cr7*4+1,3f
lwz r0,0(r4)
addi r4,r4,4
stw r0,0(r3)
addi r3,r3,4
3: sub r5,r5,r6
cmpldi r5,128
blt 5f
mflr r0
stdu r1,-STACKFRAMESIZE(r1)
std r14,STK_REG(R14)(r1)
std r15,STK_REG(R15)(r1)
std r16,STK_REG(R16)(r1)
std r17,STK_REG(R17)(r1)
std r18,STK_REG(R18)(r1)
std r19,STK_REG(R19)(r1)
std r20,STK_REG(R20)(r1)
std r21,STK_REG(R21)(r1)
std r22,STK_REG(R22)(r1)
std r0,STACKFRAMESIZE+16(r1)
srdi r6,r5,7
mtctr r6
/* Now do cacheline (128B) sized loads and stores. */
.align 5
4:
ld r0,0(r4)
ld r6,8(r4)
ld r7,16(r4)
ld r8,24(r4)
ld r9,32(r4)
ld r10,40(r4)
ld r11,48(r4)
ld r12,56(r4)
ld r14,64(r4)
ld r15,72(r4)
ld r16,80(r4)
ld r17,88(r4)
ld r18,96(r4)
ld r19,104(r4)
ld r20,112(r4)
ld r21,120(r4)
addi r4,r4,128
std r0,0(r3)
std r6,8(r3)
std r7,16(r3)
std r8,24(r3)
std r9,32(r3)
std r10,40(r3)
std r11,48(r3)
std r12,56(r3)
std r14,64(r3)
std r15,72(r3)
std r16,80(r3)
std r17,88(r3)
std r18,96(r3)
std r19,104(r3)
std r20,112(r3)
std r21,120(r3)
addi r3,r3,128
bdnz 4b
clrldi r5,r5,(64-7)
ld r14,STK_REG(R14)(r1)
ld r15,STK_REG(R15)(r1)
ld r16,STK_REG(R16)(r1)
ld r17,STK_REG(R17)(r1)
ld r18,STK_REG(R18)(r1)
ld r19,STK_REG(R19)(r1)
ld r20,STK_REG(R20)(r1)
ld r21,STK_REG(R21)(r1)
ld r22,STK_REG(R22)(r1)
addi r1,r1,STACKFRAMESIZE
/* Up to 127B to go */
5: srdi r6,r5,4
mtocrf 0x01,r6
6: bf cr7*4+1,7f
ld r0,0(r4)
ld r6,8(r4)
ld r7,16(r4)
ld r8,24(r4)
ld r9,32(r4)
ld r10,40(r4)
ld r11,48(r4)
ld r12,56(r4)
addi r4,r4,64
std r0,0(r3)
std r6,8(r3)
std r7,16(r3)
std r8,24(r3)
std r9,32(r3)
std r10,40(r3)
std r11,48(r3)
std r12,56(r3)
addi r3,r3,64
/* Up to 63B to go */
7: bf cr7*4+2,8f
ld r0,0(r4)
ld r6,8(r4)
ld r7,16(r4)
ld r8,24(r4)
addi r4,r4,32
std r0,0(r3)
std r6,8(r3)
std r7,16(r3)
std r8,24(r3)
addi r3,r3,32
/* Up to 31B to go */
8: bf cr7*4+3,9f
ld r0,0(r4)
ld r6,8(r4)
addi r4,r4,16
std r0,0(r3)
std r6,8(r3)
addi r3,r3,16
9: clrldi r5,r5,(64-4)
/* Up to 15B to go */
.Lshort_copy:
mtocrf 0x01,r5
bf cr7*4+0,12f
lwz r0,0(r4) /* Less chance of a reject with word ops */
lwz r6,4(r4)
addi r4,r4,8
stw r0,0(r3)
stw r6,4(r3)
addi r3,r3,8
12: bf cr7*4+1,13f
lwz r0,0(r4)
addi r4,r4,4
stw r0,0(r3)
addi r3,r3,4
13: bf cr7*4+2,14f
lhz r0,0(r4)
addi r4,r4,2
sth r0,0(r3)
addi r3,r3,2
14: bf cr7*4+3,15f
lbz r0,0(r4)
stb r0,0(r3)
15: ld r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
blr
.Lunwind_stack_nonvmx_copy:
addi r1,r1,STACKFRAMESIZE
b .Lnonvmx_copy
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/parasite-head.S 0000664 0000000 0000000 00000001331 14715043267 0023632 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
.section .head.text
.align 8
ENTRY(__export_parasite_head_start)
bl 0f
0: mflr r2
#define LOAD_REG_ADDR(reg, name) \
addis reg,r2,(name - 0b)@ha; \
addi reg,r2,(name - 0b)@l;
LOAD_REG_ADDR(r12,parasite_service_ptr)
ld r12,0(r12)
mtctr r12
bctrl // call parasite_service
twi 31,0,0 // Should generate SIGTRAP
parasite_service_ptr:
// We want to run the function prototype to set r2.
// Since the relocation will prefer the local entry
// point, we force it to the global one which is 2
// instructions above the local one.
// FIXME: There should be a way to specify the global entry here.
.quad parasite_service - 8
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0022636 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000005210 14715043267 0026130 0 ustar 00root root 0000000 0000000 ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
sys-types := $(obj)/include/uapi/std/syscall-types.h
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
sys-proto := $(obj)/include/uapi/std/syscall.h
sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-ppc64.tbl
sys-asm-common-name := std/syscalls/syscall-common-ppc64.S
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-lib-y += $(sys-asm:.S=).o
$(sys-codes): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
$(sys-proto): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#include " >> $@
$(Q) echo "#include " >> $@
$(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#include " >> $@
$(Q) echo "#include \"$(sys-asm-common-name)\"" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@
$(Q) echo " { }, /* terminator */" >> $@
$(Q) echo "};" >> $@
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
std-headers-deps += $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y += $(std-headers-deps)
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/syscalls/syscall-common-ppc64.S 0000664 0000000 0000000 00000000664 14715043267 0026662 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
#include /* for __NR_ipc */
#define SYSCALL(name, opcode) \
ENTRY(name); \
li r0, opcode; \
b __syscall_common; \
END(name)
.text
.align 4
ENTRY(__syscall_common)
sc
bnslr+ /* if no error return to LR */
neg r3,r3 /* r3 = -r3 to return -errno value */
blr
END(__syscall_common)
ENTRY(__cr_restore_rt)
li r0, __NR_rt_sigreturn
b __syscall_common
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl 0000664 0000000 0000000 00000022516 14715043267 0025753 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consists of only the syscalls
# really used somewhere in the project.
#
# The template is (name and arguments are optional if you need only __NR_x
# defined, but no real entry point in syscalls lib).
#
# name code name arguments
# -----------------------------------------------------------------------
#
__NR_read 3 sys_read (int fd, void *buf, unsigned long count)
__NR_write 4 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 5 sys_open (const char *filename, unsigned long flags, unsigned long mode)
__NR_close 6 sys_close (int fd)
__NR_lseek 19 sys_lseek (int fd, unsigned long offset, unsigned long origin)
__NR_mmap 90 sys_mmap (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
__NR_mprotect 125 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_munmap 91 sys_munmap (void *addr, unsigned long len)
__NR_brk 45 sys_brk (void *addr)
__NR_rt_sigaction 173 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 174 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
__NR_rt_sigreturn 172 sys_rt_sigreturn (void)
__NR_ioctl 54 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_pread64 179 sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos)
__NR_ptrace 26 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_mremap 163 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_mincore 206 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 205 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_pause 29 sys_pause (void)
__NR_nanosleep 162 sys_nanosleep (struct timespec *req, struct timespec *rem)
__NR_getitimer 105 sys_getitimer (int which, const struct itimerval *val)
__NR_setitimer 104 sys_setitimer (int which, const struct itimerval *val, struct itimerval *old)
__NR_getpid 20 sys_getpid (void)
__NR_socket 326 sys_socket (int domain, int type, int protocol)
__NR_connect 328 sys_connect (int sockfd, struct sockaddr *addr, int addrlen)
__NR_sendto 335 sys_sendto (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
__NR_recvfrom 337 sys_recvfrom (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
__NR_sendmsg 341 sys_sendmsg (int sockfd, const struct msghdr *msg, int flags)
__NR_recvmsg 342 sys_recvmsg (int sockfd, struct msghdr *msg, int flags)
__NR_shutdown 338 sys_shutdown (int sockfd, int how)
__NR_bind 327 sys_bind (int sockfd, const struct sockaddr *addr, int addrlen)
__NR_setsockopt 339 sys_setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
__NR_getsockopt 340 sys_getsockopt (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
__NR_clone 120 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
__NR_exit 1 sys_exit (unsigned long error_code)
__NR_wait4 114 sys_wait4 (int pid, int *status, int options, struct rusage *ru)
__NR_kill 37 sys_kill (long pid, int sig)
__NR_fcntl 55 sys_fcntl (int fd, int type, long arg)
__NR_flock 143 sys_flock (int fd, unsigned long cmd)
__NR_mkdir 39 sys_mkdir (const char *name, int mode)
__NR_rmdir 40 sys_rmdir (const char *name)
__NR_unlink 10 sys_unlink (char *pathname)
__NR_readlinkat 296 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_umask 60 sys_umask (int mask)
__NR_getgroups 80 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups 81 sys_setgroups (int gsize, unsigned int *groups)
__NR_setresuid 164 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid 165 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid 169 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid 170 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_getpgid 132 sys_getpgid (pid_t pid)
__NR_setfsuid 138 sys_setfsuid (int fsuid)
__NR_setfsgid 139 sys_setfsgid (int fsgid)
__NR_getsid 147 sys_getsid (void)
__NR_capget 183 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 184 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_rt_sigqueueinfo 177 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *info)
__NR_sigaltstack 185 sys_sigaltstack (const void *uss, void *uoss)
__NR_personality 136 sys_personality (unsigned int personality)
__NR_setpriority 97 sys_setpriority (int which, int who, int nice)
__NR_sched_setscheduler 156 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_prctl 171 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_setrlimit 75 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 21 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 52 sys_umount2 (char *name, int flags)
__NR_gettid 207 sys_gettid (void)
__NR_futex 221 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_tid_address 232 sys_set_tid_address (int *tid_addr)
__NR_restart_syscall 0 sys_restart_syscall (void)
__NR_sys_timer_create 240 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_sys_timer_settime 241 sys_timer_settime (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
__NR_sys_timer_gettime 242 sys_timer_gettime (int timer_id, const struct itimerspec *setting)
__NR_sys_timer_getoverrun 243 sys_timer_getoverrun (int timer_id)
__NR_sys_timer_delete 244 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 246 sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp)
__NR_exit_group 234 sys_exit_group (int error_code)
__NR_waitid 272 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_set_robust_list 300 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 299 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_vmsplice 285 sys_vmsplice (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
__NR_openat 286 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_fallocate 309 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_timerfd_settime 311 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_signalfd4 313 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_rt_tgsigqueueinfo 322 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 323 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 324 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 346 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 350 sys_setns (int fd, int nstype)
__NR_kcmp 354 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_seccomp 358 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_memfd_create 360 sys_memfd_create (const char *name, unsigned int flags)
__NR_io_setup 227 sys_io_setup (unsigned nr_events, aio_context_t *ctx_idp)
__NR_io_getevents 229 sys_io_getevents (aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
__NR_io_submit 230 sys_io_submit (aio_context_t ctx_id, long nr, struct iocb **iocbpp)
__NR_ipc 117 sys_ipc (unsigned int call, int first, unsigned long second, unsigned long third, const void *ptr, long fifth)
__NR_gettimeofday 78 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_preadv 320 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_userfaultfd 364 sys_userfaultfd (int flags)
__NR_ppoll 281 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_openat2 437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
__NR_rseq 387 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_membarrier 365 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/ppc64/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0020215 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000736 14715043267 0023323 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(powerpc:common64)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.text : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
*(.compel.exit)
*(.compel.init)
}
.data : ALIGN(0x10000) {
*(.data*)
*(.bss*)
}
.rodata : {
*(.rodata*)
*(.got*)
}
.toc : ALIGN(8) {
*(.toc*)
}
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
}
}
crac-criu-1.5.0/compel/arch/ppc64/src/ 0000775 0000000 0000000 00000000000 14715043267 0017315 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0020063 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/cpu.c 0000664 0000000 0000000 00000003167 14715043267 0021025 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "log.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static void fetch_rt_cpuinfo(void)
{
static bool rt_info_done = false;
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
}
void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
}
void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
}
int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
return 0;
}
int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
return 0;
}
int compel_cpuid(compel_cpuinfo_t *info)
{
info->hwcap[0] = getauxval(AT_HWCAP);
info->hwcap[1] = getauxval(AT_HWCAP2);
if (!info->hwcap[0] || !info->hwcap[1]) {
pr_err("Can't read the hardware capabilities\n");
return -1;
}
return 0;
}
bool compel_cpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_cpu_cap(&rt_info, feature);
}
bool compel_fpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_fpu_cap(&rt_info, feature);
}
uint32_t compel_fpu_feature_size(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
uint32_t compel_fpu_feature_offset(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
void compel_cpu_clear_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_clear_cpu_cap(&rt_info, feature);
}
void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
{
fetch_rt_cpuinfo();
memcpy(c, &rt_info, sizeof(rt_info));
}
crac-criu-1.5.0/compel/arch/ppc64/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025337 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/handle-elf.c 0000664 0000000 0000000 00000001475 14715043267 0022235 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char __maybe_unused elf_ident_64_be[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int handle_binary(void *mem, size_t size)
{
const unsigned char *elf_ident =
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
elf_ident_64_le;
#else
elf_ident_64_be;
#endif
if (memcmp(mem, elf_ident, sizeof(elf_ident_64_le)) == 0)
return handle_elf_ppc64(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0021506 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/cpu.h 0000664 0000000 0000000 00000000000 14715043267 0022434 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000466 14715043267 0023664 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define ELF_PPC64
#define __handle_elf handle_elf_ppc64
#define arch_is_machine_supported(e_machine) (e_machine == EM_PPC64)
extern int handle_elf_ppc64(void *mem, size_t size);
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/syscall.h 0000664 0000000 0000000 00000000252 14715043267 0023330 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#endif
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022444 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0023224 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/.gitignore 0000664 0000000 0000000 00000000000 14715043267 0025202 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000377 14715043267 0025725 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
}
static inline int ptrace_flush_breakpoints(pid_t pid)
{
return 0;
}
#endif
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000265 14715043267 0024167 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_CPU_H__
#define UAPI_COMPEL_ASM_CPU_H__
#include
typedef struct {
uint64_t hwcap[2];
} compel_cpuinfo_t;
#endif /* UAPI_COMPEL_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000121 14715043267 0024161 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000005306 14715043267 0026013 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#include
#include
#define SIGMAX_OLD 31
#define SIGMAX 64
/*
* Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
*/
typedef struct {
unsigned long gpr[32];
unsigned long nip;
unsigned long msr;
unsigned long orig_gpr3; /* Used for restarting system calls */
unsigned long ctr;
unsigned long link;
unsigned long xer;
unsigned long ccr;
unsigned long softe; /* Soft enabled/disabled */
unsigned long trap; /* Reason for being here */
/*
* N.B. for critical exceptions on 4xx, the dar and dsisr
* fields are overloaded to hold srr0 and srr1.
*/
unsigned long dar; /* Fault registers */
unsigned long dsisr; /* on 4xx/Book-E used for ESR */
unsigned long result; /* Result of a system call */
} user_regs_struct_t;
#define NVSXREG 32
#define USER_FPREGS_FL_FP 0x00001
#define USER_FPREGS_FL_ALTIVEC 0x00002
#define USER_FPREGS_FL_VSX 0x00004
#define USER_FPREGS_FL_TM 0x00010
#ifndef NT_PPC_TM_SPR
#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
#endif
#define MSR_TMA (1UL << 34) /* bit 29 Trans Mem state: Transactional */
#define MSR_TMS (1UL << 33) /* bit 30 Trans Mem state: Suspended */
#define MSR_TM (1UL << 32) /* bit 31 Trans Mem Available */
#define MSR_VEC (1UL << 25)
#define MSR_VSX (1UL << 23)
#define MSR_TM_ACTIVE(x) ((((x)&MSR_TM) && ((x) & (MSR_TMA | MSR_TMS))) != 0)
typedef struct {
uint64_t fpregs[NFPREG];
__vector128 vrregs[NVRREG];
uint64_t vsxregs[NVSXREG];
int flags;
struct tm_regs {
int flags;
struct {
uint64_t tfhar, texasr, tfiar;
} tm_spr_regs;
user_regs_struct_t regs;
uint64_t fpregs[NFPREG];
__vector128 vrregs[NVRREG];
uint64_t vsxregs[NVSXREG];
} tm;
} user_fpregs_struct_t;
#define REG_RES(regs) ((uint64_t)(regs).gpr[3])
#define REG_IP(regs) ((uint64_t)(regs).nip)
#define SET_REG_IP(regs, val) ((regs).nip = (val))
#define REG_SP(regs) ((uint64_t)(regs).gpr[1])
#define REG_SYSCALL_NR(regs) ((uint64_t)(regs).gpr[0])
#define user_regs_native(pregs) true
#define ARCH_SI_TRAP TRAP_BRKPT
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/processor-flags.h 0000664 0000000 0000000 00000000212 14715043267 0026501 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__
#define UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__
#endif /* UAPI_COMPEL_ASM_PROCESSOR_FLAGS_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/processor.h 0000664 0000000 0000000 00000000170 14715043267 0025412 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_PROCESSOR_H__
#define UAPI_COMPEL_ASM_PROCESSOR_H__
#endif /* UAPI_COMPEL_ASM_PROCESSOR_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000005062 14715043267 0025175 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
#include
#include
/*
* sigcontext structure defined in file
* /usr/include/powerpc64le-linux-gnu/bits/sigcontext.h,
* included from /usr/include/signal.h
*
* Kernel definition can be found in arch/powerpc/include/uapi/asm/sigcontext.h
*/
#include
// XXX: the identifier rt_sigcontext is expected to be struct by the CRIU code
#define rt_sigcontext sigcontext
#include
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
/* Copied from the Linux kernel header arch/powerpc/include/asm/ptrace.h */
#define USER_REDZONE_SIZE 512
#if _CALL_ELF != 2
#error Only supporting ABIv2.
#else
#define STACK_FRAME_MIN_SIZE 32
#endif
/* Copied from the Linux kernel source file arch/powerpc/kernel/signal_64.c */
#define TRAMP_SIZE 6
/*
* ucontext_t defined in /usr/include/powerpc64le-linux-gnu/sys/ucontext.h
*/
struct rt_sigframe {
/* sys_rt_sigreturn requires the ucontext be the first field */
ucontext_t uc;
ucontext_t uc_transact; /* Transactional state */
unsigned long _unused[2];
unsigned int tramp[TRAMP_SIZE];
struct rt_siginfo *pinfo;
void *puc;
struct rt_siginfo info;
/* New 64 bit little-endian ABI allows redzone of 512 bytes below sp */
char abigap[USER_REDZONE_SIZE];
} __attribute__((aligned(16)));
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"mr 1, %0 \n" \
"li 0, "__stringify(__NR_rt_sigreturn)" \n" \
"sc \n" \
: \
: "r"(new_sp) \
: "memory")
/* clang-format on */
#if _CALL_ELF != 2
#error Only supporting ABIv2.
#else
#define FRAME_MIN_SIZE_PARM 96
#endif
#define RT_SIGFRAME_UC(rt_sigframe) (&(rt_sigframe)->uc)
#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.gp_regs[PT_NIP])
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
#define RT_SIGFRAME_FPU(rt_sigframe) (&(rt_sigframe)->uc.uc_mcontext)
#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
#define MSR_TMA (1UL << 34) /* bit 29 Trans Mem state: Transactional */
#define MSR_TMS (1UL << 33) /* bit 30 Trans Mem state: Suspended */
#define MSR_TM (1UL << 32) /* bit 31 Trans Mem Available */
#define MSR_VEC (1UL << 25)
#define MSR_VSX (1UL << 23)
#define MSR_TM_ACTIVE(x) ((((x)&MSR_TM) && ((x) & (MSR_TMA | MSR_TMS))) != 0)
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/ppc64/src/lib/infect.c 0000664 0000000 0000000 00000036363 14715043267 0021512 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include
#include "uapi/compel/asm/infect-types.h"
#include "errno.h"
#include "log.h"
#include "common/bug.h"
#include "common/page.h"
#include "common/err.h"
#include "infect.h"
#include "infect-priv.h"
#ifndef NT_PPC_TM_SPR
#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
#endif
unsigned __page_size = 0;
unsigned __page_shift = 0;
/*
* Injected syscall instruction
*/
const uint32_t code_syscall[] = {
0x44000002, /* sc */
0x0fe00000 /* twi 31,0,0 */
};
static inline __always_unused void __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
static void prep_gp_regs(mcontext_t *dst, user_regs_struct_t *regs)
{
memcpy(dst->gp_regs, regs->gpr, sizeof(regs->gpr));
dst->gp_regs[PT_NIP] = regs->nip;
dst->gp_regs[PT_MSR] = regs->msr;
dst->gp_regs[PT_ORIG_R3] = regs->orig_gpr3;
dst->gp_regs[PT_CTR] = regs->ctr;
dst->gp_regs[PT_LNK] = regs->link;
dst->gp_regs[PT_XER] = regs->xer;
dst->gp_regs[PT_CCR] = regs->ccr;
dst->gp_regs[PT_TRAP] = regs->trap;
}
static void put_fpu_regs(mcontext_t *mc, uint64_t *fpregs)
{
uint64_t *mcfp = (uint64_t *)mc->fp_regs;
memcpy(mcfp, fpregs, sizeof(*fpregs) * NFPREG);
}
static void put_altivec_regs(mcontext_t *mc, __vector128 *vrregs)
{
vrregset_t *v_regs = (vrregset_t *)(((unsigned long)mc->vmx_reserve + 15) & ~0xful);
memcpy(&v_regs->vrregs[0][0], vrregs, sizeof(uint64_t) * 2 * (NVRREG - 1));
v_regs->vrsave = *((uint32_t *)&vrregs[NVRREG - 1]);
mc->v_regs = v_regs;
}
static void put_vsx_regs(mcontext_t *mc, uint64_t *vsxregs)
{
memcpy((uint64_t *)(mc->v_regs + 1), vsxregs, sizeof(*vsxregs) * NVSXREG);
}
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
mcontext_t *dst_tc = &sigframe->uc_transact.uc_mcontext;
mcontext_t *dst = &sigframe->uc.uc_mcontext;
if (fpregs->flags & USER_FPREGS_FL_TM) {
prep_gp_regs(&sigframe->uc_transact.uc_mcontext, &fpregs->tm.regs);
prep_gp_regs(&sigframe->uc.uc_mcontext, &fpregs->tm.regs);
} else {
prep_gp_regs(&sigframe->uc.uc_mcontext, regs);
}
if (fpregs->flags & USER_FPREGS_FL_TM)
sigframe->uc.uc_link = &sigframe->uc_transact;
if (fpregs->flags & USER_FPREGS_FL_FP) {
if (fpregs->flags & USER_FPREGS_FL_TM) {
put_fpu_regs(&sigframe->uc_transact.uc_mcontext, fpregs->tm.fpregs);
put_fpu_regs(&sigframe->uc.uc_mcontext, fpregs->tm.fpregs);
} else {
put_fpu_regs(&sigframe->uc.uc_mcontext, fpregs->fpregs);
}
}
if (fpregs->flags & USER_FPREGS_FL_ALTIVEC) {
if (fpregs->flags & USER_FPREGS_FL_TM) {
put_altivec_regs(&sigframe->uc_transact.uc_mcontext, fpregs->tm.vrregs);
put_altivec_regs(&sigframe->uc.uc_mcontext, fpregs->tm.vrregs);
dst_tc->gp_regs[PT_MSR] |= MSR_VEC;
} else {
put_altivec_regs(&sigframe->uc.uc_mcontext, fpregs->vrregs);
}
dst->gp_regs[PT_MSR] |= MSR_VEC;
if (fpregs->flags & USER_FPREGS_FL_VSX) {
if (fpregs->flags & USER_FPREGS_FL_TM) {
put_vsx_regs(&sigframe->uc_transact.uc_mcontext, fpregs->tm.vsxregs);
put_vsx_regs(&sigframe->uc.uc_mcontext, fpregs->tm.vsxregs);
dst_tc->gp_regs[PT_MSR] |= MSR_VSX;
} else {
put_vsx_regs(&sigframe->uc.uc_mcontext, fpregs->vsxregs);
}
dst->gp_regs[PT_MSR] |= MSR_VSX;
}
}
return 0;
}
static void update_vregs(mcontext_t *lcontext, mcontext_t *rcontext)
{
if (lcontext->v_regs) {
uint64_t offset = (uint64_t)(lcontext->v_regs) - (uint64_t)lcontext;
lcontext->v_regs = (vrregset_t *)((uint64_t)rcontext + offset);
pr_debug("Updated v_regs:%llx (rcontext:%llx)\n", (unsigned long long)lcontext->v_regs,
(unsigned long long)rcontext);
}
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *frame, struct rt_sigframe *rframe)
{
uint64_t msr = frame->uc.uc_mcontext.gp_regs[PT_MSR];
update_vregs(&frame->uc.uc_mcontext, &rframe->uc.uc_mcontext);
/* Sanity check: If TM so uc_link should be set, otherwise not */
if (MSR_TM_ACTIVE(msr) ^ (!!(frame->uc.uc_link))) {
BUG();
return -1;
}
/* Updating the transactional state address if any */
if (frame->uc.uc_link) {
update_vregs(&frame->uc_transact.uc_mcontext, &rframe->uc_transact.uc_mcontext);
frame->uc.uc_link = &rframe->uc_transact;
}
return 0;
}
/* This is the layout of the POWER7 VSX registers and the way they
* overlap with the existing FPR and VMX registers.
*
* VSR doubleword 0 VSR doubleword 1
* ----------------------------------------------------------------
* VSR[0] | FPR[0] | |
* ----------------------------------------------------------------
* VSR[1] | FPR[1] | |
* ----------------------------------------------------------------
* | ... | |
* ----------------------------------------------------------------
* VSR[30] | FPR[30] | |
* ----------------------------------------------------------------
* VSR[31] | FPR[31] | |
* ----------------------------------------------------------------
* VSR[32] | VR[0] |
* ----------------------------------------------------------------
* VSR[33] | VR[1] |
* ----------------------------------------------------------------
* | ... |
* ----------------------------------------------------------------
* VSR[62] | VR[30] |
* ----------------------------------------------------------------
* VSR[63] | VR[31] |
* ----------------------------------------------------------------
*
* PTRACE_GETFPREGS returns FPR[0..31] + FPSCR
* PTRACE_GETVRREGS returns VR[0..31] + VSCR + VRSAVE
* PTRACE_GETVSRREGS returns VSR[0..31]
*
* PTRACE_GETVSRREGS and PTRACE_GETFPREGS are required since we need
* to save FPSCR too.
*
* There 32 VSX double word registers to save since the 32 first VSX double
* word registers are saved through FPR[0..32] and the remaining registers
* are saved when saving the Altivec registers VR[0..32].
*/
static int get_fpu_regs(pid_t pid, user_fpregs_struct_t *fp)
{
if (ptrace(PTRACE_GETFPREGS, pid, 0, (void *)&fp->fpregs) < 0) {
pr_perror("Couldn't get floating-point registers");
return -1;
}
fp->flags |= USER_FPREGS_FL_FP;
return 0;
}
static int get_altivec_regs(pid_t pid, user_fpregs_struct_t *fp)
{
if (ptrace(PTRACE_GETVRREGS, pid, 0, (void *)&fp->vrregs) < 0) {
/* PTRACE_GETVRREGS returns EIO if Altivec is not supported.
* This should not happen if msr_vec is set. */
if (errno != EIO) {
pr_perror("Couldn't get Altivec registers");
return -1;
}
pr_debug("Altivec not supported\n");
} else {
pr_debug("Dumping Altivec registers\n");
fp->flags |= USER_FPREGS_FL_ALTIVEC;
}
return 0;
}
/*
* Since the FPR[0-31] is stored in the first double word of VSR[0-31] and
* FPR are saved through the FP state, there is no need to save the upper part
* of the first 32 VSX registers.
* Furthermore, the 32 last VSX registers are also the 32 Altivec registers
* already saved, so no need to save them.
* As a consequence, only the doubleword 1 of the 32 first VSX registers have
* to be saved (the ones are returned by PTRACE_GETVSRREGS).
*/
static int get_vsx_regs(pid_t pid, user_fpregs_struct_t *fp)
{
if (ptrace(PTRACE_GETVSRREGS, pid, 0, (void *)fp->vsxregs) < 0) {
/*
* EIO is returned in the case PTRACE_GETVRREGS is not
* supported.
*/
if (errno != EIO) {
pr_perror("Couldn't get VSX registers");
return -1;
}
pr_debug("VSX register's dump not supported.\n");
} else {
pr_debug("Dumping VSX registers\n");
fp->flags |= USER_FPREGS_FL_VSX;
}
return 0;
}
static int get_tm_regs(pid_t pid, user_fpregs_struct_t *fpregs)
{
struct iovec iov;
pr_debug("Dumping TM registers\n");
#define TM_REQUIRED 0
#define TM_OPTIONAL 1
#define PTRACE_GET_TM(s, n, c, u) \
do { \
iov.iov_base = &s; \
iov.iov_len = sizeof(s); \
if (ptrace(PTRACE_GETREGSET, pid, c, &iov)) { \
if (!u || errno != EIO) { \
pr_perror("Couldn't get TM " n); \
pr_err("Your kernel seems to not support the " \
"new TM ptrace API (>= 4.8)\n"); \
goto out_free; \
} \
pr_debug("TM " n " not supported.\n"); \
iov.iov_base = NULL; \
} \
} while (0)
/* Get special registers */
PTRACE_GET_TM(fpregs->tm.tm_spr_regs, "SPR", NT_PPC_TM_SPR, TM_REQUIRED);
/* Get checkpointed regular registers */
PTRACE_GET_TM(fpregs->tm.regs, "GPR", NT_PPC_TM_CGPR, TM_REQUIRED);
/* Get checkpointed FP registers */
PTRACE_GET_TM(fpregs->tm.fpregs, "FPR", NT_PPC_TM_CFPR, TM_OPTIONAL);
if (iov.iov_base)
fpregs->tm.flags |= USER_FPREGS_FL_FP;
/* Get checkpointed VMX (Altivec) registers */
PTRACE_GET_TM(fpregs->tm.vrregs, "VMX", NT_PPC_TM_CVMX, TM_OPTIONAL);
if (iov.iov_base)
fpregs->tm.flags |= USER_FPREGS_FL_ALTIVEC;
/* Get checkpointed VSX registers */
PTRACE_GET_TM(fpregs->tm.vsxregs, "VSX", NT_PPC_TM_CVSX, TM_OPTIONAL);
if (iov.iov_base)
fpregs->tm.flags |= USER_FPREGS_FL_VSX;
return 0;
out_free:
return -1; /* still failing the checkpoint */
}
/*
* This is inspired by kernel function check_syscall_restart in
* arch/powerpc/kernel/signal.c
*/
#ifndef TRAP
#define TRAP(r) ((r).trap & ~0xF)
#endif
static bool trap_is_scv(user_regs_struct_t *regs)
{
return TRAP(*regs) == 0x3000;
}
static bool trap_is_syscall(user_regs_struct_t *regs)
{
return trap_is_scv(regs) || TRAP(*regs) == 0x0C00;
}
static void handle_syscall(pid_t pid, user_regs_struct_t *regs)
{
unsigned long ret = regs->gpr[3];
if (trap_is_scv(regs)) {
if (!IS_ERR_VALUE(ret))
return;
ret = -ret;
} else if (!(regs->ccr & 0x10000000)) {
return;
}
/* Restart or interrupt the system call */
switch (ret) {
case ERESTARTNOHAND:
case ERESTARTSYS:
case ERESTARTNOINTR:
regs->gpr[3] = regs->orig_gpr3;
regs->nip -= 4;
break;
case ERESTART_RESTARTBLOCK:
pr_warn("Will restore %d with interrupted system call\n", pid);
regs->gpr[3] = trap_is_scv(regs) ? -EINTR : EINTR;
break;
}
}
static int __get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
pr_info("Dumping GP/FPU registers for %d\n", pid);
if (trap_is_syscall(regs))
handle_syscall(pid, regs);
/* Resetting trap since we are now coming from user space. */
regs->trap = 0;
fpregs->flags = 0;
/*
* Check for Transactional Memory operation in progress.
* Until we have support of TM register's state through the ptrace API,
* we can't checkpoint process with TM operation in progress (almost
* impossible) or suspended (easy to get).
*/
if (MSR_TM_ACTIVE(regs->msr)) {
pr_debug("Task %d has %s TM operation at 0x%lx\n", pid,
(regs->msr & MSR_TMS) ? "a suspended" : "an active", regs->nip);
if (get_tm_regs(pid, fpregs))
return -1;
fpregs->flags = USER_FPREGS_FL_TM;
}
if (get_fpu_regs(pid, fpregs))
return -1;
if (get_altivec_regs(pid, fpregs))
return -1;
if (fpregs->flags & USER_FPREGS_FL_ALTIVEC) {
/*
* Save the VSX registers if Altivec registers are supported
*/
if (get_vsx_regs(pid, fpregs))
return -1;
}
return 0;
}
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
int ret;
ret = __get_task_regs(pid, regs, fpregs);
if (ret)
return ret;
return save(arg, regs, fpregs);
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
int ret = 0;
pr_info("Restoring GP/FPU registers for %d\n", pid);
/* XXX: should restore TM registers somehow? */
if (ext_regs->flags & USER_FPREGS_FL_FP) {
if (ptrace(PTRACE_SETFPREGS, pid, 0, (void *)&ext_regs->fpregs) < 0) {
pr_perror("Couldn't set floating-point registers");
ret = -1;
}
}
if (ext_regs->flags & USER_FPREGS_FL_ALTIVEC) {
if (ptrace(PTRACE_SETVRREGS, pid, 0, (void *)&ext_regs->vrregs) < 0) {
pr_perror("Couldn't set Altivec registers");
ret = -1;
}
if (ptrace(PTRACE_SETVSRREGS, pid, 0, (void *)ext_regs->vsxregs) < 0) {
pr_perror("Couldn't set VSX registers");
ret = -1;
}
}
return ret;
}
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
regs.gpr[0] = (unsigned long)nr;
regs.gpr[3] = arg1;
regs.gpr[4] = arg2;
regs.gpr[5] = arg3;
regs.gpr[6] = arg4;
regs.gpr[7] = arg5;
regs.gpr[8] = arg6;
err = compel_execute_syscall(ctl, ®s, (char *)code_syscall);
*ret = regs.gpr[3];
return err;
}
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map = 0;
int err;
err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset);
if (err < 0 || (long)map < 0)
map = 0;
return (void *)map;
}
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
/*
* OpenPOWER ABI requires that r12 is set to the calling function address
* to compute the TOC pointer.
*/
regs->gpr[12] = new_ip;
regs->nip = new_ip;
if (stack)
regs->gpr[1] = (unsigned long)stack - STACK_FRAME_MIN_SIZE;
regs->trap = 0;
}
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
/*
* TODO: We should detect 32bit task when BE support is done.
*/
return true;
}
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
/*
* Copied for the Linux kernel arch/powerpc/include/asm/processor.h
*
* NOTE: 32bit tasks are not supported.
*/
#define TASK_SIZE_64TB (0x0000400000000000UL)
#define TASK_SIZE_512TB (0x0002000000000000UL)
#define TASK_SIZE_MIN TASK_SIZE_64TB
#define TASK_SIZE_MAX TASK_SIZE_512TB
unsigned long compel_task_size(void)
{
unsigned long task_size;
for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
if (munmap((void *)task_size, page_size()))
break;
return task_size;
}
crac-criu-1.5.0/compel/arch/s390/ 0000775 0000000 0000000 00000000000 14715043267 0016270 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0017751 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0021374 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022154 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/include/asm/prologue.h 0000777 0000000 0000000 00000000000 14715043267 0034676 2../../../../../arch/x86/plugins/include/asm/prologue.h ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000001376 14715043267 0025150 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
#define SA_RESTORER 0x04000000U
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define _KNSIG 64
#define _NSIG_BPW 64
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
typedef struct {
unsigned long sig[_KNSIG_WORDS];
} k_rtsigset_t;
/*
* Used for rt_sigaction() system call - see kernel "struct sigaction" in
* include/linux/signal.h.
*/
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
struct mmap_arg_struct;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/s390/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0020543 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/std/parasite-head.S 0000664 0000000 0000000 00000000337 14715043267 0023401 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
.section .head.text, "ax"
ENTRY(__export_parasite_head_start)
brasl %r14,parasite_service
.long 0x00010001 /* S390_BREAKPOINT_U16: Generates SIGTRAP */
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/s390/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0022400 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000005306 14715043267 0025700 0 ustar 00root root 0000000 0000000 ccflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y += -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
sys-types := $(obj)/include/uapi/std/syscall-types.h
sys-codes := $(obj)/include/uapi/std/syscall-codes.h
sys-proto := $(obj)/include/uapi/std/syscall.h
sys-def := $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-s390.tbl
sys-asm-common-name := std/syscalls/syscall-common-s390.S
sys-asm-common := $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
sys-asm := ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-lib-y += $(sys-asm:.S=).o
std-lib-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls-s390.o
$(sys-codes): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
$(sys-proto): $(sys-def)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#include " >> $@
$(Q) echo "#include " >> $@
$(Q) cat $< | awk '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#include " >> $@
$(Q) echo "#include \"$(sys-asm-common-name)\"" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}' >> $@
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {" >> $@
$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}' >> $@
$(Q) echo " { }, /* terminator */" >> $@
$(Q) echo "};" >> $@
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
std-headers-deps += $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y += $(std-headers-deps)
crac-criu-1.5.0/compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S 0000664 0000000 0000000 00000001721 14715043267 0026161 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
/*
* Define a system call
*
* C-ABI on s390:
* - Parameters 1-5 are passed in %r2-%r6
* - Parameter 6 is passed on the stack 160(%r15)
* - Return value is in %r2
* - Return address is in %r14
* - Registers %r0-%r6,%r14 are call-clobbered
* - Registers %r7-%r13,%r15 are call-saved
*
* SVC ABI on s390:
* - For SVC 0 the system call number is passed in %r1
* - Parameters 1-6 are passed in %r2-%r7
* - Return value is passed in %r2
* - Besides of %r2 all registers are call-saved
*/
#define SYSCALL(name, opcode) \
ENTRY(name); \
lgr %r0,%r7; /* Save %r7 */ \
lg %r7,160(%r15); /* Load 6th parameter */ \
lghi %r1,opcode; /* Load SVC number */ \
svc 0; /* Issue SVC 0 */ \
lgr %r7,%r0; /* Restore %r7 */ \
br %r14; /* Return to caller */ \
END(name) \
/*
* Issue rt_sigreturn system call for sa_restorer
*/
ENTRY(__cr_restore_rt)
lghi %r1,__NR_rt_sigreturn
svc 0
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl 0000664 0000000 0000000 00000022363 14715043267 0025257 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consists of only the syscalls
# really used somewhere in the project.
#
# The template is (name and arguments are optional if you need only __NR_x
# defined, but no real entry point in syscalls lib).
#
# name code name arguments
# -----------------------------------------------------------------------
#
__NR_read 3 sys_read (int fd, void *buf, unsigned long count)
__NR_write 4 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 5 sys_open (const char *filename, unsigned long flags, unsigned long mode)
__NR_close 6 sys_close (int fd)
__NR_lseek 19 sys_lseek (int fd, unsigned long offset, unsigned long origin)
__NR_mmap 90 sys_old_mmap (struct mmap_arg_struct *)
__NR_mprotect 125 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_munmap 91 sys_munmap (void *addr, unsigned long len)
__NR_brk 45 sys_brk (void *addr)
__NR_rt_sigaction 174 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 175 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
__NR_rt_sigreturn 173 sys_rt_sigreturn (void)
__NR_ioctl 54 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_pread64 180 sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos)
__NR_ptrace 26 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_mremap 163 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_mincore 218 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 219 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_pause 29 sys_pause (void)
__NR_nanosleep 162 sys_nanosleep (struct timespec *req, struct timespec *rem)
__NR_getitimer 105 sys_getitimer (int which, const struct itimerval *val)
__NR_setitimer 104 sys_setitimer (int which, const struct itimerval *val, struct itimerval *old)
__NR_getpid 20 sys_getpid (void)
__NR_socket 359 sys_socket (int domain, int type, int protocol)
__NR_connect 362 sys_connect (int sockfd, struct sockaddr *addr, int addrlen)
__NR_sendto 369 sys_sendto (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
__NR_recvfrom 371 sys_recvfrom (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
__NR_sendmsg 370 sys_sendmsg (int sockfd, const struct msghdr *msg, int flags)
__NR_recvmsg 372 sys_recvmsg (int sockfd, struct msghdr *msg, int flags)
__NR_shutdown 373 sys_shutdown (int sockfd, int how)
__NR_bind 361 sys_bind (int sockfd, const struct sockaddr *addr, int addrlen)
__NR_setsockopt 366 sys_setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
__NR_getsockopt 365 sys_getsockopt (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
__NR_clone 120 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, void *tls)
__NR_exit 1 sys_exit (unsigned long error_code)
__NR_wait4 114 sys_wait4 (int pid, int *status, int options, struct rusage *ru)
__NR_kill 37 sys_kill (long pid, int sig)
__NR_fcntl 55 sys_fcntl (int fd, int type, long arg)
__NR_flock 143 sys_flock (int fd, unsigned long cmd)
__NR_mkdir 39 sys_mkdir (const char *name, int mode)
__NR_rmdir 40 sys_rmdir (const char *name)
__NR_unlink 10 sys_unlink (char *pathname)
__NR_readlinkat 298 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_umask 60 sys_umask (int mask)
__NR_getgroups 205 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups 206 sys_setgroups (int gsize, unsigned int *groups)
__NR_setresuid 208 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid 209 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid 210 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid 211 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_getpgid 132 sys_getpgid (pid_t pid)
__NR_setfsuid 215 sys_setfsuid (int fsuid)
__NR_setfsgid 216 sys_setfsgid (int fsgid)
__NR_getsid 147 sys_getsid (void)
__NR_capget 184 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 185 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_rt_sigqueueinfo 178 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *info)
__NR_sigaltstack 186 sys_sigaltstack (const void *uss, void *uoss)
__NR_personality 136 sys_personality (unsigned int personality)
__NR_setpriority 97 sys_setpriority (int which, int who, int nice)
__NR_sched_setscheduler 156 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_prctl 172 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_setrlimit 75 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 21 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 52 sys_umount2 (char *name, int flags)
__NR_gettid 236 sys_gettid (void)
__NR_futex 238 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_tid_address 252 sys_set_tid_address (int *tid_addr)
__NR_restart_syscall 7 sys_restart_syscall (void)
__NR_sys_timer_create 254 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_sys_timer_settime 255 sys_timer_settime (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
__NR_sys_timer_gettime 256 sys_timer_gettime (int timer_id, const struct itimerspec *setting)
__NR_sys_timer_getoverrun 257 sys_timer_getoverrun (int timer_id)
__NR_sys_timer_delete 258 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 260 sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp)
__NR_exit_group 248 sys_exit_group (int error_code)
__NR_waitid 281 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_set_robust_list 304 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 305 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_vmsplice 309 sys_vmsplice (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
__NR_openat 288 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_fallocate 314 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_timerfd_settime 320 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_signalfd4 322 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_rt_tgsigqueueinfo 330 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 332 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 333 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 336 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 339 sys_setns (int fd, int nstype)
__NR_kcmp 343 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_seccomp 348 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_memfd_create 350 sys_memfd_create (const char *name, unsigned int flags)
__NR_io_setup 243 sys_io_setup (unsigned nr_events, aio_context_t *ctx_idp)
__NR_io_getevents 245 sys_io_getevents (aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
__NR_io_submit 246 sys_io_submit (aio_context_t ctx_id, long nr, struct iocb **iocbpp)
__NR_ipc 117 sys_ipc (unsigned int call, int first, unsigned long second, unsigned long third, const void *ptr, long fifth)
__NR_userfaultfd 355 sys_userfaultfd (int flags)
__NR_preadv 328 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_gettimeofday 78 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_ppoll 302 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_openat2 437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
__NR_rseq 383 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_membarrier 356 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/s390/plugins/std/syscalls/syscalls-s390.c 0000664 0000000 0000000 00000001252 14715043267 0025075 0 ustar 00root root 0000000 0000000 #include "asm/infect-types.h"
/*
* Define prototype because of compile error if we include uapi/std/syscall.h
*/
long sys_old_mmap(struct mmap_arg_struct *);
/*
* On s390 we have defined __ARCH_WANT_SYS_OLD_MMAP - Therefore implement
* system call with one parameter "mmap_arg_struct".
*/
unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd,
unsigned long offset)
{
struct mmap_arg_struct arg_struct;
arg_struct.addr = (unsigned long)addr;
arg_struct.len = len;
arg_struct.prot = prot;
arg_struct.flags = flags;
arg_struct.fd = fd;
arg_struct.offset = offset;
return sys_old_mmap(&arg_struct);
}
crac-criu-1.5.0/compel/arch/s390/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0017757 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000730 14715043267 0023057 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(s390:64-bit)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.text : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
*(.compel.exit)
*(.compel.init)
}
.data : ALIGN(0x1000) {
*(.data*)
*(.bss*)
}
.rodata : {
*(.rodata*)
*(.got*)
}
.toc : ALIGN(8) {
*(.toc*)
}
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
}
}
crac-criu-1.5.0/compel/arch/s390/src/ 0000775 0000000 0000000 00000000000 14715043267 0017057 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0017625 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/cpu.c 0000664 0000000 0000000 00000003111 14715043267 0020554 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "common/compiler.h"
#include "log.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static bool rt_info_done = false;
static void fetch_rt_cpuinfo(void)
{
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
}
void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
}
int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
{
return 0;
}
int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
return 0;
}
int compel_cpuid(compel_cpuinfo_t *info)
{
info->hwcap[0] = getauxval(AT_HWCAP);
info->hwcap[1] = getauxval(AT_HWCAP2);
if (!info->hwcap[0]) {
pr_err("Can't read the hardware capabilities\n");
return -1;
}
return 0;
}
bool compel_cpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_cpu_cap(&rt_info, feature);
}
bool compel_fpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_fpu_cap(&rt_info, feature);
}
uint32_t compel_fpu_feature_offset(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
uint32_t compel_fpu_feature_size(unsigned int feature)
{
fetch_rt_cpuinfo();
return 0;
}
void compel_cpu_clear_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_clear_cpu_cap(&rt_info, feature);
}
void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
{
fetch_rt_cpuinfo();
memcpy(c, &rt_info, sizeof(rt_info));
}
crac-criu-1.5.0/compel/arch/s390/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025101 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/handle-elf.c 0000664 0000000 0000000 00000000763 14715043267 0021776 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_64, sizeof(elf_ident_64)) == 0)
return handle_elf_s390(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/s390/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0021250 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000453 14715043267 0023422 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define ELF_S390
#define __handle_elf handle_elf_s390
#define arch_is_machine_supported(e_machine) (e_machine == EM_S390)
int handle_elf_s390(void *mem, size_t size);
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/s390/src/lib/include/syscall.h 0000664 0000000 0000000 00000000324 14715043267 0023072 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd,
unsigned long offset);
#endif
crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022206 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022766 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000377 14715043267 0025467 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
}
static inline int ptrace_flush_breakpoints(pid_t pid)
{
return 0;
}
#endif
crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000000256 14715043267 0023731 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_CPU_H__
#define UAPI_COMPEL_ASM_CPU_H__
#include
typedef struct {
uint64_t hwcap[2];
} compel_cpuinfo_t;
#endif /* __CR_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000000325 14715043267 0023731 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#include
#include
/*
* This one is used in restorer
*/
typedef struct {
bool has_fpu;
} fpu_state_t;
#endif /* __CR_ASM_FPU_H__ */
crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/infect-types.h 0000664 0000000 0000000 00000004241 14715043267 0025552 0 ustar 00root root 0000000 0000000 #ifndef UAPI_COMPEL_ASM_TYPES_H__
#define UAPI_COMPEL_ASM_TYPES_H__
#include
#include
#include
#include
#include "common/page.h"
#define SIGMAX 64
#define SIGMAX_OLD 31
/*
* Definitions from /usr/include/asm/ptrace.h:
*
* typedef struct
* {
* __u32 fpc;
* freg_t fprs[NUM_FPRS];
* } s390_fp_regs;
*
* typedef struct
* {
* psw_t psw;
* unsigned long gprs[NUM_GPRS];
* unsigned int acrs[NUM_ACRS];
* unsigned long orig_gpr2;
* } s390_regs;
*/
typedef struct {
uint64_t part1;
uint64_t part2;
} vector128_t;
struct prfpreg {
uint32_t fpc;
uint64_t fprs[16];
};
#define USER_FPREGS_VXRS 0x000000001
/* Guarded-storage control block */
#define USER_GS_CB 0x000000002
/* Guarded-storage broadcast control block */
#define USER_GS_BC 0x000000004
/* Runtime-instrumentation control block */
#define USER_RI_CB 0x000000008
/* Runtime-instrumentation bit set */
#define USER_RI_ON 0x000000010
typedef struct {
uint32_t flags;
struct prfpreg prfpreg;
uint64_t vxrs_low[16];
vector128_t vxrs_high[16];
uint64_t gs_cb[4];
uint64_t gs_bc[4];
uint64_t ri_cb[8];
} user_fpregs_struct_t;
typedef struct {
s390_regs prstatus;
uint32_t system_call;
} user_regs_struct_t;
#define REG_RES(r) ((uint64_t)(r).prstatus.gprs[2])
#define REG_IP(r) ((uint64_t)(r).prstatus.psw.addr)
#define SET_REG_IP(r, val) ((r).prstatus.psw.addr = (val))
#define REG_SP(r) ((uint64_t)(r).prstatus.gprs[15])
/*
* We assume that REG_SYSCALL_NR() is only used for pie code where we
* always use svc 0 with opcode in %r1.
*/
#define REG_SYSCALL_NR(r) ((uint64_t)(r).prstatus.gprs[1])
#define user_regs_native(pregs) true
#define __NR(syscall, compat) \
({ \
(void)compat; \
__NR_##syscall; \
})
struct mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
unsigned long flags;
unsigned long fd;
unsigned long offset;
};
#define __compel_arch_fetch_thread_area(tid, th) 0
#define compel_arch_fetch_thread_area(tctl) 0
#define compel_arch_get_tls_task(ctl, tls)
#define compel_arch_get_tls_thread(tctl, tls)
#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
crac-criu-1.5.0/compel/arch/s390/src/lib/include/uapi/asm/sigframe.h 0000664 0000000 0000000 00000003541 14715043267 0024737 0 ustar 00root root 0000000 0000000
#ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include
#include
#include
#include
// XXX: the identifier rt_sigcontext is expected to be struct by the CRIU code
#define rt_sigcontext sigcontext
#include
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
/*
* From /usr/include/asm/sigcontext.h
*
* Redefine _sigregs_ext to be able to compile on older systems
*/
#ifndef __NUM_VXRS_LOW
typedef struct {
__u32 u[4];
} __vector128;
typedef struct {
unsigned long long vxrs_low[16];
__vector128 vxrs_high[16];
unsigned char __reserved[128];
} _sigregs_ext;
#endif
/*
* From /usr/include/uapi/asm/ucontext.h
*/
struct ucontext_extended {
unsigned long uc_flags;
ucontext_t *uc_link;
stack_t uc_stack;
_sigregs uc_mcontext;
sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
unsigned char __unused[128 - sizeof(sigset_t)];
_sigregs_ext uc_mcontext_ext;
};
/*
* Signal stack frame for RT sigreturn
*/
struct rt_sigframe {
uint8_t callee_used_stack[160];
uint8_t retcode[2];
siginfo_t info;
struct ucontext_extended uc;
};
/*
* Do rt_sigreturn SVC
*/
/* clang-format off */
#define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \
asm volatile( \
"lgr %%r15,%0\n" \
"lghi %%r1,173\n" \
"svc 0\n" \
: \
: "d" (new_sp) \
: "memory")
/* clang-format on */
#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc)
#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.regs.psw.addr
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
crac-criu-1.5.0/compel/arch/s390/src/lib/infect.c 0000664 0000000 0000000 00000046472 14715043267 0021256 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "uapi/compel/asm/infect-types.h"
#include "errno.h"
#include "log.h"
#include "common/bug.h"
#include "infect.h"
#include "ptrace.h"
#include "infect-priv.h"
#define NT_PRFPREG 2
#define NT_S390_VXRS_LOW 0x309
#define NT_S390_VXRS_HIGH 0x30a
#define NT_S390_GS_CB 0x30b
#define NT_S390_GS_BC 0x30c
#define NT_S390_RI_CB 0x30d
/*
* Print general purpose and access registers
*/
static void print_user_regs_struct(const char *msg, int pid, user_regs_struct_t *regs)
{
int i;
pr_debug("%s: Registers for pid=%d\n", msg, pid);
pr_debug("system_call %08lx\n", (unsigned long)regs->system_call);
pr_debug(" psw %016lx %016lx\n", regs->prstatus.psw.mask, regs->prstatus.psw.addr);
pr_debug(" orig_gpr2 %016lx\n", regs->prstatus.orig_gpr2);
for (i = 0; i < 16; i++)
pr_debug(" g%02d %016lx\n", i, regs->prstatus.gprs[i]);
for (i = 0; i < 16; i++)
pr_debug(" a%02d %08x\n", i, regs->prstatus.acrs[i]);
}
/*
* Print vector registers
*/
static void print_vxrs(user_fpregs_struct_t *fpregs)
{
int i;
if (!(fpregs->flags & USER_FPREGS_VXRS)) {
pr_debug(" No VXRS\n");
return;
}
for (i = 0; i < 16; i++)
pr_debug(" vx_low%02d %016lx\n", i, fpregs->vxrs_low[i]);
for (i = 0; i < 16; i++)
pr_debug(" vx_high%02d %016lx %016lx\n", i, fpregs->vxrs_high[i].part1, fpregs->vxrs_high[i].part2);
}
/*
* Print guarded-storage control block
*/
static void print_gs_cb(user_fpregs_struct_t *fpregs)
{
int i;
if (!(fpregs->flags & USER_GS_CB)) {
pr_debug(" No GS_CB\n");
return;
}
for (i = 0; i < 4; i++)
pr_debug(" gs_cb%02d %016lx\n", i, fpregs->gs_cb[i]);
}
/*
* Print guarded-storage broadcast control block
*/
static void print_gs_bc(user_fpregs_struct_t *fpregs)
{
int i;
if (!(fpregs->flags & USER_GS_BC)) {
pr_debug(" No GS_BC\n");
return;
}
for (i = 0; i < 4; i++)
pr_debug(" gs_bc%02d %016lx\n", i, fpregs->gs_bc[i]);
}
/*
* Print runtime-instrumentation control block
*/
static void print_ri_cb(user_fpregs_struct_t *fpregs)
{
int i;
if (!(fpregs->flags & USER_RI_CB)) {
pr_debug(" No RI_CB\n");
return;
}
for (i = 0; i < 8; i++)
pr_debug(" ri_cb%02d %016lx\n", i, fpregs->ri_cb[i]);
}
/*
* Print FP registers, VX registers, guarded-storage, and
* runtime-instrumentation
*/
static void print_user_fpregs_struct(const char *msg, int pid, user_fpregs_struct_t *fpregs)
{
int i;
pr_debug("%s: FP registers for pid=%d\n", msg, pid);
pr_debug(" fpc %08x\n", fpregs->prfpreg.fpc);
for (i = 0; i < 16; i++)
pr_debug(" f%02d %016lx\n", i, fpregs->prfpreg.fprs[i]);
print_vxrs(fpregs);
print_gs_cb(fpregs);
print_gs_bc(fpregs);
print_ri_cb(fpregs);
}
int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
_sigregs_ext *dst_ext = &sigframe->uc.uc_mcontext_ext;
_sigregs *dst = &sigframe->uc.uc_mcontext;
memcpy(dst->regs.gprs, regs->prstatus.gprs, sizeof(regs->prstatus.gprs));
memcpy(dst->regs.acrs, regs->prstatus.acrs, sizeof(regs->prstatus.acrs));
memcpy(&dst->regs.psw, ®s->prstatus.psw, sizeof(regs->prstatus.psw));
memcpy(&dst->fpregs.fpc, &fpregs->prfpreg.fpc, sizeof(fpregs->prfpreg.fpc));
memcpy(&dst->fpregs.fprs, &fpregs->prfpreg.fprs, sizeof(fpregs->prfpreg.fprs));
if (fpregs->flags & USER_FPREGS_VXRS) {
memcpy(&dst_ext->vxrs_low, &fpregs->vxrs_low, sizeof(fpregs->vxrs_low));
memcpy(&dst_ext->vxrs_high, &fpregs->vxrs_high, sizeof(fpregs->vxrs_high));
} else {
memset(&dst_ext->vxrs_low, 0, sizeof(dst_ext->vxrs_low));
memset(&dst_ext->vxrs_high, 0, sizeof(dst_ext->vxrs_high));
}
return 0;
}
int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
/*
* Rewind the psw for 'bytes' bytes
*/
static inline void rewind_psw(psw_t *psw, unsigned long bytes)
{
unsigned long mask;
pr_debug("Rewind psw: %016lx bytes=%lu\n", psw->addr, bytes);
mask = (psw->mask & PSW_MASK_EA) ? -1UL : (psw->mask & PSW_MASK_BA) ? (1UL << 31) - 1 : (1UL << 24) - 1;
psw->addr = (psw->addr - bytes) & mask;
}
/*
* Get vector registers
*/
int get_vx_regs(pid_t pid, user_fpregs_struct_t *fpregs)
{
struct iovec iov;
fpregs->flags &= ~USER_FPREGS_VXRS;
iov.iov_base = &fpregs->vxrs_low;
iov.iov_len = sizeof(fpregs->vxrs_low);
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_VXRS_LOW, &iov) < 0) {
/*
* If the kernel does not support vector registers, we get
* EINVAL. With kernel support and old hardware, we get ENODEV.
*/
if (errno == EINVAL || errno == ENODEV) {
memset(fpregs->vxrs_low, 0, sizeof(fpregs->vxrs_low));
memset(fpregs->vxrs_high, 0, sizeof(fpregs->vxrs_high));
pr_debug("VXRS registers not supported\n");
return 0;
}
pr_perror("Couldn't get VXRS_LOW");
return -1;
}
iov.iov_base = &fpregs->vxrs_high;
iov.iov_len = sizeof(fpregs->vxrs_high);
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_VXRS_HIGH, &iov) < 0) {
pr_perror("Couldn't get VXRS_HIGH");
return -1;
}
fpregs->flags |= USER_FPREGS_VXRS;
return 0;
}
/*
* Get guarded-storage control block
*/
int get_gs_cb(pid_t pid, user_fpregs_struct_t *fpregs)
{
struct iovec iov;
fpregs->flags &= ~(USER_GS_CB | USER_GS_BC);
iov.iov_base = &fpregs->gs_cb;
iov.iov_len = sizeof(fpregs->gs_cb);
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_GS_CB, &iov) < 0) {
switch (errno) {
case EINVAL:
case ENODEV:
memset(&fpregs->gs_cb, 0, sizeof(fpregs->gs_cb));
memset(&fpregs->gs_bc, 0, sizeof(fpregs->gs_bc));
pr_debug("GS_CB not supported\n");
return 0;
case ENODATA:
pr_debug("GS_CB not set\n");
break;
default:
return -1;
}
} else {
fpregs->flags |= USER_GS_CB;
}
iov.iov_base = &fpregs->gs_bc;
iov.iov_len = sizeof(fpregs->gs_bc);
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_GS_BC, &iov) < 0) {
if (errno == ENODATA) {
pr_debug("GS_BC not set\n");
return 0;
}
pr_perror("Couldn't get GS_BC");
return -1;
}
fpregs->flags |= USER_GS_BC;
return 0;
}
/*
* Get runtime-instrumentation control block
*/
int get_ri_cb(pid_t pid, user_fpregs_struct_t *fpregs)
{
user_regs_struct_t regs;
struct iovec iov;
psw_t *psw;
fpregs->flags &= ~(USER_RI_CB | USER_RI_ON);
iov.iov_base = &fpregs->ri_cb;
iov.iov_len = sizeof(fpregs->ri_cb);
if (ptrace(PTRACE_GETREGSET, pid, NT_S390_RI_CB, &iov) < 0) {
switch (errno) {
case EINVAL:
case ENODEV:
memset(&fpregs->ri_cb, 0, sizeof(fpregs->ri_cb));
pr_debug("RI_CB not supported\n");
return 0;
case ENODATA:
pr_debug("RI_CB not set\n");
return 0;
default:
pr_perror("Couldn't get RI_CB");
return -1;
}
}
fpregs->flags |= USER_RI_CB;
/* Get PSW and check if runtime-instrumentation bit is enabled */
iov.iov_base = ®s.prstatus;
iov.iov_len = sizeof(regs.prstatus);
if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov) < 0)
return -1;
psw = ®s.prstatus.psw;
if (psw->mask & PSW_MASK_RI)
fpregs->flags |= USER_RI_ON;
return 0;
}
/*
* Disable runtime-instrumentation bit
*/
static int s390_disable_ri_bit(pid_t pid, user_regs_struct_t *regs)
{
struct iovec iov;
psw_t *psw;
iov.iov_base = ®s->prstatus;
iov.iov_len = sizeof(regs->prstatus);
psw = ®s->prstatus.psw;
psw->mask &= ~PSW_MASK_RI;
return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
}
/*
* Prepare task registers for restart
*/
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
struct iovec iov;
int rewind;
print_user_regs_struct("compel_get_task_regs", pid, regs);
memset(fpregs, 0, sizeof(*fpregs));
iov.iov_base = &fpregs->prfpreg;
iov.iov_len = sizeof(fpregs->prfpreg);
if (ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov) < 0) {
pr_perror("Couldn't get floating-point registers");
return -1;
}
if (get_vx_regs(pid, fpregs)) {
pr_perror("Couldn't get vector registers");
return -1;
}
if (get_gs_cb(pid, fpregs)) {
pr_perror("Couldn't get guarded-storage");
return -1;
}
if (get_ri_cb(pid, fpregs)) {
pr_perror("Couldn't get runtime-instrumentation");
return -1;
}
/*
* If the runtime-instrumentation bit is set, we have to disable it
* before we execute parasite code. Otherwise parasite operations
* would be recorded.
*/
if (fpregs->flags & USER_RI_ON)
s390_disable_ri_bit(pid, regs);
print_user_fpregs_struct("compel_get_task_regs", pid, fpregs);
/* Check for system call restarting. */
if (regs->system_call) {
rewind = regs->system_call >> 16;
/* see arch/s390/kernel/signal.c: do_signal() */
switch ((long)regs->prstatus.gprs[2]) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
regs->prstatus.gprs[2] = regs->prstatus.orig_gpr2;
rewind_psw(®s->prstatus.psw, rewind);
pr_debug("New gpr2: %016lx\n", regs->prstatus.gprs[2]);
break;
case -ERESTART_RESTARTBLOCK:
pr_warn("Will restore %d with interrupted system call\n", pid);
regs->prstatus.gprs[2] = -EINTR;
break;
}
}
/* Call save_task_regs() */
return save(arg, regs, fpregs);
}
int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
{
struct iovec iov;
int ret = 0;
iov.iov_base = &ext_regs->prfpreg;
iov.iov_len = sizeof(ext_regs->prfpreg);
if (ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov) < 0) {
pr_perror("Couldn't set floating-point registers");
ret = -1;
}
if (ext_regs->flags & USER_FPREGS_VXRS) {
iov.iov_base = &ext_regs->vxrs_low;
iov.iov_len = sizeof(ext_regs->vxrs_low);
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_VXRS_LOW, &iov) < 0) {
pr_perror("Couldn't set VXRS_LOW");
ret = -1;
}
iov.iov_base = &ext_regs->vxrs_high;
iov.iov_len = sizeof(ext_regs->vxrs_high);
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_VXRS_HIGH, &iov) < 0) {
pr_perror("Couldn't set VXRS_HIGH");
ret = -1;
}
}
if (ext_regs->flags & USER_GS_CB) {
iov.iov_base = &ext_regs->gs_cb;
iov.iov_len = sizeof(ext_regs->gs_cb);
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_GS_CB, &iov) < 0) {
pr_perror("Couldn't set GS_CB");
ret = -1;
}
iov.iov_base = &ext_regs->gs_bc;
iov.iov_len = sizeof(ext_regs->gs_bc);
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_GS_BC, &iov) < 0) {
pr_perror("Couldn't set GS_BC");
ret = -1;
}
}
if (ext_regs->flags & USER_RI_CB) {
iov.iov_base = &ext_regs->ri_cb;
iov.iov_len = sizeof(ext_regs->ri_cb);
if (ptrace(PTRACE_SETREGSET, pid, NT_S390_RI_CB, &iov) < 0) {
pr_perror("Couldn't set RI_CB");
ret = -1;
}
}
return ret;
}
/*
* Injected syscall instruction
*/
const char code_syscall[] = {
0x0a, 0x00, /* sc 0 */
0x00, 0x01, /* S390_BREAKPOINT_U16 */
0x00, 0x01, /* S390_BREAKPOINT_U16 */
0x00, 0x01, /* S390_BREAKPOINT_U16 */
};
static inline void __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
/*
* Issue s390 system call
*/
int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
/* Load syscall number into %r1 */
regs.prstatus.gprs[1] = (unsigned long)nr;
/* Load parameter registers %r2-%r7 */
regs.prstatus.gprs[2] = arg1;
regs.prstatus.gprs[3] = arg2;
regs.prstatus.gprs[4] = arg3;
regs.prstatus.gprs[5] = arg4;
regs.prstatus.gprs[6] = arg5;
regs.prstatus.gprs[7] = arg6;
err = compel_execute_syscall(ctl, ®s, (char *)code_syscall);
/* Return code from system is in %r2 */
if (ret)
*ret = regs.prstatus.gprs[2];
return err;
}
/*
* Issue s390 mmap call
*/
void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
void *where = (void *)ctl->ictx.syscall_ip + BUILTIN_SYSCALL_SIZE;
struct mmap_arg_struct arg_struct;
pid_t pid = ctl->rpid;
long map = 0;
int err;
/* Setup s390 mmap data */
arg_struct.addr = (unsigned long)addr;
arg_struct.len = length;
arg_struct.prot = prot;
arg_struct.flags = flags;
arg_struct.fd = fd;
arg_struct.offset = offset;
/* Move args to process */
if (ptrace_swap_area(pid, where, &arg_struct, sizeof(arg_struct))) {
pr_err("Can't inject memfd args (pid: %d)\n", pid);
return NULL;
}
/* Do syscall */
err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)where, 0, 0, 0, 0, 0);
if (err < 0 || (long)map < 0)
map = 0;
/* Restore data */
if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
pr_err("Can't restore mmap args (pid: %d)\n", pid);
if (map != 0) {
err = compel_syscall(ctl, __NR_munmap, NULL, map, length, 0, 0, 0, 0);
if (err)
pr_err("Can't munmap %d\n", err);
map = 0;
}
}
return (void *)map;
}
/*
* Setup registers for parasite call
*/
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->prstatus.psw.addr = new_ip;
if (!stack)
return;
regs->prstatus.gprs[15] = ((unsigned long)stack) - STACK_FRAME_OVERHEAD;
}
/*
* Check if we have all kernel and CRIU features to dump the task
*/
bool arch_can_dump_task(struct parasite_ctl *ctl)
{
user_fpregs_struct_t fpregs;
user_regs_struct_t regs;
pid_t pid = ctl->rpid;
char str[8];
psw_t *psw;
if (ptrace_get_regs(pid, ®s))
return false;
psw = ®s.prstatus.psw;
/* Check if the kernel supports RI ptrace interface */
if (psw->mask & PSW_MASK_RI) {
if (get_ri_cb(pid, &fpregs) < 0) {
pr_perror("Can't dump process with RI bit active");
return false;
}
}
/* We don't support 24 and 31 bit mode - only 64 bit */
if (psw->mask & PSW_MASK_EA) {
if (psw->mask & PSW_MASK_BA)
return true;
else
sprintf(str, "??");
} else {
if (psw->mask & PSW_MASK_BA)
sprintf(str, "31");
else
sprintf(str, "24");
}
pr_err("Pid %d is %s bit: Only 64 bit tasks are supported\n", pid, str);
return false;
}
/*
* Return current alternate signal stack
*/
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
/*
* Find last mapped address of current process
*/
static unsigned long max_mapped_addr(void)
{
unsigned long addr_end, addr_max = 0;
char line[128];
FILE *fp;
fp = fopen("/proc/self/maps", "r");
if (!fp)
goto out;
/* Parse lines like: 3fff415f000-3fff4180000 rw-p 00000000 00:00 0 */
while (fgets(line, sizeof(line), fp)) {
char *ptr;
/* First skip start address */
strtoul(&line[0], &ptr, 16);
addr_end = strtoul(ptr + 1, NULL, 16);
addr_max = max(addr_max, addr_end);
}
fclose(fp);
out:
return addr_max - 1;
}
/*
* Kernel task size level
*
* We have (dynamic) 4 level page tables for 64 bit since linux 2.6.25:
*
* 5a216a2083 ("[S390] Add four level page tables for CONFIG_64BIT=y.")
* 6252d702c5 ("[S390] dynamic page tables.")
*
* The code below is already prepared for future (dynamic) 5 level page tables.
*
* Besides that there is one problematic kernel bug that has been fixed for
* linux 4.11 by the following commit:
*
* ee71d16d22 ("s390/mm: make TASK_SIZE independent from the number
* of page table levels")
*
* A 64 bit process on s390x always starts with 3 levels and upgrades to 4
* levels for mmap(> 4 TB) and to 5 levels for mmap(> 16 EB).
*
* Unfortunately before fix ee71d16d22 for a 3 level process munmap()
* and mremap() fail for addresses > 4 TB. CRIU uses the task size,
* to unmap() all memory from a starting point to task size to get rid of
* unwanted mappings. CRIU uses mremap() to establish the final mappings
* which also fails if we want to restore mappings > 4 TB and the initial
* restore process still runs with 3 levels.
*
* To support the current CRIU design on s390 we return task size = 4 TB when
* a kernel without fix ee71d16d22 is detected. In this case we can dump at
* least processes with < 4 TB which is the most likely case anyway.
*
* For kernels with fix ee71d16d22 we are fully functional.
*/
enum kernel_ts_level {
/* Kernel with 4 level page tables without fix ee71d16d22 */
KERNEL_TS_LEVEL_4_FIX_NO,
/* Kernel with 4 level page tables with fix ee71d16d22 */
KERNEL_TS_LEVEL_4_FIX_YES,
/* Kernel with 4 level page tables with or without fix ee71d16d22 */
KERNEL_TS_LEVEL_4_FIX_UNKN,
/* Kernel with 5 level page tables */
KERNEL_TS_LEVEL_5,
};
/* See arch/s390/include/asm/processor.h */
#define TASK_SIZE_LEVEL_3 0x40000000000UL /* 4 TB */
#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */
#define TASK_SIZE_LEVEL_5 0xffffffffffffefffUL /* 16 EB - 0x1000 */
/*
* Return detected kernel version regarding task size level
*
* We use unmap() to probe the maximum possible page table level of kernel
*/
static enum kernel_ts_level get_kernel_ts_level(void)
{
unsigned long criu_end_addr = max_mapped_addr();
/* Check for 5 levels */
if (criu_end_addr >= TASK_SIZE_LEVEL_4)
return KERNEL_TS_LEVEL_5;
else if (munmap((void *)TASK_SIZE_LEVEL_4, 0x1000) == 0)
return KERNEL_TS_LEVEL_5;
if (criu_end_addr < TASK_SIZE_LEVEL_3) {
/* Check for 4 level kernel with fix */
if (munmap((void *)TASK_SIZE_LEVEL_3, 0x1000) == 0)
return KERNEL_TS_LEVEL_4_FIX_YES;
else
return KERNEL_TS_LEVEL_4_FIX_NO;
}
/* We can't find out if kernel has the fix */
return KERNEL_TS_LEVEL_4_FIX_UNKN;
}
/*
* Log detected level
*/
static void pr_levels(const char *str)
{
pr_debug("Max user page table levels (task size): %s\n", str);
}
/*
* Return last address (+1) of biggest possible user address space for
* current kernel
*/
unsigned long compel_task_size(void)
{
switch (get_kernel_ts_level()) {
case KERNEL_TS_LEVEL_4_FIX_NO:
pr_levels("KERNEL_TS_LEVEL_4_FIX_NO");
return TASK_SIZE_LEVEL_3;
case KERNEL_TS_LEVEL_4_FIX_YES:
pr_levels("KERNEL_TS_LEVEL_4_FIX_YES");
return TASK_SIZE_LEVEL_4;
case KERNEL_TS_LEVEL_4_FIX_UNKN:
pr_levels("KERNEL_TS_LEVEL_4_FIX_UNKN");
return TASK_SIZE_LEVEL_3;
default: /* KERNEL_TS_LEVEL_5 */
pr_levels("KERNEL_TS_LEVEL_5");
return TASK_SIZE_LEVEL_5;
}
}
/*
* Get task registers (overwrites weak function)
*/
int ptrace_get_regs(int pid, user_regs_struct_t *regs)
{
struct iovec iov;
int rc;
pr_debug("ptrace_get_regs: pid=%d\n", pid);
iov.iov_base = ®s->prstatus;
iov.iov_len = sizeof(regs->prstatus);
rc = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov);
if (rc != 0)
return rc;
iov.iov_base = ®s->system_call;
iov.iov_len = sizeof(regs->system_call);
return ptrace(PTRACE_GETREGSET, pid, NT_S390_SYSTEM_CALL, &iov);
}
/*
* Set task registers (overwrites weak function)
*/
int ptrace_set_regs(int pid, user_regs_struct_t *regs)
{
uint32_t system_call = 0;
struct iovec iov;
int rc;
pr_debug("ptrace_set_regs: pid=%d\n", pid);
iov.iov_base = ®s->prstatus;
iov.iov_len = sizeof(regs->prstatus);
rc = ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
if (rc)
return rc;
/*
* If we attached to an inferior that is sleeping in a restarting
* system call like futex_wait(), we have to reset the system_call
* to 0. Otherwise the kernel would try to finish the interrupted
* system call after PTRACE_CONT and we could not run the
* parasite code.
*/
iov.iov_base = &system_call;
iov.iov_len = sizeof(system_call);
return ptrace(PTRACE_SETREGSET, pid, NT_S390_SYSTEM_CALL, &iov);
}
crac-criu-1.5.0/compel/arch/x86/ 0000775 0000000 0000000 00000000000 14715043267 0016217 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/ 0000775 0000000 0000000 00000000000 14715043267 0017700 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/include/ 0000775 0000000 0000000 00000000000 14715043267 0021323 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/include/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022103 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/include/asm/prologue.h 0000664 0000000 0000000 00000001256 14715043267 0024114 0 ustar 00root root 0000000 0000000 #ifndef __ASM_PROLOGUE_H__
#define __ASM_PROLOGUE_H__
#ifndef __ASSEMBLY__
#include
#include
#include
#include
#define sys_recv(sockfd, ubuf, size, flags) sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL)
typedef struct prologue_init_args {
struct sockaddr_un ctl_sock_addr;
unsigned int ctl_sock_addr_len;
unsigned int arg_s;
void *arg_p;
void *sigframe;
} prologue_init_args_t;
#endif /* __ASSEMBLY__ */
/*
* Reserve enough space for sigframe.
*
* FIXME It is rather should be taken from sigframe header.
*/
#define PROLOGUE_SGFRAME_SIZE 4096
#define PROLOGUE_INIT_ARGS_SIZE 1024
#endif /* __ASM_PROLOGUE_H__ */
crac-criu-1.5.0/compel/arch/x86/plugins/include/asm/syscall-types.h 0000664 0000000 0000000 00000003100 14715043267 0025062 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
#define COMPEL_ARCH_SYSCALL_TYPES_H__
/* Types for sigaction, sigprocmask syscalls */
typedef void rt_signalfn_t(int, siginfo_t *, void *);
typedef rt_signalfn_t *rt_sighandler_t;
typedef void rt_restorefn_t(void);
typedef rt_restorefn_t *rt_sigrestore_t;
#define SA_RESTORER 0x04000000
#define _KNSIG 64
#define _NSIG_BPW 64
#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW)
/*
* Note: as k_rtsigset_t is the same size for 32-bit and 64-bit,
* sig defined as uint64_t rather than (unsigned long) - for the
* purpose if we ever going to support native 32-bit compilation.
*/
typedef struct {
uint64_t sig[_KNSIG_WORDS];
} k_rtsigset_t;
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
rt_sigrestore_t rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t;
/*
* Note: there is unaligned access on x86_64 and it's fine.
* However, when porting this code -- keep in mind about possible issues
* with unaligned rt_sa_mask.
*/
typedef struct __attribute__((packed)) {
unsigned int rt_sa_handler;
unsigned int rt_sa_flags;
unsigned int rt_sa_restorer;
k_rtsigset_t rt_sa_mask;
} rt_sigaction_t_compat;
/* Types for set_thread_area, get_thread_area syscalls */
typedef struct {
unsigned int entry_number;
unsigned int base_addr;
unsigned int limit;
unsigned int seg_32bit : 1;
unsigned int contents : 2;
unsigned int read_exec_only : 1;
unsigned int limit_in_pages : 1;
unsigned int seg_not_present : 1;
unsigned int usable : 1;
unsigned int lm : 1;
} user_desc_t;
#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
crac-criu-1.5.0/compel/arch/x86/plugins/include/features.h 0000664 0000000 0000000 00000000202 14715043267 0023304 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ARCH_FEATURES_H
#define __COMPEL_ARCH_FEATURES_H
#define ARCH_HAS_MEMCPY
#endif /* __COMPEL_ARCH_FEATURES_H */
crac-criu-1.5.0/compel/arch/x86/plugins/std/ 0000775 0000000 0000000 00000000000 14715043267 0020472 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/std/memcpy.S 0000664 0000000 0000000 00000001006 14715043267 0022105 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
/* The following code is taken from Linux kernel (arch/x86/lib/memcpy_64.S).
* There are 3 implementations in there, we use the one that relies on
* X86_FEATURE_REP_GOOD ("rep microcode works well").
*/
/*
* memcpy - Copy a memory block.
*
* Input:
* rdi destination
* rsi source
* rdx count
*
* Output:
* rax original destination
*/
ENTRY(memcpy)
movq %rdi, %rax
movq %rdx, %rcx
shrq $3, %rcx
andl $7, %edx
rep movsq
movl %edx, %ecx
rep movsb
ret
END(memcpy)
crac-criu-1.5.0/compel/arch/x86/plugins/std/parasite-head.S 0000664 0000000 0000000 00000001610 14715043267 0023323 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
.section .head.text, "ax"
#ifndef CONFIG_X86_64
# error 64-bit parasite should compile with CONFIG_X86_64
#endif
#ifdef CONFIG_COMPAT
.code32
ENTRY(__export_parasite_head_start_compat)
/* A long jump to 64-bit parasite. */
jmp $__USER_CS,$1f
1:
.code64
call parasite_service
pushq $__USER32_CS
xor %r11, %r11
movl $2f, %r11d
pushq %r11
lretq
2:
.code32
/*
* parasite_service() can run commands in non-daemon mode
* with parasite_trap_cmd(): it waits that after return there
* is a software break.
* compel_run_in_thread() uses this and after hitting the break,
* it restores register set - that's the reason, why we should
* stop in 32-bit mode for compat tasks here.
*/
int $0x03
END(__export_parasite_head_start_compat)
.code64
#endif
ENTRY(__export_parasite_head_start)
call parasite_service
int $0x03
END(__export_parasite_head_start)
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/ 0000775 0000000 0000000 00000000000 14715043267 0022327 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls 0000664 0000000 0000000 00000012444 14715043267 0025630 0 ustar 00root root 0000000 0000000 std-lib-y += ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
sys-proto-types := $(obj)/include/uapi/std/syscall-types.h
sys-proto-generic := $(obj)/include/uapi/std/syscall.h
sys-codes-generic := $(obj)/include/uapi/std/syscall-codes.h
sys-codes = $(obj)/include/uapi/std/syscall-codes-$(1).h
sys-proto = $(obj)/include/uapi/std/syscall-$(1).h
sys-def = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
sys-asm = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
sys-asm-common-name = std/syscalls/syscall-common-x86-$(1).S
sys-asm-common = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types := $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
sys-bits := 64
AV := $$$$
define gen-rule-sys-codes
$(sys-codes): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__" >> $$@
$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1; \
sub("^__NR", "SYS", SYSN); \
print "\n#ifndef ", $(AV)1; \
print "#define", $(AV)1, $(AV)2; \
print "#endif"; \
print "\n#ifndef ", SYSN; \
print "#define ", SYSN, $(AV)1; \
print "#endif";}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-proto
$(sys-proto): $(sys-def) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__" >> $$@
$(Q) echo "/* musl defines loff_t as off_t */" >> $$@
$(Q) echo '#ifndef loff_t' >> $$@
$(Q) echo '#define loff_t off_t' >> $$@
$(Q) echo '#endif' >> $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include ' >> $$@
ifeq ($(1),32)
$(Q) echo '#include "asm/syscall32.h"' >> $$@
endif
$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3, \
substr($(AV)0, index($(AV)0,$(AV)4)), ";"}' >> $$@
$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */" >> $$@
endef
define gen-rule-sys-asm
$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) echo '#include ' >> $$@
$(Q) echo '#include "$(sys-asm-common-name)"' >> $$@
$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}' >> $$@
endef
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(sys-codes-generic): $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_32.tbl $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__" >> $@
$(Q) echo "/* musl defines loff_t as off_t */" >> $@
$(Q) echo '#ifndef loff_t' >> $@
$(Q) echo '#define loff_t off_t' >> $@
$(Q) echo '#endif' >> $@
$(Q) echo '#include ' >> $@
$(Q) cat $< | awk '/^__NR/{NR32=$$1; \
sub("^__NR", "__NR32", NR32); \
print "\n#ifndef ", NR32; \
print "#define ", NR32, $$2; \
print "#endif";}' >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */" >> $@
mrproper-y += $(sys-codes-generic)
$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
$(call msg-gen, $@)
$(Q) echo "/* Autogenerated, don't edit */" > $@
$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__" >> $@
$(Q) echo "" >> $@
$(Q) echo "#ifdef CONFIG_X86_32" >> $@
$(Q) echo '#include ' >> $@
$(Q) echo "#else" >> $@
$(Q) echo '#include ' >> $@
$(Q) echo "#endif /* CONFIG_X86_32 */" >> $@
$(Q) echo "" >> $@
$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */" >> $@
mrproper-y += $(sys-proto-generic)
define gen-rule-sys-exec-tbl
$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
$(call msg-gen, $$@)
$(Q) echo "/* Autogenerated, don't edit */" > $$@
$(Q) cat $$< | awk '/^__NR/{print \
"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}' >> $$@
endef
$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
$(call msg-gen, $@)
$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
std-headers-deps += $(call sys-codes,$(sys-bits))
std-headers-deps += $(call sys-proto,$(sys-bits))
std-headers-deps += $(call sys-asm,$(sys-bits))
std-headers-deps += $(call sys-exec-tbl,$(sys-bits))
std-headers-deps += $(sys-codes-generic)
std-headers-deps += $(sys-proto-generic)
std-headers-deps += $(sys-asm-types)
mrproper-y += $(std-headers-deps)
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/syscall-common-x86-32.S 0000664 0000000 0000000 00000001073 14715043267 0026261 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
#define SYSCALL(name, opcode) \
ENTRY(name); \
movl $opcode, %eax; \
jmp __syscall_common; \
END(name)
ENTRY(__syscall_common)
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
#define __arg(n) (4 * (n) + 20)(%esp)
movl __arg(0),%ebx
movl __arg(1),%ecx
movl __arg(2),%edx
movl __arg(3),%esi
movl __arg(4),%edi
movl __arg(5),%ebp
#undef __arg
int $0x80
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
END(__syscall_common)
ENTRY(__cr_restore_rt)
movl $__NR_rt_sigreturn, %eax
jmp __syscall_common
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/syscall-common-x86-64.S 0000664 0000000 0000000 00000000505 14715043267 0026265 0 ustar 00root root 0000000 0000000 #include "common/asm/linkage.h"
#define SYSCALL(name, opcode) \
ENTRY(name); \
movl $opcode, %eax; \
jmp __syscall_common; \
END(name)
.text
.align 4
ENTRY(__syscall_common)
movq %rcx, %r10
syscall
ret
END(__syscall_common)
ENTRY(__cr_restore_rt)
movq $__NR_rt_sigreturn, %rax
syscall
END(__cr_restore_rt)
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/syscall32.c 0000664 0000000 0000000 00000006051 14715043267 0024314 0 ustar 00root root 0000000 0000000 #include "asm/types.h"
#include "syscall-32.h"
#define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */
#define SYS_CONNECT 3 /* sys_connect(2) */
#define SYS_SENDTO 11 /* sys_sendto(2) */
#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
long sys_socket(int domain, int type, int protocol)
{
uint32_t a[] = { (uint32_t)domain, (uint32_t)type, (uint32_t)protocol };
return sys_socketcall(SYS_SOCKET, (unsigned long *)a);
}
long sys_connect(int sockfd, struct sockaddr *addr, int addrlen)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen };
return sys_socketcall(SYS_CONNECT, (unsigned long *)a);
}
long sys_sendto(int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)buff, (uint32_t)len,
(uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len };
return sys_socketcall(SYS_SENDTO, (unsigned long *)a);
}
long sys_recvfrom(int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)ubuf, (uint32_t)size,
(uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len };
return sys_socketcall(SYS_RECVFROM, (unsigned long *)a);
}
long sys_sendmsg(int sockfd, const struct msghdr *msg, int flags)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags };
return sys_socketcall(SYS_SENDMSG, (unsigned long *)a);
}
long sys_recvmsg(int sockfd, struct msghdr *msg, int flags)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags };
return sys_socketcall(SYS_RECVMSG, (unsigned long *)a);
}
long sys_shutdown(int sockfd, int how)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)how };
return sys_socketcall(SYS_SHUTDOWN, (unsigned long *)a);
}
long sys_bind(int sockfd, const struct sockaddr *addr, int addrlen)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen };
return sys_socketcall(SYS_BIND, (unsigned long *)a);
}
long sys_setsockopt(int sockfd, int level, int optname, const void *optval, unsigned int optlen)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen };
return sys_socketcall(SYS_SETSOCKOPT, (unsigned long *)a);
}
long sys_getsockopt(int sockfd, int level, int optname, const void *optval, unsigned int *optlen)
{
uint32_t a[] = { (uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen };
return sys_socketcall(SYS_GETSOCKOPT, (unsigned long *)a);
}
#define SHMAT 21
long sys_shmat(int shmid, void *shmaddr, int shmflag)
{
return sys_ipc(SHMAT, shmid, shmflag, 0, shmaddr, 0);
}
long sys_pread(unsigned int fd, char *ubuf, uint32_t count, uint64_t pos)
{
return sys_pread64(fd, ubuf, count, (uint32_t)(pos & 0xffffffffu), (uint32_t)(pos >> 32));
}
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl 0000664 0000000 0000000 00000021043 14715043267 0025010 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consist only the syscalls
# really used somewhere in project.
#
# code name arguments
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
__NR_restart_syscall 0 sys_restart_syscall (void)
__NR_exit 1 sys_exit (unsigned long error_code)
__NR_read 3 sys_read (int fd, void *buf, unsigned long count)
__NR_write 4 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 5 sys_open (const char *filename, int flags, unsigned int mode)
__NR_close 6 sys_close (int fd)
__NR_unlink 10 sys_unlink (char *pathname)
__NR_lseek 19 sys_lseek (int fd, int32_t offset, unsigned int origin)
__NR_getpid 20 sys_getpid (void)
__NR_mount 21 sys_mount (const char *dev_name, const char *dir_name, const char *type, unsigned long flags, const void *data)
__NR_ptrace 26 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_kill 37 sys_kill (long pid, int sig)
__NR_mkdir 39 sys_mkdir (const char *name, int mode)
__NR_rmdir 40 sys_rmdir (const char *name)
__NR_brk 45 sys_brk (void *addr)
__NR_umount2 52 sys_umount2 (char *name, int flags)
__NR_ioctl 54 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_fcntl 55 sys_fcntl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_umask 60 sys_umask (int mask)
__NR_setrlimit 75 sys_setrlimit (unsigned int resource, struct krlimit *rlim)
__NR_gettimeofday 78 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_munmap 91 sys_munmap (void *addr, unsigned long len)
__NR_setpriority 97 sys_setpriority (int which, int who, int nice)
__NR_socketcall 102 sys_socketcall (int call, unsigned long *args)
__NR_setitimer 104 sys_setitimer (int which, struct itimerval *in, struct itimerval *out)
__NR_getitimer 105 sys_getitimer (int which, struct itimerval *it)
__NR_wait4 114 sys_wait4 (pid_t pid, int *stat_addr, int options, struct rusage *ru)
__NR_ipc 117 sys_ipc (unsigned int call, int first, unsigned long second, unsigned long third, void *ptr, long fifth)
__NR_clone 120 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
__NR_mprotect 125 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_getpgid 132 sys_getpgid (pid_t pid)
__NR_personality 136 sys_personality (unsigned int personality)
__NR_flock 143 sys_flock (int fd, unsigned long cmd)
__NR_getsid 147 sys_getsid (void)
__NR_sched_setscheduler 156 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_nanosleep 162 sys_nanosleep (struct timespec *rqtp, struct timespec *rmtp)
__NR_mremap 163 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_prctl 172 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_rt_sigreturn 173 sys_rt_sigreturn (void)
__NR_rt_sigaction 174 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 175 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *oset, size_t sigsetsize)
__NR_rt_sigqueueinfo 178 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *uinfo)
__NR_pread64 180 sys_pread64 (unsigned int fd, char *ubuf, uint32_t count, uint32_t poslo, uint32_t poshi)
__NR_capget 184 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 185 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_sigaltstack 186 sys_sigaltstack (const void *uss_ptr, void *uoss_ptr)
__NR_mmap2 192 sys_mmap (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff)
__NR_getgroups32 205 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups32 206 sys_setgroups (int gsize, unsigned int *groups)
__NR_setresuid32 208 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid32 209 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid32 210 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid32 211 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_setfsuid32 215 sys_setfsuid (int fsuid)
__NR_setfsgid32 216 sys_setfsgid (int fsgid)
__NR_mincore 218 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 219 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_gettid 224 sys_gettid (void)
__NR_futex 240 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_thread_area 243 sys_set_thread_area (user_desc_t *info)
__NR_get_thread_area 244 sys_get_thread_area (user_desc_t *info)
__NR_io_setup 245 sys_io_setup (unsigned nr_reqs, aio_context_t *ctx32p)
__NR_io_getevents 247 sys_io_getevents (aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
__NR_io_submit 248 sys_io_submit (aio_context_t ctx_id, long nr, struct iocb **iocbpp)
__NR_exit_group 252 sys_exit_group (int error_code)
__NR_set_tid_address 258 sys_set_tid_address (int *tid_addr)
__NR_timer_create 259 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_timer_settime 260 sys_timer_settime (kernel_timer_t timer_id, int flags, struct itimerspec *new, struct itimerspec *old)
__NR_timer_gettime 261 sys_timer_gettime (int timer_id, struct itimerspec *setting)
__NR_timer_getoverrun 262 sys_timer_getoverrun (int timer_id)
__NR_timer_delete 263 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 265 sys_clock_gettime (int which_clock, struct timespec *tp)
__NR_waitid 284 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_openat 295 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_readlinkat 305 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_set_robust_list 311 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 312 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_vmsplice 316 sys_vmsplice (int fd, const struct iovec *iov, unsigned int nr_segs, unsigned int flags)
__NR_signalfd 321 sys_signalfd (int ufd, const k_rtsigset_t *sigmask, size_t sigsetsize)
__NR_fallocate 324 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_timerfd_settime 325 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_preadv 333 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_rt_tgsigqueueinfo 335 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo)
__NR_fanotify_init 338 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 339 sys_fanotify_mark (int fanotify_fd, unsigned int flag, uint32_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 342 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 346 sys_setns (int fd, int nstype)
__NR_kcmp 349 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_seccomp 354 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_memfd_create 356 sys_memfd_create (const char *name, unsigned int flags)
__NR_userfaultfd 374 sys_userfaultfd (int flags)
__NR_ppoll 309 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_openat2 437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
__NR_rseq 386 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_membarrier 375 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl 0000664 0000000 0000000 00000023011 14715043267 0025012 0 ustar 00root root 0000000 0000000 #
# System calls table, please make sure the table consist only the syscalls
# really used somewhere in project.
#
# __NR_name code name arguments
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
__NR_read 0 sys_read (int fd, void *buf, unsigned long count)
__NR_write 1 sys_write (int fd, const void *buf, unsigned long count)
__NR_open 2 sys_open (const char *filename, unsigned long flags, unsigned long mode)
__NR_close 3 sys_close (int fd)
__NR_lseek 8 sys_lseek (int fd, unsigned long offset, unsigned long origin)
__NR_mmap 9 sys_mmap (void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
__NR_mprotect 10 sys_mprotect (const void *addr, unsigned long len, unsigned long prot)
__NR_munmap 11 sys_munmap (void *addr, unsigned long len)
__NR_brk 12 sys_brk (void *addr)
__NR_rt_sigaction 13 sys_sigaction (int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
__NR_rt_sigprocmask 14 sys_sigprocmask (int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
__NR_rt_sigreturn 15 sys_rt_sigreturn (void)
__NR_ioctl 16 sys_ioctl (unsigned int fd, unsigned int cmd, unsigned long arg)
__NR_pread64 17 sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos)
__NR_mremap 25 sys_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
__NR_mincore 27 sys_mincore (void *addr, unsigned long size, unsigned char *vec)
__NR_madvise 28 sys_madvise (unsigned long start, size_t len, int behavior)
__NR_shmat 30 sys_shmat (int shmid, void *shmaddr, int shmflag)
__NR_dup2 33 sys_dup2 (int oldfd, int newfd)
__NR_nanosleep 35 sys_nanosleep (struct timespec *req, struct timespec *rem)
__NR_getitimer 36 sys_getitimer (int which, const struct itimerval *val)
__NR_setitimer 38 sys_setitimer (int which, const struct itimerval *val, struct itimerval *old)
__NR_getpid 39 sys_getpid (void)
__NR_socket 41 sys_socket (int domain, int type, int protocol)
__NR_connect 42 sys_connect (int sockfd, struct sockaddr *addr, int addrlen)
__NR_sendto 44 sys_sendto (int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
__NR_recvfrom 45 sys_recvfrom (int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
__NR_sendmsg 46 sys_sendmsg (int sockfd, const struct msghdr *msg, int flags)
__NR_recvmsg 47 sys_recvmsg (int sockfd, struct msghdr *msg, int flags)
__NR_shutdown 48 sys_shutdown (int sockfd, int how)
__NR_bind 49 sys_bind (int sockfd, const struct sockaddr *addr, int addrlen)
__NR_setsockopt 54 sys_setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
__NR_getsockopt 55 sys_getsockopt (int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
__NR_clone 56 sys_clone (unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, unsigned long new_tls)
__NR_exit 60 sys_exit (unsigned long error_code)
__NR_wait4 61 sys_wait4 (int pid, int *status, int options, struct rusage *ru)
__NR_kill 62 sys_kill (long pid, int sig)
__NR_fcntl 72 sys_fcntl (int fd, int type, long arg)
__NR_flock 73 sys_flock (int fd, unsigned long cmd)
__NR_mkdir 83 sys_mkdir (const char *name, int mode)
__NR_rmdir 84 sys_rmdir (const char *name)
__NR_unlink 87 sys_unlink (char *pathname)
__NR_umask 95 sys_umask (int mask)
__NR_gettimeofday 96 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
__NR_ptrace 101 sys_ptrace (long request, pid_t pid, void *addr, void *data)
__NR_getgroups 115 sys_getgroups (int gsize, unsigned int *groups)
__NR_setgroups 116 sys_setgroups (int gsize, unsigned int *groups)
__NR_setresuid 117 sys_setresuid (int uid, int euid, int suid)
__NR_getresuid 118 sys_getresuid (int *uid, int *euid, int *suid)
__NR_setresgid 119 sys_setresgid (int gid, int egid, int sgid)
__NR_getresgid 120 sys_getresgid (int *gid, int *egid, int *sgid)
__NR_getpgid 121 sys_getpgid (pid_t pid)
__NR_setfsuid 122 sys_setfsuid (int fsuid)
__NR_setfsgid 123 sys_setfsgid (int fsgid)
__NR_getsid 124 sys_getsid (void)
__NR_capget 125 sys_capget (struct cap_header *h, struct cap_data *d)
__NR_capset 126 sys_capset (struct cap_header *h, struct cap_data *d)
__NR_rt_sigqueueinfo 129 sys_rt_sigqueueinfo (pid_t pid, int sig, siginfo_t *info)
__NR_sigaltstack 131 sys_sigaltstack (const void *uss, void *uoss)
__NR_personality 135 sys_personality (unsigned int personality)
__NR_setpriority 141 sys_setpriority (int which, int who, int nice)
__NR_sched_setscheduler 144 sys_sched_setscheduler (int pid, int policy, struct sched_param *p)
__NR_prctl 157 sys_prctl (int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
__NR_arch_prctl 158 sys_arch_prctl (int option, unsigned long addr)
__NR_setrlimit 160 sys_setrlimit (int resource, struct krlimit *rlim)
__NR_mount 165 sys_mount (char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
__NR_umount2 166 sys_umount2 (char *name, int flags)
__NR_gettid 186 sys_gettid (void)
__NR_futex 202 sys_futex (uint32_t *uaddr, int op, uint32_t val, struct timespec *utime, uint32_t *uaddr2, uint32_t val3)
__NR_set_thread_area 205 sys_set_thread_area (user_desc_t *info)
__NR_io_setup 206 sys_io_setup (unsigned nr_events, aio_context_t *ctx)
__NR_io_getevents 208 sys_io_getevents (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
__NR_io_submit 209 sys_io_submit (aio_context_t ctx, long nr, struct iocb **iocbpp)
__NR_get_thread_area 211 sys_get_thread_area (user_desc_t *info)
__NR_set_tid_address 218 sys_set_tid_address (int *tid_addr)
__NR_restart_syscall 219 sys_restart_syscall (void)
__NR_sys_timer_create 222 sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
__NR_sys_timer_settime 223 sys_timer_settime (kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
__NR_sys_timer_gettime 224 sys_timer_gettime (int timer_id, const struct itimerspec *setting)
__NR_sys_timer_getoverrun 225 sys_timer_getoverrun (int timer_id)
__NR_sys_timer_delete 226 sys_timer_delete (kernel_timer_t timer_id)
__NR_clock_gettime 228 sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp)
__NR_exit_group 231 sys_exit_group (int error_code)
__NR_openat 257 sys_openat (int dfd, const char *filename, int flags, int mode)
__NR_waitid 247 sys_waitid (int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
__NR_readlinkat 267 sys_readlinkat (int fd, const char *path, char *buf, int bufsize)
__NR_set_robust_list 273 sys_set_robust_list (struct robust_list_head *head, size_t len)
__NR_get_robust_list 274 sys_get_robust_list (int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
__NR_seccomp 317 sys_seccomp (unsigned int op, unsigned int flags, const char *uargs)
__NR_vmsplice 278 sys_vmsplice (int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
__NR_fallocate 285 sys_fallocate (int fd, int mode, loff_t offset, loff_t len)
__NR_timerfd_settime 286 sys_timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
__NR_signalfd4 289 sys_signalfd (int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
__NR_preadv 295 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
__NR_rt_tgsigqueueinfo 297 sys_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
__NR_fanotify_init 300 sys_fanotify_init (unsigned int flags, unsigned int event_f_flags)
__NR_fanotify_mark 301 sys_fanotify_mark (int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
__NR_open_by_handle_at 304 sys_open_by_handle_at (int mountdirfd, struct file_handle *handle, int flags)
__NR_setns 308 sys_setns (int fd, int nstype)
__NR_kcmp 312 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
__NR_memfd_create 319 sys_memfd_create (const char *name, unsigned int flags)
__NR_userfaultfd 323 sys_userfaultfd (int flags)
__NR_ppoll 271 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
__NR_openat2 437 sys_openat2 (int dirfd, char *pathname, struct open_how *how, size_t size)
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
__NR_rseq 334 sys_rseq (void *rseq, uint32_t rseq_len, int flags, uint32_t sig)
__NR_membarrier 324 sys_membarrier (int cmd, unsigned int flags, int cpu_id)
crac-criu-1.5.0/compel/arch/x86/scripts/ 0000775 0000000 0000000 00000000000 14715043267 0017706 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/scripts/compel-pack-compat.lds.S 0000664 0000000 0000000 00000000726 14715043267 0024274 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(i386)
TARGET(elf32-i386)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.text : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
*(.compel.exit)
*(.compel.init)
}
.data : {
*(.data*)
*(.bss*)
}
.rodata : {
*(.rodata*)
*(.got*)
}
.toc : ALIGN(8) {
*(.toc*)
}
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
}
}
crac-criu-1.5.0/compel/arch/x86/scripts/compel-pack.lds.S 0000664 0000000 0000000 00000000755 14715043267 0023015 0 ustar 00root root 0000000 0000000 OUTPUT_ARCH(i386:x86-64)
TARGET(elf64-x86-64)
EXTERN(__export_parasite_head_start)
SECTIONS
{
.text : {
*(.head.text)
ASSERT(DEFINED(__export_parasite_head_start),
"Symbol __export_parasite_head_start is missing");
*(.text*)
*(.compel.exit)
*(.compel.init)
}
.data : ALIGN(0x1000) {
*(.data*)
*(.bss*)
}
.rodata : {
*(.rodata*)
*(.got*)
}
.toc : ALIGN(8) {
*(.toc*)
}
/DISCARD/ : {
*(.debug*)
*(.comment*)
*(.note*)
*(.group*)
*(.eh_frame*)
}
}
crac-criu-1.5.0/compel/arch/x86/src/ 0000775 0000000 0000000 00000000000 14715043267 0017006 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/ 0000775 0000000 0000000 00000000000 14715043267 0017554 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/cpu.c 0000664 0000000 0000000 00000032226 14715043267 0020514 0 ustar 00root root 0000000 0000000 #include
#include
#include "compel-cpu.h"
#include "common/bitops.h"
#include "common/compiler.h"
#include "log.h"
#include "common/bug.h"
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static void fetch_rt_cpuinfo(void)
{
static bool rt_info_done = false;
if (!rt_info_done) {
compel_cpuid(&rt_info);
rt_info_done = true;
}
}
/*
* Although we spell it out in here, the Processor Trace
* xfeature is completely unused. We use other mechanisms
* to save/restore PT state in Linux.
*/
static const char *const xfeature_names[] = {
"x87 floating point registers",
"SSE registers",
"AVX registers",
"MPX bounds registers",
"MPX CSR",
"AVX-512 opmask",
"AVX-512 Hi256",
"AVX-512 ZMM_Hi256",
"Processor Trace",
"Protection Keys User registers",
"Hardware Duty Cycling",
};
static short xsave_cpuid_features[] = {
X86_FEATURE_FPU, X86_FEATURE_XMM, X86_FEATURE_AVX, X86_FEATURE_MPX,
X86_FEATURE_MPX, X86_FEATURE_AVX512F, X86_FEATURE_AVX512F, X86_FEATURE_AVX512F,
X86_FEATURE_INTEL_PT, X86_FEATURE_PKU, X86_FEATURE_HDC,
};
void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
if (likely(feature < NCAPINTS_BITS))
set_bit(feature, (unsigned long *)c->x86_capability);
}
void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
if (likely(feature < NCAPINTS_BITS))
clear_bit(feature, (unsigned long *)c->x86_capability);
}
int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
if (likely(feature < NCAPINTS_BITS))
return test_bit(feature, (unsigned long *)c->x86_capability);
return 0;
}
int compel_test_fpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
if (likely(feature < XFEATURE_MAX))
return (c->xfeatures_mask & (1UL << feature));
return 0;
}
static int compel_fpuid(compel_cpuinfo_t *c)
{
unsigned int last_good_offset;
uint32_t eax, ebx, ecx, edx;
size_t i;
BUILD_BUG_ON(ARRAY_SIZE(xsave_cpuid_features) != ARRAY_SIZE(xfeature_names));
if (!compel_test_cpu_cap(c, X86_FEATURE_FPU)) {
pr_err("fpu: No FPU detected\n");
return -1;
}
if (!compel_test_cpu_cap(c, X86_FEATURE_XSAVE)) {
pr_info("fpu: x87 FPU will use %s\n", compel_test_cpu_cap(c, X86_FEATURE_FXSR) ? "FXSAVE" : "FSAVE");
return 0;
}
cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx);
c->xfeatures_mask = eax + ((uint64_t)edx << 32);
if ((c->xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
/*
* This indicates that something really unexpected happened
* with the enumeration.
*/
pr_err("fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx\n",
(unsigned long long)c->xfeatures_mask);
return -1;
}
/*
* Clear XSAVE features that are disabled in the normal CPUID.
*/
for (i = 0; i < ARRAY_SIZE(xsave_cpuid_features); i++) {
if (!compel_test_cpu_cap(c, xsave_cpuid_features[i]))
c->xfeatures_mask &= ~(1 << i);
}
c->xfeatures_mask &= XFEATURE_MASK_USER;
c->xfeatures_mask &= ~XFEATURE_MASK_SUPERVISOR;
/*
* xsaves is not enabled in userspace, so
* xsaves is mostly for debug purpose.
*/
cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx);
c->xsave_size = ebx;
c->xsave_size_max = ecx;
cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx);
c->xsaves_size = ebx;
pr_debug("fpu: xfeatures_mask 0x%llx xsave_size %u xsave_size_max %u xsaves_size %u\n",
(unsigned long long)c->xfeatures_mask, c->xsave_size, c->xsave_size_max, c->xsaves_size);
if (c->xsave_size_max > sizeof(struct xsave_struct))
pr_warn_once("fpu: max xsave frame exceed xsave_struct (%u %u)\n", c->xsave_size_max,
(unsigned)sizeof(struct xsave_struct));
memset(c->xstate_offsets, 0xff, sizeof(c->xstate_offsets));
memset(c->xstate_sizes, 0xff, sizeof(c->xstate_sizes));
memset(c->xstate_comp_offsets, 0xff, sizeof(c->xstate_comp_offsets));
memset(c->xstate_comp_sizes, 0xff, sizeof(c->xstate_comp_sizes));
/* start at the beginning of the "extended state" */
last_good_offset = offsetof(struct xsave_struct, extended_state_area);
/*
* The FP xstates and SSE xstates are legacy states. They are always
* in the fixed offsets in the xsave area in either compacted form
* or standard form.
*/
c->xstate_offsets[0] = 0;
c->xstate_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
c->xstate_offsets[1] = c->xstate_sizes[0];
c->xstate_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
if (!(c->xfeatures_mask & (1UL << i)))
continue;
/*
* If an xfeature is supervisor state, the offset
* in EBX is invalid. We leave it to -1.
*
* SDM says: If state component 'i' is a user state component,
* ECX[0] return 0; if state component i is a supervisor
* state component, ECX[0] returns 1.
*/
cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx);
if (!(ecx & 1))
c->xstate_offsets[i] = ebx;
c->xstate_sizes[i] = eax;
/*
* In our xstate size checks, we assume that the
* highest-numbered xstate feature has the
* highest offset in the buffer. Ensure it does.
*/
if (last_good_offset > c->xstate_offsets[i])
pr_warn_once("fpu: misordered xstate %d %d\n", last_good_offset, c->xstate_offsets[i]);
last_good_offset = c->xstate_offsets[i];
}
BUILD_BUG_ON(sizeof(c->xstate_offsets) != sizeof(c->xstate_sizes));
BUILD_BUG_ON(sizeof(c->xstate_comp_offsets) != sizeof(c->xstate_comp_sizes));
c->xstate_comp_offsets[0] = 0;
c->xstate_comp_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
c->xstate_comp_offsets[1] = c->xstate_comp_sizes[0];
c->xstate_comp_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
if (!compel_test_cpu_cap(c, X86_FEATURE_XSAVES)) {
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
if ((c->xfeatures_mask & (1UL << i))) {
c->xstate_comp_offsets[i] = c->xstate_offsets[i];
c->xstate_comp_sizes[i] = c->xstate_sizes[i];
}
}
} else {
c->xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] = FXSAVE_SIZE + XSAVE_HDR_SIZE;
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
if ((c->xfeatures_mask & (1UL << i)))
c->xstate_comp_sizes[i] = c->xstate_sizes[i];
else
c->xstate_comp_sizes[i] = 0;
if (i > FIRST_EXTENDED_XFEATURE) {
c->xstate_comp_offsets[i] = c->xstate_comp_offsets[i - 1] + c->xstate_comp_sizes[i - 1];
/*
* The value returned by ECX[1] indicates the alignment
* of state component 'i' when the compacted format
* of the extended region of an XSAVE area is used:
*/
cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx);
if (ecx & 2)
c->xstate_comp_offsets[i] = ALIGN(c->xstate_comp_offsets[i], 64);
}
}
}
if (!pr_quelled(COMPEL_LOG_DEBUG)) {
for (i = 0; i < ARRAY_SIZE(c->xstate_offsets); i++) {
if (!(c->xfeatures_mask & (1UL << i)))
continue;
pr_debug("fpu: %-32s xstate_offsets %6d / %-6d xstate_sizes %6d / %-6d\n", xfeature_names[i],
c->xstate_offsets[i], c->xstate_comp_offsets[i], c->xstate_sizes[i],
c->xstate_comp_sizes[i]);
}
}
return 0;
}
int compel_cpuid(compel_cpuinfo_t *c)
{
uint32_t eax, ebx, ecx, edx;
/*
* See cpu_detect() in the kernel, also
* read cpuid specs not only from general
* SDM but for extended instructions set
* reference.
*/
/* Get vendor name */
cpuid(0x00000000, (unsigned int *)&c->cpuid_level, (unsigned int *)&c->x86_vendor_id[0],
(unsigned int *)&c->x86_vendor_id[8], (unsigned int *)&c->x86_vendor_id[4]);
if (!strcmp(c->x86_vendor_id, "GenuineIntel")) {
c->x86_vendor = X86_VENDOR_INTEL;
} else if (!strcmp(c->x86_vendor_id, "AuthenticAMD") || !strcmp(c->x86_vendor_id, "HygonGenuine")) {
c->x86_vendor = X86_VENDOR_AMD;
} else {
pr_err("Unsupported CPU vendor %s\n", c->x86_vendor_id);
return -1;
}
c->x86_family = 4;
/* Intel-defined flags: level 0x00000001 */
if (c->cpuid_level >= 0x00000001) {
cpuid(0x00000001, &eax, &ebx, &ecx, &edx);
c->x86_family = (eax >> 8) & 0xf;
c->x86_model = (eax >> 4) & 0xf;
c->x86_mask = eax & 0xf;
if (c->x86_family == 0xf)
c->x86_family += (eax >> 20) & 0xff;
if (c->x86_family >= 0x6)
c->x86_model += ((eax >> 16) & 0xf) << 4;
c->x86_capability[CPUID_1_EDX] = edx;
c->x86_capability[CPUID_1_ECX] = ecx;
}
/* Thermal and Power Management Leaf: level 0x00000006 (eax) */
if (c->cpuid_level >= 0x00000006)
c->x86_capability[CPUID_6_EAX] = cpuid_eax(0x00000006);
/* Additional Intel-defined flags: level 0x00000007 */
if (c->cpuid_level >= 0x00000007) {
cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_7_0_EBX] = ebx;
c->x86_capability[CPUID_7_0_ECX] = ecx;
c->x86_capability[CPUID_7_0_EDX] = edx;
}
/* Extended state features: level 0x0000000d */
if (c->cpuid_level >= 0x0000000d) {
cpuid_count(0x0000000d, 1, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_D_1_EAX] = eax;
}
/* Additional Intel-defined flags: level 0x0000000F */
if (c->cpuid_level >= 0x0000000F) {
/* QoS sub-leaf, EAX=0Fh, ECX=0 */
cpuid_count(0x0000000F, 0, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_F_0_EDX] = edx;
if (compel_test_cpu_cap(c, X86_FEATURE_CQM_LLC)) {
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
cpuid_count(0x0000000F, 1, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_F_1_EDX] = edx;
}
}
/* AMD-defined flags: level 0x80000001 */
eax = cpuid_eax(0x80000000);
c->extended_cpuid_level = eax;
if ((eax & 0xffff0000) == 0x80000000) {
if (eax >= 0x80000001) {
cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_8000_0001_ECX] = ecx;
c->x86_capability[CPUID_8000_0001_EDX] = edx;
}
}
/*
* We're don't care about scattered features for now,
* otherwise look into init_scattered_cpuid_features()
* in kernel.
*
* Same applies to speculation control. Look into
* init_speculation_control() otherwise.
*/
if (c->extended_cpuid_level >= 0x80000004) {
unsigned int *v;
char *p, *q;
v = (unsigned int *)c->x86_model_id;
cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
c->x86_model_id[48] = 0;
/*
* Intel chips right-justify this string for some dumb reason;
* undo that brain damage:
*/
p = q = &c->x86_model_id[0];
while (*p == ' ')
p++;
if (p != q) {
while (*p)
*q++ = *p++;
while (q <= &c->x86_model_id[48])
*q++ = '\0'; /* Zero-pad the rest */
}
}
if (c->extended_cpuid_level >= 0x80000007) {
cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
c->x86_capability[CPUID_8000_0007_EBX] = ebx;
c->x86_power = edx;
}
if (c->extended_cpuid_level >= 0x8000000a)
c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
if (c->extended_cpuid_level >= 0x80000008)
c->x86_capability[CPUID_8000_0008_EBX] = cpuid_ebx(0x80000008);
/* On x86-64 CPUID is always present */
compel_set_cpu_cap(c, X86_FEATURE_CPUID);
/* On x86-64 NOP is always present */
compel_set_cpu_cap(c, X86_FEATURE_NOPL);
/*
* On x86-64 syscalls32 are enabled but we don't
* set it yet for backward compatibility reason
*/
//compel_set_cpu_cap(c, X86_FEATURE_SYSCALL32);
/* See filter_cpuid_features in kernel */
if ((int32_t)c->cpuid_level < (int32_t)0x0000000d)
compel_clear_cpu_cap(c, X86_FEATURE_XSAVE);
/*
* We only care about small subset from c_early_init:
* early_init_amd and early_init_intel
*/
switch (c->x86_vendor) {
case X86_VENDOR_INTEL:
/*
* Strictly speaking we need to read MSR_IA32_MISC_ENABLE
* here but on ring3 it's impossible.
*/
if (c->x86_family == 15) {
compel_clear_cpu_cap(c, X86_FEATURE_REP_GOOD);
compel_clear_cpu_cap(c, X86_FEATURE_ERMS);
} else if (c->x86_family == 6) {
/* On x86-64 rep is fine */
compel_set_cpu_cap(c, X86_FEATURE_REP_GOOD);
}
break;
case X86_VENDOR_AMD:
/*
* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
* 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway
*/
compel_clear_cpu_cap(c, 0 * 32 + 31);
if (c->x86_family >= 0x10)
compel_set_cpu_cap(c, X86_FEATURE_REP_GOOD);
if (c->x86_family == 0xf) {
uint32_t level;
/* On C+ stepping K8 rep microcode works well for copy/memset */
level = cpuid_eax(1);
if ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
compel_set_cpu_cap(c, X86_FEATURE_REP_GOOD);
}
break;
}
pr_debug("x86_family %u x86_vendor_id %s x86_model_id %s\n", c->x86_family, c->x86_vendor_id, c->x86_model_id);
return compel_fpuid(c);
}
bool compel_cpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_cpu_cap(&rt_info, feature);
}
bool compel_fpu_has_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_test_fpu_cap(&rt_info, feature);
}
uint32_t compel_fpu_feature_size(unsigned int feature)
{
fetch_rt_cpuinfo();
if (feature >= FIRST_EXTENDED_XFEATURE && feature < XFEATURE_MAX)
return rt_info.xstate_sizes[feature];
return 0;
}
uint32_t compel_fpu_feature_offset(unsigned int feature)
{
fetch_rt_cpuinfo();
if (feature >= FIRST_EXTENDED_XFEATURE && feature < XFEATURE_MAX)
return rt_info.xstate_offsets[feature];
return 0;
}
void compel_cpu_clear_feature(unsigned int feature)
{
fetch_rt_cpuinfo();
return compel_clear_cpu_cap(&rt_info, feature);
}
void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
{
fetch_rt_cpuinfo();
memcpy(c, &rt_info, sizeof(rt_info));
}
crac-criu-1.5.0/compel/arch/x86/src/lib/handle-elf-host.c 0000777 0000000 0000000 00000000000 14715043267 0025030 2handle-elf.c ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/handle-elf.c 0000664 0000000 0000000 00000000776 14715043267 0021731 0 ustar 00root root 0000000 0000000 #include
#include
#include "handle-elf.h"
#include "piegen.h"
#include "log.h"
static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int handle_binary(void *mem, size_t size)
{
if (memcmp(mem, elf_ident_64_le, sizeof(elf_ident_64_le)) == 0)
return handle_elf_x86_64(mem, size);
pr_err("Unsupported Elf format detected\n");
return -EINVAL;
}
crac-criu-1.5.0/compel/arch/x86/src/lib/include/ 0000775 0000000 0000000 00000000000 14715043267 0021177 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/include/cpu.h 0000664 0000000 0000000 00000002426 14715043267 0022143 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_ASM_CPU_H__
#define __COMPEL_ASM_CPU_H__
static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
{
/* ecx is often an input as well as an output. */
asm volatile("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(*eax), "2"(*ecx) : "memory");
}
static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
{
*eax = op;
*ecx = 0;
native_cpuid(eax, ebx, ecx, edx);
}
static inline void cpuid_count(unsigned int op, int count, unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
unsigned int *edx)
{
*eax = op;
*ecx = count;
native_cpuid(eax, ebx, ecx, edx);
}
static inline unsigned int cpuid_eax(unsigned int op)
{
unsigned int eax, ebx, ecx, edx;
cpuid(op, &eax, &ebx, &ecx, &edx);
return eax;
}
static inline unsigned int cpuid_ebx(unsigned int op)
{
unsigned int eax, ebx, ecx, edx;
cpuid(op, &eax, &ebx, &ecx, &edx);
return ebx;
}
static inline unsigned int cpuid_ecx(unsigned int op)
{
unsigned int eax, ebx, ecx, edx;
cpuid(op, &eax, &ebx, &ecx, &edx);
return ecx;
}
static inline unsigned int cpuid_edx(unsigned int op)
{
unsigned int eax, ebx, ecx, edx;
cpuid(op, &eax, &ebx, &ecx, &edx);
return edx;
}
#endif
crac-criu-1.5.0/compel/arch/x86/src/lib/include/handle-elf.h 0000664 0000000 0000000 00000000772 14715043267 0023355 0 ustar 00root root 0000000 0000000 #ifndef COMPEL_HANDLE_ELF_H__
#define COMPEL_HANDLE_ELF_H__
#include "elf64-types.h"
#define ELF_X86_64
#ifndef R_X86_64_GOTPCRELX
#define R_X86_64_GOTPCRELX 41
#endif
#ifndef R_X86_64_REX_GOTPCRELX
#define R_X86_64_REX_GOTPCRELX 42
#endif
#define __handle_elf handle_elf_x86_64
#define arch_is_machine_supported(e_machine) (e_machine == EM_X86_64)
extern int handle_elf_x86_32(void *mem, size_t size);
extern int handle_elf_x86_64(void *mem, size_t size);
#endif /* COMPEL_HANDLE_ELF_H__ */
crac-criu-1.5.0/compel/arch/x86/src/lib/include/syscall.h 0000664 0000000 0000000 00000000651 14715043267 0023024 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_SYSCALL_H__
#define __COMPEL_SYSCALL_H__
#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall)
/*
* For x86_32 __NR_mmap inside the kernel represents old_mmap system
* call, but since we didn't use it yet lets go further and simply
* define own alias for __NR_mmap2 which would allow us to unify code
* between 32 and 64 bits version.
*/
#define __NR32_mmap __NR32_mmap2
#endif
crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/ 0000775 0000000 0000000 00000000000 14715043267 0022135 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/asm/ 0000775 0000000 0000000 00000000000 14715043267 0022715 5 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/asm/.gitignore 0000664 0000000 0000000 00000000000 14715043267 0024673 0 ustar 00root root 0000000 0000000 crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/asm/breakpoints.h 0000664 0000000 0000000 00000000321 14715043267 0025403 0 ustar 00root root 0000000 0000000 #ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP SI_KERNEL
extern int ptrace_set_breakpoint(pid_t pid, void *addr);
extern int ptrace_flush_breakpoints(pid_t pid);
#endif
crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/asm/cpu.h 0000664 0000000 0000000 00000051201 14715043267 0023654 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_CPU_H__
#define __CR_ASM_CPU_H__
#include
#include
/*
* Adopted from linux kernel and enhanced from Intel/AMD manuals.
* Note these bits are not ABI for linux kernel but they _are_
* for us, so make sure they are at proper position between
* versions.
*
* In particular since we already used leaf 11 we have
* to keep it here, since it's an ABI now.
*/
enum cpuid_leafs {
CPUID_1_EDX = 0,
CPUID_8000_0001_EDX = 1,
CPUID_8086_0001_EDX = 2,
CPUID_LNX_1 = 3,
CPUID_1_ECX = 4,
CPUID_C000_0001_EDX = 5,
CPUID_8000_0001_ECX = 6,
CPUID_LNX_2 = 7,
CPUID_LNX_3 = 8,
CPUID_7_0_EBX = 9,
CPUID_D_1_EAX = 10,
CPUID_7_0_ECX = 11,
CPUID_F_1_EDX = 12,
CPUID_8000_0008_EBX = 13,
CPUID_6_EAX = 14,
CPUID_8000_000A_EDX = 15,
CPUID_F_0_EDX = 16,
CPUID_8000_0007_EBX = 17,
CPUID_7_0_EDX = 18,
};
#define NCAPINTS_V1 12
#define NCAPINTS_V2 19
#define NCAPINTS (NCAPINTS_V2) /* N 32-bit words worth of info */
#define NCAPINTS_BITS (NCAPINTS * 32)
/* Intel-defined CPU features, CPUID level 0x00000001 (EDX), word 0 */
#define X86_FEATURE_FPU (0 * 32 + 0) /* Onboard FPU */
#define X86_FEATURE_VME (0 * 32 + 1) /* Virtual Mode Extensions */
#define X86_FEATURE_DE (0 * 32 + 2) /* Debugging Extensions */
#define X86_FEATURE_PSE (0 * 32 + 3) /* Page Size Extensions */
#define X86_FEATURE_TSC (0 * 32 + 4) /* Time Stamp Counter */
#define X86_FEATURE_MSR (0 * 32 + 5) /* Model-Specific Registers */
#define X86_FEATURE_PAE (0 * 32 + 6) /* Physical Address Extensions */
#define X86_FEATURE_MCE (0 * 32 + 7) /* Machine Check Exception */
#define X86_FEATURE_CX8 (0 * 32 + 8) /* CMPXCHG8 instruction */
#define X86_FEATURE_APIC (0 * 32 + 9) /* Onboard APIC */
#define X86_FEATURE_SEP (0 * 32 + 11) /* SYSENTER/SYSEXIT */
#define X86_FEATURE_MTRR (0 * 32 + 12) /* Memory Type Range Registers */
#define X86_FEATURE_PGE (0 * 32 + 13) /* Page Global Enable */
#define X86_FEATURE_MCA (0 * 32 + 14) /* Machine Check Architecture */
#define X86_FEATURE_CMOV (0 * 32 + 15) /* CMOV instructions (plus FCMOVcc, FCOMI with FPU) */
#define X86_FEATURE_PAT (0 * 32 + 16) /* Page Attribute Table */
#define X86_FEATURE_PSE36 (0 * 32 + 17) /* 36-bit PSEs */
#define X86_FEATURE_PN (0 * 32 + 18) /* Processor serial number */
#define X86_FEATURE_CLFLUSH (0 * 32 + 19) /* CLFLUSH instruction */
#define X86_FEATURE_DS (0 * 32 + 21) /* "dts" Debug Store */
#define X86_FEATURE_ACPI (0 * 32 + 22) /* ACPI via MSR */
#define X86_FEATURE_MMX (0 * 32 + 23) /* Multimedia Extensions */
#define X86_FEATURE_FXSR (0 * 32 + 24) /* FXSAVE/FXRSTOR, CR4.OSFXSR */
#define X86_FEATURE_XMM (0 * 32 + 25) /* "sse" */
#define X86_FEATURE_XMM2 (0 * 32 + 26) /* "sse2" */
#define X86_FEATURE_SELFSNOOP (0 * 32 + 27) /* "ss" CPU self snoop */
#define X86_FEATURE_HT (0 * 32 + 28) /* Hyper-Threading */
#define X86_FEATURE_ACC (0 * 32 + 29) /* "tm" Automatic clock control */
#define X86_FEATURE_IA64 (0 * 32 + 30) /* IA-64 processor */
#define X86_FEATURE_PBE (0 * 32 + 31) /* Pending Break Enable */
/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
/* Don't duplicate feature flags which are redundant with Intel! */
#define X86_FEATURE_SYSCALL (1 * 32 + 11) /* SYSCALL/SYSRET */
#define X86_FEATURE_MP (1 * 32 + 19) /* MP Capable */
#define X86_FEATURE_NX (1 * 32 + 20) /* Execute Disable */
#define X86_FEATURE_MMXEXT (1 * 32 + 22) /* AMD MMX extensions */
#define X86_FEATURE_FXSR_OPT (1 * 32 + 25) /* FXSAVE/FXRSTOR optimizations */
#define X86_FEATURE_GBPAGES (1 * 32 + 26) /* "pdpe1gb" GB pages */
#define X86_FEATURE_RDTSCP (1 * 32 + 27) /* RDTSCP */
#define X86_FEATURE_LM (1 * 32 + 29) /* Long Mode (x86-64, 64-bit support) */
#define X86_FEATURE_3DNOWEXT (1 * 32 + 30) /* AMD 3DNow extensions */
#define X86_FEATURE_3DNOW (1 * 32 + 31) /* 3DNow */
/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
#define X86_FEATURE_RECOVERY (2 * 32 + 0) /* CPU in recovery mode */
#define X86_FEATURE_LONGRUN (2 * 32 + 1) /* Longrun power control */
#define X86_FEATURE_LRTI (2 * 32 + 3) /* LongRun table interface */
/* Other features, Linux-defined mapping, word 3 */
/* This range is used for feature bits which conflict or are synthesized */
#define X86_FEATURE_CXMMX (3 * 32 + 0) /* Cyrix MMX extensions */
#define X86_FEATURE_K6_MTRR (3 * 32 + 1) /* AMD K6 nonstandard MTRRs */
#define X86_FEATURE_CYRIX_ARR (3 * 32 + 2) /* Cyrix ARRs (= MTRRs) */
#define X86_FEATURE_CENTAUR_MCR (3 * 32 + 3) /* Centaur MCRs (= MTRRs) */
/* CPU types for specific tunings: */
#define X86_FEATURE_K8 (3 * 32 + 4) /* "" Opteron, Athlon64 */
#define X86_FEATURE_K7 (3 * 32 + 5) /* "" Athlon */
#define X86_FEATURE_P3 (3 * 32 + 6) /* "" P3 */
#define X86_FEATURE_P4 (3 * 32 + 7) /* "" P4 */
#define X86_FEATURE_CONSTANT_TSC (3 * 32 + 8) /* TSC ticks at a constant rate */
#define X86_FEATURE_UP (3 * 32 + 9) /* SMP kernel running on UP */
#define X86_FEATURE_ART (3 * 32 + 10) /* Always running timer (ART) */
#define X86_FEATURE_ARCH_PERFMON (3 * 32 + 11) /* Intel Architectural PerfMon */
#define X86_FEATURE_PEBS (3 * 32 + 12) /* Precise-Event Based Sampling */
#define X86_FEATURE_BTS (3 * 32 + 13) /* Branch Trace Store */
#define X86_FEATURE_SYSCALL32 (3 * 32 + 14) /* "" syscall in IA32 userspace */
#define X86_FEATURE_SYSENTER32 (3 * 32 + 15) /* "" sysenter in IA32 userspace */
#define X86_FEATURE_REP_GOOD (3 * 32 + 16) /* REP microcode works well */
#define X86_FEATURE_MFENCE_RDTSC (3 * 32 + 17) /* "" MFENCE synchronizes RDTSC */
#define X86_FEATURE_LFENCE_RDTSC (3 * 32 + 18) /* "" LFENCE synchronizes RDTSC */
#define X86_FEATURE_ACC_POWER (3 * 32 + 19) /* AMD Accumulated Power Mechanism */
#define X86_FEATURE_NOPL (3 * 32 + 20) /* The NOPL (0F 1F) instructions */
#define X86_FEATURE_ALWAYS (3 * 32 + 21) /* "" Always-present feature */
#define X86_FEATURE_XTOPOLOGY (3 * 32 + 22) /* CPU topology enum extensions */
#define X86_FEATURE_TSC_RELIABLE (3 * 32 + 23) /* TSC is known to be reliable */
#define X86_FEATURE_NONSTOP_TSC (3 * 32 + 24) /* TSC does not stop in C states */
#define X86_FEATURE_CPUID (3 * 32 + 25) /* CPU has CPUID instruction itself */
#define X86_FEATURE_EXTD_APICID (3 * 32 + 26) /* Extended APICID (8 bits) */
#define X86_FEATURE_AMD_DCM (3 * 32 + 27) /* AMD multi-node processor */
#define X86_FEATURE_APERFMPERF (3 * 32 + 28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */
#define X86_FEATURE_NONSTOP_TSC_S3 (3 * 32 + 30) /* TSC doesn't stop in S3 state */
#define X86_FEATURE_TSC_KNOWN_FREQ (3 * 32 + 31) /* TSC has known frequency */
/* Intel-defined CPU features, CPUID level 0x00000001 (ECX), word 4 */
#define X86_FEATURE_XMM3 (4 * 32 + 0) /* "pni" SSE-3 */
#define X86_FEATURE_PCLMULQDQ (4 * 32 + 1) /* PCLMULQDQ instruction */
#define X86_FEATURE_DTES64 (4 * 32 + 2) /* 64-bit Debug Store */
#define X86_FEATURE_MWAIT (4 * 32 + 3) /* "monitor" MONITOR/MWAIT support */
#define X86_FEATURE_DSCPL (4 * 32 + 4) /* "ds_cpl" CPL-qualified (filtered) Debug Store */
#define X86_FEATURE_VMX (4 * 32 + 5) /* Hardware virtualization */
#define X86_FEATURE_SMX (4 * 32 + 6) /* Safer Mode eXtensions */
#define X86_FEATURE_EST (4 * 32 + 7) /* Enhanced SpeedStep */
#define X86_FEATURE_TM2 (4 * 32 + 8) /* Thermal Monitor 2 */
#define X86_FEATURE_SSSE3 (4 * 32 + 9) /* Supplemental SSE-3 */
#define X86_FEATURE_CID (4 * 32 + 10) /* Context ID */
#define X86_FEATURE_SDBG (4 * 32 + 11) /* Silicon Debug */
#define X86_FEATURE_FMA (4 * 32 + 12) /* Fused multiply-add */
#define X86_FEATURE_CX16 (4 * 32 + 13) /* CMPXCHG16B instruction */
#define X86_FEATURE_XTPR (4 * 32 + 14) /* Send Task Priority Messages */
#define X86_FEATURE_PDCM (4 * 32 + 15) /* Perf/Debug Capabilities MSR */
#define X86_FEATURE_PCID (4 * 32 + 17) /* Process Context Identifiers */
#define X86_FEATURE_DCA (4 * 32 + 18) /* Direct Cache Access */
#define X86_FEATURE_XMM4_1 (4 * 32 + 19) /* "sse4_1" SSE-4.1 */
#define X86_FEATURE_XMM4_2 (4 * 32 + 20) /* "sse4_2" SSE-4.2 */
#define X86_FEATURE_X2APIC (4 * 32 + 21) /* X2APIC */
#define X86_FEATURE_MOVBE (4 * 32 + 22) /* MOVBE instruction */
#define X86_FEATURE_POPCNT (4 * 32 + 23) /* POPCNT instruction */
#define X86_FEATURE_TSC_DEADLINE_TIMER (4 * 32 + 24) /* TSC deadline timer */
#define X86_FEATURE_AES (4 * 32 + 25) /* AES instructions */
#define X86_FEATURE_XSAVE (4 * 32 + 26) /* XSAVE/XRSTOR/XSETBV/XGETBV instructions */
#define X86_FEATURE_OSXSAVE (4 * 32 + 27) /* "" XSAVE instruction enabled in the OS */
#define X86_FEATURE_AVX (4 * 32 + 28) /* Advanced Vector Extensions */
#define X86_FEATURE_F16C (4 * 32 + 29) /* 16-bit FP conversions */
#define X86_FEATURE_RDRAND (4 * 32 + 30) /* RDRAND instruction */
#define X86_FEATURE_HYPERVISOR (4 * 32 + 31) /* Running on a hypervisor */
/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
#define X86_FEATURE_XSTORE (5 * 32 + 2) /* "rng" RNG present (xstore) */
#define X86_FEATURE_XSTORE_EN (5 * 32 + 3) /* "rng_en" RNG enabled */
#define X86_FEATURE_XCRYPT (5 * 32 + 6) /* "ace" on-CPU crypto (xcrypt) */
#define X86_FEATURE_XCRYPT_EN (5 * 32 + 7) /* "ace_en" on-CPU crypto enabled */
#define X86_FEATURE_ACE2 (5 * 32 + 8) /* Advanced Cryptography Engine v2 */
#define X86_FEATURE_ACE2_EN (5 * 32 + 9) /* ACE v2 enabled */
#define X86_FEATURE_PHE (5 * 32 + 10) /* PadLock Hash Engine */
#define X86_FEATURE_PHE_EN (5 * 32 + 11) /* PHE enabled */
#define X86_FEATURE_PMM (5 * 32 + 12) /* PadLock Montgomery Multiplier */
#define X86_FEATURE_PMM_EN (5 * 32 + 13) /* PMM enabled */
/* More extended AMD flags: CPUID level 0x80000001, ECX, word 6 */
#define X86_FEATURE_LAHF_LM (6 * 32 + 0) /* LAHF/SAHF in long mode */
#define X86_FEATURE_CMP_LEGACY (6 * 32 + 1) /* If yes HyperThreading not valid */
#define X86_FEATURE_SVM (6 * 32 + 2) /* Secure Virtual Machine */
#define X86_FEATURE_EXTAPIC (6 * 32 + 3) /* Extended APIC space */
#define X86_FEATURE_CR8_LEGACY (6 * 32 + 4) /* CR8 in 32-bit mode */
#define X86_FEATURE_ABM (6 * 32 + 5) /* Advanced bit manipulation */
#define X86_FEATURE_SSE4A (6 * 32 + 6) /* SSE-4A */
#define X86_FEATURE_MISALIGNSSE (6 * 32 + 7) /* Misaligned SSE mode */
#define X86_FEATURE_3DNOWPREFETCH (6 * 32 + 8) /* 3DNow prefetch instructions */
#define X86_FEATURE_OSVW (6 * 32 + 9) /* OS Visible Workaround */
#define X86_FEATURE_IBS (6 * 32 + 10) /* Instruction Based Sampling */
#define X86_FEATURE_XOP (6 * 32 + 11) /* extended AVX instructions */
#define X86_FEATURE_SKINIT (6 * 32 + 12) /* SKINIT/STGI instructions */
#define X86_FEATURE_WDT (6 * 32 + 13) /* Watchdog timer */
#define X86_FEATURE_LWP (6 * 32 + 15) /* Light Weight Profiling */
#define X86_FEATURE_FMA4 (6 * 32 + 16) /* 4 operands MAC instructions */
#define X86_FEATURE_TCE (6 * 32 + 17) /* Translation Cache Extension */
#define X86_FEATURE_NODEID_MSR (6 * 32 + 19) /* NodeId MSR */
#define X86_FEATURE_TBM (6 * 32 + 21) /* Trailing Bit Manipulations */
#define X86_FEATURE_TOPOEXT (6 * 32 + 22) /* Topology extensions CPUID leafs */
#define X86_FEATURE_PERFCTR_CORE (6 * 32 + 23) /* Core performance counter extensions */
#define X86_FEATURE_PERFCTR_NB (6 * 32 + 24) /* NB performance counter extensions */
#define X86_FEATURE_BPEXT (6 * 32 + 26) /* Data breakpoint extension */
#define X86_FEATURE_PTSC (6 * 32 + 27) /* Performance time-stamp counter */
#define X86_FEATURE_PERFCTR_LLC (6 * 32 + 28) /* Last Level Cache performance counter extensions */
#define X86_FEATURE_MWAITX (6 * 32 + 29) /* MWAIT extension (MONITORX/MWAITX instructions) */
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
#define X86_FEATURE_FSGSBASE (9 * 32 + 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
#define X86_FEATURE_TSC_ADJUST (9 * 32 + 1) /* TSC adjustment MSR 0x3B */
#define X86_FEATURE_BMI1 (9 * 32 + 3) /* 1st group bit manipulation extensions */
#define X86_FEATURE_HLE (9 * 32 + 4) /* Hardware Lock Elision */
#define X86_FEATURE_AVX2 (9 * 32 + 5) /* AVX2 instructions */
#define X86_FEATURE_SMEP (9 * 32 + 7) /* Supervisor Mode Execution Protection */
#define X86_FEATURE_BMI2 (9 * 32 + 8) /* 2nd group bit manipulation extensions */
#define X86_FEATURE_ERMS (9 * 32 + 9) /* Enhanced REP MOVSB/STOSB instructions */
#define X86_FEATURE_INVPCID (9 * 32 + 10) /* Invalidate Processor Context ID */
#define X86_FEATURE_RTM (9 * 32 + 11) /* Restricted Transactional Memory */
#define X86_FEATURE_CQM (9 * 32 + 12) /* Cache QoS Monitoring */
#define X86_FEATURE_MPX (9 * 32 + 14) /* Memory Protection Extension */
#define X86_FEATURE_RDT_A (9 * 32 + 15) /* Resource Director Technology Allocation */
#define X86_FEATURE_AVX512F (9 * 32 + 16) /* AVX-512 Foundation */
#define X86_FEATURE_AVX512DQ (9 * 32 + 17) /* AVX-512 DQ (Double/Quad granular) Instructions */
#define X86_FEATURE_RDSEED (9 * 32 + 18) /* RDSEED instruction */
#define X86_FEATURE_ADX (9 * 32 + 19) /* ADCX and ADOX instructions */
#define X86_FEATURE_SMAP (9 * 32 + 20) /* Supervisor Mode Access Prevention */
#define X86_FEATURE_AVX512IFMA (9 * 32 + 21) /* AVX-512 Integer Fused Multiply-Add instructions */
#define X86_FEATURE_CLFLUSHOPT (9 * 32 + 23) /* CLFLUSHOPT instruction */
#define X86_FEATURE_CLWB (9 * 32 + 24) /* CLWB instruction */
#define X86_FEATURE_INTEL_PT (9 * 32 + 25) /* Intel Processor Trace */
#define X86_FEATURE_AVX512PF (9 * 32 + 26) /* AVX-512 Prefetch */
#define X86_FEATURE_AVX512ER (9 * 32 + 27) /* AVX-512 Exponential and Reciprocal */
#define X86_FEATURE_AVX512CD (9 * 32 + 28) /* AVX-512 Conflict Detection */
#define X86_FEATURE_SHA_NI (9 * 32 + 29) /* SHA1/SHA256 Instruction Extensions */
#define X86_FEATURE_AVX512BW (9 * 32 + 30) /* AVX-512 BW (Byte/Word granular) Instructions */
#define X86_FEATURE_AVX512VL (9 * 32 + 31) /* AVX-512 VL (128/256 Vector Length) Extensions */
/* Extended state features, CPUID level 0x0000000d:1 (EAX), word 10 */
#define X86_FEATURE_XSAVEOPT (10 * 32 + 0) /* XSAVEOPT instruction */
#define X86_FEATURE_XSAVEC (10 * 32 + 1) /* XSAVEC instruction */
#define X86_FEATURE_XGETBV1 (10 * 32 + 2) /* XGETBV with ECX = 1 instruction */
#define X86_FEATURE_XSAVES (10 * 32 + 3) /* XSAVES/XRSTORS instructions */
/* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 11 */
#define X86_FEATURE_PREFETCHWT1 (11 * 32 + 0) /* PREFETCHWT1 Intel® Xeon PhiTM only */
#define X86_FEATURE_AVX512VBMI (11 * 32 + 1) /* AVX512 Vector Bit Manipulation instructions*/
#define X86_FEATURE_UMIP (11 * 32 + 2) /* User Mode Instruction Protection */
#define X86_FEATURE_PKU (11 * 32 + 3) /* Protection Keys for Userspace */
#define X86_FEATURE_OSPKE (11 * 32 + 4) /* OS Protection Keys Enable */
#define X86_FEATURE_AVX512_VBMI2 (11 * 32 + 6) /* Additional AVX512 Vector Bit Manipulation Instructions */
#define X86_FEATURE_GFNI (11 * 32 + 8) /* Galois Field New Instructions */
#define X86_FEATURE_VAES (11 * 32 + 9) /* Vector AES */
#define X86_FEATURE_VPCLMULQDQ (11 * 32 + 10) /* Carry-Less Multiplication Double Quadword */
#define X86_FEATURE_AVX512_VNNI (11 * 32 + 11) /* Vector Neural Network Instructions */
#define X86_FEATURE_AVX512_BITALG (11 * 32 + 12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */
#define X86_FEATURE_TME (11 * 32 + 13) /* Intel Total Memory Encryption */
#define X86_FEATURE_AVX512_VPOPCNTDQ (11 * 32 + 14) /* POPCNT for vectors of DW/QW */
#define X86_FEATURE_LA57 (11 * 32 + 16) /* 5-level page tables */
#define X86_FEATURE_RDPID (11 * 32 + 22) /* RDPID instruction */
#define X86_FEATURE_CLDEMOTE (11 * 32 + 25) /* CLDEMOTE instruction */
/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (EDX), word 12 */
#define X86_FEATURE_CQM_OCCUP_LLC (12 * 32 + 0) /* LLC occupancy monitoring */
#define X86_FEATURE_CQM_MBM_TOTAL (12 * 32 + 1) /* LLC Total MBM monitoring */
#define X86_FEATURE_CQM_MBM_LOCAL (12 * 32 + 2) /* LLC Local MBM monitoring */
/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
#define X86_FEATURE_CLZERO (13 * 32 + 0) /* CLZERO instruction */
#define X86_FEATURE_IRPERF (13 * 32 + 1) /* Instructions Retired Count */
#define X86_FEATURE_XSAVEERPTR (13 * 32 + 2) /* Always save/restore FP error pointers */
#define X86_FEATURE_IBPB (13 * 32 + 12) /* Indirect Branch Prediction Barrier */
#define X86_FEATURE_IBRS (13 * 32 + 14) /* Indirect Branch Restricted Speculation */
#define X86_FEATURE_STIBP (13 * 32 + 15) /* Single Thread Indirect Branch Predictors */
/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
#define X86_FEATURE_DTHERM (14 * 32 + 0) /* Digital Thermal Sensor */
#define X86_FEATURE_IDA (14 * 32 + 1) /* Intel Dynamic Acceleration */
#define X86_FEATURE_ARAT (14 * 32 + 2) /* Always Running APIC Timer */
#define X86_FEATURE_PLN (14 * 32 + 4) /* Intel Power Limit Notification */
#define X86_FEATURE_PTS (14 * 32 + 6) /* Intel Package Thermal Status */
#define X86_FEATURE_HWP (14 * 32 + 7) /* Intel Hardware P-states */
#define X86_FEATURE_HWP_NOTIFY (14 * 32 + 8) /* HWP Notification */
#define X86_FEATURE_HWP_ACT_WINDOW (14 * 32 + 9) /* HWP Activity Window */
#define X86_FEATURE_HWP_EPP (14 * 32 + 10) /* HWP Energy Perf. Preference */
#define X86_FEATURE_HWP_PKG_REQ (14 * 32 + 11) /* HWP Package Level Request */
#define X86_FEATURE_HDC (14 * 32 + 13) /* HDC base registers present */
/* AMD SVM Feature Identification, CPUID level 0x8000000a (EDX), word 15 */
#define X86_FEATURE_NPT (15 * 32 + 0) /* Nested Page Table support */
#define X86_FEATURE_LBRV (15 * 32 + 1) /* LBR Virtualization support */
#define X86_FEATURE_SVML (15 * 32 + 2) /* "svm_lock" SVM locking MSR */
#define X86_FEATURE_NRIPS (15 * 32 + 3) /* "nrip_save" SVM next_rip save */
#define X86_FEATURE_TSCRATEMSR (15 * 32 + 4) /* "tsc_scale" TSC scaling support */
#define X86_FEATURE_VMCBCLEAN (15 * 32 + 5) /* "vmcb_clean" VMCB clean bits support */
#define X86_FEATURE_FLUSHBYASID (15 * 32 + 6) /* flush-by-ASID support */
#define X86_FEATURE_DECODEASSISTS (15 * 32 + 7) /* Decode Assists support */
#define X86_FEATURE_PAUSEFILTER (15 * 32 + 10) /* filtered pause intercept */
#define X86_FEATURE_PFTHRESHOLD (15 * 32 + 12) /* pause filter threshold */
#define X86_FEATURE_AVIC (15 * 32 + 13) /* Virtual Interrupt Controller */
#define X86_FEATURE_V_VMSAVE_VMLOAD (15 * 32 + 15) /* Virtual VMSAVE VMLOAD */
#define X86_FEATURE_VGIF (15 * 32 + 16) /* Virtual GIF */
/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (EDX), word 16 */
#define X86_FEATURE_CQM_LLC (16 * 32 + 1) /* LLC QoS if 1 */
/* AMD-defined CPU features, CPUID level 0x80000007 (EBX), word 17 */
#define X86_FEATURE_OVERFLOW_RECOV (17 * 32 + 0) /* MCA overflow recovery support */
#define X86_FEATURE_SUCCOR (17 * 32 + 1) /* Uncorrectable error containment and recovery */
#define X86_FEATURE_SMCA (17 * 32 + 3) /* Scalable MCA */
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
#define X86_FEATURE_AVX512_4VNNIW (18 * 32 + 2) /* AVX-512 Neural Network Instructions */
#define X86_FEATURE_AVX512_4FMAPS (18 * 32 + 3) /* AVX-512 Multiply Accumulation Single precision */
#define X86_FEATURE_PCONFIG (18 * 32 + 18) /* Intel PCONFIG */
#define X86_FEATURE_SPEC_CTRL (18 * 32 + 26) /* "" Speculation Control (IBRS + IBPB) */
#define X86_FEATURE_INTEL_STIBP (18 * 32 + 27) /* "" Single Thread Indirect Branch Predictors */
#define X86_FEATURE_ARCH_CAPABILITIES (18 * 32 + 29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */
#define X86_FEATURE_SPEC_CTRL_SSBD (18 * 32 + 31) /* "" Speculative Store Bypass Disable */
enum {
X86_VENDOR_INTEL = 0,
X86_VENDOR_AMD = 1,
X86_VENDOR_MAX
};
struct cpuinfo_x86 {
/* cpu context */
uint8_t x86_family;
uint8_t x86_vendor;
uint8_t x86_model;
uint8_t x86_mask;
uint32_t x86_capability[NCAPINTS];
uint32_t x86_power;
uint32_t extended_cpuid_level;
int cpuid_level;
char x86_vendor_id[16];
char x86_model_id[64];
/* fpu context */
uint64_t xfeatures_mask;
uint32_t xsave_size_max;
uint32_t xsave_size;
uint32_t xstate_offsets[XFEATURE_MAX];
uint32_t xstate_sizes[XFEATURE_MAX];
uint32_t xsaves_size;
uint32_t xstate_comp_offsets[XFEATURE_MAX];
uint32_t xstate_comp_sizes[XFEATURE_MAX];
};
typedef struct cpuinfo_x86 compel_cpuinfo_t;
#endif /* __CR_ASM_CPU_H__ */
crac-criu-1.5.0/compel/arch/x86/src/lib/include/uapi/asm/fpu.h 0000664 0000000 0000000 00000021461 14715043267 0023664 0 ustar 00root root 0000000 0000000 #ifndef __CR_ASM_FPU_H__
#define __CR_ASM_FPU_H__
#include
#include
#include