Re: [PATCH 01/13] x86/HV: Initialize GHCB page in Isolation VM

From: Tianyu Lan
Date: Mon Aug 02 2021 - 08:35:48 EST


Hi Joerg:
Thanks for your review.


On 8/2/2021 7:53 PM, Joerg Roedel wrote:
On Wed, Jul 28, 2021 at 10:52:16AM -0400, Tianyu Lan wrote:
+static int hyperv_init_ghcb(void)
+{
+ u64 ghcb_gpa;
+ void *ghcb_va;
+ void **ghcb_base;
+
+ if (!ms_hyperv.ghcb_base)
+ return -EINVAL;
+
+ rdmsrl(MSR_AMD64_SEV_ES_GHCB, ghcb_gpa);
+ ghcb_va = memremap(ghcb_gpa, HV_HYP_PAGE_SIZE, MEMREMAP_WB);

This deserves a comment. As I understand it, the GHCB pa is set by
Hyper-V or the paravisor, so the page does not need to be allocated by
Linux.
And it is not mapped unencrypted because the GHCB page is allocated
above the VTOM boundary?

You are right. The ghdb page is allocated by paravisor and its physical address is above VTOM boundary. Will add a comment to describe this.
Thanks for suggestion.


@@ -167,6 +190,31 @@ static int hv_cpu_die(unsigned int cpu)
{
struct hv_reenlightenment_control re_ctrl;
unsigned int new_cpu;
+ unsigned long flags;
+ void **input_arg;
+ void *pg;
+ void **ghcb_va = NULL;
+
+ local_irq_save(flags);
+ input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg);
+ pg = *input_arg;

Pg is never used later on, why is it set?

Sorry for noise. This should be removed during rebase and will fix in the next version.