Skip to content

Commit ed4ed15

Browse files
willdeaconMarc Zyngier
authored andcommitted
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 <[email protected]> Tested-by: Fuad Tabba <[email protected]> Reviewed-by: Fuad Tabba <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7e04f05 commit ed4ed15

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

arch/arm64/kvm/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
hyp_constants.h

arch/arm64/kvm/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \
2525
vgic/vgic-its.o vgic/vgic-debug.o
2626

2727
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

arch/arm64/kvm/hyp/hyp-constants.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

0 commit comments

Comments
 (0)