Re: [RFC v2-fix-v2 1/1] x86: Introduce generic protected guest abstraction

From: Borislav Petkov
Date: Wed Jun 09 2021 - 10:33:00 EST


On Wed, Jun 09, 2021 at 07:01:13AM -0700, Kuppuswamy, Sathyanarayanan wrote:
> I am still not clear. What happens when a driver which includes
> linux/protected-guest.h is compiled for non-x86 arch (s390 or arm64)?

I was wondering what felt weird: why is prot{ected,}_guest_has() in a
generic linux/ namespace header and not in an asm/ one?

I think the proper way is for the other arches should be to provide
their own prot_guest_has() implementation which generic code uses and
the generic header would contain only the PR_GUEST_* defines.

Take ioremap() as an example:

arch/x86/include/asm/io.h
arch/arm64/include/asm/io.h
arch/s390/include/asm/io.h
...

and pretty much every arch has that arch-specific io.h header which
defines ioremap() and generic code includes include/linux/io.h which
includes the respective asm/io.h header so that users can call the
respective ioremap() implementation.

prot_guest_has() sounds just the same to me.

Better?

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette