@@ -191,6 +222,15 @@ void hv_synic_free(void)The re-encryption must be done*before* pages are freed!
free_page((unsigned long)hv_cpu->synic_event_page);
free_page((unsigned long)hv_cpu->synic_message_page);
free_page((unsigned long)hv_cpu->post_msg_page);
+
+ if (hv_isolation_type_en_snp()) {
+ set_memory_encrypted((unsigned long)
+ hv_cpu->synic_message_page, 1);
+ set_memory_encrypted((unsigned long)
+ hv_cpu->synic_event_page, 1);
+ set_memory_encrypted((unsigned long)
+ hv_cpu->post_msg_page, 1);
+ }
Furthermore, if the re-encryption fails, we should not free
the page as it would pollute the free memory pool. The best
we can do is leak the memory. See Patch 5 in Dexuan's
TDX series, which does the same thing (but still doesn't
get it quite right, per my comments).