* [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
@ 2012-10-19 14:09 Olaf Hering
2012-10-19 14:14 ` Olaf Hering
2012-10-22 15:22 ` Tim Deegan
0 siblings, 2 replies; 9+ messages in thread
From: Olaf Hering @ 2012-10-19 14:09 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1350655745 -7200
# Node ID 8ebe7b80f02900d5a83e023c2833de26b70f3ff1
# Parent 3fa2ab30bb05297f30d9a33b30f29db960900971
hvm: handle PoD and grant pages in HVMOP_get_mem_type
During kexec in a ballooned PVonHVM guest the new kernel needs to check
each pfn if its backed by a mfn to find ballooned pages. Currently all
PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
to assume they are ballooned. This is wrong: PoD pages may turn into
real RAM at runtime, grant pages are also RAM.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff -r 3fa2ab30bb05 -r 8ebe7b80f029 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4086,6 +4086,10 @@ long do_hvm_op(unsigned long op, XEN_GUE
a.mem_type = HVMMEM_ram_ro;
else if ( p2m_is_ram(t) )
a.mem_type = HVMMEM_ram_rw;
+ else if ( p2m_is_magic(t) )
+ a.mem_type = HVMMEM_ram_rw;
+ else if ( p2m_is_grant(t) )
+ a.mem_type = HVMMEM_ram_rw;
else
a.mem_type = HVMMEM_mmio_dm;
rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-19 14:09 [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type Olaf Hering
@ 2012-10-19 14:14 ` Olaf Hering
2012-10-22 15:22 ` Tim Deegan
1 sibling, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2012-10-19 14:14 UTC (permalink / raw)
To: xen-devel
On Fri, Oct 19, Olaf Hering wrote:
> + else if ( p2m_is_grant(t) )
I'm not sure if p2m_is_grant() can be true in a HVM guest.
Olaf
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-19 14:09 [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type Olaf Hering
2012-10-19 14:14 ` Olaf Hering
@ 2012-10-22 15:22 ` Tim Deegan
2012-10-22 15:33 ` Olaf Hering
1 sibling, 1 reply; 9+ messages in thread
From: Tim Deegan @ 2012-10-22 15:22 UTC (permalink / raw)
To: Olaf Hering; +Cc: xen-devel
At 16:09 +0200 on 19 Oct (1350662980), Olaf Hering wrote:
> hvm: handle PoD and grant pages in HVMOP_get_mem_type
>
> During kexec in a ballooned PVonHVM guest the new kernel needs to check
> each pfn if its backed by a mfn to find ballooned pages. Currently all
> PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
> to assume they are ballooned. This is wrong: PoD pages may turn into
> real RAM at runtime, grant pages are also RAM.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
Applied, thanks.
Tim.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-22 15:22 ` Tim Deegan
@ 2012-10-22 15:33 ` Olaf Hering
2012-10-22 16:13 ` Tim Deegan
0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2012-10-22 15:33 UTC (permalink / raw)
To: Tim Deegan; +Cc: xen-devel
On Mon, Oct 22, Tim Deegan wrote:
> At 16:09 +0200 on 19 Oct (1350662980), Olaf Hering wrote:
> > hvm: handle PoD and grant pages in HVMOP_get_mem_type
> >
> > During kexec in a ballooned PVonHVM guest the new kernel needs to check
> > each pfn if its backed by a mfn to find ballooned pages. Currently all
> > PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
> > to assume they are ballooned. This is wrong: PoD pages may turn into
> > real RAM at runtime, grant pages are also RAM.
> >
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> Applied, thanks.
Would you backport this to 4.2 and 4.1?
Without this change the guest will get a wrong picture.
Too bad I did not consider this initially in 23298:26413986e6e0.
Olaf
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-22 15:33 ` Olaf Hering
@ 2012-10-22 16:13 ` Tim Deegan
2012-10-23 7:16 ` Jan Beulich
0 siblings, 1 reply; 9+ messages in thread
From: Tim Deegan @ 2012-10-22 16:13 UTC (permalink / raw)
To: Olaf Hering; +Cc: keir, JBeulich, xen-devel
At 17:33 +0200 on 22 Oct (1350927213), Olaf Hering wrote:
> On Mon, Oct 22, Tim Deegan wrote:
>
> > At 16:09 +0200 on 19 Oct (1350662980), Olaf Hering wrote:
> > > hvm: handle PoD and grant pages in HVMOP_get_mem_type
> > >
> > > During kexec in a ballooned PVonHVM guest the new kernel needs to check
> > > each pfn if its backed by a mfn to find ballooned pages. Currently all
> > > PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
> > > to assume they are ballooned. This is wrong: PoD pages may turn into
> > > real RAM at runtime, grant pages are also RAM.
> > >
> > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> >
> > Applied, thanks.
>
> Would you backport this to 4.2 and 4.1?
Actually, I don't handle backports. IIRC Jan owns 4.2-testing and Keir
4.1-testing; I've CC'd them both.
Cheers,
Tim.
> Without this change the guest will get a wrong picture.
> Too bad I did not consider this initially in 23298:26413986e6e0.
>
> Olaf
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-22 16:13 ` Tim Deegan
@ 2012-10-23 7:16 ` Jan Beulich
0 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2012-10-23 7:16 UTC (permalink / raw)
To: Olaf Hering, Tim Deegan; +Cc: keir, xen-devel
>>> On 22.10.12 at 18:13, Tim Deegan <tim@xen.org> wrote:
> At 17:33 +0200 on 22 Oct (1350927213), Olaf Hering wrote:
>> On Mon, Oct 22, Tim Deegan wrote:
>>
>> > At 16:09 +0200 on 19 Oct (1350662980), Olaf Hering wrote:
>> > > hvm: handle PoD and grant pages in HVMOP_get_mem_type
>> > >
>> > > During kexec in a ballooned PVonHVM guest the new kernel needs to check
>> > > each pfn if its backed by a mfn to find ballooned pages. Currently all
>> > > PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
>> > > to assume they are ballooned. This is wrong: PoD pages may turn into
>> > > real RAM at runtime, grant pages are also RAM.
>> > >
>> > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
>> >
>> > Applied, thanks.
>>
>> Would you backport this to 4.2 and 4.1?
>
> Actually, I don't handle backports. IIRC Jan owns 4.2-testing and Keir
> 4.1-testing; I've CC'd them both.
Actually, I handle both and will take care of it within the next few
days (hopefully before the end of the week).
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.15017.1350657933.1399.xen-devel@lists.xen.org>]
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
[not found] <mailman.15017.1350657933.1399.xen-devel@lists.xen.org>
@ 2012-10-19 15:45 ` Andres Lagar-Cavilla
2012-10-22 14:48 ` Olaf Hering
0 siblings, 1 reply; 9+ messages in thread
From: Andres Lagar-Cavilla @ 2012-10-19 15:45 UTC (permalink / raw)
To: xen-devel; +Cc: Olaf Hering
> # HG changeset patch
> # User Olaf Hering <olaf@aepfle.de>
> # Date 1350655745 -7200
> # Node ID 8ebe7b80f02900d5a83e023c2833de26b70f3ff1
> # Parent 3fa2ab30bb05297f30d9a33b30f29db960900971
> hvm: handle PoD and grant pages in HVMOP_get_mem_type
>
> During kexec in a ballooned PVonHVM guest the new kernel needs to check
> each pfn if its backed by a mfn to find ballooned pages. Currently all
> PoD and grant pages will appear as HVMMEM_mmio_dm, so the new kernel has
> to assume they are ballooned. This is wrong: PoD pages may turn into
> real RAM at runtime, grant pages are also RAM.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> diff -r 3fa2ab30bb05 -r 8ebe7b80f029 xen/arch/x86/hvm/hvm.c
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -4086,6 +4086,10 @@ long do_hvm_op(unsigned long op, XEN_GUE
> a.mem_type = HVMMEM_ram_ro;
> else if ( p2m_is_ram(t) )
> a.mem_type = HVMMEM_ram_rw;
> + else if ( p2m_is_magic(t) )
> + a.mem_type = HVMMEM_ram_rw;
p2m_is_magic is this bizarre thing that should just be p2m_is_pod. Can you take advantage of this opportunity and fix it?
> + else if ( p2m_is_grant(t) )
> + a.mem_type = HVMMEM_ram_rw;
Yes there can be p2m_is_grant pages in an HVM, if it is running a backend. Note that you need to discriminate whether the grant is mapped writable in order to return ram_rw or ram_ro.
It might be a good idea to extend this interface to return HVMMEM_grant_rw/ro. These are, in essence, different types of ram from an HVM point of view. However, it might be overkill for the current users.
Thanks
Andres
> else
> a.mem_type = HVMMEM_mmio_dm;
> rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-19 15:45 ` Andres Lagar-Cavilla
@ 2012-10-22 14:48 ` Olaf Hering
2012-10-22 14:59 ` Olaf Hering
0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2012-10-22 14:48 UTC (permalink / raw)
To: Andres Lagar-Cavilla; +Cc: xen-devel
On Fri, Oct 19, Andres Lagar-Cavilla wrote:
> > + else if ( p2m_is_magic(t) )
> > + a.mem_type = HVMMEM_ram_rw;
> p2m_is_magic is this bizarre thing that should just be p2m_is_pod. Can
> you take advantage of this opportunity and fix it?
I will prepare a separate patch for that rename.
> > + else if ( p2m_is_grant(t) )
> > + a.mem_type = HVMMEM_ram_rw;
>
> Yes there can be p2m_is_grant pages in an HVM, if it is running a
> backend. Note that you need to discriminate whether the grant is
> mapped writable in order to return ram_rw or ram_ro.
I will put p2m_grant_map_rw into HVMMEM_ram_rw, and p2m_grant_map_ro
into HVMMEM_ram_ro.
> It might be a good idea to extend this interface to return
> HVMMEM_grant_rw/ro. These are, in essence, different types of ram from
> an HVM point of view. However, it might be overkill for the current
> users.
Would the guest really care about the info that a given page is a grant
page? What would it do with that info?
Olaf
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type
2012-10-22 14:48 ` Olaf Hering
@ 2012-10-22 14:59 ` Olaf Hering
0 siblings, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2012-10-22 14:59 UTC (permalink / raw)
To: Andres Lagar-Cavilla; +Cc: xen-devel
On Mon, Oct 22, Olaf Hering wrote:
> On Fri, Oct 19, Andres Lagar-Cavilla wrote:
> > > + else if ( p2m_is_grant(t) )
> > > + a.mem_type = HVMMEM_ram_rw;
> >
> > Yes there can be p2m_is_grant pages in an HVM, if it is running a
> > backend. Note that you need to discriminate whether the grant is
> > mapped writable in order to return ram_rw or ram_ro.
>
> I will put p2m_grant_map_rw into HVMMEM_ram_rw, and p2m_grant_map_ro
> into HVMMEM_ram_ro.
Reading through the p2m_is_* defines, p2m_grant_map_ro maps already to
HVMMEM_ram_ro. So the patch covers all cases already.
Olaf
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-10-23 7:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-19 14:09 [PATCH] hvm: handle PoD and grant pages in HVMOP_get_mem_type Olaf Hering
2012-10-19 14:14 ` Olaf Hering
2012-10-22 15:22 ` Tim Deegan
2012-10-22 15:33 ` Olaf Hering
2012-10-22 16:13 ` Tim Deegan
2012-10-23 7:16 ` Jan Beulich
[not found] <mailman.15017.1350657933.1399.xen-devel@lists.xen.org>
2012-10-19 15:45 ` Andres Lagar-Cavilla
2012-10-22 14:48 ` Olaf Hering
2012-10-22 14:59 ` Olaf Hering
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.