[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <988f20e4-821f-b493-c25d-ca9107a6e891@gmail.com>
Date: Mon, 2 Aug 2021 21:18:15 +0800
From: Tianyu Lan <ltykernel@...il.com>
To: Joerg Roedel <joro@...tes.org>
Cc: kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
wei.liu@...nel.org, decui@...rosoft.com, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, x86@...nel.org, hpa@...or.com,
dave.hansen@...ux.intel.com, luto@...nel.org, peterz@...radead.org,
konrad.wilk@...cle.com, boris.ostrovsky@...cle.com,
jgross@...e.com, sstabellini@...nel.org, will@...nel.org,
davem@...emloft.net, kuba@...nel.org, jejb@...ux.ibm.com,
martin.petersen@...cle.com, arnd@...db.de, hch@....de,
m.szyprowski@...sung.com, robin.murphy@....com,
thomas.lendacky@....com, brijesh.singh@....com, ardb@...nel.org,
Tianyu.Lan@...rosoft.com, rientjes@...gle.com,
martin.b.radev@...il.com, akpm@...ux-foundation.org,
rppt@...nel.org, kirill.shutemov@...ux.intel.com,
aneesh.kumar@...ux.ibm.com, krish.sadhukhan@...cle.com,
saravanand@...com, xen-devel@...ts.xenproject.org,
pgonda@...gle.com, david@...hat.com, keescook@...omium.org,
hannes@...xchg.org, sfr@...b.auug.org.au,
michael.h.kelley@...rosoft.com, iommu@...ts.linux-foundation.org,
linux-arch@...r.kernel.org, linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
netdev@...r.kernel.org, vkuznets@...hat.com, anparri@...rosoft.com
Subject: Re: [PATCH 05/13] HV: Add Write/Read MSR registers via ghcb page
On 8/2/2021 8:28 PM, Joerg Roedel wrote:
> On Wed, Jul 28, 2021 at 10:52:20AM -0400, Tianyu Lan wrote:
>> +void hv_ghcb_msr_write(u64 msr, u64 value)
>> +{
>> + union hv_ghcb *hv_ghcb;
>> + void **ghcb_base;
>> + unsigned long flags;
>> +
>> + if (!ms_hyperv.ghcb_base)
>> + return;
>> +
>> + WARN_ON(in_nmi());
>> +
>> + local_irq_save(flags);
>> + ghcb_base = (void **)this_cpu_ptr(ms_hyperv.ghcb_base);
>> + hv_ghcb = (union hv_ghcb *)*ghcb_base;
>> + if (!hv_ghcb) {
>> + local_irq_restore(flags);
>> + return;
>> + }
>> +
>> + memset(hv_ghcb, 0x00, HV_HYP_PAGE_SIZE);
>
> Do you really need to zero out the whole 4k? The validation bitmap
> should be enough, there are no secrets on the page anyway.
> Same in hv_ghcb_msr_read().
OK. Thanks for suggestion. I will have a try.
>
>> +enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
>> + struct es_em_ctxt *ctxt,
>> + u64 exit_code, u64 exit_info_1,
>> + u64 exit_info_2)
>> {
>> enum es_result ret;
>>
>> @@ -109,7 +109,16 @@ static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
>> ghcb_set_sw_exit_info_1(ghcb, exit_info_1);
>> ghcb_set_sw_exit_info_2(ghcb, exit_info_2);
>>
>> - sev_es_wr_ghcb_msr(__pa(ghcb));
>> + /*
>> + * Hyper-V runs paravisor with SEV. Ghcb page is allocated by
>> + * paravisor and not needs to be updated in the Linux guest.
>> + * Otherwise, the ghcb page's PA reported by paravisor is above
>> + * VTOM. Hyper-V use this function with NULL for ctxt point and
>> + * skip setting ghcb page in such case.
>> + */
>> + if (ctxt)
>> + sev_es_wr_ghcb_msr(__pa(ghcb));
>
> No, do not make this function work with ctxt==NULL. Instead, factor out
> a helper function which contains what Hyper-V needs and use that in
> sev_es_ghcb_hv_call() and Hyper-V code.
>
OK. Will update.
>> +union hv_ghcb {
>> + struct ghcb ghcb;
>> +} __packed __aligned(PAGE_SIZE);
>
> I am curious what this will end up being good for.
>
Hyper-V introduces a specific hypercall request in GHCB page and use
same union in the Linux Hyper-V code to read/write MSR and call the new
hypercall request.
Powered by blists - more mailing lists