From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Tim Deegan <tim@xen.org>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH RFC 1/2] xen/pvh: take the p2m lock when doing logdirty ops from HVM domains
Date: Thu, 16 Oct 2014 12:03:02 +0200 [thread overview]
Message-ID: <543F97D6.7080702@citrix.com> (raw)
In-Reply-To: <20141016092005.GB71219@deinos.phlegethon.org>
El 16/10/14 a les 11.20, Tim Deegan ha escrit:
> At 12:53 +0200 on 15 Oct (1413374024), Roger Pau Monne wrote:
>> Due to locking order, the p2m lock must be taken before the paging lock, or
>> else the following panic occurs when trying to use logdirty ops from a PVH
>> Dom0:
>>
>> (XEN) mm locking order violation: 292 > 222
>> (XEN) Xen BUG at mm-locks.h:140
>> (XEN) ----[ Xen-4.5-unstable x86_64 debug=y Not tainted ]----
>> (XEN) CPU: 1
>> (XEN) RIP: e008:[<ffff82d0801e9ea5>] get_page_from_gfn_p2m+0xb0/0x286
>> (XEN) RFLAGS: 0000000000010282 CONTEXT: hypervisor
>> (XEN) rax: 0000000000000000 rbx: ffff83019a1f7884 rcx: 0000000000000000
>> (XEN) rdx: ffff83019a1f0000 rsi: 000000000000000a rdi: ffff82d0802926c0
>> (XEN) rbp: ffff83019a1f77f8 rsp: ffff83019a1f7798 r8: ffff83019e830000
>> (XEN) r9: 0000000000000003 r10: 00000000000000de r11: 0000000000000003
>> (XEN) r12: ffff83019a1f77c4 r13: ffff83019a138820 r14: ffff83019a1f7974
>> (XEN) r15: 0000000000057431 cr0: 0000000080050033 cr4: 00000000000026f0
>> (XEN) cr3: 000000019ea86000 cr2: 000000080205d000
>> (XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: 0000 cs: e008
>> [...]
>> (XEN) Xen call trace:
>> (XEN) [<ffff82d0801e9ea5>] get_page_from_gfn_p2m+0xb0/0x286
>> (XEN) [<ffff82d0802223e9>] hap_p2m_ga_to_gfn_4_levels+0x59/0x2b7
>> (XEN) [<ffff82d080222663>] hap_gva_to_gfn_4_levels+0x1c/0x29
>> (XEN) [<ffff82d0801edf67>] paging_gva_to_gfn+0xb8/0xce
>> (XEN) [<ffff82d0801b9bc0>] clear_user_hvm+0xd7/0x324
>> (XEN) [<ffff82d0801e8776>] paging_log_dirty_op+0x358/0x552
>> (XEN) [<ffff82d0801e8d47>] paging_domctl+0x140/0x177
>> (XEN) [<ffff82d08015ccca>] arch_do_domctl+0x212/0x269e
>> (XEN) [<ffff82d08010487c>] do_domctl+0x195d/0x1cd1
>> (XEN) [<ffff82d0801bafba>] hvm_do_hypercall+0x1b8/0x31c
>> (XEN) [<ffff82d0801e0d3f>] vmx_vmexit_handler+0xf91/0x1a5f
>> (XEN) [<ffff82d0801e7a51>] vmx_asm_vmexit_handler+0x41/0xc0
>> (XEN)
>> (XEN)
>> (XEN) ****************************************
>> (XEN) Panic on CPU 1:
>> (XEN) Xen BUG at mm-locks.h:140
>> (XEN) ****************************************
>> (XEN)
>> (XEN) Reboot in five seconds...
>>
>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>> Cc: Tim Deegan <tim@xen.org>
>> Cc: Jan Beulich <jbeulich@suse.com>
>> ---
>> xen/arch/x86/mm/paging.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
>> index 6b788f7..5af6309 100644
>> --- a/xen/arch/x86/mm/paging.c
>> +++ b/xen/arch/x86/mm/paging.c
>> @@ -412,6 +412,8 @@ static int paging_log_dirty_op(struct domain *d,
>>
>> if ( !resuming )
>> domain_pause(d);
>> + if (has_hvm_container_vcpu(current))
>> + p2m_lock(p2m_get_hostp2m(current->domain));
>> paging_lock(d);
>
> Ah, I see. This is the _caller_'s p2m lock but the _target_'s paging
> lock. Holding the caller's p2m lock to unstick this seems a bit of a
> strange answer -- the paging op might be quite a long one. And having
> all vcpus take their own p2m locks before remote paging locks (and
> probably other MM locks too operations) is going to be quite messy.
>
> I guess the tricky path is clear_user_hvm, writing the bitmap back to
> the caller's memory. I wonder whether we could use unlocked p2m
> lookups for that. Probably not, because what if the caller's memory is
> PoD, etc?
Yes, the functions that need the caller p2m lock is
clear_user_hvm/copy_to_user_hvm. If I'm not mistaken we explicitly
stated that PVH is not going to use PoD, but since we are there we can
try to fix this function so it can work with pure HVM domains that can
indeed use PoD.
> Getting hold of all the bitmap pages before taking the lock would be
> messy too.
>
> So this may end up being the least bad answer but I'd like to see if
> we can think of something better first.
I'm certainly open to ideas, this was the naive way I've found to fixing it.
Roger.
next prev parent reply other threads:[~2014-10-16 10:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 10:53 [PATCH RFC 0/2] xen/pvh: enable migration on PVH Dom0 Roger Pau Monne
2014-10-15 10:53 ` [PATCH RFC 1/2] xen/pvh: take the p2m lock when doing logdirty ops from HVM domains Roger Pau Monne
2014-10-15 11:31 ` Andrew Cooper
2014-10-15 11:52 ` Roger Pau Monné
2014-10-15 11:55 ` Andrew Cooper
2014-10-15 11:58 ` Roger Pau Monné
2014-10-16 8:21 ` Jan Beulich
2014-10-16 9:20 ` Tim Deegan
2014-10-16 10:03 ` Roger Pau Monné [this message]
2014-11-13 15:46 ` Tim Deegan
2014-11-13 16:17 ` Jan Beulich
2014-10-16 14:15 ` Jan Beulich
2014-10-16 15:05 ` Tim Deegan
2014-10-15 10:53 ` [PATCH RFC 2/2] xen/pvh: enable mmu_update hypercall Roger Pau Monne
2014-10-16 7:53 ` Tim Deegan
2014-10-16 8:45 ` Jan Beulich
2014-10-16 11:30 ` Roger Pau Monné
2014-10-16 13:28 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=543F97D6.7080702@citrix.com \
--to=roger.pau@citrix.com \
--cc=jbeulich@suse.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.