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.6 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 802ADC433ED for ; Tue, 18 May 2021 11:51:10 +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 07C44611BF for ; Tue, 18 May 2021 11:51:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07C44611BF 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:References: Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LfgfMHU/iW1dhAXXKaWkg6wNVIto8G8Bb2G2L6TyK5o=; b=U8yRjgtQ/bukuoot4Bu3c3L2+ DApo5Y5Wp2A+ke+g7vPpZZ3a9ouoHb+6MskxJEz3CaetCR5smEH4INop02KJkfVBwK9U4ZA7gb2Y5 olCYNPtxLQr29rLazC/Sjj5hnxq+pqGkLRH/N0mKozm4Tphew8uCVrZc3Lm4904VfUr7GPSBPr8AJ MNJs93XdTqfrwqJXCh13Et4vFxXzyOHVGUESvm/YW0ozxLeHuqNxS31XvYeL0hGuEqP41dSXV9v+z YD9YaGdQX7xB9ugFcKEbh10qXUEsNP+SFrBM1lKkTO+ayvuNJF+8yuPKDSBi62Xv0v4KWIMUUjhKR Fd+JjEiUw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liyDj-000dU2-6N; Tue, 18 May 2021 11:49:08 +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 1liyDe-000dTa-R6 for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 11:49:03 +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:References:Cc:To:From: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=mlQ7G6nQMS0+u70jyAdMN6frxJBI8Gxh0QekrRUBeO0=; b=wjqMBD3b7NyIQjoaek3NAWfNj/ 2vZlRJoB29qB87E3e8ToS2PMEgs7SFAsHuXa5Od/lY5JqevpVo7gGvfHusOxgZfuLRRvYxRmFAEwp Yg/y/ZUSOl1r+VwblF2RCeWiQL8h5Kr/I0NCYcx59CfcO4DD+YdUwQIVprF3VFKuKO5LcNttWBed3 SnCyzhN145sYO7GkIUpKpRJK7wCA1Qt879N4pvZHMlt7DTiTermvM6Ns2pVHUgz0iDXWuPHfzEdq+ L80oVq+eNMwsdloi3l/NNgv2igiEtANJZBlEI7cldhFq3i5t+XX7uTt8zPzfbQUeFe16Uc9Towzoi B+lWvSCw==; 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 1liyDb-00EcFA-Gu for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 11:49:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621338534; 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=mlQ7G6nQMS0+u70jyAdMN6frxJBI8Gxh0QekrRUBeO0=; b=c8Wx0W77KntKqi5egR/Yn4KdpMgSzgZOOhQqwYNp4Y6ih63kPsGxTVRECHJB5Ru12qScFX e+m1fFdF+cZF9ShbygPVNd3QISRDDlKyd4LP6HKoQ7PdoqZBnzgZEJxTRTw97cLmiSTqYc q1tSQYwngPVItcPSKOMDzL+jMIdAf1k= 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-209-h6kIOpP2MM6TE80SuJXNVA-1; Tue, 18 May 2021 07:48:53 -0400 X-MC-Unique: h6kIOpP2MM6TE80SuJXNVA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A794C107ACE3; Tue, 18 May 2021 11:48:50 +0000 (UTC) Received: from [10.36.114.156] (ovpn-114-156.ams2.redhat.com [10.36.114.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 457A860855; Tue, 18 May 2021 11:48:43 +0000 (UTC) Subject: Re: [PATCH 15/56] KVM: arm64: Add build rules for separate VHE/nVHE object files From: Auger Eric 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> <2ff3a1cb-a310-7963-4171-bd1e7d08e39b@redhat.com> Message-ID: <5d1853ed-3474-edbc-545a-1f88f2a4e5ca@redhat.com> Date: Tue, 18 May 2021 13:48:41 +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: <2ff3a1cb-a310-7963-4171-bd1e7d08e39b@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_044859_678431_81CCE34F X-CRM114-Status: GOOD ( 30.41 ) 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 5/4/21 4:47 PM, Auger Eric wrote: > 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? Were you eventually able to reproduce? Thanks Eric > > Thanks > > Eric > > >> NULL >> }; >> >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel