From patchwork Wed Nov 30 23:09:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13060668 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 C6831C4321E for ; Wed, 30 Nov 2022 23:13:06 +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:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WlHUT/iRl0Wjat7t1gbGaDZLCdQjq1CS0t/Qm2l/q4c=; b=oRoXcoZCK7zIYe zXx+ao3VKGRmKwTrUFakm6dbMW0AlX9FoFDHYEv3+/KOL1gjLfao3JFmVxRrru5WwRYKEDmW4Y0SD QTTg/CDXBl+s6ZIIteAH6SGP4nJr2QzWkGDUpDj7220fouiffebWuqQ1qtXEmKPjKc8ooJ9vYihE6 ej7uWCqGrrP7ZdATqnuMQTpH6erI42Pv3elt5EAJnv5o95Y8fjf2Myd0cuPAQlCUlMhZKer0RehFU aQs3diMJI7wbMB0fKMybLEwLnNgkmx3the/roLi9rBEXwIlqj7WDoBzMhzj3hy3hwZwcfeIIXAUuG mup4uvHNpPkCgqI72fiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0WGB-0037kj-4N; Wed, 30 Nov 2022 23:12:59 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0WDd-0036T1-Lb for linux-riscv@lists.infradead.org; Wed, 30 Nov 2022 23:10:23 +0000 Received: by mail-pf1-x449.google.com with SMTP id z19-20020a056a001d9300b0056df4b6f421so202726pfw.4 for ; Wed, 30 Nov 2022 15:10:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=sCL5nUY5jVECdqbz+DtfaNancd0JoKLrDsCNzQeZ4VM=; b=FdJXVaCerL0aYXlSKCNZGaBsvhStCr0raOxBeYIkp4Eahw58g8dUGOpjjTZmNCmTe0 mkfDd/jmN5dDwhAszOU5fy3Z2W7/1AljlI0GNy9pf8gtw1DfpMPRyWAgaw/dH7x/k+e6 ElYy/YZxg7mPUT8eVlsbEwMxRfjFKCESq4lpHqyvLKLyNyU3+0kw+OatGoe/LZdK65Gm iDCtq/GyihCca4Nix9chWcnsGAukForJwZUR0+JY1L+Pf5Gk3bKEFqAVQzlBFWu3/frk 9DcYaRLE/q/y1bYN4asBB9T511P9HVDAxCLbepbuuyEkNPOgwPqEFTJkjpVg81LSfjfV pvJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sCL5nUY5jVECdqbz+DtfaNancd0JoKLrDsCNzQeZ4VM=; b=uuMFcar9Z+ZbvxSNj6iI7zHJnztS/vfzpwUalkoH+BuUBeFRwatUNLr1UDWZBGuOiA sduHPKRnFfw9xd+HA5+Z4PFsDXLt6ljG/CQVBuSBDwIVpWJ5slCpdRffzzuzQ+1Dpg+K VIR2unZvXjiaQeunwcXCsX1lt+G6EraAi6xrWSZUOQQQExI9UxYhWWwQxSTSrZra53ko CxJq6jvB/88cW/xlcFpBQhXbb8xG8hIKIxmd88XW0gc2evFQseyg+SuhAtb17m11heSy 86k7HSoxNR1lKIqOP3ZzsH7uY3G6bqPlSub1LsONalN17jw0GbkL77SZ0WMtArAY/KiA YuiA== X-Gm-Message-State: ANoB5pn+EIebQEyNwjXbnznLH2Rm/8etpqkmNMBfYKotQRPv3sCABtSo 9EwjX02l1Bthlvy07p+u3LkqXA2aGNg= X-Google-Smtp-Source: AA0mqf5VFykTikxn6Nmxzh1/iLDcJ+DMZWcjAIIeDPd3Nna5HVSkx0xzOx2E3cTUFx7HQ+ZbJkQjtPKQzYw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:aa7:8493:0:b0:563:8d32:abdc with SMTP id u19-20020aa78493000000b005638d32abdcmr44676437pfn.47.1669849820421; Wed, 30 Nov 2022 15:10:20 -0800 (PST) Date: Wed, 30 Nov 2022 23:09:09 +0000 In-Reply-To: <20221130230934.1014142-1-seanjc@google.com> Mime-Version: 1.0 References: <20221130230934.1014142-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221130230934.1014142-26-seanjc@google.com> Subject: [PATCH v2 25/50] KVM: RISC-V: Tag init functions and data with __init, __ro_after_init From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Sean Christopherson , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao , Cornelia Huck , Isaku Yamahata , " =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= " , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_151021_750589_492AE2F9 X-CRM114-Status: GOOD ( 11.48 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that KVM setup is handled directly in riscv_kvm_init(), tag functions and data that are used/set only during init with __init/__ro_after_init. Signed-off-by: Sean Christopherson Acked-by: Anup Patel --- arch/riscv/include/asm/kvm_host.h | 6 +++--- arch/riscv/kvm/mmu.c | 12 ++++++------ arch/riscv/kvm/vmid.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h index 8c771fc4f5d2..778ff0f282b7 100644 --- a/arch/riscv/include/asm/kvm_host.h +++ b/arch/riscv/include/asm/kvm_host.h @@ -295,11 +295,11 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu, int kvm_riscv_gstage_alloc_pgd(struct kvm *kvm); void kvm_riscv_gstage_free_pgd(struct kvm *kvm); void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu); -void kvm_riscv_gstage_mode_detect(void); -unsigned long kvm_riscv_gstage_mode(void); +void __init kvm_riscv_gstage_mode_detect(void); +unsigned long __init kvm_riscv_gstage_mode(void); int kvm_riscv_gstage_gpa_bits(void); -void kvm_riscv_gstage_vmid_detect(void); +void __init kvm_riscv_gstage_vmid_detect(void); unsigned long kvm_riscv_gstage_vmid_bits(void); int kvm_riscv_gstage_vmid_init(struct kvm *kvm); bool kvm_riscv_gstage_vmid_ver_changed(struct kvm_vmid *vmid); diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index 3620ecac2fa1..f42a34c7879a 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -20,12 +20,12 @@ #include #ifdef CONFIG_64BIT -static unsigned long gstage_mode = (HGATP_MODE_SV39X4 << HGATP_MODE_SHIFT); -static unsigned long gstage_pgd_levels = 3; +static unsigned long gstage_mode __ro_after_init = (HGATP_MODE_SV39X4 << HGATP_MODE_SHIFT); +static unsigned long gstage_pgd_levels __ro_after_init = 3; #define gstage_index_bits 9 #else -static unsigned long gstage_mode = (HGATP_MODE_SV32X4 << HGATP_MODE_SHIFT); -static unsigned long gstage_pgd_levels = 2; +static unsigned long gstage_mode __ro_after_init = (HGATP_MODE_SV32X4 << HGATP_MODE_SHIFT); +static unsigned long gstage_pgd_levels __ro_after_init = 2; #define gstage_index_bits 10 #endif @@ -760,7 +760,7 @@ void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu) kvm_riscv_local_hfence_gvma_all(); } -void kvm_riscv_gstage_mode_detect(void) +void __init kvm_riscv_gstage_mode_detect(void) { #ifdef CONFIG_64BIT /* Try Sv57x4 G-stage mode */ @@ -784,7 +784,7 @@ void kvm_riscv_gstage_mode_detect(void) #endif } -unsigned long kvm_riscv_gstage_mode(void) +unsigned long __init kvm_riscv_gstage_mode(void) { return gstage_mode >> HGATP_MODE_SHIFT; } diff --git a/arch/riscv/kvm/vmid.c b/arch/riscv/kvm/vmid.c index 6cd93995fb65..5246da1c9167 100644 --- a/arch/riscv/kvm/vmid.c +++ b/arch/riscv/kvm/vmid.c @@ -17,10 +17,10 @@ static unsigned long vmid_version = 1; static unsigned long vmid_next; -static unsigned long vmid_bits; +static unsigned long vmid_bits __ro_after_init; static DEFINE_SPINLOCK(vmid_lock); -void kvm_riscv_gstage_vmid_detect(void) +void __init kvm_riscv_gstage_vmid_detect(void) { unsigned long old;