Re: [RFC v2 26/32] x86/mm: Move force_dma_unencrypted() to common code

From: Sean Christopherson
Date: Wed May 12 2021 - 14:03:30 EST


On Wed, May 12, 2021, Dave Hansen wrote:
> On 5/12/21 6:08 AM, Kirill A. Shutemov wrote:
> >> That's not an excuse to have a bunch of AMD (or Intel) feature-specific
> >> code in a file named "common". I'd make an attempt to keep them
> >> separate and then call into the two separate functions *from* the common
> >> function.
> > But why? What good does the additional level of inderection brings?
> >
> > It's like saying arch/x86/kernel/cpu/common.c shouldn't have anything AMD
> > or Intel specific. If a function can cover both vendors I don't see a
> > point for additinal complexity.
>
> Because the code is already separate. You're actually going to some
> trouble to move the SEV-specific code and then combine it with the
> TDX-specific code.
>
> Anyway, please just give it a shot. Should take all of ten minutes. If
> it doesn't work out in practice, fine. You'll have a good paragraph for
> the changelog.

Or maybe wait to see how Boris' propose protected_guest_has() pans out? E.g. if
we can do "protected_guest_has(MEMORY_ENCRYPTION)" or whatever, then the truly
common bits could be placed into common.c without any vendor-specific logic.