All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch V2 0/4] xen: correct several bugs in new p2m list setup
@ 2015-01-12  5:05 Juergen Gross
  2015-01-12  5:05 ` [Patch V2 1/4] xen: correct error for building p2m list on 32 bits Juergen Gross
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Juergen Gross @ 2015-01-12  5:05 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel,
	boris.ostrovsky, jbeulich
  Cc: Juergen Gross

In the setup code of the linear mapped p2m list several bugs have
been found, especially for 32 bit dom0. These patches correct the
errors and make 32 bit dom0 bootable again.

Changes since V1:
- split up patch 3 as requested by David Vrabel
- use phys_addr_t instead of u64 as requested by Jan Beulich
- compare pfns instead physical addresses as suggested by Jan Beulich

Juergen Gross (4):
  xen: correct error for building p2m list on 32 bits
  xen: correct race in alloc_p2m_pmd()
  xen: use correct type for physical addresses
  xen: check for zero sized area when invalidating memory

 arch/x86/xen/p2m.c   | 11 ++++-------
 arch/x86/xen/setup.c |  6 ++++--
 2 files changed, 8 insertions(+), 9 deletions(-)

-- 
2.1.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Patch V2 1/4] xen: correct error for building p2m list on 32 bits
  2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
@ 2015-01-12  5:05 ` Juergen Gross
  2015-01-12  5:05 ` [Patch V2 2/4] xen: correct race in alloc_p2m_pmd() Juergen Gross
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2015-01-12  5:05 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel,
	boris.ostrovsky, jbeulich
  Cc: Juergen Gross

In xen_rebuild_p2m_list() for large areas of invalid or identity
mapped memory the pmd entries on 32 bit systems are initialized
wrong. Correct this error.

Suggested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index d9660a5..36ae094 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -379,7 +379,7 @@ static void __init xen_rebuild_p2m_list(unsigned long *p2m)
 			p2m_missing_pte : p2m_identity_pte;
 		for (i = 0; i < PMDS_PER_MID_PAGE; i++) {
 			pmdp = populate_extra_pmd(
-				(unsigned long)(p2m + pfn + i * PTRS_PER_PTE));
+				(unsigned long)(p2m + pfn) + i * PMD_SIZE);
 			set_pmd(pmdp, __pmd(__pa(ptep) | _KERNPG_TABLE));
 		}
 	}
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Patch V2 2/4] xen: correct race in alloc_p2m_pmd()
  2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
  2015-01-12  5:05 ` [Patch V2 1/4] xen: correct error for building p2m list on 32 bits Juergen Gross
@ 2015-01-12  5:05 ` Juergen Gross
  2015-01-12  5:05 ` [Patch V2 3/4] xen: use correct type for physical addresses Juergen Gross
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2015-01-12  5:05 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel,
	boris.ostrovsky, jbeulich
  Cc: Juergen Gross

When allocating a new pmd for the linear mapped p2m list a check is
done for not introducing another pmd when this just happened on
another cpu. In this case the old pte pointer was returned which
points to the p2m_missing or p2m_identity page. The correct value
would be the pointer to the found new page.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/p2m.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 36ae094..fdb996e 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -440,10 +440,9 @@ EXPORT_SYMBOL_GPL(get_phys_to_machine);
  * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual
  * pmd. In case of PAE/x86-32 there are multiple pmds to allocate!
  */
-static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)
+static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *pte_pg)
 {
 	pte_t *ptechk;
-	pte_t *pteret = ptep;
 	pte_t *pte_newpg[PMDS_PER_MID_PAGE];
 	pmd_t *pmdp;
 	unsigned int level;
@@ -477,8 +476,6 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)
 		if (ptechk == pte_pg) {
 			set_pmd(pmdp,
 				__pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE));
-			if (vaddr == (addr & ~(PMD_SIZE - 1)))
-				pteret = pte_offset_kernel(pmdp, addr);
 			pte_newpg[i] = NULL;
 		}
 
@@ -492,7 +489,7 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)
 		vaddr += PMD_SIZE;
 	}
 
-	return pteret;
+	return lookup_address(addr, &level);
 }
 
 /*
@@ -521,7 +518,7 @@ static bool alloc_p2m(unsigned long pfn)
 
 	if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) {
 		/* PMD level is missing, allocate a new one */
-		ptep = alloc_p2m_pmd(addr, ptep, pte_pg);
+		ptep = alloc_p2m_pmd(addr, pte_pg);
 		if (!ptep)
 			return false;
 	}
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Patch V2 3/4] xen: use correct type for physical addresses
  2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
  2015-01-12  5:05 ` [Patch V2 1/4] xen: correct error for building p2m list on 32 bits Juergen Gross
  2015-01-12  5:05 ` [Patch V2 2/4] xen: correct race in alloc_p2m_pmd() Juergen Gross
