static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)So CC_ATTR_MEM_ENCRYPT is set for SEV* guests too. You need to change
{
- if (cc_platform_has(CC_ATTR_MEM_ENCRYPT))
- return __set_memory_enc_pgtable(addr, numpages, enc);
+ int ret = 0;
- return 0;
+ if (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
+ if (!down_read_trylock(&mem_enc_lock))
+ return -EBUSY;
+
+ ret = __set_memory_enc_pgtable(addr, numpages, enc);
+
+ up_read(&mem_enc_lock);
+ }
that code here to take the lock only on TDX, where you want it, not on
the others.