[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241104170514.GGZyj-yvIHo8Y-eKpj@fat_crate.local>
Date: Mon, 4 Nov 2024 18:05:14 +0100
From: Borislav Petkov <bp@...en8.de>
To: Tom Lendacky <thomas.lendacky@....com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Michael Roth <michael.roth@....com>,
Ashish Kalra <ashish.kalra@....com>,
Nikunj A Dadhania <nikunj@....com>,
Neeraj Upadhyay <Neeraj.Upadhyay@....com>
Subject: Re: [PATCH v5 6/8] x86/sev: Treat the contiguous RMP table as a
single RMP segment
On Mon, Nov 04, 2024 at 10:03:22AM -0600, Tom Lendacky wrote:
> >> +static u64 rmp_segment_size_max;
> >
> > This one is used in a single function. Generate it there pls.
>
> It's used in two functions, alloc_rmp_segment_desc() and
> set_rmp_segment_info().
You can always lift it up later if it is needed more than now:
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 37ff4f98e8d1..77bdf4d6a8f4 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -103,7 +103,6 @@ struct rmp_segment_desc {
static struct rmp_segment_desc **rmp_segment_table __ro_after_init;
static unsigned int rst_max_index __ro_after_init = 512;
-static u64 rmp_segment_size_max;
static unsigned int rmp_segment_coverage_shift;
static u64 rmp_segment_coverage_size;
static u64 rmp_segment_coverage_mask;
@@ -223,9 +222,13 @@ static bool __init init_rmptable_bookkeeping(void)
static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
{
+ u64 rst_index, rmp_segment_size_max;
struct rmp_segment_desc *desc;
void *rmp_segment;
- u64 rst_index;
+
+ /* Calculate the maximum size an RMP can be (16 bytes/page mapped) */
+ rmp_segment_size_max = PHYS_PFN(rmp_segment_coverage_size);
+ rmp_segment_size_max <<= 4;
/* Validate the RMP segment size */
if (segment_size > rmp_segment_size_max) {
@@ -415,10 +418,6 @@ static void set_rmp_segment_info(unsigned int segment_shift)
rmp_segment_coverage_shift = segment_shift;
rmp_segment_coverage_size = 1ULL << rmp_segment_coverage_shift;
rmp_segment_coverage_mask = rmp_segment_coverage_size - 1;
-
- /* Calculate the maximum size an RMP can be (16 bytes/page mapped) */
- rmp_segment_size_max = PHYS_PFN(rmp_segment_coverage_size);
- rmp_segment_size_max <<= 4;
}
#define RMP_ADDR_MASK GENMASK_ULL(51, 13)
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists