Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Generate hyp_constants.h for the host

In order to avoid exposing hypervisor (EL2) data structures directly to
the host, generate hyp_constants.h to provide constants such as structure
sizes to the host without dragging in the definitions themselves.

Signed-off-by: Will Deacon <will@kernel.org>
Tested-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211202171048.26924-3-will@kernel.org

authored by

Will Deacon and committed by
Marc Zyngier
ed4ed15d 7e04f059

+28
+2
arch/arm64/kvm/.gitignore
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + hyp_constants.h
+16
arch/arm64/kvm/Makefile
··· 25 25 vgic/vgic-its.o vgic/vgic-debug.o 26 26 27 27 kvm-$(CONFIG_HW_PERF_EVENTS) += pmu-emul.o 28 + 29 + always-y := hyp_constants.h hyp-constants.s 30 + 31 + define rule_gen_hyp_constants 32 + $(call filechk,offsets,__HYP_CONSTANTS_H__) 33 + endef 34 + 35 + CFLAGS_hyp-constants.o = -I $(srctree)/$(src)/hyp/include 36 + $(obj)/hyp-constants.s: $(src)/hyp/hyp-constants.c FORCE 37 + $(call if_changed_dep,cc_s_c) 38 + 39 + $(obj)/hyp_constants.h: $(obj)/hyp-constants.s FORCE 40 + $(call if_changed_rule,gen_hyp_constants) 41 + 42 + obj-kvm := $(addprefix $(obj)/, $(kvm-y)) 43 + $(obj-kvm): $(obj)/hyp_constants.h
+10
arch/arm64/kvm/hyp/hyp-constants.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + #include <linux/kbuild.h> 4 + #include <nvhe/memory.h> 5 + 6 + int main(void) 7 + { 8 + DEFINE(STRUCT_HYP_PAGE_SIZE, sizeof(struct hyp_page)); 9 + return 0; 10 + }