Re: [PATCH v4 10/15] virt: sev-guest: Choose the VMPCK key based on executing VMPL

From: Tom Lendacky
Date: Fri May 31 2024 - 14:36:23 EST


On 5/31/24 07:55, Borislav Petkov wrote:
On Wed, Apr 24, 2024 at 10:58:06AM -0500, Tom Lendacky wrote:
+int snp_get_vmpl(void)
+{
+ return vmpl;

The vmpl doesn't change after init, right?

If so, you can make that vmpl variable __ro_after_init and drop yet

It already is __ro_after_init.

another parrotting accessor.

The sev-guest driver needs to access it. Given it is a driver/module, I created the accessor rather than mark the variable EXPORT_SYMBOL_GPL(). Your call, I'm fine with either.


-static u32 vmpck_id;
-module_param(vmpck_id, uint, 0444);
+static int vmpck_id = -1;
+module_param(vmpck_id, int, 0444);
MODULE_PARM_DESC(vmpck_id, "The VMPCK ID to use when communicating with the PSP.");

Can the driver figure out the vmpck_id from the kernel directly instead
of having to supply it with a module param?

Yes, the driver can and does figure it out. However, this module parameter was added in the off chance the default VMPCK gets wiped. Then you can reload the driver and use a different (less privileged) VMPCK.

Thanks,
Tom


This is yet another silly module param which you have to go and engineer
into the loading and have to know what you're doing.

If you can automate that, then it is a win-win thing.

Thx.