Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 include ../../../build/Build.include
0003 
0004 all:
0005 
0006 top_srcdir = ../../../..
0007 include $(top_srcdir)/scripts/subarch.include
0008 ARCH            ?= $(SUBARCH)
0009 
0010 # For cross-builds to work, UNAME_M has to map to ARCH and arch specific
0011 # directories and targets in this Makefile. "uname -m" doesn't map to
0012 # arch specific sub-directory names.
0013 #
0014 # UNAME_M variable to used to run the compiles pointing to the right arch
0015 # directories and build the right targets for these supported architectures.
0016 #
0017 # TEST_GEN_PROGS and LIBKVM are set using UNAME_M variable.
0018 # LINUX_TOOL_ARCH_INCLUDE is set using ARCH variable.
0019 #
0020 # x86_64 targets are named to include x86_64 as a suffix and directories
0021 # for includes are in x86_64 sub-directory. s390x and aarch64 follow the
0022 # same convention. "uname -m" doesn't result in the correct mapping for
0023 # s390x and aarch64.
0024 #
0025 # No change necessary for x86_64
0026 UNAME_M := $(shell uname -m)
0027 
0028 # Set UNAME_M for arm64 compile/install to work
0029 ifeq ($(ARCH),arm64)
0030         UNAME_M := aarch64
0031 endif
0032 # Set UNAME_M s390x compile/install to work
0033 ifeq ($(ARCH),s390)
0034         UNAME_M := s390x
0035 endif
0036 # Set UNAME_M riscv compile/install to work
0037 ifeq ($(ARCH),riscv)
0038         UNAME_M := riscv
0039 endif
0040 
0041 LIBKVM += lib/assert.c
0042 LIBKVM += lib/elf.c
0043 LIBKVM += lib/guest_modes.c
0044 LIBKVM += lib/io.c
0045 LIBKVM += lib/kvm_util.c
0046 LIBKVM += lib/perf_test_util.c
0047 LIBKVM += lib/rbtree.c
0048 LIBKVM += lib/sparsebit.c
0049 LIBKVM += lib/test_util.c
0050 
0051 LIBKVM_STRING += lib/string_override.c
0052 
0053 LIBKVM_x86_64 += lib/x86_64/apic.c
0054 LIBKVM_x86_64 += lib/x86_64/handlers.S
0055 LIBKVM_x86_64 += lib/x86_64/perf_test_util.c
0056 LIBKVM_x86_64 += lib/x86_64/processor.c
0057 LIBKVM_x86_64 += lib/x86_64/svm.c
0058 LIBKVM_x86_64 += lib/x86_64/ucall.c
0059 LIBKVM_x86_64 += lib/x86_64/vmx.c
0060 
0061 LIBKVM_aarch64 += lib/aarch64/gic.c
0062 LIBKVM_aarch64 += lib/aarch64/gic_v3.c
0063 LIBKVM_aarch64 += lib/aarch64/handlers.S
0064 LIBKVM_aarch64 += lib/aarch64/processor.c
0065 LIBKVM_aarch64 += lib/aarch64/spinlock.c
0066 LIBKVM_aarch64 += lib/aarch64/ucall.c
0067 LIBKVM_aarch64 += lib/aarch64/vgic.c
0068 
0069 LIBKVM_s390x += lib/s390x/diag318_test_handler.c
0070 LIBKVM_s390x += lib/s390x/processor.c
0071 LIBKVM_s390x += lib/s390x/ucall.c
0072 
0073 LIBKVM_riscv += lib/riscv/processor.c
0074 LIBKVM_riscv += lib/riscv/ucall.c
0075 
0076 # Non-compiled test targets
0077 TEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
0078 
0079 # Compiled test targets
0080 TEST_GEN_PROGS_x86_64 = x86_64/cpuid_test
0081 TEST_GEN_PROGS_x86_64 += x86_64/cr4_cpuid_sync_test
0082 TEST_GEN_PROGS_x86_64 += x86_64/get_msr_index_features
0083 TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
0084 TEST_GEN_PROGS_x86_64 += x86_64/emulator_error_test
0085 TEST_GEN_PROGS_x86_64 += x86_64/fix_hypercall_test
0086 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_clock
0087 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
0088 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_features
0089 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_svm_test
0090 TEST_GEN_PROGS_x86_64 += x86_64/kvm_clock_test
0091 TEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test
0092 TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
0093 TEST_GEN_PROGS_x86_64 += x86_64/monitor_mwait_test
0094 TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
0095 TEST_GEN_PROGS_x86_64 += x86_64/pmu_event_filter_test
0096 TEST_GEN_PROGS_x86_64 += x86_64/set_boot_cpu_id
0097 TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
0098 TEST_GEN_PROGS_x86_64 += x86_64/smm_test
0099 TEST_GEN_PROGS_x86_64 += x86_64/state_test
0100 TEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test
0101 TEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test
0102 TEST_GEN_PROGS_x86_64 += x86_64/svm_int_ctl_test
0103 TEST_GEN_PROGS_x86_64 += x86_64/svm_nested_soft_inject_test
0104 TEST_GEN_PROGS_x86_64 += x86_64/tsc_scaling_sync
0105 TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
0106 TEST_GEN_PROGS_x86_64 += x86_64/ucna_injection_test
0107 TEST_GEN_PROGS_x86_64 += x86_64/userspace_io_test
0108 TEST_GEN_PROGS_x86_64 += x86_64/userspace_msr_exit_test
0109 TEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
0110 TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
0111 TEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
0112 TEST_GEN_PROGS_x86_64 += x86_64/vmx_exception_with_invalid_guest_state
0113 TEST_GEN_PROGS_x86_64 += x86_64/vmx_msrs_test
0114 TEST_GEN_PROGS_x86_64 += x86_64/vmx_invalid_nested_guest_state
0115 TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
0116 TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
0117 TEST_GEN_PROGS_x86_64 += x86_64/vmx_nested_tsc_scaling_test
0118 TEST_GEN_PROGS_x86_64 += x86_64/xapic_ipi_test
0119 TEST_GEN_PROGS_x86_64 += x86_64/xapic_state_test
0120 TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test
0121 TEST_GEN_PROGS_x86_64 += x86_64/debug_regs
0122 TEST_GEN_PROGS_x86_64 += x86_64/tsc_msrs_test
0123 TEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_caps_test
0124 TEST_GEN_PROGS_x86_64 += x86_64/xen_shinfo_test
0125 TEST_GEN_PROGS_x86_64 += x86_64/xen_vmcall_test
0126 TEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests
0127 TEST_GEN_PROGS_x86_64 += x86_64/amx_test
0128 TEST_GEN_PROGS_x86_64 += x86_64/max_vcpuid_cap_test
0129 TEST_GEN_PROGS_x86_64 += x86_64/triple_fault_event_test
0130 TEST_GEN_PROGS_x86_64 += access_tracking_perf_test
0131 TEST_GEN_PROGS_x86_64 += demand_paging_test
0132 TEST_GEN_PROGS_x86_64 += dirty_log_test
0133 TEST_GEN_PROGS_x86_64 += dirty_log_perf_test
0134 TEST_GEN_PROGS_x86_64 += hardware_disable_test
0135 TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus
0136 TEST_GEN_PROGS_x86_64 += kvm_page_table_test
0137 TEST_GEN_PROGS_x86_64 += max_guest_memory_test
0138 TEST_GEN_PROGS_x86_64 += memslot_modification_stress_test
0139 TEST_GEN_PROGS_x86_64 += memslot_perf_test
0140 TEST_GEN_PROGS_x86_64 += rseq_test
0141 TEST_GEN_PROGS_x86_64 += set_memory_region_test
0142 TEST_GEN_PROGS_x86_64 += steal_time
0143 TEST_GEN_PROGS_x86_64 += kvm_binary_stats_test
0144 TEST_GEN_PROGS_x86_64 += system_counter_offset_test
0145 
0146 # Compiled outputs used by test targets
0147 TEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
0148 
0149 TEST_GEN_PROGS_aarch64 += aarch64/arch_timer
0150 TEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions
0151 TEST_GEN_PROGS_aarch64 += aarch64/get-reg-list
0152 TEST_GEN_PROGS_aarch64 += aarch64/hypercalls
0153 TEST_GEN_PROGS_aarch64 += aarch64/psci_test
0154 TEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config
0155 TEST_GEN_PROGS_aarch64 += aarch64/vgic_init
0156 TEST_GEN_PROGS_aarch64 += aarch64/vgic_irq
0157 TEST_GEN_PROGS_aarch64 += demand_paging_test
0158 TEST_GEN_PROGS_aarch64 += dirty_log_test
0159 TEST_GEN_PROGS_aarch64 += dirty_log_perf_test
0160 TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
0161 TEST_GEN_PROGS_aarch64 += kvm_page_table_test
0162 TEST_GEN_PROGS_aarch64 += memslot_modification_stress_test
0163 TEST_GEN_PROGS_aarch64 += memslot_perf_test
0164 TEST_GEN_PROGS_aarch64 += rseq_test
0165 TEST_GEN_PROGS_aarch64 += set_memory_region_test
0166 TEST_GEN_PROGS_aarch64 += steal_time
0167 TEST_GEN_PROGS_aarch64 += kvm_binary_stats_test
0168 
0169 TEST_GEN_PROGS_s390x = s390x/memop
0170 TEST_GEN_PROGS_s390x += s390x/resets
0171 TEST_GEN_PROGS_s390x += s390x/sync_regs_test
0172 TEST_GEN_PROGS_s390x += s390x/tprot
0173 TEST_GEN_PROGS_s390x += demand_paging_test
0174 TEST_GEN_PROGS_s390x += dirty_log_test
0175 TEST_GEN_PROGS_s390x += kvm_create_max_vcpus
0176 TEST_GEN_PROGS_s390x += kvm_page_table_test
0177 TEST_GEN_PROGS_s390x += rseq_test
0178 TEST_GEN_PROGS_s390x += set_memory_region_test
0179 TEST_GEN_PROGS_s390x += kvm_binary_stats_test
0180 
0181 TEST_GEN_PROGS_riscv += demand_paging_test
0182 TEST_GEN_PROGS_riscv += dirty_log_test
0183 TEST_GEN_PROGS_riscv += kvm_create_max_vcpus
0184 TEST_GEN_PROGS_riscv += kvm_page_table_test
0185 TEST_GEN_PROGS_riscv += set_memory_region_test
0186 TEST_GEN_PROGS_riscv += kvm_binary_stats_test
0187 
0188 TEST_PROGS += $(TEST_PROGS_$(UNAME_M))
0189 TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
0190 TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(UNAME_M))
0191 LIBKVM += $(LIBKVM_$(UNAME_M))
0192 
0193 INSTALL_HDR_PATH = $(top_srcdir)/usr
0194 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
0195 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
0196 ifeq ($(ARCH),x86_64) 
0197 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
0198 else
0199 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
0200 endif
0201 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
0202         -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
0203         -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
0204         -I$(<D) -Iinclude/$(UNAME_M) -I ../rseq -I.. $(EXTRA_CFLAGS) \
0205         $(KHDR_INCLUDES)
0206 
0207 no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
0208         $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)
0209 
0210 # On s390, build the testcases KVM-enabled
0211 pgste-option = $(call try-run, echo 'int main() { return 0; }' | \
0212         $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)
0213 
0214 LDLIBS += -ldl
0215 LDFLAGS += -pthread $(no-pie-option) $(pgste-option)
0216 
0217 # After inclusion, $(OUTPUT) is defined and
0218 # $(TEST_GEN_PROGS) starts with $(OUTPUT)/
0219 include ../lib.mk
0220 
0221 LIBKVM_C := $(filter %.c,$(LIBKVM))
0222 LIBKVM_S := $(filter %.S,$(LIBKVM))
0223 LIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C))
0224 LIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S))
0225 LIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING))
0226 LIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
0227 
0228 EXTRA_CLEAN += $(LIBKVM_OBJS) cscope.*
0229 
0230 x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
0231 $(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
0232         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
0233 
0234 $(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
0235         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
0236 
0237 # Compile the string overrides as freestanding to prevent the compiler from
0238 # generating self-referential code, e.g. without "freestanding" the compiler may
0239 # "optimize" memcmp() by invoking memcmp(), thus causing infinite recursion.
0240 $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
0241         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
0242 
0243 x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
0244 $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
0245 $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
0246 
0247 cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. 
0248 cscope:
0249         $(RM) cscope.*
0250         (find $(include_paths) -name '*.h' \
0251                 -exec realpath --relative-base=$(PWD) {} \;; \
0252         find . -name '*.c' \
0253                 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
0254         cscope -b