[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240126184340.GEZbP9XA13X91-eybA@fat_crate.local>
Date: Fri, 26 Jan 2024 19:43:40 +0100
From: Borislav Petkov <bp@...en8.de>
To: Michael Roth <michael.roth@....com>
Cc: x86@...nel.org, kvm@...r.kernel.org, linux-coco@...ts.linux.dev,
linux-mm@...ck.org, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...hat.com,
jroedel@...e.de, thomas.lendacky@....com, hpa@...or.com,
ardb@...nel.org, pbonzini@...hat.com, seanjc@...gle.com,
vkuznets@...hat.com, jmattson@...gle.com, luto@...nel.org,
dave.hansen@...ux.intel.com, slp@...hat.com, pgonda@...gle.com,
peterz@...radead.org, srinivas.pandruvada@...ux.intel.com,
rientjes@...gle.com, tobin@....com, vbabka@...e.cz,
kirill@...temov.name, ak@...ux.intel.com, tony.luck@...el.com,
sathyanarayanan.kuppuswamy@...ux.intel.com, alpergun@...gle.com,
jarkko@...nel.org, ashish.kalra@....com, nikunj.dadhania@....com,
pankaj.gupta@....com, liam.merwick@...cle.com
Subject: Re: [PATCH v2 11/25] x86/sev: Adjust directmap to avoid inadvertant
RMP faults
On Fri, Jan 26, 2024 at 11:04:15AM -0600, Michael Roth wrote:
> vaddr comes from pfn_to_kaddr(pfn), i.e. __va(paddr), so it will
> necessarily be a direct-mapped address above __PAGE_OFFSET.
Ah, true.
> For upper-end, a pfn_valid(pfn) check might suffice, since only a valid
> PFN would have a possibly-valid mapping wthin the directmap range.
Looking at it, yap, that could be a sensible thing to check.
> These are PFNs that are owned/allocated-to the caller. Due to the nature
> of the directmap it's possible non-owners would write to a mapping that
> overlaps, but vmalloc()/etc. would not create mappings for any pages that
> were not specifically part of an allocation that belongs to the caller,
> so I don't see where there's any chance for an overlap there. And the caller
> of these functions would not be adjusting directmap for PFNs that might be
> mapped into other kernel address ranges like kernel-text/etc unless the
> caller was specifically making SNP-aware adjustments to those ranges, in
> which case it would be responsible for making those other adjustments,
> or implementing the necessary helpers/etc.
Why does any of that matter?
If you can make this helper as generic as possible now, why don't you?
> I'm not aware of such cases in the current code, and I don't think it makes
> sense to attempt to try to handle them here generically until such a case
> arises, since it will likely involve more specific requirements than what
> we can anticipate from a theoretical/generic standpoint.
Then that's a different story. If it will likely involve more specific
handling, then that function should deal with pfns for which it can DTRT
and for others warn loudly so that the code gets fixed in time.
IOW, then it should check for the upper pfn of the direct map here and
we have two, depending on the page sizes used...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists