Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3260319pxb; Fri, 4 Feb 2022 05:05:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkMQVjahK4RCYnFgfCfiY4fAiEuWLCPB6j5pFRnb4ZRfCCeuyvaxUlZOecMBhGbfruAUnc X-Received: by 2002:a17:907:9253:: with SMTP id kb19mr2424607ejb.707.1643979937605; Fri, 04 Feb 2022 05:05:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643979937; cv=none; d=google.com; s=arc-20160816; b=Mbf/fEak3lJ1xIQPNZl6cPAR/AAIAGc8fH1BjYIyyNDxekx2qzN+G6TD3HnF6K9KzS BNw57hD66MLMPf7v7UqgZFsHo++QFMoW4lPb7LLzyPTkukJ6y5O03nwF/+k1BHS6xOtQ 9VPzro1P/QEJ3DWYVz8Y3bB/cSXa2TyKnesuaDZMMchoA8LMD1oDThN3RtWHBPFl+oNP Y06ZlFfSLAlYpvwdRBqOqG/Ly1vQZoLA6yFzVJas6etQ14VKV1LGzUXtMsYoy3B9P5AA +CGOWjEBdkuApjfOz02fSKUIIBlpmaG1oMflQp8cIA5L4g1RXfmdgc4WXeWoEctFSuWV mWgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=23LmqLrLqw9sHYk580lY5bQARRIz3tEWlrRaxErbyko=; b=AP6vqC1Y8NQmCtWHVMLJAUTkVUctu8ewziU+IuqzsXumMe8X9AlSCOExv7ST1SjIYR 7D+kxmemZSJw1vgevcMpSR4HAhdCgSXOvBbxVN4Qf+AV2oaoDKUiTEpBnwBnTXpBsdjE 00+3bVWDJx+JRQfqrACHtlVXfF4BGN+nwMAxXrPUjhFK2SHKbesubQuvUb89e/vHKeFt LqhoDNZzPqS924naLMjOKmC3erPT5YuB1hoN0DZhMWIWGA0qlM9Ea4dRK7k5r4xY+hWf eNev5Kz5rtnZnETTe+8/kBOlomFPg/EKr4qlz21XH6CvEcsfy5A26qvKfGamoXUKxGf3 x7qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OHnf5oWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm11si1082698ejc.173.2022.02.04.05.05.12; Fri, 04 Feb 2022 05:05:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OHnf5oWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358588AbiBDL5c (ORCPT + 99 others); Fri, 4 Feb 2022 06:57:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46156 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358510AbiBDL5Y (ORCPT ); Fri, 4 Feb 2022 06:57:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643975843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=23LmqLrLqw9sHYk580lY5bQARRIz3tEWlrRaxErbyko=; b=OHnf5oWE8syqk8EyXNRfbRd3Pk7AtKXsESd3vCktZEL3BvFuBLWW52wRWPgFYj+u2Y3z4j 1BNW6h/K86fTIOVLJouXWQnBF2gWK16RRa34aSbC7E6c9PLNyd8oJcd1/ZLe78Tq4v4rni 9gbGl/+Is5Gndxwxtkjro1yXAtk320I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-aJmuQr2pNgieNtln78GC6g-1; Fri, 04 Feb 2022 06:57:22 -0500 X-MC-Unique: aJmuQr2pNgieNtln78GC6g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 962AE190B2A1; Fri, 4 Feb 2022 11:57:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 299AA1081172; Fri, 4 Feb 2022 11:57:21 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: dmatlack@google.com, seanjc@google.com, vkuznets@redhat.com Subject: [PATCH 04/23] KVM: MMU: constify uses of struct kvm_mmu_role_regs Date: Fri, 4 Feb 2022 06:56:59 -0500 Message-Id: <20220204115718.14934-5-pbonzini@redhat.com> In-Reply-To: <20220204115718.14934-1-pbonzini@redhat.com> References: <20220204115718.14934-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org struct kvm_mmu_role_regs is computed just once and then accessed. Use const to enforce this. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 0039b2f21286..3add9d8b0630 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -208,7 +208,7 @@ struct kvm_mmu_role_regs { * the single source of truth for the MMU's state. */ #define BUILD_MMU_ROLE_REGS_ACCESSOR(reg, name, flag) \ -static inline bool __maybe_unused ____is_##reg##_##name(struct kvm_mmu_role_regs *regs)\ +static inline bool __maybe_unused ____is_##reg##_##name(const struct kvm_mmu_role_regs *regs)\ { \ return !!(regs->reg & flag); \ } @@ -255,7 +255,7 @@ static struct kvm_mmu_role_regs vcpu_to_role_regs(struct kvm_vcpu *vcpu) return regs; } -static int role_regs_to_root_level(struct kvm_mmu_role_regs *regs) +static int role_regs_to_root_level(const struct kvm_mmu_role_regs *regs) { if (!____is_cr0_pg(regs)) return 0; @@ -4666,7 +4666,7 @@ static void paging32_init_context(struct kvm_mmu *context) } static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu, - struct kvm_mmu_role_regs *regs) + const struct kvm_mmu_role_regs *regs) { union kvm_mmu_extended_role ext = {0}; @@ -4687,7 +4687,7 @@ static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu, } static union kvm_mmu_role kvm_calc_mmu_role_common(struct kvm_vcpu *vcpu, - struct kvm_mmu_role_regs *regs, + const struct kvm_mmu_role_regs *regs, bool base_only) { union kvm_mmu_role role = {0}; @@ -4723,7 +4723,8 @@ static inline int kvm_mmu_get_tdp_level(struct kvm_vcpu *vcpu) static union kvm_mmu_role kvm_calc_tdp_mmu_root_page_role(struct kvm_vcpu *vcpu, - struct kvm_mmu_role_regs *regs, bool base_only) + const struct kvm_mmu_role_regs *regs, + bool base_only) { union kvm_mmu_role role = kvm_calc_mmu_role_common(vcpu, regs, base_only); @@ -4769,7 +4770,8 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) static union kvm_mmu_role kvm_calc_shadow_root_page_role_common(struct kvm_vcpu *vcpu, - struct kvm_mmu_role_regs *regs, bool base_only) + const struct kvm_mmu_role_regs *regs, + bool base_only) { union kvm_mmu_role role = kvm_calc_mmu_role_common(vcpu, regs, base_only); @@ -4782,7 +4784,8 @@ kvm_calc_shadow_root_page_role_common(struct kvm_vcpu *vcpu, static union kvm_mmu_role kvm_calc_shadow_mmu_root_page_role(struct kvm_vcpu *vcpu, - struct kvm_mmu_role_regs *regs, bool base_only) + const struct kvm_mmu_role_regs *regs, + bool base_only) { union kvm_mmu_role role = kvm_calc_shadow_root_page_role_common(vcpu, regs, base_only); @@ -4940,7 +4943,7 @@ static void init_kvm_softmmu(struct kvm_vcpu *vcpu) } static union kvm_mmu_role -kvm_calc_nested_mmu_role(struct kvm_vcpu *vcpu, struct kvm_mmu_role_regs *regs) +kvm_calc_nested_mmu_role(struct kvm_vcpu *vcpu, const struct kvm_mmu_role_regs *regs) { union kvm_mmu_role role; -- 2.31.1