From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03AA1C433B4 for ; Tue, 4 May 2021 14:50:23 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BBE161175 for ; Tue, 4 May 2021 14:50:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BBE161175 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HWk35s2h/kYk6JWORe3ilKpovlhLwUxbNxTzsofsa8s=; b=ix3SLOVxaWdo496tkkd+Km6N5 3xaPQYHObZTqa0Z0vCRlimWOZgXxbCws1tFeF0Gfpv8M9rI763ePtcda6R27Nru7d9wze/J68BEfj Sqm3mbDHpTpz9iTHo+Fa4EzWfxPyFqypWc1uf6CDLJ7+MgeljxOqZTVeln2toenffWjbX3r5joXJJ Prev9mlEpMpknn4fnHLY2H5Dp7YMS2ohrC3YcDVapGQ8/o3MTCdX2kYrkDb2JRkQuz3sDQuBtUiZb xGMCT5n9lv/FxL1vWPaOw0uZw83N8/gK70/wHBRRGvPYzZePj0vxEgd4L0iMSkcfK5sWxPm7M4B0V 6Xe2VKeXw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ldwLs-00GO1I-SM; Tue, 04 May 2021 14:48:45 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldwLq-00GO0v-2N for linux-arm-kernel@desiato.infradead.org; Tue, 04 May 2021 14:48:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=ZdnkN5ICt/SkFxgX40PMOCB89b2MDJYUx+B8oGK9YpA=; b=Xme3u0Z72pw8KV+XZKVwo/TZps ZwB1xflIrCbmjnk2JQX1DecXtZAc8taLSyRYOW8q6vHlRX6/FFC99dUF6mIS+SZnGrIH+Nuf3EBPK wpg/Emf7hYdM5o8tjVPxxMZqd6evMT1TKBPTb9/PfHJ3JJWB/z45JbnRmr7Pp24A1QejoAMky4avH OzwvFDHcNtT2uUMhmG//JPn8J576xb/PtvQtt5LxIUJWG3xGQ+avUrIm96DRGQX0ZzhKMMGWJrkb1 mW/ty0f1nuUeWJRbc7CRfIIlfJ1iEcYzvl3mXwEQdZZ5dWHpiIIXp6DrW178tyD05Fhw8hbYceUvE hfZFMTtg==; Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldwLn-0042xo-24 for linux-arm-kernel@lists.infradead.org; Tue, 04 May 2021 14:48:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620139715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZdnkN5ICt/SkFxgX40PMOCB89b2MDJYUx+B8oGK9YpA=; b=Fev/87721/Y7LBNvmSM48uYP+FLl5ECW+OeGLfj2AwFlX8c3EckQdtnY2cywVO2NyrLBT/ TT7RQTdU/xJgKsGIA13ouFl9hA/6HM2SttHkc8i1e+yVK1uLbVTDtvMPVDX8aqmud7o5h0 3on9LVJ1wOdjGqyRDn6fvEkgYRS4EMY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-3SwFKME1PLq8QCJvJvMJpw-1; Tue, 04 May 2021 10:48:33 -0400 X-MC-Unique: 3SwFKME1PLq8QCJvJvMJpw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BBE810CEF00; Tue, 4 May 2021 14:47:43 +0000 (UTC) Received: from [10.36.113.191] (ovpn-113-191.ams2.redhat.com [10.36.113.191]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 747E95B4A4; Tue, 4 May 2021 14:47:38 +0000 (UTC) Subject: Re: [PATCH 15/56] KVM: arm64: Add build rules for separate VHE/nVHE object files To: Marc Zyngier , Paolo Bonzini Cc: Alexander Graf , Alexandru Elisei , Andrew Scull , Catalin Marinas , Christoffer Dall , David Brazdil , Gavin Shan , James Morse , Mark Rutland , Peng Hao , Quentin Perret , Will Deacon , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com References: <20200805175700.62775-1-maz@kernel.org> <20200805175700.62775-16-maz@kernel.org> From: Auger Eric Message-ID: <2ff3a1cb-a310-7963-4171-bd1e7d08e39b@redhat.com> Date: Tue, 4 May 2021 16:47:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20200805175700.62775-16-maz@kernel.org> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210504_074839_220239_F56ACC4C X-CRM114-Status: GOOD ( 33.63 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi David, Marc, On 8/5/20 7:56 PM, Marc Zyngier wrote: > From: David Brazdil > > Add new folders arch/arm64/kvm/hyp/{vhe,nvhe} and Makefiles for building code > that runs in EL2 under VHE/nVHE KVM, repsectivelly. Add an include folder for > hyp-specific header files which will include code common to VHE/nVHE. > > Build nVHE code with -D__KVM_NVHE_HYPERVISOR__, VHE code with > -D__KVM_VHE_HYPERVISOR__. > > Under nVHE compile each source file into a `.hyp.tmp.o` object first, then > prefix all its symbols with "__kvm_nvhe_" using `objcopy` and produce > a `.hyp.o`. Suffixes were chosen so that it would be possible for VHE and nVHE > to share some source files, but compiled with different CFLAGS. > > The nVHE ELF symbol prefix is added to kallsyms.c as ignored. EL2-only symbols > will never appear in EL1 stack traces. > > Due to symbol prefixing, add a section in image-vars.h for aliases of symbols > that are defined in nVHE EL2 and accessed by kernel in EL1 or vice versa. > > Signed-off-by: David Brazdil > Signed-off-by: Marc Zyngier > Link: https://lore.kernel.org/r/20200625131420.71444-4-dbrazdil@google.com > --- > arch/arm64/kernel/image-vars.h | 14 +++++++++++++ > arch/arm64/kvm/hyp/Makefile | 10 +++++++--- > arch/arm64/kvm/hyp/nvhe/Makefile | 34 ++++++++++++++++++++++++++++++++ > arch/arm64/kvm/hyp/vhe/Makefile | 17 ++++++++++++++++ > scripts/kallsyms.c | 1 + > 5 files changed, 73 insertions(+), 3 deletions(-) > create mode 100644 arch/arm64/kvm/hyp/nvhe/Makefile > create mode 100644 arch/arm64/kvm/hyp/vhe/Makefile > > diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h > index be0a63ffed23..3dc27da47712 100644 > --- a/arch/arm64/kernel/image-vars.h > +++ b/arch/arm64/kernel/image-vars.h > @@ -51,4 +51,18 @@ __efistub__ctype = _ctype; > > #endif > > +#ifdef CONFIG_KVM > + > +/* > + * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to > + * separate it from the kernel proper. The following symbols are legally > + * accessed by it, therefore provide aliases to make them linkable. > + * Do not include symbols which may not be safely accessed under hypervisor > + * memory mappings. > + */ > + > +#define KVM_NVHE_ALIAS(sym) __kvm_nvhe_##sym = sym; > + > +#endif /* CONFIG_KVM */ > + > #endif /* __ARM64_KERNEL_IMAGE_VARS_H */ > diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile > index 5d8357ddc234..9c5dfe6ff80b 100644 > --- a/arch/arm64/kvm/hyp/Makefile > +++ b/arch/arm64/kvm/hyp/Makefile > @@ -3,10 +3,14 @@ > # Makefile for Kernel-based Virtual Machine module, HYP part > # > > -ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING \ > - $(DISABLE_STACKLEAK_PLUGIN) > +incdir := $(srctree)/$(src)/include > +subdir-asflags-y := -I$(incdir) > +subdir-ccflags-y := -I$(incdir) \ > + -fno-stack-protector \ > + -DDISABLE_BRANCH_PROFILING \ > + $(DISABLE_STACKLEAK_PLUGIN) > > -obj-$(CONFIG_KVM) += hyp.o > +obj-$(CONFIG_KVM) += hyp.o nvhe/ > obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o > > hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ > diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile > new file mode 100644 > index 000000000000..955f4188e00f > --- /dev/null > +++ b/arch/arm64/kvm/hyp/nvhe/Makefile > @@ -0,0 +1,34 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Makefile for Kernel-based Virtual Machine module, HYP/nVHE part > +# > + > +asflags-y := -D__KVM_NVHE_HYPERVISOR__ > +ccflags-y := -D__KVM_NVHE_HYPERVISOR__ > + > +obj-y := > + > +obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) > +extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y)) > + > +$(obj)/%.hyp.tmp.o: $(src)/%.c FORCE > + $(call if_changed_rule,cc_o_c) > +$(obj)/%.hyp.tmp.o: $(src)/%.S FORCE > + $(call if_changed_rule,as_o_S) > +$(obj)/%.hyp.o: $(obj)/%.hyp.tmp.o FORCE > + $(call if_changed,hypcopy) > + > +quiet_cmd_hypcopy = HYPCOPY $@ > + cmd_hypcopy = $(OBJCOPY) --prefix-symbols=__kvm_nvhe_ $< $@ > + > +# KVM nVHE code is run at a different exception code with a different map, so > +# compiler instrumentation that inserts callbacks or checks into the code may > +# cause crashes. Just disable it. > +GCOV_PROFILE := n > +KASAN_SANITIZE := n > +UBSAN_SANITIZE := n > +KCOV_INSTRUMENT := n > + > +# Skip objtool checking for this directory because nVHE code is compiled with > +# non-standard build rules. > +OBJECT_FILES_NON_STANDARD := y > diff --git a/arch/arm64/kvm/hyp/vhe/Makefile b/arch/arm64/kvm/hyp/vhe/Makefile > new file mode 100644 > index 000000000000..e04375546081 > --- /dev/null > +++ b/arch/arm64/kvm/hyp/vhe/Makefile > @@ -0,0 +1,17 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Makefile for Kernel-based Virtual Machine module, HYP/nVHE part > +# > + > +asflags-y := -D__KVM_VHE_HYPERVISOR__ > +ccflags-y := -D__KVM_VHE_HYPERVISOR__ > + > +obj-y := > + > +# KVM code is run at a different exception code with a different map, so > +# compiler instrumentation that inserts callbacks or checks into the code may > +# cause crashes. Just disable it. > +GCOV_PROFILE := n > +KASAN_SANITIZE := n > +UBSAN_SANITIZE := n > +KCOV_INSTRUMENT := n > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > index 6dc3078649fa..0096cd965332 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -109,6 +109,7 @@ static bool is_ignored_symbol(const char *name, char type) > ".LASANPC", /* s390 kasan local symbols */ > "__crc_", /* modversions */ > "__efistub_", /* arm64 EFI stub namespace */ > + "__kvm_nvhe_", /* arm64 non-VHE KVM namespace */ The addition of this line seems to have introduced errors on the 'vmlinux symtab matches kallsyms' perf test (perf test -v 1) which fails on aarch64 for all __kvm_nvhe_ prefixed symbols, like ERR : : __kvm_nvhe___invalid not on kallsyms ERR : : __kvm_nvhe___do_hyp_init not on kallsyms ERR : : __kvm_nvhe___kvm_handle_stub_hvc not on kallsyms ERR : : __kvm_nvhe_reset not on kallsyms ../.. I understand we willingly hided those symbols from /proc/kallsyms. Do you confirm the right fix is to upgrade the perf test suite accordingly? Thanks Eric > NULL > }; > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel