1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2edf88417SAvi Kivity 36fb3084aSSiddharth Chandrasekaranccflags-y += -I $(srctree)/arch/x86/kvm 44f337fafSPaolo Bonziniccflags-$(CONFIG_KVM_WERROR) += -Werror 5edf88417SAvi Kivity 66f2cdbdbSDavid Woodhouseinclude $(srctree)/virt/kvm/Makefile.kvm 7284e9b0fSChristoph Hellwig 8e76c2745SSean Christophersonkvm-y += x86.o emulate.o irq.o lapic.o cpuid.o pmu.o mtrr.o \ 9e76c2745SSean Christopherson debugfs.o mmu/mmu.o mmu/page_track.o mmu/spte.o 103c86c0d3SVineeth Pillai 11897218ffSPaolo Bonzinikvm-$(CONFIG_X86_64) += mmu/tdp_iter.o mmu/tdp_mmu.o 12628a2773SSean Christophersonkvm-$(CONFIG_KVM_IOAPIC) += i8259.o i8254.o ioapic.o 13b4f69df0SVitaly Kuznetsovkvm-$(CONFIG_KVM_HYPERV) += hyperv.o 14b59b153dSPaolo Bonzinikvm-$(CONFIG_KVM_XEN) += xen.o 154b8e1b32SPaolo Bonzinikvm-$(CONFIG_KVM_SMM) += smm.o 16e83d5887SAndrey Smetanin 178888cdd0SXiaoyao Likvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ 185f18c642SPaolo Bonzini vmx/nested.o vmx/posted_intr.o vmx/main.o 199798adbcSSean Christopherson 20b4f69df0SVitaly Kuznetsovkvm-intel-$(CONFIG_X86_SGX_KVM) += vmx/sgx.o 21b4f69df0SVitaly Kuznetsovkvm-intel-$(CONFIG_KVM_HYPERV) += vmx/hyperv.o vmx/hyperv_evmcs.o 22fcdbdf63SKai Huangkvm-intel-$(CONFIG_KVM_INTEL_TDX) += vmx/tdx.o 2350a82b0eSVitaly Kuznetsov 240d7bf5e5SPaolo Bonzinikvm-amd-y += svm/svm.o svm/vmenter.o svm/pmu.o svm/nested.o svm/avic.o 250d7bf5e5SPaolo Bonzini 260d7bf5e5SPaolo Bonzinikvm-amd-$(CONFIG_KVM_AMD_SEV) += svm/sev.o 27b4f69df0SVitaly Kuznetsovkvm-amd-$(CONFIG_KVM_HYPERV) += svm/hyperv.o 28284e9b0fSChristoph Hellwig 291183646aSVineeth Pillaiifdef CONFIG_HYPERV 30b4f69df0SVitaly Kuznetsovkvm-y += kvm_onhyperv.o 31b4f69df0SVitaly Kuznetsovkvm-intel-y += vmx/vmx_onhyperv.o vmx/hyperv_evmcs.o 321183646aSVineeth Pillaikvm-amd-y += svm/svm_onhyperv.o 331183646aSVineeth Pillaiendif 341183646aSVineeth Pillai 35ea4290d7SPaolo Bonziniobj-$(CONFIG_KVM_X86) += kvm.o 36edf88417SAvi Kivityobj-$(CONFIG_KVM_INTEL) += kvm-intel.o 37edf88417SAvi Kivityobj-$(CONFIG_KVM_AMD) += kvm-amd.o 38debc5a1eSPaolo Bonzini 3916fdc1deSPaolo BonziniAFLAGS_svm/vmenter.o := -iquote $(obj) 4016fdc1deSPaolo Bonzini$(obj)/svm/vmenter.o: $(obj)/kvm-asm-offsets.h 4116fdc1deSPaolo Bonzini 42debc5a1eSPaolo BonziniAFLAGS_vmx/vmenter.o := -iquote $(obj) 43debc5a1eSPaolo Bonzini$(obj)/vmx/vmenter.o: $(obj)/kvm-asm-offsets.h 44debc5a1eSPaolo Bonzini 45debc5a1eSPaolo Bonzini$(obj)/kvm-asm-offsets.h: $(obj)/kvm-asm-offsets.s FORCE 46debc5a1eSPaolo Bonzini $(call filechk,offsets,__KVM_ASM_OFFSETS_H__) 47debc5a1eSPaolo Bonzini 48debc5a1eSPaolo Bonzinitargets += kvm-asm-offsets.s 49debc5a1eSPaolo Bonziniclean-files += kvm-asm-offsets.h 50*fc4d3a65SSean Christopherson 51*fc4d3a65SSean Christopherson 52*fc4d3a65SSean Christopherson# Fail the build if there is unexpected EXPORT_SYMBOL_GPL (or EXPORT_SYMBOL) 53*fc4d3a65SSean Christopherson# usage. All KVM-internal exports should use EXPORT_SYMBOL_FOR_KVM_INTERNAL. 54*fc4d3a65SSean Christopherson# Only a handful of exports intended for other modules (VFIO, KVMGT) should 55*fc4d3a65SSean Christopherson# use EXPORT_SYMBOL_GPL, and EXPORT_SYMBOL should never be used. 56*fc4d3a65SSean Christophersonifdef CONFIG_KVM_X86 57*fc4d3a65SSean Christopherson# Search recursively for whole words and print line numbers. Filter out the 58*fc4d3a65SSean Christopherson# allowed set of exports, i.e. those that are intended for external usage. 59*fc4d3a65SSean Christophersonexports_grep_trailer := --include='*.[ch]' -nrw $(srctree)/virt/kvm $(srctree)/arch/x86/kvm | \ 60*fc4d3a65SSean Christopherson grep -v -e kvm_page_track_register_notifier \ 61*fc4d3a65SSean Christopherson -e kvm_page_track_unregister_notifier \ 62*fc4d3a65SSean Christopherson -e kvm_write_track_add_gfn \ 63*fc4d3a65SSean Christopherson -e kvm_write_track_remove_gfn \ 64*fc4d3a65SSean Christopherson -e kvm_get_kvm \ 65*fc4d3a65SSean Christopherson -e kvm_get_kvm_safe \ 66*fc4d3a65SSean Christopherson -e kvm_put_kvm 67*fc4d3a65SSean Christopherson 68*fc4d3a65SSean Christopherson# Force grep to emit a goofy group separator that can in turn be replaced with 69*fc4d3a65SSean Christopherson# the above newline macro (newlines in Make are a nightmare). Note, grep only 70*fc4d3a65SSean Christopherson# prints the group separator when N lines of context are requested via -C, 71*fc4d3a65SSean Christopherson# a.k.a. --NUM. Simply request zero lines. Print the separator only after 72*fc4d3a65SSean Christopherson# filtering out expected exports to avoid extra newlines in the error message. 73*fc4d3a65SSean Christophersondefine get_kvm_exports 74*fc4d3a65SSean Christopherson$(shell grep "$(1)" -C0 $(exports_grep_trailer) | grep "$(1)" -C0 --group-separator="!SEP!") 75*fc4d3a65SSean Christophersonendef 76*fc4d3a65SSean Christopherson 77*fc4d3a65SSean Christophersondefine check_kvm_exports 78*fc4d3a65SSean Christophersonnr_kvm_exports := $(shell grep "$(1)" $(exports_grep_trailer) | wc -l) 79*fc4d3a65SSean Christopherson 80*fc4d3a65SSean Christophersonifneq (0,$$(nr_kvm_exports)) 81*fc4d3a65SSean Christopherson$$(error ERROR ***\ 82*fc4d3a65SSean Christopherson$$(newline)found $$(nr_kvm_exports) unwanted occurrences of $(1):\ 83*fc4d3a65SSean Christopherson$$(newline) $(subst !SEP!,$$(newline) ,$(call get_kvm_exports,$(1)))\ 84*fc4d3a65SSean Christopherson$$(newline)in directories:\ 85*fc4d3a65SSean Christopherson$$(newline) $(srctree)/arch/x86/kvm\ 86*fc4d3a65SSean Christopherson$$(newline) $(srctree)/virt/kvm\ 87*fc4d3a65SSean Christopherson$$(newline)Use EXPORT_SYMBOL_FOR_KVM_INTERNAL, not $(1)) 88*fc4d3a65SSean Christophersonendif # nr_kvm_exports != 0 89*fc4d3a65SSean Christophersonundefine nr_kvm_exports 90*fc4d3a65SSean Christophersonendef # check_kvm_exports 91*fc4d3a65SSean Christopherson 92*fc4d3a65SSean Christopherson$(eval $(call check_kvm_exports,EXPORT_SYMBOL_GPL)) 93*fc4d3a65SSean Christopherson$(eval $(call check_kvm_exports,EXPORT_SYMBOL)) 94*fc4d3a65SSean Christopherson 95*fc4d3a65SSean Christophersonundefine check_kvm_exports 96*fc4d3a65SSean Christophersonundefine get_kvm_exports 97*fc4d3a65SSean Christophersonundefine exports_grep_trailer 98*fc4d3a65SSean Christophersonendif # CONFIG_KVM_X86 99