linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: <xen-devel@lists.xenproject.org>, <linux-kernel@vger.kernel.org>,
	<boris.ostrovsky@oracle.com>, <stefano.stabellini@eu.citrix.com>,
	<david.vrabel@citrix.com>, <hpa@zytor.com>
Subject: Re: [PATCH v13 05/19] xen/mmu/p2m: Refactor the xen_pagetable_init code (v2).
Date: Sun, 5 Jan 2014 17:51:56 +0000	[thread overview]
Message-ID: <alpine.DEB.2.02.1401051751160.8667@kaball.uk.xensource.com> (raw)
In-Reply-To: <1388777916-1328-6-git-send-email-konrad.wilk@oracle.com>

On Fri, 3 Jan 2014, Konrad Rzeszutek Wilk wrote:
> The revector and copying of the P2M only happens when
> !auto-xlat and on 64-bit builds. It is not obvious from
> the code, so lets have seperate 32 and 64-bit functions.
> 
> We also invert the check for auto-xlat to make the code
> flow simpler.
> 
> Suggested-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  arch/x86/xen/mmu.c | 70 +++++++++++++++++++++++++++++-------------------------
>  1 file changed, 37 insertions(+), 33 deletions(-)
> 
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index ce563be..c140eff 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -1198,44 +1198,40 @@ static void __init xen_cleanhighmap(unsigned long vaddr,
>  	 * instead of somewhere later and be confusing. */
>  	xen_mc_flush();
>  }
> -#endif
> -static void __init xen_pagetable_init(void)
> +static void __init xen_pagetable_p2m_copy(void)
>  {
> -#ifdef CONFIG_X86_64
>  	unsigned long size;
>  	unsigned long addr;
> -#endif
> -	paging_init();
> -	xen_setup_shared_info();
> -#ifdef CONFIG_X86_64
> -	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
> -		unsigned long new_mfn_list;
> +	unsigned long new_mfn_list;
> +
> +	if (xen_feature(XENFEAT_auto_translated_physmap))
> +		return;
> +
> +	size = PAGE_ALIGN(xen_start_info->nr_pages * sizeof(unsigned long));
> +
> +	/* On 32-bit, we get zero so this never gets executed. */
> +	new_mfn_list = xen_revector_p2m_tree();
> +	if (new_mfn_list && new_mfn_list != xen_start_info->mfn_list) {
> +		/* using __ka address and sticking INVALID_P2M_ENTRY! */
> +		memset((void *)xen_start_info->mfn_list, 0xff, size);
> +
> +		/* We should be in __ka space. */
> +		BUG_ON(xen_start_info->mfn_list < __START_KERNEL_map);
> +		addr = xen_start_info->mfn_list;
> +		/* We roundup to the PMD, which means that if anybody at this stage is
> +		 * using the __ka address of xen_start_info or xen_start_info->shared_info
> +		 * they are in going to crash. Fortunatly we have already revectored
> +		 * in xen_setup_kernel_pagetable and in xen_setup_shared_info. */
> +		size = roundup(size, PMD_SIZE);
> +		xen_cleanhighmap(addr, addr + size);
>  
>  		size = PAGE_ALIGN(xen_start_info->nr_pages * sizeof(unsigned long));
> +		memblock_free(__pa(xen_start_info->mfn_list), size);
> +		/* And revector! Bye bye old array */
> +		xen_start_info->mfn_list = new_mfn_list;
> +	} else
> +		return;
>  
> -		/* On 32-bit, we get zero so this never gets executed. */
> -		new_mfn_list = xen_revector_p2m_tree();
> -		if (new_mfn_list && new_mfn_list != xen_start_info->mfn_list) {
> -			/* using __ka address and sticking INVALID_P2M_ENTRY! */
> -			memset((void *)xen_start_info->mfn_list, 0xff, size);
> -
> -			/* We should be in __ka space. */
> -			BUG_ON(xen_start_info->mfn_list < __START_KERNEL_map);
> -			addr = xen_start_info->mfn_list;
> -			/* We roundup to the PMD, which means that if anybody at this stage is
> -			 * using the __ka address of xen_start_info or xen_start_info->shared_info
> -			 * they are in going to crash. Fortunatly we have already revectored
> -			 * in xen_setup_kernel_pagetable and in xen_setup_shared_info. */
> -			size = roundup(size, PMD_SIZE);
> -			xen_cleanhighmap(addr, addr + size);
> -
> -			size = PAGE_ALIGN(xen_start_info->nr_pages * sizeof(unsigned long));
> -			memblock_free(__pa(xen_start_info->mfn_list), size);
> -			/* And revector! Bye bye old array */
> -			xen_start_info->mfn_list = new_mfn_list;
> -		} else
> -			goto skip;
> -	}
>  	/* At this stage, cleanup_highmap has already cleaned __ka space
>  	 * from _brk_limit way up to the max_pfn_mapped (which is the end of
>  	 * the ramdisk). We continue on, erasing PMD entries that point to page
> @@ -1255,7 +1251,15 @@ static void __init xen_pagetable_init(void)
>  	 * anything at this stage. */
>  	xen_cleanhighmap(MODULES_VADDR, roundup(MODULES_VADDR, PUD_SIZE) - 1);
>  #endif
> -skip:
> +}
> +#endif
> +
> +static void __init xen_pagetable_init(void)
> +{
> +	paging_init();
> +	xen_setup_shared_info();
> +#ifdef CONFIG_X86_64
> +	xen_pagetable_p2m_copy();
>  #endif
>  	xen_post_allocator_init();
>  }
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2014-01-05 17:52 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03 19:38 [PATCH v13] Linux Xen PVH support (v13) Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 01/19] xen/p2m: Check for auto-xlat when doing mfn_to_local_pfn Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 02/19] xen/pvh/x86: Define what an PVH guest is (v3) Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 03/19] xen/pvh: Early bootup changes in PV code (v4) Konrad Rzeszutek Wilk
2014-01-05 17:49   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 04/19] xen/pvh: Don't setup P2M tree Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 05/19] xen/mmu/p2m: Refactor the xen_pagetable_init code (v2) Konrad Rzeszutek Wilk
2014-01-05 17:51   ` Stefano Stabellini [this message]
2014-01-03 19:38 ` [PATCH v13 06/19] xen/mmu: Cleanup xen_pagetable_p2m_copy a bit Konrad Rzeszutek Wilk
2014-01-05 17:56   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 07/19] xen/pvh: MMU changes for PVH (v2) Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 08/19] xen/pvh/mmu: Use PV TLB instead of native Konrad Rzeszutek Wilk
2014-01-05 18:11   ` Stefano Stabellini
2014-01-05 19:41     ` Konrad Rzeszutek Wilk
2014-01-06 11:33       ` Stefano Stabellini
2014-01-06 14:59         ` Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 09/19] xen/pvh: Setup up shared_info Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 10/19] xen/pvh: Load GDT/GS in early PV bootup code for BSP Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 11/19] xen/pvh: Secondary VCPU bringup (non-bootup CPUs) Konrad Rzeszutek Wilk
2014-01-06 10:52   ` David Vrabel
2014-01-06 15:03     ` Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 12/19] xen/pvh: Update E820 to work with PVH (v2) Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 13/19] xen/pvh: Piggyback on PVHVM for event channels (v2) Konrad Rzeszutek Wilk
2014-01-05 18:15   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 14/19] xen/grants: Remove gnttab_max_grant_frames dependency on gnttab_init Konrad Rzeszutek Wilk
2014-01-05 18:16   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 15/19] xen/grant-table: Refactor gnttab_init Konrad Rzeszutek Wilk
2014-01-05 18:18   ` Stefano Stabellini
2014-01-05 19:33     ` Konrad Rzeszutek Wilk
2014-01-03 19:38 ` [PATCH v13 16/19] xen/grant: Implement an grant frame array struct (v2) Konrad Rzeszutek Wilk
2014-01-05 18:38   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 17/19] xen/pvh: Piggyback on PVHVM for grant driver (v4) Konrad Rzeszutek Wilk
2014-01-05 18:20   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 18/19] xen/pvh: Piggyback on PVHVM XenBus Konrad Rzeszutek Wilk
2014-01-05 17:54   ` Stefano Stabellini
2014-01-03 19:38 ` [PATCH v13 19/19] xen/pvh: Support ParaVirtualized Hardware extensions (v3) Konrad Rzeszutek Wilk
2014-01-06 10:55 ` [PATCH v13] Linux Xen PVH support (v13) David Vrabel
2014-01-06 14:53   ` 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=alpine.DEB.2.02.1401051751160.8667@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hpa@zytor.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.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 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).