Skip to contentSkip to conversation

error in xen/arch/x86/mm.c:get_page during migration

DISCUSSION Andres Lagar-Cavilla 4 participants 7 messages Feb 25, 2013 – Feb 28, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Olaf Hering

It did not happen with xl.

But the same guest and Dom0 kernel, and the same hypervisor?

Yes, same sles11sp2 dom0, and 3.7.9 pvops guest.

Quoted 7 lines
Quoted 7 lines

Here is the output while doing xm migrate:

(XEN) HVM2 restore: VMCE_VCPU 0
(XEN) HVM2 restore: VMCE_VCPU 1
(XEN) HVM2 restore: TSC_ADJUST 0
(XEN) HVM2 restore: TSC_ADJUST 1
(XEN) mm.c:1983:d0 Error pfn 4112c5: rd=ffff83036ffef000,

od=0000000000000000, caf=180000000000000, taf=7400000000000001

Quoted 12 lines

Didn't even notice yesterday that this is apparently after restore has already started. Which makes me curious whether the domain that is being referenced with rd= is the old or the new one (would require printing the domain ID; honestly I never understood what use printing of the domain pointer is).

I'm also confused by the domain pointer always being the same; I would expect it to at least toggle between two values, but probably even be different between every instance of the guest. But you're not having a stubdom configured for the guest either, according to the config you sent earlier...

Quoted 4 lines
Quoted 1 line

The rd->domain_id is DOMID_COW in both cases.

Which suggests that memory sharing is in use. At least I'm unaware of other uses of that pseudo domain.

There are none.

There seems to be something else amiss though. Unless I am parsing this incorrectly, taf == PGT_writable | PGT_pae_xen_l2? And caf == PAT | PCD? Looks like a very unlikely combination

Andres

Quoted 2 lines

Jan

#2 lore raw
Quoted 33 lines · Andres Lagar-Cavilla
Quoted 33 lines
Quoted 32 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Olaf Hering

It did not happen with xl.

But the same guest and Dom0 kernel, and the same hypervisor?

Yes, same sles11sp2 dom0, and 3.7.9 pvops guest.

Quoted 7 lines
Quoted 7 lines

Here is the output while doing xm migrate:

(XEN) HVM2 restore: VMCE_VCPU 0
(XEN) HVM2 restore: VMCE_VCPU 1
(XEN) HVM2 restore: TSC_ADJUST 0
(XEN) HVM2 restore: TSC_ADJUST 1
(XEN) mm.c:1983:d0 Error pfn 4112c5: rd=ffff83036ffef000,

od=0000000000000000, caf=180000000000000, taf=7400000000000001

Quoted 7 lines

Didn't even notice yesterday that this is apparently after restore has already started. Which makes me curious whether the domain that is being referenced with rd= is the old or the new one (would require printing the domain ID; honestly I never understood what use printing of the domain pointer is).

Quoted 5 lines

I'm also confused by the domain pointer always being the same; I would expect it to at least toggle between two values, but probably even be different between every instance of the guest. But you're not having a stubdom configured for the guest either, according to the config you sent earlier...

The rd->domain_id is DOMID_COW in both cases.

Quoted 8 lines
Quoted 2 lines

Which suggests that memory sharing is in use. At least I'm unaware of other uses of that pseudo domain.

There are none.

There seems to be something else amiss though. Unless I am parsing this incorrectly, taf == PGT_writable | PGT_pae_xen_l2? And caf == PAT | PCD? Looks like a very unlikely combination

By my reading,

taf = 0x7400000000000001 = typecount 1, PGT_writable_page | PGT_validated caf = 0x0180000000000000 = refcount 0, PGC_state_free

iow this is a free page but somehow has ended up with a typecount (which explains why the get_page() failed). And presumably this is one of the various get_page[_and_type](page, dom_cow) calls in mem_sharing.c.

Since free_domheap_pages() has a BUG_ON(typecount != 0), it seems like something's gone badly off the rails here.

One place I can see that tinkers with typecount without holding a ref is share_xen_page_with_guest(), which sets exactly this typecount, but then calls page_set_owner(page, d).

There's some hairy code in __gnttab_map_grant_ref() too, but I _think_ it can't end up taking typecounts without refcounts.

__acquire_grant_for_copy() looks pretty hairy too, in particular this:

        (void)page_get_owner_and_reference(*page);

but presumably the matching put_page() would have crashed if that was
the problem. Does anyone understand the grant code well enough to get into that?

If you can repro this, it might be worth tracing all the refcount ops into a large buffer and dumping the history of this MFN on failure.

Cheers,

Tim.

#3 lore raw
Quoted 2 lines · Tim Deegan

If you can repro this, it might be worth tracing all the refcount ops into a large buffer and dumping the history of this MFN on failure.

I can reproduce it with xend, will have a look next week.

Olaf

#4 lore raw
In reply to Tim Deegan
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 3 lines · Andres Lagar-Cavilla

