Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1263589

Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD

From "H. Peter Anvin" <hpa@zytor.com>
Newsgroups linux.kernel
Subject Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD
Date 2015-11-05 23:40 +0100
Message-ID <qrBmh-4ms-21@gated-at.bofh.it> (permalink)
References <qrxVo-1Y0-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 11/05/15 10:56, Boris Ostrovsky wrote:
> The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved
> for hypervisor and therefore we should not try to follow PGD's indexes
> corresponding to those addresses.
> 
> While this has alsways been a problem, with commit e1a58320a38d ("x86/mm:
> Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called
> during boot, causing a PV Xen guest to crash.
> 
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
>  arch/x86/mm/dump_pagetables.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
> index 1bf417e..756c921 100644
> --- a/arch/x86/mm/dump_pagetables.c
> +++ b/arch/x86/mm/dump_pagetables.c
> @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>  				       bool checkwx)
>  {
>  #ifdef CONFIG_X86_64
> +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */
> +#define is_hypervisor_range(idx) (paravirt_enabled() && \
> +				  (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \
> +				   ((idx) < pgd_index(__PAGE_OFFSET))))
>  	pgd_t *start = (pgd_t *) &init_level4_pgt;
>  #else
> +#define is_hypervisor_range(idx)   0
>  	pgd_t *start = swapper_pg_dir;
>  #endif
>  	pgprotval_t prot;
> @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
>  
>  	for (i = 0; i < PTRS_PER_PGD; i++) {
>  		st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
> -		if (!pgd_none(*start)) {
> +		if (!pgd_none(*start) && !is_hypervisor_range(i)) {
>  			if (pgd_large(*start) || !pgd_present(*start)) {
>  				prot = pgd_flags(*start);
>  				note_page(m, &st, __pgprot(prot), 1);
> 

Maybe we could use the max_lines field in the address_markers[] array?
We really shouldn't be mapping anything in the hypervisor space even on
native.

	-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86/mm: Skip the hypervisor range when walking PGD Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-11-05 20:00 +0100
  Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD "H. Peter Anvin" <hpa@zytor.com> - 2015-11-05 23:40 +0100
    Re: [PATCH] x86/mm: Skip the hypervisor range when walking PGD Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-11-06 04:40 +0100
  [tip:x86/urgent] x86/mm:   Skip the hypervisor range when walking PGD tip-bot for Boris Ostrovsky <tipbot@zytor.com> - 2015-11-07 10:50 +0100

csiph-web