[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201113153333.yt54enp5dbqjj5nu@liuwe-devbox-debian-v2>
Date: Fri, 13 Nov 2020 15:33:33 +0000
From: Wei Liu <wei.liu@...nel.org>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: Wei Liu <wei.liu@...nel.org>,
Linux on Hyper-V List <linux-hyperv@...r.kernel.org>,
virtualization@...ts.linux-foundation.org,
Linux Kernel List <linux-kernel@...r.kernel.org>,
Michael Kelley <mikelley@...rosoft.com>,
Vineeth Pillai <viremana@...ux.microsoft.com>,
Sunil Muthuswamy <sunilmut@...rosoft.com>,
Nuno Das Neves <nunodasneves@...ux.microsoft.com>,
Lillian Grassin-Drake <ligrassi@...rosoft.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v2 08/17] x86/hyperv: handling hypercall page setup for
root
On Thu, Nov 12, 2020 at 04:51:09PM +0100, Vitaly Kuznetsov wrote:
> Wei Liu <wei.liu@...nel.org> writes:
>
> > When Linux is running as the root partition, the hypercall page will
> > have already been setup by Hyper-V. Copy the content over to the
> > allocated page.
> >
> > The suspend, resume and cleanup paths remain untouched because they are
> > not supported in this setup yet.
>
> What about adding BUG_ONs there then?
I generally avoid cluttering code if I'm sure it definitely does not
work.
In any case, adding BUG_ONs is not the right answer. Both hv_suspend and
hv_resume can return an error code. I would rather just do
if (hv_root_partition)
return -EPERM;
in both places.
And also make hv_is_hibernation_supported return false when Linux is the
root partition.
> > +
> > + if (hv_root_partition) {
> > + struct page *pg;
> > + void *src, *dst;
> > +
> > + /*
> > + * For the root partition, the hypervisor will set up its
> > + * hypercall page. The hypervisor guarantees it will not show
> > + * up in the root's address space. The root can't change the
> > + * location of the hypercall page.
> > + *
> > + * Order is important here. We must enable the hypercall page
> > + * so it is populated with code, then copy the code to an
> > + * executable page.
> > + */
> > + wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > +
> > + pg = vmalloc_to_page(hv_hypercall_pg);
> > + dst = kmap(pg);
> > + src = memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAGE_SIZE,
> > + MEMREMAP_WB);
> > + BUG_ON(!(src && dst));
> > + memcpy(dst, src, PAGE_SIZE);
>
> Super-nit: while on x86 PAGE_SIZE always matches HV_HYP_PAGE_SIZE, would
> it be more accurate to use the later here?
Sure. That can be done.
Wei.
Powered by blists - more mailing lists