There seems to be something else amiss though. Unless I am parsing this incorrectly, taf == PGT_writable | PGT_pae_xen_l2? And caf == PAT | PCD? Looks like a very unlikely combination

By my reading,

taf = 0x7400000000000001 = typecount 1, PGT_writable_page | PGT_validated caf = 0x0180000000000000 = refcount 0, PGC_state_free

Right.

Quoted 11 lines

iow this is a free page but somehow has ended up with a typecount (which explains why the get_page() failed). And presumably this is one of the various get_page[_and_type](page, dom_cow) calls in mem_sharing.c.

Since free_domheap_pages() has a BUG_ON(typecount != 0), it seems like something's gone badly off the rails here.

One place I can see that tinkers with typecount without holding a ref is share_xen_page_with_guest(), which sets exactly this typecount, but then calls page_set_owner(page, d).

Quoted 8 lines

There's some hairy code in __gnttab_map_grant_ref() too, but I _think_ it can't end up taking typecounts without refcounts.

__acquire_grant_for_copy() looks pretty hairy too, in particular this:

        (void)page_get_owner_and_reference(*page);

but presumably the matching put_page() would have crashed if that was
the problem. Does anyone understand the grant code well enough to get into that?

Problem is that the domain reported in the message is DOM_COW according to Olaf, yet he's not knowingly using page sharing. But that fact pretty much excluded the grant table or any other of the "usual" code paths for me (and I never looked at the sharing code, so hoped one of you two would).

Jan

#5 lore raw
Quoted 2 lines · Jan Beulich

Problem is that the domain reported in the message is DOM_COW according to Olaf, yet he's not knowingly using page sharing.

Oh. In that case, a backtrace (e.g. from WARN()) in the offending call would be enlightening.

Quoted 3 lines

But that fact pretty much excluded the grant table or any other of the "usual" code paths for me (and I never looked at the sharing code, so hoped one of you two would).

I just looked thorough it for unguarded typecount modifications and didn't find one. But presumably something else is wrong if we're trying to unshare a page with no sharing enabled.

Tim.

#6 lore raw
In reply to Jan Beulich
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 3 lines · Andres Lagar-Cavilla

There seems to be something else amiss though. Unless I am parsing this incorrectly, taf == PGT_writable | PGT_pae_xen_l2? And caf == PAT | PCD? Looks like a very unlikely combination

Quoted 6 lines
Quoted 4 lines

By my reading,

taf = 0x7400000000000001 = typecount 1, PGT_writable_page | PGT_validated caf = 0x0180000000000000 = refcount 0, PGC_state_free

Right.

D'oh :)

Sharing code never sets PGT_writable, only sets/clears PGT_shared. I tend to think the dom_cow rd belies a different problem. To use dom_cow, the domain has to have an explicit domctl that enables memory sharing.

Andres

Quoted 29 lines
Quoted 12 lines

iow this is a free page but somehow has ended up with a typecount (which explains why the get_page() failed). And presumably this is one of the various get_page[_and_type](page, dom_cow) calls in mem_sharing.c.

Since free_domheap_pages() has a BUG_ON(typecount != 0), it seems like something's gone badly off the rails here.

One place I can see that tinkers with typecount without holding a ref is share_xen_page_with_guest(), which sets exactly this typecount, but then calls page_set_owner(page, d).

Quoted 8 lines

There's some hairy code in __gnttab_map_grant_ref() too, but I _think_ it can't end up taking typecounts without refcounts.

__acquire_grant_for_copy() looks pretty hairy too, in particular this:

       (void)page_get_owner_and_reference(*page);

but presumably the matching put_page() would have crashed if that was the problem. Does anyone understand the grant code well enough to get into that?

Problem is that the domain reported in the message is DOM_COW according to Olaf, yet he's not knowingly using page sharing. But that fact pretty much excluded the grant table or any other of the "usual" code paths for me (and I never looked at the sharing code, so hoped one of you two would).

Jan

#7 lore raw
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Andres Lagar-Cavilla
Quoted 11 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 3 lines · Andres Lagar-Cavilla

There seems to be something else amiss though. Unless I am parsing this incorrectly, taf == PGT_writable | PGT_pae_xen_l2? And caf == PAT | PCD? Looks like a very unlikely combination

By my reading,

taf = 0x7400000000000001 = typecount 1, PGT_writable_page | PGT_validated caf = 0x0180000000000000 = refcount 0, PGC_state_free

Quoted 6 lines
Quoted 1 line

Right.

D'oh :)

Sharing code never sets PGT_writable, only sets/clears PGT_shared. I tend to think the dom_cow rd belies a different problem. To use dom_cow, the domain has to have an explicit domctl that enables memory sharing.

In that case, Olaf, could you simply set dom_cow to some invalid pointer right after it got set up through domain_create(), so that any dereference of it would blow up? That might be the faster path towards finding the first bogus use.

Jan