Re: [PATCH v6 6/8] x86/sev: Treat the contiguous RMP table as a single RMP segment
From: Borislav Petkov
Date: Mon Dec 09 2024 - 14:43:50 EST
On Mon, Dec 02, 2024 at 02:50:51PM -0600, Tom Lendacky wrote:
> static struct rmpentry_raw *get_raw_rmpentry(u64 pfn)
> {
> - if (!rmptable)
> + u64 paddr, rst_index, segment_index;
> + struct rmp_segment_desc *desc;
> +
> + if (!rmp_segment_table)
> return ERR_PTR(-ENODEV);
>
> - if (unlikely(pfn > rmptable_max_pfn))
> + paddr = pfn << PAGE_SHIFT;
> +
> + rst_index = RST_ENTRY_INDEX(paddr);
> + if (unlikely(rst_index >= rst_max_index))
> + return ERR_PTR(-EFAULT);
> + rst_index = array_index_nospec(rst_index, rst_max_index);
I think we should collect the deliberation why we're doing this nospec stuff
from here:
https://lore.kernel.org/r/79be2e29-6487-dd60-9b6f-3daa48a2e93f@xxxxxxx
into a comment around here for future reference.
This is the best example for those: "uff, why did we do it back then"?
questions when we stare at this months, years from now.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette