xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>,
	Juergen Gross <jgross@suse.com>, Jan Beulich <JBeulich@suse.com>
Cc: Kevin Moraga <kmoragas@riseup.net>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	xen-devel@lists.xen.org
Subject: Re: crash on boot with 4.6.1 on fedora 24
Date: Thu, 26 May 2016 11:24:59 +0100	[thread overview]
Message-ID: <5746CEFB.7020403@citrix.com> (raw)
In-Reply-To: <573B3484.1080603@citrix.com>

On 17/05/16 16:11, David Vrabel wrote:
> On 11/05/16 11:16, David Vrabel wrote:
>>
>> Why don't we get the RW bits correct when making the pteval when we
>> already have the pfn, instead trying to fix it up afterwards.
> 
> Kevin, can you try this patch.
> 
> David
> 
> 8<-----------------
> x86/xen: avoid m2p lookup when setting early page table entries
> 
> When page tables entries are set using xen_set_pte_init() during early
> boot there is no page fault handler that could handle a fault when
> performing an M2P lookup.
> 
> In 64 guest (usually dom0) early_ioremap() would fault in
> xen_set_pte_init() because an M2P lookup faults because the MFN is in
> MMIO space and not mapped in the M2P.  This lookup is done to see if
> the PFN in in the range used for the initial page table pages, so that
> the PTE may be set as read-only.
> 
> The M2P lookup can be avoided by moving the check (and clear of RW)
> earlier when the PFN is still available.
> 
> [ Not entirely happy with this as the 32/64 bit paths diverge even
>   more. Is there some way to unify them instead? ]

Boris, Juergen, any opinion on this patch?

David

> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -1562,7 +1562,7 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t
> pte)
>  	return pte;
>  }
>  #else /* CONFIG_X86_64 */
> -static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
> +static pteval_t __init mask_rw_pte(pteval_t pte)
>  {
>  	unsigned long pfn;
> 
> @@ -1577,10 +1577,10 @@ static pte_t __init mask_rw_pte(pte_t *ptep,
> pte_t pte)
>  	 * page tables for mapping the p2m list, too, and page tables MUST be
>  	 * mapped read-only.
>  	 */
> -	pfn = pte_pfn(pte);
> +	pfn = (pte & PTE_PFN_MASK) >> PAGE_SHIFT;
>  	if (pfn >= xen_start_info->first_p2m_pfn &&
>  	    pfn < xen_start_info->first_p2m_pfn + xen_start_info->nr_p2m_frames)
> -		pte = __pte_ma(pte_val_ma(pte) & ~_PAGE_RW);
> +		pte &= ~_PAGE_RW;
> 
>  	return pte;
>  }
> @@ -1600,13 +1600,26 @@ static pte_t __init mask_rw_pte(pte_t *ptep,
> pte_t pte)
>   * so always write the PTE directly and rely on Xen trapping and
>   * emulating any updates as necessary.
>   */
> +__visible __init pte_t xen_make_pte_init(pteval_t pte)
> +{
> +#ifdef CONFIG_X86_64
> +	pte = mask_rw_pte(pte);
> +#endif
> +	pte = pte_pfn_to_mfn(pte);
> +
> +	if ((pte & PTE_PFN_MASK) >> PAGE_SHIFT == INVALID_P2M_ENTRY)
> +		pte = 0;
> +
> +	return native_make_pte(pte);
> +}
> +PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte_init);
> +
>  static void __init xen_set_pte_init(pte_t *ptep, pte_t pte)
>  {
> +#ifdef CONFIG_X86_32
>  	if (pte_mfn(pte) != INVALID_P2M_ENTRY)
>  		pte = mask_rw_pte(ptep, pte);
> -	else
> -		pte = __pte_ma(0);
> -
> +#endif
>  	native_set_pte(ptep, pte);
>  }
> 
> @@ -2407,6 +2420,7 @@ static void __init xen_post_allocator_init(void)
>  	pv_mmu_ops.alloc_pud = xen_alloc_pud;
>  	pv_mmu_ops.release_pud = xen_release_pud;
>  #endif
> +	pv_mmu_ops.make_pte = PV_CALLEE_SAVE(xen_make_pte);
> 
>  #ifdef CONFIG_X86_64
>  	pv_mmu_ops.write_cr3 = &xen_write_cr3;
> @@ -2455,7 +2469,7 @@ static const struct pv_mmu_ops xen_mmu_ops
> __initconst = {
>  	.pte_val = PV_CALLEE_SAVE(xen_pte_val),
>  	.pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
> 
> -	.make_pte = PV_CALLEE_SAVE(xen_make_pte),
> +	.make_pte = PV_CALLEE_SAVE(xen_make_pte_init),
>  	.make_pgd = PV_CALLEE_SAVE(xen_make_pgd),
> 
>  #ifdef CONFIG_X86_PAE
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-05-26 10:24 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-08 22:51 crash on boot with 4.6.1 on fedora 24 Kevin Moraga
2016-05-09  7:23 ` Andrew Cooper
2016-05-09 10:05   ` Jan Beulich
2016-05-09 10:08 ` Jan Beulich
2016-05-09 14:52   ` Kevin Moraga
2016-05-09 15:53     ` Jan Beulich
2016-05-09 16:40       ` Kevin Moraga
2016-05-09 17:15         ` Boris Ostrovsky
2016-05-09 17:22           ` Kevin Moraga
2016-05-09 18:40             ` Boris Ostrovsky
2016-05-10  7:23               ` Jan Beulich
2016-05-10 13:39                 ` Boris Ostrovsky
2016-05-10 13:57                   ` Jan Beulich
2016-05-10 15:19                     ` Juergen Gross
2016-05-10 15:35                       ` Jan Beulich
     [not found]                       ` <57321BFA02000078000EA3C2@suse.com>
2016-05-10 15:43                         ` Juergen Gross
2016-05-10 16:35                           ` Boris Ostrovsky
2016-05-11  5:49                             ` Juergen Gross
2016-05-11  6:35                               ` Jan Beulich
     [not found]                               ` <5732EEBF02000078000EA613@suse.com>
2016-05-11  7:00                                 ` Juergen Gross
2016-05-11  7:15                                   ` Jan Beulich
     [not found]                                   ` <5732F83D02000078000EA6A2@suse.com>
2016-05-11  9:57                                     ` Juergen Gross
2016-05-11 10:03                                       ` Jan Beulich
     [not found]                                       ` <57331FA002000078000EA831@suse.com>
2016-05-11 10:10                                         ` Juergen Gross
2016-05-11 12:09                                           ` Jan Beulich
2016-05-11 10:16                                   ` David Vrabel
2016-05-11 12:21                                     ` Jan Beulich
2016-05-11 12:48                                       ` David Vrabel
2016-05-11 13:13                                         ` Jan Beulich
2016-05-11 13:15                                         ` Juergen Gross
2016-05-17 15:11                                     ` David Vrabel
2016-05-17 20:58                                       ` Kevin Moraga
2016-05-26 10:24                                       ` David Vrabel [this message]
2016-05-26 14:05                                         ` Boris Ostrovsky
2016-05-26 15:24                                           ` David Vrabel
2016-06-01 16:12                                         ` Martin Cerveny
2016-06-01 16:23                                           ` Martin Cerveny
2016-06-01 19:32                                             ` Boris Ostrovsky
2016-06-01 21:01                                               ` Martin Cerveny
2016-06-01 22:37                                                 ` Boris Ostrovsky
2016-06-02  6:04                                                   ` Martin Cerveny
2016-06-02 13:15                                                     ` Martin Cerveny
2016-06-02  9:54                                           ` David Vrabel
2016-05-10 16:11                 ` Kevin Moraga
2016-05-10 20:11                   ` Boris Ostrovsky
2016-05-12  4:52                     ` Kevin Moraga
  -- strict thread matches above, loose matches on Subject: below --
2016-03-28 17:00 Michael Young
2016-03-29 10:07 ` Jan Beulich
2016-03-29 17:50 ` Konrad Rzeszutek Wilk

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=5746CEFB.7020403@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=kmoragas@riseup.net \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).