From patchwork Thu Dec 2 17:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12694540 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42163C433F5 for ; Thu, 2 Dec 2021 17:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vamUxz2l42kyWMQLqPygTMilNk6Ye/WfDaFPfO3kP7Y=; b=h4zhji/FfjQAWH UJUEHwCFGuRiFwRMDMec7WmGKBNwRmhMTJG2L9SttryP5Ugx/3UduqXRj3hLkA8omC25X6AVpmx3Q NQ9goGvj/2XY5HDlgf8blta0ZhzxjgmHMjMNd9mm5PgiBpEcBuhlOPq+v6DYYt/e58NFQ7JUQFZIG qdMj+Rp3KiKiNLZjsEi91RoC0F471tdUImto2SKEMjBZ7n2ODQmLflslj1Gm3favjOO989peHFAzH g3XG+d2IPoPAxy9Vk4i3uPKPsPgybALHj+RpQjXSaTkVrPy625jiUhESTEnpnb4kpUIIM3uEpsPaj x90fiwudYSQs5FhJ5Lig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mspc8-00D7B2-AI; Thu, 02 Dec 2021 17:11:20 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mspbo-00D76b-Pj for linux-arm-kernel@lists.infradead.org; Thu, 02 Dec 2021 17:11:02 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 78CA4B82243; Thu, 2 Dec 2021 17:10:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EBC4C53FD1; Thu, 2 Dec 2021 17:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638465058; bh=v3zl9mHxxg1HALqob7r/4qFX7wNgjAZhwam6ujRoXYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhMSRBAC31b3M+uR2h6BUgD6dSBtG1h5jvckFUOwNENqL8n76zA2hnSIeclNfhBXb 24N1A9Ss8+584XOuZociC2uOnIJKgUS3iu1JRhJ6efa7CFa730fK6cG9amcmggx8Jj 61m41BMVHMmb2sf+Z4w9OHdYVQjndSjzbJ4ff2tApzu1ACjz2sCyeMTGLqzI69pcfZ MAGqo4U++zEp+70th2kq0jrDS2LQkN3ZHPMLNigLUZqWI5XXvHqwjySd5dtNAVBA+v Y7XHquVEX7OcGHW8DXWetBrRF2EzAlpbtXxwpTwn1KebzdtrbMB4muWCEgt3Y6tCJk gIeuZYCKTB3Qg== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Alexandru Elisei , James Morse , Quentin Perret , Suzuki K Poulose , Fuad Tabba , Marc Zyngier Subject: [PATCH 2/3] KVM: arm64: Generate hyp_constants.h for the host Date: Thu, 2 Dec 2021 17:10:47 +0000 Message-Id: <20211202171048.26924-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211202171048.26924-1-will@kernel.org> References: <20211202171048.26924-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211202_091101_015200_93AFB150 X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Tested-by: Fuad Tabba Reviewed-by: Fuad Tabba --- arch/arm64/kvm/.gitignore | 2 ++ arch/arm64/kvm/Makefile | 16 ++++++++++++++++ arch/arm64/kvm/hyp/hyp-constants.c | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 arch/arm64/kvm/.gitignore create mode 100644 arch/arm64/kvm/hyp/hyp-constants.c diff --git a/arch/arm64/kvm/.gitignore b/arch/arm64/kvm/.gitignore new file mode 100644 index 000000000000..6182aefb8302 --- /dev/null +++ b/arch/arm64/kvm/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +hyp_constants.h diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index 989bb5dad2c8..0b561752f8d8 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -25,3 +25,19 @@ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ vgic/vgic-its.o vgic/vgic-debug.o kvm-$(CONFIG_HW_PERF_EVENTS) += pmu-emul.o + +always-y := hyp_constants.h hyp-constants.s + +define rule_gen_hyp_constants + $(call filechk,offsets,__HYP_CONSTANTS_H__) +endef + +CFLAGS_hyp-constants.o = -I $(srctree)/$(src)/hyp/include +$(obj)/hyp-constants.s: $(src)/hyp/hyp-constants.c FORCE + $(call if_changed_dep,cc_s_c) + +$(obj)/hyp_constants.h: $(obj)/hyp-constants.s FORCE + $(call if_changed_rule,gen_hyp_constants) + +obj-kvm := $(addprefix $(obj)/, $(kvm-y)) +$(obj-kvm): $(obj)/hyp_constants.h diff --git a/arch/arm64/kvm/hyp/hyp-constants.c b/arch/arm64/kvm/hyp/hyp-constants.c new file mode 100644 index 000000000000..b3742a6691e8 --- /dev/null +++ b/arch/arm64/kvm/hyp/hyp-constants.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +int main(void) +{ + DEFINE(STRUCT_HYP_PAGE_SIZE, sizeof(struct hyp_page)); + return 0; +}