143fbd8cdSSean Christopherson# SPDX-License-Identifier: GPL-2.0-only 243fbd8cdSSean Christophersoninclude ../../../build/Build.include 343fbd8cdSSean Christopherson 443fbd8cdSSean Christophersonall: 543fbd8cdSSean Christopherson 643fbd8cdSSean ChristophersonLIBKVM += lib/assert.c 743fbd8cdSSean ChristophersonLIBKVM += lib/elf.c 843fbd8cdSSean ChristophersonLIBKVM += lib/guest_modes.c 943fbd8cdSSean ChristophersonLIBKVM += lib/io.c 1043fbd8cdSSean ChristophersonLIBKVM += lib/kvm_util.c 1143fbd8cdSSean ChristophersonLIBKVM += lib/lru_gen_util.c 1243fbd8cdSSean ChristophersonLIBKVM += lib/memstress.c 1343fbd8cdSSean ChristophersonLIBKVM += lib/guest_sprintf.c 1443fbd8cdSSean ChristophersonLIBKVM += lib/rbtree.c 1543fbd8cdSSean ChristophersonLIBKVM += lib/sparsebit.c 1643fbd8cdSSean ChristophersonLIBKVM += lib/test_util.c 1743fbd8cdSSean ChristophersonLIBKVM += lib/ucall_common.c 1843fbd8cdSSean ChristophersonLIBKVM += lib/userfaultfd_util.c 1943fbd8cdSSean Christopherson 2043fbd8cdSSean ChristophersonLIBKVM_STRING += lib/string_override.c 2167730e6cSSean Christopherson 2267730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/apic.c 2367730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/handlers.S 2467730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/hyperv.c 2567730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/memstress.c 2667730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/pmu.c 2767730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/processor.c 2867730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/sev.c 2967730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/svm.c 3067730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/ucall.c 3143fbd8cdSSean ChristophersonLIBKVM_x86 += lib/x86/vmx.c 3267730e6cSSean Christopherson 3367730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic.c 3467730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic_v3.c 3567730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic_v3_its.c 3667730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/handlers.S 3767730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/processor.c 3867730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/spinlock.c 3967730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/ucall.c 4043fbd8cdSSean ChristophersonLIBKVM_arm64 += lib/arm64/vgic.c 4167730e6cSSean Christopherson 4267730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/diag318_test_handler.c 4367730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/processor.c 4467730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/ucall.c 4543fbd8cdSSean ChristophersonLIBKVM_s390 += lib/s390/facility.c 4643fbd8cdSSean Christopherson 4743fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/handlers.S 4843fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/processor.c 4943fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/ucall.c 5043fbd8cdSSean Christopherson 5167730e6cSSean ChristophersonLIBKVM_loongarch += lib/loongarch/processor.c 5243fbd8cdSSean ChristophersonLIBKVM_loongarch += lib/loongarch/ucall.c 53*c57047f6SPaolo BonziniLIBKVM_loongarch += lib/loongarch/exception.S 54*c57047f6SPaolo Bonzini 55*c57047f6SPaolo Bonzini# Non-compiled test targets 56*c57047f6SPaolo BonziniTEST_PROGS_x86 += x86/nx_huge_pages_test.sh 57*c57047f6SPaolo Bonzini 58*c57047f6SPaolo Bonzini# Compiled test targets valid on all architectures with libkvm support 59*c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON = demand_paging_test 60*c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += dirty_log_test 61*c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += guest_print_test 6243fbd8cdSSean ChristophersonTEST_GEN_PROGS_COMMON += kvm_binary_stats_test 63*c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += kvm_create_max_vcpus 64*c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += kvm_page_table_test 6567730e6cSSean ChristophersonTEST_GEN_PROGS_COMMON += set_memory_region_test 6667730e6cSSean Christopherson 6767730e6cSSean Christopherson# Compiled test targets 6867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 = $(TEST_GEN_PROGS_COMMON) 6967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/cpuid_test 7067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/cr4_cpuid_sync_test 7167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/dirty_log_page_splitting_test 7267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/feature_msrs_test 7367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/exit_on_emulation_failure_test 7467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/fastops_test 7567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/fix_hypercall_test 7667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hwcr_msr_test 7767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_clock 7867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_cpuid 7967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_evmcs 8067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_extended_hypercalls 8167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_features 822428865bSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_ipi 8367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_svm_test 8467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_tlb_flush 8567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/kvm_clock_test 8667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/kvm_pv_test 8767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/kvm_buslock_test 8867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/monitor_mwait_test 8967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/nested_emulation_test 9067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/nested_exceptions_test 9167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/platform_info_test 9267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/pmu_counters_test 9367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/pmu_event_filter_test 9467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/private_mem_conversions_test 9567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/private_mem_kvm_exits_test 9667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/set_boot_cpu_id 9767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/set_sregs_test 9867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/smaller_maxphyaddr_emulation_test 9967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/smm_test 10067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/state_test 10167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_preemption_timer_test 10267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_vmcall_test 10367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_int_ctl_test 10467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_nested_shutdown_test 10567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_nested_soft_inject_test 10667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/tsc_scaling_sync 10767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sync_regs_test 10867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/ucna_injection_test 10967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/userspace_io_test 11067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/userspace_msr_exit_test 11167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_apic_access_test 11267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_close_while_nested_test 11367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_dirty_log_test 11467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_exception_with_invalid_guest_state 11567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_msrs_test 11667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_invalid_nested_guest_state 11767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_set_nested_state_test 11867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_tsc_adjust_test 11967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_nested_tsc_scaling_test 12067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/apic_bus_clock_test 12167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xapic_ipi_test 12267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xapic_state_test 12367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xcr0_cpuid_test 12467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xss_msr_test 12567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/debug_regs 12667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/tsc_msrs_test 12767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_pmu_caps_test 12867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xen_shinfo_test 12967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xen_vmcall_test 13067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_init2_tests 13167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_migrate_tests 13267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_smoke_test 13367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/amx_test 13467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/max_vcpuid_cap_test 13567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/triple_fault_event_test 13667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/recalc_apic_map_test 13767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += access_tracking_perf_test 13867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += coalesced_io_test 13967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += dirty_log_perf_test 14067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += guest_memfd_test 14167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += hardware_disable_test 14243fbd8cdSSean ChristophersonTEST_GEN_PROGS_x86 += memslot_modification_stress_test 14343fbd8cdSSean ChristophersonTEST_GEN_PROGS_x86 += memslot_perf_test 14467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += mmu_stress_test 14543fbd8cdSSean ChristophersonTEST_GEN_PROGS_x86 += rseq_test 146*c57047f6SPaolo BonziniTEST_GEN_PROGS_x86 += steal_time 14767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += system_counter_offset_test 14867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += pre_fault_memory_test 14967730e6cSSean Christopherson 15067730e6cSSean Christopherson# Compiled outputs used by test targets 15167730e6cSSean ChristophersonTEST_GEN_PROGS_EXTENDED_x86 += x86/nx_huge_pages_test 15267730e6cSSean Christopherson 15367730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 = $(TEST_GEN_PROGS_COMMON) 15467730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/aarch32_id_regs 15567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/arch_timer_edge_cases 15667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/debug-exceptions 15767730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/host_sve 15867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/hypercalls 15967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/mmio_abort 16067730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/page_fault_test 16167730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/psci_test 16267730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/set_id_regs 16367730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/smccc_filter 16467730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vcpu_width_config 16567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_init 16667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_irq 16767730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_lpi_stress 16867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vpmu_counter_access 16967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/no-vgic-v3 17067730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += access_tracking_perf_test 17167730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arch_timer 17243fbd8cdSSean ChristophersonTEST_GEN_PROGS_arm64 += coalesced_io_test 173*c57047f6SPaolo BonziniTEST_GEN_PROGS_arm64 += dirty_log_perf_test 174*c57047f6SPaolo BonziniTEST_GEN_PROGS_arm64 += get-reg-list 17567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += memslot_modification_stress_test 17667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += memslot_perf_test 17767730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += mmu_stress_test 17867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += rseq_test 17967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += steal_time 18067730e6cSSean Christopherson 18167730e6cSSean ChristophersonTEST_GEN_PROGS_s390 = $(TEST_GEN_PROGS_COMMON) 18267730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/memop 18367730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/resets 18443fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/sync_regs_test 185*c57047f6SPaolo BonziniTEST_GEN_PROGS_s390 += s390/tprot 18643fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/cmma_test 18743fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/debug_test 18843fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/cpumodel_subfuncs_test 18943fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/shared_zeropage_test 19043fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/ucontrol_test 19143fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += rseq_test 19243fbd8cdSSean Christopherson 19343fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON) 19443fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += riscv/sbi_pmu_test 19543fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += riscv/ebreak_test 1969af04539SSean ChristophersonTEST_GEN_PROGS_riscv += arch_timer 1979af04539SSean ChristophersonTEST_GEN_PROGS_riscv += coalesced_io_test 1989af04539SSean ChristophersonTEST_GEN_PROGS_riscv += get-reg-list 1999af04539SSean ChristophersonTEST_GEN_PROGS_riscv += steal_time 20043fbd8cdSSean Christopherson 20143fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += coalesced_io_test 20243fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += demand_paging_test 20343fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += dirty_log_perf_test 20443fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += dirty_log_test 20543fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += guest_print_test 20643fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += hardware_disable_test 20743fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += kvm_binary_stats_test 20843fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += kvm_create_max_vcpus 20943fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += kvm_page_table_test 21043fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += memslot_modification_stress_test 2119af04539SSean ChristophersonTEST_GEN_PROGS_loongarch += memslot_perf_test 21243fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += set_memory_region_test 21343fbd8cdSSean Christopherson 21443fbd8cdSSean ChristophersonSPLIT_TESTS += arch_timer 21543fbd8cdSSean ChristophersonSPLIT_TESTS += get-reg-list 21643fbd8cdSSean Christopherson 21743fbd8cdSSean ChristophersonTEST_PROGS += $(TEST_PROGS_$(ARCH)) 2189af04539SSean ChristophersonTEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH)) 21943fbd8cdSSean ChristophersonTEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH)) 22043fbd8cdSSean ChristophersonLIBKVM += $(LIBKVM_$(ARCH)) 22143fbd8cdSSean Christopherson 22243fbd8cdSSean ChristophersonOVERRIDE_TARGETS = 1 22343fbd8cdSSean Christopherson 22443fbd8cdSSean Christopherson# lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most 22543fbd8cdSSean Christopherson# importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`, 22643fbd8cdSSean Christopherson# which causes the environment variable to override the makefile). 22743fbd8cdSSean Christophersoninclude ../lib.mk 22843fbd8cdSSean Christophersoninclude ../cgroup/lib/libcgroup.mk 22943fbd8cdSSean Christopherson 23043fbd8cdSSean ChristophersonINSTALL_HDR_PATH = $(top_srcdir)/usr 23143fbd8cdSSean ChristophersonLINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ 23243fbd8cdSSean ChristophersonLINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include 23343fbd8cdSSean ChristophersonLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include 23443fbd8cdSSean ChristophersonCFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ 23543fbd8cdSSean Christopherson -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ 23643fbd8cdSSean Christopherson -fno-builtin-memcmp -fno-builtin-memcpy \ 23743fbd8cdSSean Christopherson -fno-builtin-memset -fno-builtin-strnlen \ 23843fbd8cdSSean Christopherson -fno-stack-protector -fno-PIE -fno-strict-aliasing \ 23943fbd8cdSSean Christopherson -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_TOOL_ARCH_INCLUDE) \ 24043fbd8cdSSean Christopherson -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(ARCH) \ 24143fbd8cdSSean Christopherson -I ../rseq -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES) 24243fbd8cdSSean Christophersonifeq ($(ARCH),s390) 24343fbd8cdSSean Christopherson CFLAGS += -march=z10 24443fbd8cdSSean Christophersonendif 24543fbd8cdSSean Christophersonifeq ($(ARCH),x86) 24643fbd8cdSSean Christophersonifeq ($(shell echo "void foo(void) { }" | $(CC) -march=x86-64-v2 -x c - -c -o /dev/null 2>/dev/null; echo "$$?"),0) 24743fbd8cdSSean Christopherson CFLAGS += -march=x86-64-v2 24843fbd8cdSSean Christophersonendif 24943fbd8cdSSean Christophersonendif 25043fbd8cdSSean Christophersonifeq ($(ARCH),arm64) 25143fbd8cdSSean Christophersontools_dir := $(top_srcdir)/tools 25243fbd8cdSSean Christophersonarm64_tools_dir := $(tools_dir)/arch/arm64/tools/ 25343fbd8cdSSean Christopherson 25443fbd8cdSSean Christophersonifneq ($(abs_objdir),) 25543fbd8cdSSean Christophersonarm64_hdr_outdir := $(abs_objdir)/tools/ 25643fbd8cdSSean Christophersonelse 25743fbd8cdSSean Christophersonarm64_hdr_outdir := $(tools_dir)/ 25843fbd8cdSSean Christophersonendif 25943fbd8cdSSean Christopherson 26043fbd8cdSSean ChristophersonGEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/ 26143fbd8cdSSean ChristophersonCFLAGS += -I$(GEN_HDRS) 2629af04539SSean Christopherson 26343fbd8cdSSean Christopherson$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*) 26443fbd8cdSSean Christopherson $(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir) 26543fbd8cdSSean Christophersonendif 26643fbd8cdSSean Christopherson 26743fbd8cdSSean Christophersonno-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \ 26843fbd8cdSSean Christopherson $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) 26943fbd8cdSSean Christopherson 27043fbd8cdSSean Christopherson# On s390, build the testcases KVM-enabled 2719af04539SSean Christophersonpgste-option = $(call try-run, echo 'int main(void) { return 0; }' | \ 27243fbd8cdSSean Christopherson $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste) 27343fbd8cdSSean Christopherson 27443fbd8cdSSean ChristophersonLDLIBS += -ldl 27543fbd8cdSSean ChristophersonLDFLAGS += -pthread $(no-pie-option) $(pgste-option) 27643fbd8cdSSean Christopherson 27743fbd8cdSSean ChristophersonLIBKVM_C := $(filter %.c,$(LIBKVM)) 27843fbd8cdSSean ChristophersonLIBKVM_S := $(filter %.S,$(LIBKVM)) 2799af04539SSean ChristophersonLIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C)) 28043fbd8cdSSean ChristophersonLIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S)) 2819af04539SSean ChristophersonLIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING)) 28243fbd8cdSSean ChristophersonLIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ) $(LIBCGROUP_O) 28343fbd8cdSSean ChristophersonSPLIT_TEST_GEN_PROGS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS)) 28443fbd8cdSSean ChristophersonSPLIT_TEST_GEN_OBJ := $(patsubst %, $(OUTPUT)/$(ARCH)/%.o, $(SPLIT_TESTS)) 28543fbd8cdSSean Christopherson 28643fbd8cdSSean ChristophersonTEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS)) 28743fbd8cdSSean ChristophersonTEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) 28843fbd8cdSSean ChristophersonTEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ)) 28943fbd8cdSSean ChristophersonTEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS)) 29043fbd8cdSSean ChristophersonTEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TEST_GEN_OBJ)) 29143fbd8cdSSean Christopherson-include $(TEST_DEP_FILES) 29243fbd8cdSSean Christopherson 29343fbd8cdSSean Christopherson$(shell mkdir -p $(sort $(OUTPUT)/$(ARCH) $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ)))) 29443fbd8cdSSean Christopherson 29543fbd8cdSSean Christopherson$(filter-out $(SPLIT_TEST_GEN_PROGS), $(TEST_GEN_PROGS)) \ 29643fbd8cdSSean Christopherson$(TEST_GEN_PROGS_EXTENDED): %: %.o 29743fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@ 29843fbd8cdSSean Christopherson$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c 29943fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 30043fbd8cdSSean Christopherson 30143fbd8cdSSean Christopherson$(SPLIT_TEST_GEN_PROGS): $(OUTPUT)/%: $(OUTPUT)/%.o $(OUTPUT)/$(ARCH)/%.o 30243fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@ 30343fbd8cdSSean Christopherson$(SPLIT_TEST_GEN_OBJ): $(OUTPUT)/$(ARCH)/%.o: $(ARCH)/%.c 30443fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 30543fbd8cdSSean Christopherson 30643fbd8cdSSean ChristophersonEXTRA_CLEAN += $(GEN_HDRS) \ 30743fbd8cdSSean Christopherson $(LIBKVM_OBJS) \ 30843fbd8cdSSean Christopherson $(SPLIT_TEST_GEN_OBJ) \ 30943fbd8cdSSean Christopherson $(TEST_DEP_FILES) \ 31043fbd8cdSSean Christopherson $(TEST_GEN_OBJ) \ 31143fbd8cdSSean Christopherson cscope.* 31243fbd8cdSSean Christopherson 31343fbd8cdSSean Christopherson$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS) 31443fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 31543fbd8cdSSean Christopherson 31643fbd8cdSSean Christopherson$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_HDRS) 317 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 318 319# Compile the string overrides as freestanding to prevent the compiler from 320# generating self-referential code, e.g. without "freestanding" the compiler may 321# "optimize" memcmp() by invoking memcmp(), thus causing infinite recursion. 322$(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c 323 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@ 324 325$(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS)))) 326$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS) 327$(TEST_GEN_PROGS): $(LIBKVM_OBJS) 328$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS) 329$(TEST_GEN_OBJ): $(GEN_HDRS) 330 331cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. 332cscope: 333 $(RM) cscope.* 334 (find $(include_paths) -name '*.h' \ 335 -exec realpath --relative-base=$(PWD) {} \;; \ 336 find . -name '*.c' \ 337 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files 338 cscope -b 339