xref: /linux/tools/testing/selftests/kvm/Makefile (revision e301aea030d60da760f85f854a82ce788d5cf6e7)
1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only
2b61442dfSMasahiro Yamadainclude ../../../build/Build.include
3c2390f16SPaolo Bonzini
4783e9e51SPaolo Bonziniall:
5783e9e51SPaolo Bonzini
6cc68765dSAndrew Jonestop_srcdir = ../../../..
7baea2ce5SPaolo Bonziniinclude $(top_srcdir)/scripts/subarch.include
8baea2ce5SPaolo BonziniARCH            ?= $(SUBARCH)
966d69e08SShuah Khan
106a5db83aSSean Christophersonifeq ($(ARCH),x86)
116a5db83aSSean Christopherson	ARCH_DIR := x86_64
126a5db83aSSean Christophersonelse ifeq ($(ARCH),arm64)
136a5db83aSSean Christopherson	ARCH_DIR := aarch64
146a5db83aSSean Christophersonelse ifeq ($(ARCH),s390)
156a5db83aSSean Christopherson	ARCH_DIR := s390x
166a5db83aSSean Christophersonelse
176a5db83aSSean Christopherson	ARCH_DIR := $(ARCH)
183e06cdf1SAnup Patelendif
1966d69e08SShuah Khan
20cf97d5e9SDavid MatlackLIBKVM += lib/assert.c
21cf97d5e9SDavid MatlackLIBKVM += lib/elf.c
22cf97d5e9SDavid MatlackLIBKVM += lib/guest_modes.c
23cf97d5e9SDavid MatlackLIBKVM += lib/io.c
24cf97d5e9SDavid MatlackLIBKVM += lib/kvm_util.c
259fda6753SDavid MatlackLIBKVM += lib/memstress.c
26e5119382SAaron LewisLIBKVM += lib/guest_sprintf.c
27cf97d5e9SDavid MatlackLIBKVM += lib/rbtree.c
28cf97d5e9SDavid MatlackLIBKVM += lib/sparsebit.c
29cf97d5e9SDavid MatlackLIBKVM += lib/test_util.c
3070466381SSean ChristophersonLIBKVM += lib/ucall_common.c
31a93871d0SRicardo KollerLIBKVM += lib/userfaultfd_util.c
32cf97d5e9SDavid Matlack
336b6f7148SSean ChristophersonLIBKVM_STRING += lib/string_override.c
346b6f7148SSean Christopherson
35cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/apic.c
36cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/handlers.S
37e8f3d23cSVitaly KuznetsovLIBKVM_x86_64 += lib/x86_64/hyperv.c
389fda6753SDavid MatlackLIBKVM_x86_64 += lib/x86_64/memstress.c
39e6faa049SJinrong LiangLIBKVM_x86_64 += lib/x86_64/pmu.c
40cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/processor.c
41ae20eef5SPeter GondaLIBKVM_x86_64 += lib/x86_64/sev.c
42cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/svm.c
43cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/ucall.c
44cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/vmx.c
45cf97d5e9SDavid Matlack
46cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/gic.c
47cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/gic_v3.c
48be26db61SOliver UptonLIBKVM_aarch64 += lib/aarch64/gic_v3_its.c
49cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/handlers.S
50cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/processor.c
51cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/spinlock.c
52cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/ucall.c
53cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/vgic.c
54cf97d5e9SDavid Matlack
55cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/diag318_test_handler.c
56cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/processor.c
57cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/ucall.c
58cf97d5e9SDavid Matlack
5938f680c2SHaibo XuLIBKVM_riscv += lib/riscv/handlers.S
60cf97d5e9SDavid MatlackLIBKVM_riscv += lib/riscv/processor.c
61cf97d5e9SDavid MatlackLIBKVM_riscv += lib/riscv/ucall.c
62783e9e51SPaolo Bonzini
638448ec59SBen Gardon# Non-compiled test targets
648448ec59SBen GardonTEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
658448ec59SBen Gardon
668448ec59SBen Gardon# Compiled test targets
679e6d484fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 = x86_64/cpuid_test
689e6d484fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/cr4_cpuid_sync_test
69dfa78a20SBen GardonTEST_GEN_PROGS_x86_64 += x86_64/dirty_log_page_splitting_test
7077a3aa26SEmanuele Giuseppe EspositoTEST_GEN_PROGS_x86_64 += x86_64/get_msr_index_features
713ae5b759SDavid MatlackTEST_GEN_PROGS_x86_64 += x86_64/exit_on_emulation_failure_test
726c2fa8b2SOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/fix_hypercall_test
7359145532SJim MattsonTEST_GEN_PROGS_x86_64 += x86_64/hwcr_msr_test
742c7f76b4SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_clock
757edcb734SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
760fa32dadSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_evmcs
7760325261SVipin SharmaTEST_GEN_PROGS_x86_64 += x86_64/hyperv_extended_hypercalls
78e2e1cc1fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_features
7999848924SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_ipi
80e67bd7dfSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_svm_test
819e7726a8SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_tlb_flush
8261fb1c54SOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/kvm_clock_test
83ac4a4d6dSOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test
842325d4ddSSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/monitor_mwait_test
8528c40b2cSSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/nested_exceptions_test
8661cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
874f1bd6b1SJinrong LiangTEST_GEN_PROGS_x86_64 += x86_64/pmu_counters_test
88bef9a701SJim MattsonTEST_GEN_PROGS_x86_64 += x86_64/pmu_event_filter_test
8943f623f3SVishal AnnapurveTEST_GEN_PROGS_x86_64 += x86_64/private_mem_conversions_test
90e3577788SAckerley TngTEST_GEN_PROGS_x86_64 += x86_64/private_mem_kvm_exits_test
913df22524SEmanuele Giuseppe EspositoTEST_GEN_PROGS_x86_64 += x86_64/set_boot_cpu_id
9261cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
9352d3a4fbSDavid MatlackTEST_GEN_PROGS_x86_64 += x86_64/smaller_maxphyaddr_emulation_test
9461cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/smm_test
9561cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/state_test
968d7fbf01SMakarand SonareTEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test
9794c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test
981ad32105SMaxim LevitskyTEST_GEN_PROGS_x86_64 += x86_64/svm_int_ctl_test
990bd2d3f4SMaxim LevitskyTEST_GEN_PROGS_x86_64 += x86_64/svm_nested_shutdown_test
100d8969871SMaciej S. SzmigieroTEST_GEN_PROGS_x86_64 += x86_64/svm_nested_soft_inject_test
101e467b0deSDavid WoodhouseTEST_GEN_PROGS_x86_64 += x86_64/tsc_scaling_sync
10261cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
103eede2065SJue WangTEST_GEN_PROGS_x86_64 += x86_64/ucna_injection_test
10410e7a099SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/userspace_io_test
1053cea1891SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/userspace_msr_exit_test
10697a71a54SJim MattsonTEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
10761cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
10809444420SPaolo BonziniTEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
109e337f7e0SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_exception_with_invalid_guest_state
110ce30d8b9SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_msrs_test
111ab1ef344SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_invalid_nested_guest_state
112da1e3071SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
11361cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
114efe58549SIlias StamatisTEST_GEN_PROGS_x86_64 += x86_64/vmx_nested_tsc_scaling_test
11582222ee7SIsaku YamahataTEST_GEN_PROGS_x86_64 += x86_64/apic_bus_clock_test
116678e90a3SPeter ShierTEST_GEN_PROGS_x86_64 += x86_64/xapic_ipi_test
11785c68eb4SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/xapic_state_test
11803a405b7SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/xcr0_cpuid_test
119c90992bfSAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test
120449aa906SPeter XuTEST_GEN_PROGS_x86_64 += x86_64/debug_regs
1210c899c25SPaolo BonziniTEST_GEN_PROGS_x86_64 += x86_64/tsc_msrs_test
122825be3b5SYang WeijiangTEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_caps_test
1238d4e7e80SDavid WoodhouseTEST_GEN_PROGS_x86_64 += x86_64/xen_shinfo_test
12423200b7aSJoao MartinsTEST_GEN_PROGS_x86_64 += x86_64/xen_vmcall_test
125dfc083a1SPaolo BonziniTEST_GEN_PROGS_x86_64 += x86_64/sev_init2_tests
1266a581508SPeter GondaTEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests
127be250ff4SPeter GondaTEST_GEN_PROGS_x86_64 += x86_64/sev_smoke_test
128bf70636dSYang ZhongTEST_GEN_PROGS_x86_64 += x86_64/amx_test
129753dcf7aSZeng GuangTEST_GEN_PROGS_x86_64 += x86_64/max_vcpuid_cap_test
13030267b43SChenyi QiangTEST_GEN_PROGS_x86_64 += x86_64/triple_fault_event_test
13147d2804bSMichal LuczajTEST_GEN_PROGS_x86_64 += x86_64/recalc_apic_map_test
132de1956f4SDavid MatlackTEST_GEN_PROGS_x86_64 += access_tracking_perf_test
133215b3cb7SSean ChristophersonTEST_GEN_PROGS_x86_64 += coalesced_io_test
134025eed7bSBen GardonTEST_GEN_PROGS_x86_64 += demand_paging_test
13594c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += dirty_log_test
1364fd94ec7SBen GardonTEST_GEN_PROGS_x86_64 += dirty_log_perf_test
1378a89efd4SChao PengTEST_GEN_PROGS_x86_64 += guest_memfd_test
1385d1d46f9SAaron LewisTEST_GEN_PROGS_x86_64 += guest_print_test
1391838b06bSIgnacio AlvaradoTEST_GEN_PROGS_x86_64 += hardware_disable_test
140fd4198bfSPaolo BonziniTEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus
141b9c2bd50SYanan WangTEST_GEN_PROGS_x86_64 += kvm_page_table_test
142b58c55d5SSean ChristophersonTEST_GEN_PROGS_x86_64 += max_guest_memory_test
143f73a3446SBen GardonTEST_GEN_PROGS_x86_64 += memslot_modification_stress_test
144cad347faSMaciej S. SzmigieroTEST_GEN_PROGS_x86_64 += memslot_perf_test
14561e52f16SSean ChristophersonTEST_GEN_PROGS_x86_64 += rseq_test
1465b4f758fSSean ChristophersonTEST_GEN_PROGS_x86_64 += set_memory_region_test
14794c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += steal_time
1480b45d587SJing ZhangTEST_GEN_PROGS_x86_64 += kvm_binary_stats_test
1493f9808caSOliver UptonTEST_GEN_PROGS_x86_64 += system_counter_offset_test
1509ff0e37cSIsaku YamahataTEST_GEN_PROGS_x86_64 += pre_fault_memory_test
151fff8dcd7SAndrew Jones
1528448ec59SBen Gardon# Compiled outputs used by test targets
1538448ec59SBen GardonTEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
1548448ec59SBen Gardon
155797b8451SOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/aarch32_id_regs
15654306f56SColton LewisTEST_GEN_PROGS_aarch64 += aarch64/arch_timer_edge_cases
1574f05223aSRicardo KollerTEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions
1585ca24697SRaghavendra Rao AnantaTEST_GEN_PROGS_aarch64 += aarch64/hypercalls
15935c58101SRicardo KollerTEST_GEN_PROGS_aarch64 += aarch64/page_fault_test
160bf08515dSOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/psci_test
16154a9ea73SJing ZhangTEST_GEN_PROGS_aarch64 += aarch64/set_id_regs
16260e7dadeSOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/smccc_filter
1632f5d27e6SReiji WatanabeTEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config
164dc0e058eSEric AugerTEST_GEN_PROGS_aarch64 += aarch64/vgic_init
16550b020cdSRicardo KollerTEST_GEN_PROGS_aarch64 += aarch64/vgic_irq
16696d36ad9SOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/vgic_lpi_stress
1678d0aebe1SReiji WatanabeTEST_GEN_PROGS_aarch64 += aarch64/vpmu_counter_access
168de2e7520SMarc ZyngierTEST_GEN_PROGS_aarch64 += aarch64/no-vgic-v3
16945681804SOliver UptonTEST_GEN_PROGS_aarch64 += access_tracking_perf_test
170c20dd9e0SHaibo XuTEST_GEN_PROGS_aarch64 += arch_timer
171215b3cb7SSean ChristophersonTEST_GEN_PROGS_aarch64 += coalesced_io_test
172025eed7bSBen GardonTEST_GEN_PROGS_aarch64 += demand_paging_test
17394c4b76bSAndrew JonesTEST_GEN_PROGS_aarch64 += dirty_log_test
17487c5f35eSAndrew JonesTEST_GEN_PROGS_aarch64 += dirty_log_perf_test
1755d1d46f9SAaron LewisTEST_GEN_PROGS_aarch64 += guest_print_test
17617da79e0SAndrew JonesTEST_GEN_PROGS_aarch64 += get-reg-list
17749fe9a5dSThomas HuthTEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
178b9c2bd50SYanan WangTEST_GEN_PROGS_aarch64 += kvm_page_table_test
179358928fdSRicardo KollerTEST_GEN_PROGS_aarch64 += memslot_modification_stress_test
180358928fdSRicardo KollerTEST_GEN_PROGS_aarch64 += memslot_perf_test
18161e52f16SSean ChristophersonTEST_GEN_PROGS_aarch64 += rseq_test
1825b4f758fSSean ChristophersonTEST_GEN_PROGS_aarch64 += set_memory_region_test
18394c4b76bSAndrew JonesTEST_GEN_PROGS_aarch64 += steal_time
1840b45d587SJing ZhangTEST_GEN_PROGS_aarch64 += kvm_binary_stats_test
185783e9e51SPaolo Bonzini
186be6f55a6SThomas HuthTEST_GEN_PROGS_s390x = s390x/memop
187b25d4cb4SJanosch FrankTEST_GEN_PROGS_s390x += s390x/resets
18894c4b76bSAndrew JonesTEST_GEN_PROGS_s390x += s390x/sync_regs_test
189c7ef9ebbSJanis Schoetterl-GlauschTEST_GEN_PROGS_s390x += s390x/tprot
190e325ba22SNico BoehrTEST_GEN_PROGS_s390x += s390x/cmma_test
191642dbc03SIlya LeoshkevichTEST_GEN_PROGS_s390x += s390x/debug_test
19201c51a32SDavid HildenbrandTEST_GEN_PROGS_s390x += s390x/shared_zeropage_test
193011901fcSChristoph SchlameussTEST_GEN_PROGS_s390x += s390x/ucontrol_test
194025eed7bSBen GardonTEST_GEN_PROGS_s390x += demand_paging_test
19594c4b76bSAndrew JonesTEST_GEN_PROGS_s390x += dirty_log_test
1965d1d46f9SAaron LewisTEST_GEN_PROGS_s390x += guest_print_test
19749fe9a5dSThomas HuthTEST_GEN_PROGS_s390x += kvm_create_max_vcpus
198b9c2bd50SYanan WangTEST_GEN_PROGS_s390x += kvm_page_table_test
19961e52f16SSean ChristophersonTEST_GEN_PROGS_s390x += rseq_test
2005b4f758fSSean ChristophersonTEST_GEN_PROGS_s390x += set_memory_region_test
2010b45d587SJing ZhangTEST_GEN_PROGS_s390x += kvm_binary_stats_test
202783e9e51SPaolo Bonzini
203158cb9e6SAtish PatraTEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
204f1c48c1eSChao DuTEST_GEN_PROGS_riscv += riscv/ebreak_test
205d0b94bcbSHaibo XuTEST_GEN_PROGS_riscv += arch_timer
206215b3cb7SSean ChristophersonTEST_GEN_PROGS_riscv += coalesced_io_test
2073e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += demand_paging_test
2083e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += dirty_log_test
20947706939SHaibo XuTEST_GEN_PROGS_riscv += get-reg-list
21060b6e31cSAndrew JonesTEST_GEN_PROGS_riscv += guest_print_test
21160b6e31cSAndrew JonesTEST_GEN_PROGS_riscv += kvm_binary_stats_test
2123e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += kvm_create_max_vcpus
2133e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += kvm_page_table_test
2143e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += set_memory_region_test
21560b6e31cSAndrew JonesTEST_GEN_PROGS_riscv += steal_time
2163e06cdf1SAnup Patel
217c20dd9e0SHaibo XuSPLIT_TESTS += arch_timer
21817da79e0SAndrew JonesSPLIT_TESTS += get-reg-list
21917da79e0SAndrew Jones
2206a5db83aSSean ChristophersonTEST_PROGS += $(TEST_PROGS_$(ARCH_DIR))
2216a5db83aSSean ChristophersonTEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH_DIR))
2226a5db83aSSean ChristophersonTEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH_DIR))
2236a5db83aSSean ChristophersonLIBKVM += $(LIBKVM_$(ARCH_DIR))
224783e9e51SPaolo Bonzini
2255ed19528SYu ZhangOVERRIDE_TARGETS = 1
2265ed19528SYu Zhang
2275efb946bSSean Christopherson# lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most
2285efb946bSSean Christopherson# importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`,
2295efb946bSSean Christopherson# which causes the environment variable to override the makefile).
2305efb946bSSean Christophersoninclude ../lib.mk
2315efb946bSSean Christopherson
232783e9e51SPaolo BonziniINSTALL_HDR_PATH = $(top_srcdir)/usr
233783e9e51SPaolo BonziniLINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
234cc68765dSAndrew JonesLINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
235b80db73dSVitaly Kuznetsovifeq ($(ARCH),x86_64)
236b80db73dSVitaly KuznetsovLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
237b80db73dSVitaly Kuznetsovelse
23866d69e08SShuah KhanLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
239b80db73dSVitaly Kuznetsovendif
240319f6f97SThomas HuthCFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
241b4b12469SHaibo Xu	-Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \
242cc937dadSEdward Liaw	-fno-builtin-memcmp -fno-builtin-memcpy \
243730cfa45SSean Christopherson	-fno-builtin-memset -fno-builtin-strnlen \
244319f6f97SThomas Huth	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
245a5543d34SSean Christopherson	-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
2466a5db83aSSean Christopherson	-I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \
24766d42ac7SGavin Shan	$(KHDR_INCLUDES)
248d7b9dc14SNina Schoetterl-Glauschifeq ($(ARCH),s390)
249d7b9dc14SNina Schoetterl-Glausch	CFLAGS += -march=z10
250d7b9dc14SNina Schoetterl-Glauschendif
251*c2ee9f59SMark Brownifeq ($(ARCH),x86)
252*c2ee9f59SMark Brown	CFLAGS += -march=x86-64-v2
253*c2ee9f59SMark Brownendif
2540c12e6c8SOliver Uptonifeq ($(ARCH),arm64)
2550c12e6c8SOliver Uptontools_dir := $(top_srcdir)/tools
2560c12e6c8SOliver Uptonarm64_tools_dir := $(tools_dir)/arch/arm64/tools/
2570c12e6c8SOliver Upton
2580c12e6c8SOliver Uptonifneq ($(abs_objdir),)
2590c12e6c8SOliver Uptonarm64_hdr_outdir := $(abs_objdir)/tools/
2600c12e6c8SOliver Uptonelse
2610c12e6c8SOliver Uptonarm64_hdr_outdir := $(tools_dir)/
2620c12e6c8SOliver Uptonendif
2630c12e6c8SOliver Upton
2640c12e6c8SOliver UptonGEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/
2650c12e6c8SOliver UptonCFLAGS += -I$(GEN_HDRS)
2660c12e6c8SOliver Upton
2670c12e6c8SOliver Upton$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
2680c12e6c8SOliver Upton	$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
2690c12e6c8SOliver Uptonendif
270c2390f16SPaolo Bonzini
2715dc38777SSean Christophersonno-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
2722b2d8afcSSean Christopherson        $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
273c2390f16SPaolo Bonzini
2748343ba2dSChristian Borntraeger# On s390, build the testcases KVM-enabled
2755dc38777SSean Christophersonpgste-option = $(call try-run, echo 'int main(void) { return 0; }' | \
2768343ba2dSChristian Borntraeger	$(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)
2778343ba2dSChristian Borntraeger
27866d42ac7SGavin ShanLDLIBS += -ldl
2798343ba2dSChristian BorntraegerLDFLAGS += -pthread $(no-pie-option) $(pgste-option)
280783e9e51SPaolo Bonzini
28129faeb96SAaron LewisLIBKVM_C := $(filter %.c,$(LIBKVM))
28229faeb96SAaron LewisLIBKVM_S := $(filter %.S,$(LIBKVM))
28329faeb96SAaron LewisLIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C))
28429faeb96SAaron LewisLIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S))
2856b6f7148SSean ChristophersonLIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING))
2866b6f7148SSean ChristophersonLIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
2872c5af1c8SPaolo BonziniSPLIT_TEST_GEN_PROGS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS))
2882c5af1c8SPaolo BonziniSPLIT_TEST_GEN_OBJ := $(patsubst %, $(OUTPUT)/$(ARCH_DIR)/%.o, $(SPLIT_TESTS))
289cdc979daSDavid Matlack
2905ed19528SYu ZhangTEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS))
2915ed19528SYu ZhangTEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED))
2925ed19528SYu ZhangTEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ))
2935ed19528SYu ZhangTEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS))
2942c5af1c8SPaolo BonziniTEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TEST_GEN_OBJ))
2955ed19528SYu Zhang-include $(TEST_DEP_FILES)
2965ed19528SYu Zhang
29747811790SPaolo Bonzini$(shell mkdir -p $(sort $(OUTPUT)/$(ARCH_DIR) $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
2982c5af1c8SPaolo Bonzini
2992c5af1c8SPaolo Bonzini$(filter-out $(SPLIT_TEST_GEN_PROGS), $(TEST_GEN_PROGS)) \
3002c5af1c8SPaolo Bonzini$(TEST_GEN_PROGS_EXTENDED): %: %.o
3015ed19528SYu Zhang	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@
3025ed19528SYu Zhang$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
3035ed19528SYu Zhang	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
3045ed19528SYu Zhang
3052c5af1c8SPaolo Bonzini$(SPLIT_TEST_GEN_PROGS): $(OUTPUT)/%: $(OUTPUT)/%.o $(OUTPUT)/$(ARCH_DIR)/%.o
30617da79e0SAndrew Jones	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
3072c5af1c8SPaolo Bonzini$(SPLIT_TEST_GEN_OBJ): $(OUTPUT)/$(ARCH_DIR)/%.o: $(ARCH_DIR)/%.c
3082c5af1c8SPaolo Bonzini	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
30917da79e0SAndrew Jones
3109697d84cSOliver UptonEXTRA_CLEAN += $(GEN_HDRS) \
3119697d84cSOliver Upton	       $(LIBKVM_OBJS) \
3122c5af1c8SPaolo Bonzini	       $(SPLIT_TEST_GEN_OBJ) \
3139697d84cSOliver Upton	       $(TEST_DEP_FILES) \
3149697d84cSOliver Upton	       $(TEST_GEN_OBJ) \
3159697d84cSOliver Upton	       cscope.*
316783e9e51SPaolo Bonzini
31770c7b704SOliver Upton$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS)
318783e9e51SPaolo Bonzini	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
319783e9e51SPaolo Bonzini
32070c7b704SOliver Upton$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_HDRS)
32129faeb96SAaron Lewis	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
32229faeb96SAaron Lewis
3236b6f7148SSean Christopherson# Compile the string overrides as freestanding to prevent the compiler from
3246b6f7148SSean Christopherson# generating self-referential code, e.g. without "freestanding" the compiler may
3256b6f7148SSean Christopherson# "optimize" memcmp() by invoking memcmp(), thus causing infinite recursion.
3266b6f7148SSean Christopherson$(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
3276b6f7148SSean Christopherson	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
3286b6f7148SSean Christopherson
32947811790SPaolo Bonzini$(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
3302c5af1c8SPaolo Bonzini$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS)
331cdc979daSDavid Matlack$(TEST_GEN_PROGS): $(LIBKVM_OBJS)
3328448ec59SBen Gardon$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
33370c7b704SOliver Upton$(TEST_GEN_OBJ): $(GEN_HDRS)
334eea192bfSAndrew Jones
335eea192bfSAndrew Jonescscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
336eea192bfSAndrew Jonescscope:
337eea192bfSAndrew Jones	$(RM) cscope.*
338eea192bfSAndrew Jones	(find $(include_paths) -name '*.h' \
339eea192bfSAndrew Jones		-exec realpath --relative-base=$(PWD) {} \;; \
340eea192bfSAndrew Jones	find . -name '*.c' \
341eea192bfSAndrew Jones		-exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
342eea192bfSAndrew Jones	cscope -b
343