mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Michael Roth <michael.roth@amd.com>,
	Ashish Kalra <ashish.kalra@amd.com>
Subject: Re: [PATCH v3 6/8] x86/sev: Treat the contiguous RMP table as a single RMP segment
Date: Fri, 18 Oct 2024 11:29:13 +0530	[thread overview]
Message-ID: <4692a0c7-3eef-45c1-ba06-fa01b4f01d74@amd.com> (raw)
In-Reply-To: <3a9a4f94fefe3b4ebb23a7dd3d33d9fd7a344ce1.1727709735.git.thomas.lendacky@amd.com>



On 9/30/2024 8:52 PM, Tom Lendacky wrote:
> In preparation for support of a segmented RMP table, treat the contiguous
> RMP table as a segmented RMP table with a single segment covering all
> of memory. By treating a contiguous RMP table as a single segment, much
> of the code that initializes and accesses the RMP can be re-used.
> 
> Segmented RMP tables can have up to 512 segment entries. Each segment
> will have metadata associated with it to identify the segment location,
> the segment size, etc. The segment data and the physical address are used
> to determine the index of the segment within the table and then the RMP
> entry within the segment. For an actual segmented RMP table environment,
> much of the segment information will come from a configuration MSR. For
> the contiguous RMP, though, much of the information will be statically
> defined.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  arch/x86/virt/svm/sev.c | 195 ++++++++++++++++++++++++++++++++++++----
>  1 file changed, 176 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 81e21d833cf0..ebfb924652f8 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -18,6 +18,7 @@
>  #include <linux/cpumask.h>
>  #include <linux/iommu.h>
>  #include <linux/amd-iommu.h>
> +#include <linux/nospec.h>
>  
>  #include <asm/sev.h>
>  #include <asm/processor.h>
> @@ -74,12 +75,42 @@ struct rmpentry_raw {
>   */
>  #define RMPTABLE_CPU_BOOKKEEPING_SZ	0x4000
>  
> +/*
> + * For a non-segmented RMP table, use the maximum physical addressing as the
> + * segment size in order to always arrive at index 0 in the table.
> + */
> +#define RMPTABLE_NON_SEGMENTED_SHIFT	52
> +
> +struct rmp_segment_desc {
> +	struct rmpentry_raw *rmp_entry;
> +	u64 max_index;
> +	u64 size;
> +};
> +
> +/*
> + * Segmented RMP Table support.
> + *   - The segment size is used for two purposes:
> + *     - Identify the amount of memory covered by an RMP segment
> + *     - Quickly locate an RMP segment table entry for a physical address
> + *
> + *   - The RMP segment table contains pointers to an RMP table that covers
> + *     a specific portion of memory. There can be up to 512 8-byte entries,
> + *     one pages worth.
> + */
> +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 unsigned long rmp_segment_coverage_size;
> +static unsigned long rmp_segment_coverage_mask;

rmp_segment_size_max is of type u64 and rmp_segment_coverage_size is 1 << 52
for single RMP segment. So, maybe use u64 for rmp_segment_coverage_size
and rmp_segment_coverage_mask also?


- Neeraj

  parent reply	other threads:[~2024-10-18  5:59 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 15:22 [PATCH v3 0/8] Provide support for RMPREAD and a segmented RMP Tom Lendacky
2024-09-30 15:22 ` [PATCH v3 1/8] x86/sev: Prepare for using the RMPREAD instruction to access the RMP Tom Lendacky
2024-10-16  8:52   ` Nikunj A. Dadhania
2024-10-16 14:43     ` Tom Lendacky
2024-10-17  5:24       ` Nikunj A. Dadhania
2024-10-16 15:01   ` Neeraj Upadhyay
2024-09-30 15:22 ` [PATCH v3 2/8] x86/sev: Add support for the RMPREAD instruction Tom Lendacky
2024-10-16 10:46   ` Nikunj A. Dadhania
2024-10-17 15:26   ` Borislav Petkov
2024-10-17 16:24     ` Tom Lendacky
2024-10-18  4:21   ` Neeraj Upadhyay
2024-10-18 12:41   ` Borislav Petkov
2024-10-18 15:14     ` Tom Lendacky
2024-10-21 15:41       ` Borislav Petkov
2024-10-21 17:10         ` Tom Lendacky
2024-10-21 17:49           ` Borislav Petkov
2024-09-30 15:22 ` [PATCH v3 3/8] x86/sev: Require the RMPREAD instruction after Fam19h Tom Lendacky
2024-09-30 17:03   ` Dave Hansen
2024-09-30 18:59     ` Tom Lendacky
2024-10-18 13:06       ` Borislav Petkov
2024-10-18  4:26   ` Neeraj Upadhyay
2024-10-18 13:30     ` Tom Lendacky
2024-09-30 15:22 ` [PATCH v3 4/8] x86/sev: Move the SNP probe routine out of the way Tom Lendacky
2024-10-16 11:05   ` Nikunj A. Dadhania
2024-10-18  4:28   ` Neeraj Upadhyay
2024-09-30 15:22 ` [PATCH v3 5/8] x86/sev: Map only the RMP table entries instead of the full RMP range Tom Lendacky
2024-10-16 11:25   ` [sos-linux-ext-patches] " Nikunj A. Dadhania
2024-10-18  4:38   ` Neeraj Upadhyay
2024-10-18 13:32     ` Tom Lendacky
2024-09-30 15:22 ` [PATCH v3 6/8] x86/sev: Treat the contiguous RMP table as a single RMP segment Tom Lendacky
2024-10-17 11:05   ` Nikunj A. Dadhania
2024-10-18  5:59   ` Neeraj Upadhyay [this message]
2024-10-18 13:56     ` Tom Lendacky
2024-10-18 14:42       ` Tom Lendacky
2024-09-30 15:22 ` [PATCH v3 7/8] x86/sev: Add full support for a segmented RMP table Tom Lendacky
2024-10-18  6:32   ` Nikunj A. Dadhania
2024-10-18 14:41     ` Tom Lendacky
2024-10-18  8:37   ` Neeraj Upadhyay
2024-10-18 15:06     ` Tom Lendacky
2024-09-30 15:22 ` [PATCH v3 8/8] x86/sev/docs: Document the SNP Reverse Map Table (RMP) Tom Lendacky
2024-10-18  6:56   ` Nikunj A. Dadhania
2024-10-18 14:48     ` Tom Lendacky
2024-10-18 13:31   ` Neeraj Upadhyay

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=4692a0c7-3eef-45c1-ba06-fa01b4f01d74@amd.com \
    --to=neeraj.upadhyay@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /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®