Re: [RFC PATCH V3 07/16] drivers: hv: Decrypt percpu hvcall input arg page in sev-snp enlightened guest

From: Tianyu Lan
Date: Fri Feb 03 2023 - 00:23:24 EST


On 2/1/2023 2:02 AM, Michael Kelley (LINUX) wrote:
@@ -134,6 +136,17 @@ int hv_common_cpu_init(unsigned int cpu)
if (!(*inputarg))
return -ENOMEM;

+ if (hv_isolation_type_en_snp()) {
+ ret = set_memory_decrypted((unsigned long)*inputarg, pgcount);
You used "pgcount" here in response to a comment on v2 of the
patch. But the corresponding re-encryption in hv_common_cpu_die()
uses a fixed value of "1". The two cases should be consistent. Either
assert that hv_root_partition will never be true in an SNP VM, in which
case hard coding "1" is OK. Or properly calculate the number of pages
in both cases so they are consistent.


Agree. We should keep the logic in both hv_common_cpu_init() and hv_common_cpu_die(). Will fix it.