@ 2015-01-12  5:05 ` Juergen Gross
  2015-01-12  5:05 ` [Patch V2 4/4] xen: check for zero sized area when invalidating memory Juergen Gross
  2015-01-12 11:10   ` David Vrabel
  4 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2015-01-12  5:05 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel,
	boris.ostrovsky, jbeulich
  Cc: Juergen Gross

When converting a pfn to a physical address be sure to use 64 bit
wide types or convert the physical address to a pfn if possible.

Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/xen/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index feb6d86..410210f 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -140,7 +140,7 @@ static void __init xen_del_extra_mem(u64 start, u64 size)
 unsigned long __ref xen_chk_extra_mem(unsigned long pfn)
 {
 	int i;
-	unsigned long addr = PFN_PHYS(pfn);
+	phys_addr_t addr = PFN_PHYS(pfn);
 
 	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
 		if (addr >= xen_extra_mem[i].start &&
@@ -284,7 +284,7 @@ static void __init xen_update_mem_tables(unsigned long pfn, unsigned long mfn)
 	}
 
 	/* Update kernel mapping, but not for highmem. */
-	if ((pfn << PAGE_SHIFT) >= __pa(high_memory))
+	if (pfn >= PFN_UP(__pa(high_memory - 1)))
 		return;
 
 	if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT),
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Patch V2 4/4] xen: check for zero sized area when invalidating memory
  2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
                   ` (2 preceding siblings ...)
  2015-01-12  5:05 ` [Patch V2 3/4] xen: use correct type for physical addresses Juergen Gross
@ 2015-01-12  5:05 ` Juergen Gross
  2015-01-12 11:10   ` David Vrabel
  4 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2015-01-12  5:05 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel,
	boris.ostrovsky, jbeulich
  Cc: Juergen Gross

With the introduction of the linear mapped p2m list setting memory
areas to "invalid" had to be delayed. When doing the invalidation
make sure no zero sized areas are processed.

Signed-off-by: Juegren Gross <jgross@suse.com>
---
 arch/x86/xen/setup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 410210f..865e56c 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -160,6 +160,8 @@ void __init xen_inv_extra_mem(void)
 	int i;
 
 	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
+		if (!xen_extra_mem[i].size)
+			continue;
 		pfn_s = PFN_DOWN(xen_extra_mem[i].start);
 		pfn_e = PFN_UP(xen_extra_mem[i].start + xen_extra_mem[i].size);
 		for (pfn = pfn_s; pfn < pfn_e; pfn++)
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Xen-devel] [Patch V2 0/4] xen: correct several bugs in new p2m list setup
  2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
@ 2015-01-12 11:10   ` David Vrabel
  2015-01-12  5:05 ` [Patch V2 2/4] xen: correct race in alloc_p2m_pmd() Juergen Gross
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: David Vrabel @ 2015-01-12 11:10 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, konrad.wilk,
	david.vrabel, boris.ostrovsky, jbeulich

On 12/01/15 05:05, Juergen Gross wrote:
> In the setup code of the linear mapped p2m list several bugs have
> been found, especially for 32 bit dom0. These patches correct the
> errors and make 32 bit dom0 bootable again.

Applied to stable/for-linus-3.19, thanks.

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xen-devel] [Patch V2 0/4] xen: correct several bugs in new p2m list setup
@ 2015-01-12 11:10   ` David Vrabel
  0 siblings, 0 replies; 7+ messages in thread
From: David Vrabel @ 2015-01-12 11:10 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, konrad.wilk,
	david.vrabel, boris.ostrovsky, jbeulich

On 12/01/15 05:05, Juergen Gross wrote:
> In the setup code of the linear mapped p2m list several bugs have
> been found, especially for 32 bit dom0. These patches correct the
> errors and make 32 bit dom0 bootable again.

Applied to stable/for-linus-3.19, thanks.

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-12 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12  5:05 [Patch V2 0/4] xen: correct several bugs in new p2m list setup Juergen Gross
2015-01-12  5:05 ` [Patch V2 1/4] xen: correct error for building p2m list on 32 bits Juergen Gross
2015-01-12  5:05 ` [Patch V2 2/4] xen: correct race in alloc_p2m_pmd() Juergen Gross
2015-01-12  5:05 ` [Patch V2 3/4] xen: use correct type for physical addresses Juergen Gross
2015-01-12  5:05 ` [Patch V2 4/4] xen: check for zero sized area when invalidating memory Juergen Gross
2015-01-12 11:10 ` [Xen-devel] [Patch V2 0/4] xen: correct several bugs in new p2m list setup David Vrabel
2015-01-12 11:10   ` David Vrabel

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.