From patchwork Tue Nov 17 18:15:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 11913159 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=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 DD08BC5519F for ; Tue, 17 Nov 2020 18:19:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 6BB8A221FD for ; Tue, 17 Nov 2020 18:19:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="te49Ky7I"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="E0fCuokE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BB8A221FD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=frPdwMUWFyjNOOqQ2ExoYajbjslU/YtT1Yr/lav81uc=; b=te49Ky7IffYneSiV+x4SVINPn GeWZemBgt7ZGTYNxFZn9BE4FORN24EKsiz4BJ+ljAkA/6IeEYWdyV0KjYENNzLMpnyG/qGesEmJUd 9HJJnwXKcdfg+f+qvGPb5sCSdqTjtqvlvjS2qImaMzJN+VoXX0F8vP8urHgwloTWp6+KWhTbKRoAz HuSAjnQ4qcdh6wPZ32tFl7nReX/dQr4mPPmY9DzUlLCEN0HLWOCyDtBTRjrGly/G3rPjy93UTmZbJ 2FyZJ4pvl/1TX7xL4DsxmoGyIfH4C53IohSn7hZAJIpf2fJpR0qEcUzTx4QY+VVz+PCfZ0b+OH4iG Yg0ko6bZw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf5Z7-00039l-U4; Tue, 17 Nov 2020 18:18:54 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf5X1-0002Gf-C0 for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2020 18:16:44 +0000 Received: by mail-qv1-xf49.google.com with SMTP id u19so13699583qvx.4 for ; Tue, 17 Nov 2020 10:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=TDLolWJ6DLDdLZxFLwTPZoAbRqc8wO9K1ZVQwJmhgQI=; b=E0fCuokET/iSPfCmN0hv1bpwVzG19gOi60bqbVg4tbU/MXV8JkAYrWoJTWsyKtcZmb NCzh+HSrGM/VrpPjSSavb+jAMioMF4i51wNcX3ISkV63+fEwxFrZc6vXKw/yNZVQcwCy 05Hvg2hX6rvUiRO1FEufam8DDHknNkWZPYw2fzBkTd8AuB8YloMYzzbBHwuePeZao66I UYUGCo9WEpMJep8NfwFKG2NCoQu+vd/Oqeqg/bAdwkpHhbpnuHl+hVrGxKJS3KlbgYWl e+Gk+eHeUbd/8E9fdjlIquCJgsoKzgzbJUq0eQYXqTuK5nk5LEhfuIzVSQAxYT+jwcTN pZ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TDLolWJ6DLDdLZxFLwTPZoAbRqc8wO9K1ZVQwJmhgQI=; b=KkYiGJy1ZB3rPmTd3VT0Gs0AFZspdOGXUgYuNeuh1sM7h1RfMDaN/PWXvEFqbvYoj2 +z2BsyLPxsMWqTVWs9HCniqz4HdTCFV6IpVD7/pth90UtcZsSozQBlSTF0yq5HTuH6jf M76SycWOg78K/NATYf7LoLR8Y119Y/U8KdS3pKLAgDMaWBH3gFb3h7gmc8dA3xsSSj6F EFZMjvf4AxkDEoNhWf6gKlk6Kb8Y1JiAtz9imJhqIXRFQZcIs1PsNjWb688P9qYW1NL0 vmMSI72Vkgjsxu7aJPc0ti566IW68DWw1O2oF00HV5q3basWJV0kN4RGW2KSe52Y6SCE fLKg== X-Gm-Message-State: AOAM5316L7EcGH//g8tRVxoyYcwhOSGl+o33gi1fqFGvEVGB1pXy+84y AY49y/u4HGp3bHEcq2JdeI9Lnqt+97eQ X-Google-Smtp-Source: ABdhPJzbODkjl7s4UxQH0AkdtMhlkcj6CRSeDqE2+AHaFV3kAPIwJibRapqdnHmTcqcB2PiXnAFDr9sXfpa9 X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) (user=qperret job=sendgmr) by 2002:a0c:df08:: with SMTP id g8mr854334qvl.17.1605636999772; Tue, 17 Nov 2020 10:16:39 -0800 (PST) Date: Tue, 17 Nov 2020 18:15:49 +0000 In-Reply-To: <20201117181607.1761516-1-qperret@google.com> Message-Id: <20201117181607.1761516-10-qperret@google.com> Mime-Version: 1.0 References: <20201117181607.1761516-1-qperret@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [RFC PATCH 09/27] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code From: Quentin Perret To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201117_131643_468951_10AFD1EC X-CRM114-Status: GOOD ( 14.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Quentin Perret , android-kvm@google.com, open list , kernel-team@android.com, "open list:KERNEL VIRTUAL MACHINE FOR ARM64 \(KVM/arm64\)" , "moderated list:ARM64 PORT \(AARCH64 ARCHITECTURE\)" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to allow the usage of code shared by the host and the hyp in static inline library function, allow the usage of kvm_nvhe_sym() at el2 by defaulting to the raw symbol name. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/hyp_image.h | 4 ++++ arch/arm64/include/asm/kvm_asm.h | 4 ++-- arch/arm64/kvm/arm.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/hyp_image.h b/arch/arm64/include/asm/hyp_image.h index daa1a1da539e..8b807b646b8f 100644 --- a/arch/arm64/include/asm/hyp_image.h +++ b/arch/arm64/include/asm/hyp_image.h @@ -7,11 +7,15 @@ #ifndef __ARM64_HYP_IMAGE_H__ #define __ARM64_HYP_IMAGE_H__ +#ifndef __KVM_NVHE_HYPERVISOR__ /* * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, * to separate it from the kernel proper. */ #define kvm_nvhe_sym(sym) __kvm_nvhe_##sym +#else +#define kvm_nvhe_sym(sym) sym +#endif #ifdef LINKER_SCRIPT diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index 1a86581e581e..e4934f5e4234 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -173,11 +173,11 @@ struct kvm_s2_mmu; DECLARE_KVM_NVHE_SYM(__kvm_hyp_init); DECLARE_KVM_NVHE_SYM(__kvm_hyp_host_vector); DECLARE_KVM_HYP_SYM(__kvm_hyp_vector); -DECLARE_KVM_NVHE_SYM(__kvm_hyp_psci_cpu_entry); #define __kvm_hyp_init CHOOSE_NVHE_SYM(__kvm_hyp_init) #define __kvm_hyp_host_vector CHOOSE_NVHE_SYM(__kvm_hyp_host_vector) #define __kvm_hyp_vector CHOOSE_HYP_SYM(__kvm_hyp_vector) -#define __kvm_hyp_psci_cpu_entry CHOOSE_NVHE_SYM(__kvm_hyp_psci_cpu_entry) + +void kvm_nvhe_sym(__kvm_hyp_psci_cpu_entry)(void); extern unsigned long kvm_arm_hyp_percpu_base[NR_CPUS]; DECLARE_KVM_NVHE_SYM(__per_cpu_start); diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 882eb383bd75..391cf6753a13 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1369,7 +1369,7 @@ static void cpu_prepare_hyp_mode(int cpu) params->vector_hyp_va = kern_hyp_va((unsigned long)kvm_ksym_ref(__kvm_hyp_host_vector)); params->stack_hyp_va = kern_hyp_va(per_cpu(kvm_arm_hyp_stack_page, cpu) + PAGE_SIZE); - params->entry_hyp_va = kern_hyp_va((unsigned long)kvm_ksym_ref(__kvm_hyp_psci_cpu_entry)); + params->entry_hyp_va = kern_hyp_va((unsigned long)kvm_ksym_ref_nvhe(__kvm_hyp_psci_cpu_entry)); params->pgd_pa = kvm_mmu_get_httbr(); /*