Re: [PATCH 3/3] rust: arch/um: Add support for CONFIG_RUST under x86_64 UML

From: Sergio González Collado
Date: Sun Jan 15 2023 - 04:52:15 EST


On Sat, 17 Dec 2022 at 05:48, David Gow <davidgow@xxxxxxxxxx> wrote:
>
> CONFIG_RUST currently supports x86_64, but does not support it under
> UML. With the previous patches applied, adding support is trivial:
> add CONFIG_HAVE_RUST to UML if X86_64 is set.
>
> The scripts/generate_rust_target.rs file already checks for
> CONFIG_X86_64, not CONFIG_X86, so is prepared for UML support.
>
> The Rust support does not currently support X86_32.
>
> Also, update the Rust architecture support documentation to not that
> this is being maintained: I intend to look after this as best I can.
>
> Signed-off-by: David Gow <davidgow@xxxxxxxxxx>
> ---
> Documentation/rust/arch-support.rst | 2 ++
> arch/um/Kconfig | 1 +
> 2 files changed, 3 insertions(+)
>
> diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst
> index 6982b63775da..a526ca1c688b 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -17,3 +17,5 @@ Architecture Level of support Constraints
> ============ ================ ==============================================
> ``x86`` Maintained ``x86_64`` only.
> ============ ================ ==============================================
> +``um`` Maintained ``x86_64`` only.
> +============ ================ ==============================================
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index ad4ff3b0e91e..4db186f019ae 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -28,6 +28,7 @@ config UML
> select TRACE_IRQFLAGS_SUPPORT
> select TTY # Needed for line.c
> select HAVE_ARCH_VMAP_STACK
> + select HAVE_RUST if X86_64
>
> config MMU
> bool
> --
> 2.39.0.314.g84b9a713c41-goog
>

Tested-by: Sergio González Collado <sergio.collado@xxxxxxxxx>

sergio@laptop:~/repos/rust-for-linux$ git log -4 --oneline
888468208678 (HEAD) rust: arch/um: Add support for CONFIG_RUST under x86_64 UML
055730a58ded rust: arch/um: Disable FP/SIMD instruction to match x86
924ccc99887f rust: arch/um: Use 'pie' relocation mode under UML
615131b8e9bc (tag: rust-v6.1-rc1, origin/for-next/rust) MAINTAINERS: Rust
sergio@laptop:~/repos/rust-for-linux$ ./tools/testing/kunit/kunit.py
run --kconfig_add CONFIG_RUST=y --make_options LLVM=1
[10:43:28] Configuring KUnit Kernel ...
[10:43:28] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig LLVM=1
Building with:
$ make ARCH=um O=.kunit --jobs=12 LLVM=1
/usr/bin/ld: warning: arch/x86/um/vdso/vdso.o: missing .note.GNU-stack
section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in
a future version of the linker
/usr/bin/ld: init/main.o: warning: relocation in read-only section `.ref.text'
/usr/bin/ld: warning: .tmp_vmlinux.kallsyms1 has a LOAD segment with
RWX permissions
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
/usr/bin/ld: warning: .tmp_vmlinux.kallsyms1.o: missing
.note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in
a future version of the linker
/usr/bin/ld: init/main.o: warning: relocation in read-only section `.ref.text'
/usr/bin/ld: warning: .tmp_vmlinux.kallsyms2 has a LOAD segment with
RWX permissions
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
/usr/bin/ld: warning: .tmp_vmlinux.kallsyms2.o: missing
.note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in
a future version of the linker
/usr/bin/ld: init/main.o: warning: relocation in read-only section `.ref.text'
/usr/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

[10:44:20] Starting KUnit Kernel (1/1)...
[10:44:20] ============================================================
[10:44:21] =============== time_test_cases (1 subtest) ================
[10:44:21] [PASSED] time64_to_tm_test_date_range
[10:44:21] ================= [PASSED] time_test_cases =================
[10:44:21] ================== resource (2 subtests) ===================
[10:44:21] [PASSED] resource_test_union
[10:44:21] [PASSED] resource_test_intersection
[10:44:21] ==================== [PASSED] resource =====================
[10:44:21] ================ sysctl_test (10 subtests) =================
[10:44:21] [PASSED] sysctl_test_api_dointvec_null_tbl_data
[10:44:21] [PASSED] sysctl_test_api_dointvec_table_maxlen_unset
[10:44:21] [PASSED] sysctl_test_api_dointvec_table_len_is_zero
[10:44:21] [PASSED] sysctl_test_api_dointvec_table_read_but_position_set
[10:44:21] [PASSED] sysctl_test_dointvec_read_happy_single_positive
[10:44:21] [PASSED] sysctl_test_dointvec_read_happy_single_negative
[10:44:21] [PASSED] sysctl_test_dointvec_write_happy_single_positive
[10:44:21] [PASSED] sysctl_test_dointvec_write_happy_single_negative
[10:44:21] [PASSED] sysctl_test_api_dointvec_write_single_less_int_min
[10:44:21] [PASSED] sysctl_test_api_dointvec_write_single_greater_int_max
[10:44:21] =================== [PASSED] sysctl_test ===================
[10:44:21] ================== binfmt_elf (1 subtest) ==================
[10:44:21] [PASSED] total_mapping_size_test
[10:44:21] =================== [PASSED] binfmt_elf ====================
[10:44:21] =================== cpumask (6 subtests) ===================
[10:44:21] [PASSED] test_cpumask_weight
[10:44:21] [PASSED] test_cpumask_first
[10:44:21] [PASSED] test_cpumask_last
[10:44:21] [PASSED] test_cpumask_next
[10:44:21] [PASSED] test_cpumask_iterators
[10:44:21] [PASSED] test_cpumask_iterators_builtin
[10:44:21] ===================== [PASSED] cpumask =====================
[10:44:21] ==================== hash (2 subtests) =====================
[10:44:21] [PASSED] test_string_or
[10:44:21] [PASSED] test_hash_or
[10:44:21] ====================== [PASSED] hash =======================
[10:44:21] ================== list_sort (1 subtest) ===================
[10:44:21] [PASSED] list_sort_test
[10:44:21] ==================== [PASSED] list_sort ====================
[10:44:21] =================== lib_sort (1 subtest) ===================
[10:44:21] [PASSED] test_sort
[10:44:21] ==================== [PASSED] lib_sort =====================
[10:44:21] ============= kunit_executor_test (4 subtests) =============
[10:44:21] [PASSED] parse_filter_test
[10:44:21] [PASSED] filter_suites_test
[10:44:21] [PASSED] filter_suites_test_glob_test
[10:44:21] [PASSED] filter_suites_to_empty_test
[10:44:21] =============== [PASSED] kunit_executor_test ===============
[10:44:21] ============ kunit-try-catch-test (2 subtests) =============
[10:44:21] [PASSED] kunit_test_try_catch_successful_try_no_catch
[10:44:21] [PASSED] kunit_test_try_catch_unsuccessful_try_does_catch
[10:44:21] ============== [PASSED] kunit-try-catch-test ===============
[10:44:21] ============= kunit-resource-test (8 subtests) =============
[10:44:21] [PASSED] kunit_resource_test_init_resources
[10:44:21] [PASSED] kunit_resource_test_alloc_resource
[10:44:21] [PASSED] kunit_resource_test_destroy_resource
[10:44:21] [PASSED] kunit_resource_test_remove_resource
[10:44:21] [PASSED] kunit_resource_test_cleanup_resources
[10:44:21] [PASSED] kunit_resource_test_proper_free_ordering
[10:44:21] [PASSED] kunit_resource_test_static
[10:44:21] [PASSED] kunit_resource_test_named
[10:44:21] =============== [PASSED] kunit-resource-test ===============
[10:44:21] ================ kunit-log-test (1 subtest) ================
[10:44:21] [PASSED] kunit_log_test
[10:44:21] ================= [PASSED] kunit-log-test ==================
[10:44:21] ================ kunit_status (2 subtests) =================
[10:44:21] [PASSED] kunit_status_set_failure_test
[10:44:21] [PASSED] kunit_status_mark_skipped_test
[10:44:21] ================== [PASSED] kunit_status ===================
[10:44:21] ============= string-stream-test (3 subtests) ==============
[10:44:21] [PASSED] string_stream_test_empty_on_creation
[10:44:21] [PASSED] string_stream_test_not_empty_after_add
[10:44:21] [PASSED] string_stream_test_get_string
[10:44:21] =============== [PASSED] string-stream-test ================
[10:44:21] =================== example (4 subtests) ===================
[10:44:21] [PASSED] example_simple_test
[10:44:21] [SKIPPED] example_skip_test
[10:44:21] [SKIPPED] example_mark_skipped_test
[10:44:21] [PASSED] example_all_expect_macros_test
[10:44:21] ===================== [PASSED] example =====================
[10:44:21] ================== bitfields (2 subtests) ==================
[10:44:21] [PASSED] test_bitfields_constants
[10:44:21] [PASSED] test_bitfields_variables
[10:44:21] ==================== [PASSED] bitfields ====================
[10:44:21] ============== list-kunit-test (39 subtests) ===============
[10:44:21] [PASSED] list_test_list_init
[10:44:21] [PASSED] list_test_list_add
[10:44:21] [PASSED] list_test_list_add_tail
[10:44:21] [PASSED] list_test_list_del
[10:44:21] [PASSED] list_test_list_replace
[10:44:21] [PASSED] list_test_list_replace_init
[10:44:21] [PASSED] list_test_list_swap
[10:44:21] [PASSED] list_test_list_del_init
[10:44:21] [PASSED] list_test_list_del_init_careful
[10:44:21] [PASSED] list_test_list_move
[10:44:21] [PASSED] list_test_list_move_tail
[10:44:21] [PASSED] list_test_list_bulk_move_tail
[10:44:21] [PASSED] list_test_list_is_head
[10:44:21] [PASSED] list_test_list_is_first
[10:44:21] [PASSED] list_test_list_is_last
[10:44:21] [PASSED] list_test_list_empty
[10:44:21] [PASSED] list_test_list_empty_careful
[10:44:21] [PASSED] list_test_list_rotate_left
[10:44:21] [PASSED] list_test_list_rotate_to_front
[10:44:21] [PASSED] list_test_list_is_singular
[10:44:21] [PASSED] list_test_list_cut_position
[10:44:21] [PASSED] list_test_list_cut_before
[10:44:21] [PASSED] list_test_list_splice
[10:44:21] [PASSED] list_test_list_splice_tail
[10:44:21] [PASSED] list_test_list_splice_init
[10:44:21] [PASSED] list_test_list_splice_tail_init
[10:44:21] [PASSED] list_test_list_entry
[10:44:21] [PASSED] list_test_list_entry_is_head
[10:44:21] [PASSED] list_test_list_first_entry
[10:44:21] [PASSED] list_test_list_last_entry
[10:44:21] [PASSED] list_test_list_first_entry_or_null
[10:44:21] [PASSED] list_test_list_next_entry
[10:44:21] [PASSED] list_test_list_prev_entry
[10:44:21] [PASSED] list_test_list_for_each
[10:44:21] [PASSED] list_test_list_for_each_prev
[10:44:21] [PASSED] list_test_list_for_each_safe
[10:44:21] [PASSED] list_test_list_for_each_prev_safe
[10:44:21] [PASSED] list_test_list_for_each_entry
[10:44:21] [PASSED] list_test_list_for_each_entry_reverse
[10:44:21] ================= [PASSED] list-kunit-test =================
[10:44:21] =================== hlist (18 subtests) ====================
[10:44:21] [PASSED] hlist_test_init
[10:44:21] [PASSED] hlist_test_unhashed
[10:44:21] [PASSED] hlist_test_unhashed_lockless
[10:44:21] [PASSED] hlist_test_del
[10:44:21] [PASSED] hlist_test_del_init
[10:44:21] [PASSED] hlist_test_add
[10:44:21] [PASSED] hlist_test_fake
[10:44:21] [PASSED] hlist_test_is_singular_node
[10:44:21] [PASSED] hlist_test_empty
[10:44:21] [PASSED] hlist_test_move_list
[10:44:21] [PASSED] hlist_test_entry
[10:44:21] [PASSED] hlist_test_entry_safe
[10:44:21] [PASSED] hlist_test_for_each
[10:44:21] [PASSED] hlist_test_for_each_safe
[10:44:21] [PASSED] hlist_test_for_each_entry
[10:44:21] [PASSED] hlist_test_for_each_entry_continue
[10:44:21] [PASSED] hlist_test_for_each_entry_from
[10:44:21] [PASSED] hlist_test_for_each_entry_safe
[10:44:21] ====================== [PASSED] hlist ======================
[10:44:21] ================== bits-test (3 subtests) ==================
[10:44:21] [PASSED] genmask_test
[10:44:21] [PASSED] genmask_ull_test
[10:44:21] [PASSED] genmask_input_check_test
[10:44:21] ==================== [PASSED] bits-test ====================
[10:44:21] =================== cmdline (4 subtests) ===================
[10:44:21] [PASSED] cmdline_test_noint
[10:44:21] [PASSED] cmdline_test_lead_int
[10:44:21] [PASSED] cmdline_test_tail_int
[10:44:21] [PASSED] cmdline_test_range
[10:44:21] ===================== [PASSED] cmdline =====================
[10:44:21] ================== slub_test (5 subtests) ==================
[10:44:21] [PASSED] test_clobber_zone
[10:44:21] [PASSED] test_next_pointer
[10:44:21] [PASSED] test_first_word
[10:44:21] [PASSED] test_clobber_50th_byte
[10:44:21] [PASSED] test_clobber_redzone_free
[10:44:21] ==================== [PASSED] slub_test ====================
[10:44:21] =================== memcpy (3 subtests) ====================
[10:44:21] [PASSED] memset_test
[10:44:21] [PASSED] memcpy_test
[10:44:21] [PASSED] memmove_test
[10:44:21] ===================== [PASSED] memcpy ======================
[10:44:21] ================== overflow (11 subtests) ==================
[10:44:21] [PASSED] u8_overflow_test
[10:44:21] [PASSED] s8_overflow_test
[10:44:21] [PASSED] u16_overflow_test
[10:44:21] [PASSED] s16_overflow_test
[10:44:21] [PASSED] u32_overflow_test
[10:44:21] [PASSED] s32_overflow_test
[10:44:21] [PASSED] u64_overflow_test
[10:44:21] [PASSED] s64_overflow_test
[10:44:21] [PASSED] overflow_shift_test
[10:44:21] [PASSED] overflow_allocation_test
[10:44:21] [PASSED] overflow_size_helpers_test
[10:44:21] ==================== [PASSED] overflow =====================
[10:44:21] ================= stackinit (65 subtests) ==================
[10:44:21] [PASSED] test_u8_zero
[10:44:21] [PASSED] test_u16_zero
[10:44:21] [PASSED] test_u32_zero
[10:44:21] [PASSED] test_u64_zero
[10:44:21] [PASSED] test_char_array_zero
[10:44:21] [PASSED] test_small_hole_zero
[10:44:21] [PASSED] test_big_hole_zero
[10:44:21] [PASSED] test_trailing_hole_zero
[10:44:21] [PASSED] test_packed_zero
[10:44:21] [PASSED] test_small_hole_dynamic_partial
[10:44:21] [PASSED] test_big_hole_dynamic_partial
[10:44:21] [PASSED] test_trailing_hole_dynamic_partial
[10:44:21] [PASSED] test_packed_dynamic_partial
[10:44:21] [PASSED] test_small_hole_assigned_dynamic_partial
[10:44:21] [PASSED] test_big_hole_assigned_dynamic_partial
[10:44:21] [PASSED] test_trailing_hole_assigned_dynamic_partial
[10:44:21] [PASSED] test_packed_assigned_dynamic_partial
[10:44:21] [PASSED] test_small_hole_static_partial
[10:44:21] [PASSED] test_big_hole_static_partial
[10:44:21] [PASSED] test_trailing_hole_static_partial
[10:44:21] [PASSED] test_packed_static_partial
[10:44:21] [PASSED] test_small_hole_static_all
[10:44:21] [PASSED] test_big_hole_static_all
[10:44:21] [PASSED] test_trailing_hole_static_all
[10:44:21] [PASSED] test_packed_static_all
[10:44:21] [PASSED] test_small_hole_dynamic_all
[10:44:21] [PASSED] test_big_hole_dynamic_all
[10:44:21] [PASSED] test_trailing_hole_dynamic_all
[10:44:21] [PASSED] test_packed_dynamic_all
[10:44:21] [PASSED] test_small_hole_runtime_partial
[10:44:21] [PASSED] test_big_hole_runtime_partial
[10:44:21] [PASSED] test_trailing_hole_runtime_partial
[10:44:21] [PASSED] test_packed_runtime_partial
[10:44:21] [PASSED] test_small_hole_runtime_all
[10:44:21] [PASSED] test_big_hole_runtime_all
[10:44:21] [PASSED] test_trailing_hole_runtime_all
[10:44:21] [PASSED] test_packed_runtime_all
[10:44:21] [PASSED] test_small_hole_assigned_static_partial
[10:44:21] [PASSED] test_big_hole_assigned_static_partial
[10:44:21] [PASSED] test_trailing_hole_assigned_static_partial
[10:44:21] [PASSED] test_packed_assigned_static_partial
[10:44:21] [PASSED] test_small_hole_assigned_static_all
[10:44:21] [PASSED] test_big_hole_assigned_static_all
[10:44:21] [PASSED] test_trailing_hole_assigned_static_all
[10:44:21] [PASSED] test_packed_assigned_static_all
[10:44:21] [PASSED] test_small_hole_assigned_dynamic_all
[10:44:21] [PASSED] test_big_hole_assigned_dynamic_all
[10:44:21] [PASSED] test_trailing_hole_assigned_dynamic_all
[10:44:21] [PASSED] test_packed_assigned_dynamic_all
[10:44:21] [SKIPPED] test_small_hole_assigned_copy
[10:44:21] [SKIPPED] test_big_hole_assigned_copy
[10:44:21] [SKIPPED] test_trailing_hole_assigned_copy
[10:44:21] [PASSED] test_packed_assigned_copy
[10:44:21] [PASSED] test_u8_none
[10:44:21] [PASSED] test_u16_none
[10:44:21] [PASSED] test_u32_none
[10:44:21] [PASSED] test_u64_none
[10:44:21] [PASSED] test_char_array_none
[10:44:21] [SKIPPED] test_switch_1_none
[10:44:21] [SKIPPED] test_switch_2_none
[10:44:21] [PASSED] test_small_hole_none
[10:44:21] [PASSED] test_big_hole_none
[10:44:21] [PASSED] test_trailing_hole_none
[10:44:21] [PASSED] test_packed_none
[10:44:21] [PASSED] test_user
[10:44:21] ==================== [PASSED] stackinit ====================
[10:44:21] =============== qos-kunit-test (3 subtests) ================
[10:44:21] [PASSED] freq_qos_test_min
[10:44:21] [PASSED] freq_qos_test_maxdef
[10:44:21] [PASSED] freq_qos_test_readd
[10:44:21] ================= [PASSED] qos-kunit-test ==================
[10:44:21] =============== property-entry (7 subtests) ================
[10:44:21] [PASSED] pe_test_uints
[10:44:21] [PASSED] pe_test_uint_arrays
[10:44:21] [PASSED] pe_test_strings
[10:44:21] [PASSED] pe_test_bool
[10:44:21] [PASSED] pe_test_move_inline_u8
[10:44:21] [PASSED] pe_test_move_inline_str
[10:44:21] [PASSED] pe_test_reference
[10:44:21] ================= [PASSED] property-entry ==================
[10:44:21] ============================================================
[10:44:21] Testing complete. Ran 208 tests: passed: 201, skipped: 7
[10:44:21] Elapsed time: 52.940s total, 0.001s configuring, 52.223s
building, 0.696s running

sergio@laptop:~/repos/rust-for-linux$ date
dom 15 ene 2023 10:44:26 CET
sergio@laptop:~/repos/rust-for-linux$ grep CONFIG_RUST .kunit/.config
CONFIG_RUST_IS_AVAILABLE=y
CONFIG_RUST=y
CONFIG_RUSTC_VERSION_TEXT="rustc 1.62.0 (a8314ef7d 2022-06-27)"
# CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y