mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] KVM: SVM: Make MSR permission bitmap offsets read-only after init
Date: Thu, 10 Nov 2022 01:30:02 +0000	[thread overview]
Message-ID: <20221110013003.1421895-3-seanjc@google.com> (raw)
In-Reply-To: <20221110013003.1421895-1-seanjc@google.com>

Tag the pre-computed offsets into the MSR permission bitmaps as read-only
after init, and similarly tag add_msr_offset() and init_msrpm_offsets()
as __init.  The bitmaps themselves are dynamically configured, but the
offsets, i.e. the set of MSRs that can be passed through to the guest, is
static for a given instance of KVM.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 arch/x86/kvm/svm/svm.c | 6 +++---
 arch/x86/kvm/svm/svm.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 527f18d8cc44..e96c808fa8d3 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -65,7 +65,7 @@ MODULE_DEVICE_TABLE(x86cpu, svm_cpu_id);
 
 static bool erratum_383_found __read_mostly;
 
-u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
+u32 msrpm_offsets[MSRPM_OFFSETS] __ro_after_init;
 
 /*
  * Set osvw_len to higher value when updated Revision Guides
@@ -860,7 +860,7 @@ static void svm_msr_filter_changed(struct kvm_vcpu *vcpu)
 	}
 }
 
-static void add_msr_offset(u32 offset)
+__init static void add_msr_offset(u32 offset)
 {
 	int i;
 
@@ -887,7 +887,7 @@ static void add_msr_offset(u32 offset)
 	BUG();
 }
 
-static void init_msrpm_offsets(void)
+__init static void init_msrpm_offsets(void)
 {
 	int i;
 
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 199a2ecef1ce..ca348e016729 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -31,7 +31,7 @@
 
 #define MAX_DIRECT_ACCESS_MSRS	46
 #define MSRPM_OFFSETS	32
-extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
+extern u32 msrpm_offsets[MSRPM_OFFSETS] __ro_after_init;
 extern bool npt_enabled;
 extern int vgif;
 extern bool intercept_smi;
-- 
2.38.1.431.g37b22c650d-goog


  parent reply	other threads:[~2022-11-10  1:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10  1:30 [PATCH 0/3] KVM: Mark vendor module param " Sean Christopherson
2022-11-10  1:30 ` [PATCH 1/3] KVM: VMX: Make module params and other variables " Sean Christopherson
2022-11-10  1:30 ` Sean Christopherson [this message]
2022-11-10  1:30 ` [PATCH 3/3] KVM: SVM: " Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110013003.1421895-3-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®