Messages in this thread | | | Date | Wed, 17 Apr 2024 13:46:58 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH v3 02/14] x86/sev: Make the VMPL0 checking function more generic |
| |
On Mon, Mar 25, 2024 at 05:26:21PM -0500, Tom Lendacky wrote: > -static void enforce_vmpl0(void) > +static bool running_at_vmpl0(void *va)
Not too crazy about it: you're turning it into a function which runs in boolean context but takes a void *?!
And the boolean result is only a side-effect or what it does to the argument - modify its permissions. Which is weird and not really obvious.
I'd prefer it if you made it into
static void vmpl0_modify_permissions(void *va)
which basically says, modify the permissions of @va in vmpl0, which is a lot closer to what the function does.
And then do
#define running_at_vmpl0(va) vmpl0_modify_permissions((va))
because then through the indirection is at least clear how that "am I running at VMPL0?" check is being done.
And later, if we need other VMPLs, we can extend vmpl0_modify_permissions() and even do a more generic
vmpl_modify_permissions(unsigned int vmpl_level, void *va)
and so on and kill the silly macro.
Thx.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |