[PATCH v2 4/5] x86_64/mm: map and unmap page tables in destroy_compat_m2p_mapping

2020-04-08 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v2: - there is pretty much no point in keeping l3_ro_mpt mapped, just fetch the l3e instead, which also cleans up the code. --- xen/arch/x86/x86_64/mm.c | 12 1 file changed, 8 insertions(+), 4

[PATCH v2 5/5] x86_64/mm: map and unmap page tables in destroy_m2p_mapping

2020-04-08 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v2: - no point in re-mapping l2t because it is exactly the same as l2_ro_mpt. - point l2_ro_mpt to the entry instead of doing l2_table_offset() all the time. --- xen/arch/x86/x86_64/mm.c | 17

[PATCH v2 3/5] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table

2020-04-08 Thread Hongyan Xia
From: Wei Liu Fetch lYe by mapping and unmapping lXe instead of using the direct map, which is now done via the lYe_from_lXe() helpers. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v2: - the introduction of the macros is now lifted to a previous patch. --- xen/arch/x86

[PATCH v2 2/5] x86_64/mm: map and unmap page tables in m2p_mapped

2020-04-08 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v2: - avoid adding goto labels, simply get the PTE and unmap quickly. - code style fixes. --- xen/arch/x86/x86_64/mm.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch

[PATCH v2 0/5] use new API for Xen page tables

2020-04-08 Thread Hongyan Xia
From: Hongyan Xia This small series is basically just rewriting functions using the new API to map and unmap PTEs. Each patch is independent. Apart from mapping and unmapping page tables, no other functional change intended. --- Changed in v2: - I kept UNMAP_DOMAIN_PAGE() for now in v2, but I

Re: [PATCH v2 1/5] x86/shim: map and unmap page tables in replace_va_mapping

2020-04-14 Thread Hongyan Xia
On Thu, 2020-04-09 at 11:42 +0200, Jan Beulich wrote: > On 08.04.2020 15:36, Hongyan Xia wrote: > > --- a/xen/arch/x86/pv/shim.c > > +++ b/xen/arch/x86/pv/shim.c > > @@ -168,16 +168,17 @@ const struct platform_bad_page *__init > > pv_shim_reserved_pages(unsigned int *s

Re: [PATCH 1/2] x86: drop unnecessary page table walking in compat r/o M2P handling

2020-04-15 Thread Hongyan Xia
OMPAT_MPT_VIRT_START); > /* Allocate and map the compatibility mode machine-to-phys > table. */ > mpt_size = (mpt_size >> 1) + (1UL << (L2_PAGETABLE_SHIFT - 1)); The code around here, I am wondering if there is a reason to put it in this patch. If we bisect, we

Re: [PATCH 1/2] x86: drop unnecessary page table walking in compat r/o M2P handling

2020-04-15 Thread Hongyan Xia
On Wed, 2020-04-15 at 12:34 +0200, Jan Beulich wrote: > On 15.04.2020 11:59, Hongyan Xia wrote: > > ... > > I would like to drop relevant map/unmap patches and replace them > > with > > the new clean-up ones (and place them at the beginning of the > > series),

[PATCH v3 1/4] x86/shim: map and unmap page tables in replace_va_mapping

2020-04-15 Thread Hongyan Xia
-by: Hongyan Xia --- Changed in v3: - use unmap_domain_page() instead of the macro in several places. - also introduce l1e_from_l2e(). - add _ prefix in macros to avoid aliasing. Changed in v2: - instead of map, map, map, read/write, unmap, unmap, unmap, do map, read PTE, unmap for each level

[PATCH v3 0/4] use new API for Xen page tables

2020-04-15 Thread Hongyan Xia
From: Hongyan Xia This small series is basically just rewriting functions using the new API to map and unmap PTEs. Each patch is independent. Apart from mapping and unmapping page tables, no other functional change intended. --- Changed in v3: - address all comments in v2. - drop patch 4

[PATCH v3 4/4] x86_64/mm: map and unmap page tables in destroy_m2p_mapping

2020-04-15 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v3: - rename l2_ro_mpt into pl2e to avoid confusion. Changed in v2: - no point in re-mapping l2t because it is exactly the same as l2_ro_mpt. - point l2_ro_mpt to the entry instead of doing l2_table_offset() all

[PATCH v3 3/4] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table

2020-04-15 Thread Hongyan Xia
From: Wei Liu Fetch lYe by mapping and unmapping lXe instead of using the direct map, which is now done via the lYe_from_lXe() helpers. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- Changed in v2: - the introduction of the macros is now lifted to a previous

[PATCH v3 2/4] x86_64/mm: map and unmap page tables in m2p_mapped

2020-04-15 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- Changed in v3: - rename l3e_ro_mpt and l2e_ro_mpt, just call them l3e and l2e. Changed in v2: - avoid adding goto labels, simply get the PTE and unmap quickly. - code style fixes. --- xen/arch/x86

[PATCH v4 1/4] x86/shim: map and unmap page tables in replace_va_mapping

2020-04-15 Thread Hongyan Xia
-by: Hongyan Xia --- Changed in v4: - use _ suffixes instead of prefixes. Changed in v3: - use unmap_domain_page() instead of the macro in several places. - also introduce l1e_from_l2e(). - add _ prefix in macros to avoid aliasing. Changed in v2: - instead of map, map, map, read/write, unmap

[PATCH v4 2/4] x86_64/mm: map and unmap page tables in m2p_mapped

2020-04-15 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- Changed in v3: - rename l3e_ro_mpt and l2e_ro_mpt, just call them l3e and l2e. Changed in v2: - avoid adding goto labels, simply get the PTE and unmap quickly. - code style fixes. --- xen/arch/x86

[PATCH v4 4/4] x86_64/mm: map and unmap page tables in destroy_m2p_mapping

2020-04-15 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v4: - switch to normal unmap_domain_page() for variable right before end-of-scope. Changed in v3: - rename l2_ro_mpt into pl2e to avoid confusion. Changed in v2: - no point in re-mapping l2t because it is

[PATCH v4 0/4] use new API for Xen page tables

2020-04-15 Thread Hongyan Xia
From: Hongyan Xia This small series is basically just rewriting functions using the new API to map and unmap PTEs. Each patch is independent. Apart from mapping and unmapping page tables, no other functional change intended. --- Changed in v4: - use _ suffix instead of prefix in macros. - use

[PATCH v4 3/4] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table

2020-04-15 Thread Hongyan Xia
From: Wei Liu Fetch lYe by mapping and unmapping lXe instead of using the direct map, which is now done via the lYe_from_lXe() helpers. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- Changed in v2: - the introduction of the macros is now lifted to a previous

[PATCH 2/6] x86_64/mm: map and unmap page tables in subarch_init_memory

2020-04-17 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 18210405f4..5714e5ba62 100644 --- a/xen/arch/x86/x86_64/mm.c

[PATCH 4/6] x86/smpboot: map and unmap page tables in cleanup_cpu_root_pgt

2020-04-17 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/smpboot.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 09264b02d1..275ce7661d 100644 --- a/xen/arch/x86

[PATCH 0/6] convert more Xen page table code to the new API

2020-04-17 Thread Hongyan Xia
From: Hongyan Xia Basically just rewriting functions using the new API to map and unmap PTEs. Each patch is independent. Apart from mapping and unmapping page tables, no other functional change intended. Wei Liu (6): x86_64/mm: map and unmap page tables in cleanup_frame_table x86_64/mm

[PATCH 3/6] x86_64/mm: map and unmap page tables in subarch_memory_op

2020-04-17 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 5714e5ba62..6d52183559 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b

[PATCH 1/6] x86_64/mm: map and unmap page tables in cleanup_frame_table

2020-04-17 Thread Hongyan Xia
From: Wei Liu Also fix a weird indentation. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index e85ef449f3..18210405f4

[PATCH 6/6] x86/pv: map and unmap page table in dom0_construct_pv

2020-04-17 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 28a939b68a..a03f0501ab 100644 --- a/xen/arch/x86/pv

[PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-17 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 32 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 5678da782d..28a939b68a

Re: [PATCH 0/6] convert more Xen page table code to the new API

2020-04-24 Thread Hongyan Xia
A gentle ping. On Fri, 2020-04-17 at 10:52 +0100, Hongyan Xia wrote: > From: Hongyan Xia > > Basically just rewriting functions using the new API to map and unmap > PTEs. Each patch is independent. > > Apart from mapping and unmapping page tables, no other functional &

Re: [PATCH 1/6] x86_64/mm: map and unmap page tables in cleanup_frame_table

2020-04-24 Thread Hongyan Xia
Hi Julien, On Fri, 2020-04-24 at 09:59 +0100, Julien Grall wrote: > (resending) > > On 17/04/2020 10:52, Hongyan Xia wrote: > > From: Wei Liu > > > > Also fix a weird indentation. > > > > Signed-off-by: Wei Liu > > Signed-off-by: Hongyan Xia

[PATCH v6 01/15] x86/mm: map_pages_to_xen would better have one exit path

2020-04-24 Thread Hongyan Xia
-by: Hongyan Xia --- Changed since v4: - drop the end_of_loop goto label. Changed since v3: - remove asserts on rc since rc never gets changed to anything else. - reword commit message. --- xen/arch/x86/mm.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a

[PATCH v6 07/15] x86_64/mm: switch to new APIs in paging_init

2020-04-24 Thread Hongyan Xia
From: Wei Liu Map and unmap pages instead of relying on the direct map. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 43 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen

[PATCH v6 06/15] x86_64/mm: introduce pl2e in paging_init

2020-04-24 Thread Hongyan Xia
From: Wei Liu Introduce pl2e so that we can use l2_ro_mpt to point to the page table itself. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x

[PATCH v6 03/15] x86/mm: rewrite virt_to_xen_l*e

2020-04-24 Thread Hongyan Xia
From: Wei Liu Rewrite those functions to use the new APIs. Modify its callers to unmap the pointer returned. Note that the change of virt_to_xen_l1e() also requires vmap_to_mfn() to unmap the page, which requires domain_page.h header in vmap. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia

[PATCH v6 04/15] x86/mm: switch to new APIs in map_pages_to_xen

2020-04-24 Thread Hongyan Xia
From: Wei Liu Page tables allocated in that function should be mapped and unmapped now. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 60 --- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86

[PATCH v6 00/15] switch to domheap for Xen page tables

2020-04-24 Thread Hongyan Xia
From: Hongyan Xia This series rewrites all the remaining functions and finally makes the switch from xenheap to domheap for Xen page tables, so that they no longer need to rely on the direct map, which is a big step towards removing the direct map. This series depends on the following two mini

[PATCH v6 08/15] x86_64/mm: switch to new APIs in setup_m2p_table

2020-04-24 Thread Hongyan Xia
From: Wei Liu Also reduce the scope of l2_ro_mpt as it is only used inside the loop, and remove two lines of l2_ro_mpt check which serve no purpose. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 24 +--- 1 file changed, 13 insertions

[PATCH v6 05/15] x86/mm: switch to new APIs in modify_xen_mappings

2020-04-24 Thread Hongyan Xia
From: Wei Liu Page tables allocated in that function should be mapped and unmapped now. Note that pl2e now maybe mapped and unmapped in different iterations, so we need to add clean-ups for that. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 57

[PATCH v6 09/15] efi: use new page table APIs in copy_mapping

2020-04-24 Thread Hongyan Xia
From: Wei Liu After inspection ARM doesn't have alloc_xen_pagetable so this function is x86 only, which means it is safe for us to change. Signed-off-by: Wei Liu --- xen/common/efi/boot.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b

[PATCH v6 02/15] x86/mm: make sure there is one exit path for modify_xen_mappings

2020-04-24 Thread Hongyan Xia
From: Wei Liu We will soon need to handle dynamically mapping / unmapping page tables in the said function. Since dynamic mappings may map and unmap pl3e in different iterations, lift pl3e out of the loop. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed

[PATCH v6 12/15] x86/smpboot: switch pl*e to use new APIs in clone_mapping

2020-04-24 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/smpboot.c | 54 +++--- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 5b0e24f925..0e0ae56c76 100644 --- a

[PATCH v6 11/15] x86/smpboot: clone_mapping should have one exit path

2020-04-24 Thread Hongyan Xia
From: Wei Liu We will soon need to clean up page table mappings in the exit path. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/smpboot.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/smpboot.c b

[PATCH v6 13/15] x86/mm: drop old page table APIs

2020-04-24 Thread Hongyan Xia
From: Hongyan Xia Two sets of old APIs, alloc/free_xen_pagetable() and lXe_to_lYe(), are now dropped to avoid the dependency on direct map. There are two special cases which still have not been re-written into the new APIs, thus need special treatment: rpt in smpboot.c cannot use ephemeral

[PATCH v6 14/15] x86: switch to use domheap page for page tables

2020-04-24 Thread Hongyan Xia
From: Hongyan Xia Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 749b6f23e5..7e212cc3e0 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c

[PATCH v6 10/15] efi: switch to new APIs in EFI code

2020-04-24 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/efi/runtime.h | 10 +++-- xen/common/efi/boot.c | 46 ++ xen/common/efi/efi.h | 3 ++- xen/common/efi/runtime.c | 8 +++ 4 files changed, 46 insertions

[PATCH v6 15/15] x86/mm: drop _new suffix for page table APIs

2020-04-24 Thread Hongyan Xia
From: Wei Liu No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c| 48 xen/arch/x86/smpboot.c | 12 +- xen/arch/x86/x86_64/mm.c | 10 - xen/common/efi/boot.c| 10 - xen

Re: [PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-28 Thread Hongyan Xia
On Tue, 2020-04-28 at 17:33 +0200, Jan Beulich wrote: > On 17.04.2020 11:52, Hongyan Xia wrote: > > --- a/xen/arch/x86/pv/dom0_build.c > > +++ b/xen/arch/x86/pv/dom0_build.c > > @@ -50,17 +50,17 @@ static __init void > > mark_pv_pt_pages_rdonly(struct domain *d, &

Re: [PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-28 Thread Hongyan Xia
On Tue, 2020-04-28 at 16:55 +0100, Hongyan Xia wrote: > On Tue, 2020-04-28 at 17:33 +0200, Jan Beulich wrote: > > On 17.04.2020 11:52, Hongyan Xia wrote: > > > --- a/xen/arch/x86/pv/dom0_build.c > > > +++ b/xen/arch/x86/pv/dom0_build.c > > > @@

Re: [PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-29 Thread Hongyan Xia
On Tue, 2020-04-28 at 16:59 +0100, Hongyan Xia wrote: > On Tue, 2020-04-28 at 16:55 +0100, Hongyan Xia wrote: > > On Tue, 2020-04-28 at 17:33 +0200, Jan Beulich wrote: > > > On 17.04.2020 11:52, Hongyan Xia wrote: > > > > --- a/xen/arch/x86/pv/dom0_build.c

Re: [PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-29 Thread Hongyan Xia
-by: Hongyan Xia Reviewed-by: Julien Grall --- xen/arch/x86/pv/dom0_build.c | 32 +--- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index abfbe5f436..3522eb0114 100644 --- a/xen/arch/x86/pv

[PATCH] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly

2020-04-29 Thread Hongyan Xia
From: Wei Liu Also, clean up the initialisation of plXe. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since last revision: - lift this patch out since others in the series have been merged. - remove lXt variables and reuse plXe for unmapping. - clean up plXe initialisation

[PATCH 09/16] x86: lift mapcache variable to the arch level

2020-04-30 Thread Hongyan Xia
: Wei Wang Signed-off-by: Hongyan Xia --- xen/arch/x86/domain.c| 4 ++-- xen/arch/x86/domain_page.c | 22 ++ xen/include/asm-x86/domain.h | 12 ++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c

[PATCH 05/16] x86: map/unmap pages in restore_all_guests.

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia Before, it assumed the pv cr3 could be accessed via a direct map. This is no longer true. Note that we do not map and unmap root_pgt for now since it is still a xenheap page. Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/entry.S | 27 ++- 1 file

[PATCH 00/16] Remove the direct map

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia This series depends on Xen page table domheap conversion: https://lists.xenproject.org/archives/html/xen-devel/2020-04/msg01374.html. After breaking the reliance on the direct map to manipulate Xen page tables, we can now finally remove the direct map altogether. This series

[PATCH 07/16] x86/pv: rewrite how building PV dom0 handles domheap mappings

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. This is clearly wrong. Fix. Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 58 ++-- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a

[PATCH 06/16] x86/pv: domheap pages should be mapped while relocating initrd

2020-04-30 Thread Hongyan Xia
From: Wei Liu Xen shouldn't use domheap page as if they were xenheap pages. Map and unmap pages accordingly. Signed-off-by: Wei Liu Signed-off-by: Wei Wang --- xen/arch/x86/pv/dom0_build.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/pv/d

[PATCH 02/16] acpi: vmap pages in acpi_os_alloc_memory

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia Also, introduce a wrapper around vmap that maps a contiguous range for boot allocations. Signed-off-by: Hongyan Xia --- xen/drivers/acpi/osl.c | 9 - xen/include/xen/vmap.h | 5 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/drivers/acpi

[PATCH 04/16] x86/srat: vmap the pages for acpi_slit

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia This avoids the assumption that boot pages are in the direct map. Signed-off-by: Hongyan Xia --- xen/arch/x86/srat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index 506a56d66b..9a84c6c8a8 100644 --- a/xen

[PATCH 01/16] x86/setup: move vm_init() before acpi calls

2020-04-30 Thread Hongyan Xia
what vmap is for. Therefore, we bring vm_init into early boot stage. To allow vmap to be initialised and used in early boot, we need to modify vmap to receive pages from the boot allocator during early boot stage. Signed-off-by: Wei Liu Signed-off-by: David Woodhouse Signed-off-by: Hongyan Xia

[PATCH 08/16] x86: add Persistent Map (PMAP) infrastructure

2020-04-30 Thread Hongyan Xia
infrastructure is not lock-protected therefore can only be used before smpboot. After smpboot, mapcache has to be used. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/Makefile| 1 + xen/arch/x86/pmap.c | 87 xen/include

[PATCH 03/16] x86/numa: vmap the pages for memnodemap

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia This avoids the assumption that there is a direct map and boot pages fall inside the direct map. Clean up the variables so that mfn actually stores a type-safe mfn. Signed-off-by: Hongyan Xia --- xen/arch/x86/numa.c | 8 1 file changed, 4 insertions(+), 4 deletions

[PATCH 12/16] x86/domain_page: remove the fast paths when mfn is not in the directmap

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia When mfn is not in direct map, never use mfn_to_virt for any mappings. We replace mfn_x(mfn) <= PFN_DOWN(__pa(HYPERVISOR_VIRT_END - 1)) with arch_mfn_in_direct_map(mfn) because these two are equivalent. The extra comparison in arch_mfn_in_direct_map() looks different

[PATCH 16/16] x86/setup: do not create valid mappings when directmap=no

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia Create empty mappings in the second e820 pass. Also, destroy existing direct map mappings created in the first pass. To make xenheap pages visible in guests, it is necessary to create empty L3 tables in the direct map even when directmap=no, since guest cr3s copy idle domain&#

[PATCH 11/16] x86: add a boot option to enable and disable the direct map

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia Also add a helper function to retrieve it. Change arch_mfn_in_direct_map to check this option before returning. This is added as a boot command line option, not a Kconfig. We do not produce different builds for EC2 so this is not introduced as a compile-time configuration

[PATCH 13/16] xen/page_alloc: add a path for xenheap when there is no direct map

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia When there is not an always-mapped direct map, xenheap allocations need to be mapped and unmapped on-demand. Signed-off-by: Hongyan Xia --- xen/common/page_alloc.c | 45 ++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a

[PATCH 15/16] x86/setup: vmap heap nodes when they are outside the direct map

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia When we do not have a direct map, arch_mfn_in_direct_map() will always return false, thus init_node_heap() will allocate xenheap pages from an existing node for the metadata of a new node. This means that the metadata of a new node is in a different node, slowing down heap

[PATCH 10/16] x86/mapcache: initialise the mapcache for the idle domain

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia In order to use the mapcache in the idle domain, we also have to populate its page tables in the PERDOMAIN region, and we need to move mapcache_domain_init() earlier in arch_domain_create(). Note, commit 'x86: lift mapcache variable to the arch level' has initi

[PATCH 14/16] x86/setup: leave early boot slightly earlier

2020-04-30 Thread Hongyan Xia
From: Hongyan Xia When we do not have a direct map, memory for metadata of heap nodes in init_node_heap() is allocated from xenheap, which needs to be mapped and unmapped on demand. However, we cannot just take memory from the boot allocator to create the PTEs while we are passing memory to the

Re: [PATCH 02/16] acpi: vmap pages in acpi_os_alloc_memory

2020-05-01 Thread Hongyan Xia
On Fri, 2020-05-01 at 12:02 +, Wei Liu wrote: > On Thu, Apr 30, 2020 at 09:44:11PM +0100, Hongyan Xia wrote: > > From: Hongyan Xia > > > > Also, introduce a wrapper around vmap that maps a contiguous range > > for > > boot allocations. > > > >

Re: [PATCH 11/16] x86: add a boot option to enable and disable the direct map

2020-05-01 Thread Hongyan Xia
On Fri, 2020-05-01 at 12:11 +, Wei Liu wrote: > On Thu, Apr 30, 2020 at 09:44:20PM +0100, Hongyan Xia wrote: > > From: Hongyan Xia > > > > Also add a helper function to retrieve it. Change > > arch_mfn_in_direct_map > > to check this option before returning.

Re: [PATCH 00/16] Remove the direct map

2020-05-01 Thread Hongyan Xia
On Fri, 2020-05-01 at 12:07 +, Wei Liu wrote: > On Thu, Apr 30, 2020 at 09:44:09PM +0100, Hongyan Xia wrote: > > From: Hongyan Xia > > > > This series depends on Xen page table domheap conversion: > > https://lists.xenproject.org/archives/html/xen-

Re: [PATCH 02/16] acpi: vmap pages in acpi_os_alloc_memory

2020-05-04 Thread Hongyan Xia
On Fri, 2020-05-01 at 22:35 +0100, Julien Grall wrote: > Hi, > > On Thu, 30 Apr 2020 at 21:44, Hongyan Xia wrote: > > > > From: Hongyan Xia > > > > Also, introduce a wrapper around vmap that maps a contiguous range > > for > > boot all

[PATCH] x86/traps: fix an off-by-one error

2020-05-05 Thread Hongyan Xia
From: Hongyan Xia stack++ can go into the next page and unmap_domain_page() will unmap the wrong one, causing mapcache and memory corruption. Fix. This is found with direct map removal. For now, the idle domain does not have a mapcache and uses the direct map, so no errors will occur. Signed

Re: [PATCH] x86/traps: fix an off-by-one error

2020-05-05 Thread Hongyan Xia
On Tue, 2020-05-05 at 15:38 +0200, Jan Beulich wrote: > On 05.05.2020 13:06, Hongyan Xia wrote: > > --- a/xen/arch/x86/traps.c > > +++ b/xen/arch/x86/traps.c > > @@ -300,6 +300,7 @@ static void show_guest_stack(struct vcpu *v, > > const struct cpu_user_regs *regs) > &

[PATCH v2] x86/traps: fix an off-by-one error

2020-05-05 Thread Hongyan Xia
From: Hongyan Xia stack++ can go into the next page and unmap_domain_page() will unmap the wrong one, causing mapcache and memory corruption. Fix. Signed-off-by: Hongyan Xia --- Changed in v2: - tweak how the unmap is handled. - fix the bug in compat as well. - remove part of the commit

Re: [PATCH v6 12/15] x86/smpboot: switch pl*e to use new APIs in clone_mapping

2020-05-11 Thread Hongyan Xia
On Thu, 2020-04-30 at 17:15 +0200, Jan Beulich wrote: > On 24.04.2020 16:09, Hongyan Xia wrote: > > From: Wei Liu > > Nit: Why the emphasis on pl*e in the title? Is there anything left > unconverted in the function? IOW how about "switch clone_mapping() > to new pa

[PATCH] domain_page: handle NULL within unmap_domain_page() itself

2020-05-13 Thread Hongyan Xia
From: Hongyan Xia The macro version UNMAP_DOMAIN_PAGE() does both NULL checking and variable clearing. Move NULL checking into the function itself so that the semantics is consistent with other similar constructs like XFREE(). This also eases the use unmap_domain_page() in error handling paths

Re: Error during update_runstate_area with KPTI activated

2020-05-15 Thread Hongyan Xia
On Fri, 2020-05-15 at 11:08 +0100, Julien Grall wrote: > Hi, > > On 15/05/2020 10:57, Roger Pau Monné wrote: > > On Fri, May 15, 2020 at 10:23:16AM +0100, Julien Grall wrote: > > > [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open > > > attachments unless you have verified the sender a

Re: RoCE adapters and Xen.

2020-05-17 Thread Hongyan Xia
On Sun, 2020-05-17 at 13:15 +, Jason Long wrote: > Hello, > The Xen hypervisor doesn't support the RoCE adapters? The Oracle > migrates to the KVM because of it. > Why not add this feature? I am curious. Aren't RoCE adapters just PCIe devices? If things are set up correctly and drivers are pre

[Xen-devel] [PATCH] x86/mm: switch to new APIs in arch_init_memory

2020-02-21 Thread Hongyan Xia
after unmapping, and ignore NULL in unmap_domain_page. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c| 2 +- xen/arch/x86/mm.c | 14 -- xen/include/xen/domain_page.h | 5 + 3 files changed, 14 insertions(+), 7 deletions(-) diff

[Xen-devel] [PATCH v2] x86/mm: switch to new APIs in arch_init_memory

2020-02-27 Thread Hongyan Xia
the UNMAP_DOMAIN_PAGE macro to nullify the variable after unmapping, and ignore NULL. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed in v2: - let UNMAP_DOMAIN_PAGE itself check whether the input is NULL to avoid adding the check in unmap_domain_page. - reword the commit message

[Xen-devel] [PATCH] x86/tboot: check return value of dmar_table allocation

2020-03-16 Thread Hongyan Xia
From: Hongyan Xia The allocation can just return NULL. Return an error value early instead of crashing later on. Signed-off-by: Hongyan Xia --- xen/arch/x86/tboot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 8c232270b4..ce85a710dd

[Xen-devel] [PATCH 3/5] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table

2020-03-23 Thread Hongyan Xia
From: Wei Liu Fetch lYe by mapping and unmapping lXe instead of using the direct map, which is now done via the new lYe_from_lXe() helpers. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 12 ++-- xen/include/asm-x86/page.h | 18

[Xen-devel] [PATCH 0/5] use new API for Xen page tables

2020-03-23 Thread Hongyan Xia
From: Hongyan Xia This small series is basically just rewriting functions using the new API to map and unmap PTEs. Each patch is independent. Apart from mapping and unmapping page tables, no other functional change intended. Wei Liu (5): x86/shim: map and unmap page tables in

[Xen-devel] [PATCH 2/5] x86_64/mm: map and unmap page tables in m2p_mapped

2020-03-23 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Reviewed-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index b7ce833ffc..a440dac25e 100644 --- a/xen/arch/x86/x86_64

[Xen-devel] [PATCH 4/5] x86_64/mm: map and unmap page tables in destroy_compat_m2p_mapping

2020-03-23 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Reviewed-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 2680173fab..71c84ac593 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b

[Xen-devel] [PATCH 1/5] x86/shim: map and unmap page tables in replace_va_mapping

2020-03-23 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Reviewed-by: Hongyan Xia --- xen/arch/x86/pv/shim.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index ed2ece8a8a..1229d5ffb3 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen

[Xen-devel] [PATCH 5/5] x86_64/mm: map and unmap page tables in destroy_m2p_mapping

2020-03-23 Thread Hongyan Xia
From: Wei Liu Signed-off-by: Wei Liu Reviewed-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 71c84ac593..6a0ffe088b 100644 --- a/xen/arch/x86/x86_64

Re: [Xen-devel] [PATCH 16/17] xen/mm: Convert {s, g}et_gpfn_from_mfn() to use typesafe MFN

2020-03-23 Thread Hongyan Xia
h > index a2c6049834..39dae242b0 100644 > --- a/xen/include/asm-x86/p2m.h > +++ b/xen/include/asm-x86/p2m.h > @@ -505,7 +505,7 @@ static inline struct page_info > *get_page_from_gfn( > static inline gfn_t mfn_to_gfn(const struct domain *d, mfn_t mfn) > { > if ( paging_mode_translate(d) ) > -return _gfn(get_gpfn_from_mfn(mfn_x(mfn))); > +return _gfn(get_pfn_from_mfn(mfn)); > else > return _gfn(mfn_x(mfn)); > } Apart from the two comments above, looks good to me. Reviewed-by: Hongyan Xia ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH] Revert "domctl: improve locking during domain destruction"

2020-03-24 Thread Hongyan Xia
From: Hongyan Xia Unfortunately, even though that commit dropped the domctl lock and allowed other domctl to continue, it created severe lock contention within domain destructions themselves. Multiple domain destructions in parallel now spin for the global heap lock when freeing memory and could

XSM and the idle domain

2020-10-21 Thread Hongyan Xia
Hi, A while ago there was a quick chat on IRC about how XSM interacts with the idle domain. The conversation did not reach any clear conclusions so it might be a good idea to summarise the questions in an email. Basically there were two questions in that conversation: 1. In its current state, ar

Re: XSM and the idle domain

2020-10-22 Thread Hongyan Xia
(also replying to others in this thread.) On Wed, 2020-10-21 at 12:21 -0400, Jason Andryuk wrote: > On Wed, Oct 21, 2020 at 10:35 AM Hongyan Xia wrote: > > > > Hi, > > ... > > > > The first question came up during ongoing work in LiveUpdate. After > > a

Re: XSM and the idle domain

2020-10-22 Thread Hongyan Xia
On Thu, 2020-10-22 at 13:51 +0100, Andrew Cooper wrote: > On 21/10/2020 15:34, Hongyan Xia wrote: > > The first question came up during ongoing work in LiveUpdate. After > > an > > LU, the next Xen needs to restore all domains. To do that, some > > hypercalls need to be

[Xen-devel] [PATCH v5 2/7] x86: introduce a new set of APIs to manage Xen page tables

2020-01-07 Thread Hongyan Xia
tched to use domheap and dynamic mappings when usage of old APIs is eliminated. No functional change intended in this patch. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall --- Changed since v4: - properly handle INVALID_MFN. - remove the _new suffix fo

[Xen-devel] [PATCH v5 1/7] x86: move some xen mm function declarations

2020-01-07 Thread Hongyan Xia
From: Wei Liu They were put into page.h but mm.h is more appropriate. The real reason is that I will be adding some new functions which takes mfn_t. It turns out it is a bit difficult to do in page.h. No functional change. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- Changed since v3: -

[Xen-devel] [PATCH v5 4/7] x86/mm: introduce l{1, 2}t local variables to modify_xen_mappings

2020-01-07 Thread Hongyan Xia
From: Wei Liu The pl2e and pl1e variables are heavily (ab)used in that function. It is fine at the moment because all page tables are always mapped so there is no need to track the life time of each variable. We will soon have the requirement to map and unmap page tables. We need to track the l

[Xen-devel] [PATCH v5 7/7] x86/mm: change pl*e to l*t in virt_to_xen_l*e

2020-01-07 Thread Hongyan Xia
From: Wei Liu We will need to have a variable named pl*e when we rewrite virt_to_xen_l*e. Change pl*e to l*t to reflect better its purpose. This will make reviewing later patch easier. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- xen

[Xen-devel] [PATCH v5 5/7] x86/mm: map_pages_to_xen would better have one exit path

2020-01-07 Thread Hongyan Xia
From: Wei Liu We will soon rewrite the function to handle dynamically mapping and unmapping of page tables. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v4: - drop the end_of_loop goto label since this function may be refactored in the future

[Xen-devel] [PATCH v5 0/7] Add alternative API for XEN PTEs

2020-01-07 Thread Hongyan Xia
This batch adds an alternative alloc-map-unmap-free Xen PTE API to the normal alloc-free on the xenheap, in preparation of switching to domheap for Xen page tables. Since map and unmap are basically no-ops now, and other changes are cosmetic to ease future patches, this batch does not introduce any

[Xen-devel] [PATCH v5 6/7] x86/mm: make sure there is one exit path for modify_xen_mappings

2020-01-07 Thread Hongyan Xia
From: Wei Liu We will soon need to handle dynamically mapping / unmapping page tables in the said function. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v4: - drop the end_of_loop goto label since this function may be refactored in the future

[Xen-devel] [PATCH v5 3/7] x86/mm: introduce l{1, 2}t local variables to map_pages_to_xen

2020-01-07 Thread Hongyan Xia
From: Wei Liu The pl2e and pl1e variables are heavily (ab)used in that function. It is fine at the moment because all page tables are always mapped so there is no need to track the life time of each variable. We will soon have the requirement to map and unmap page tables. We need to track the li

[Xen-devel] [PATCH v6] x86: introduce a new set of APIs to manage Xen page tables

2020-01-28 Thread Hongyan Xia
Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall --- Changed since v5: - sounds like we are happy to use map_domain_page for Xen PTEs. Remove map/unmap_xen_pagetable, just use map/unmap_domain_page instead. - remove redundant logic in free_xen_pagetable. Changed since v4: - properly handle

[Xen-devel] [PATCH] x86/domain_page: implement pure per-vCPU mapping infrastructure

2020-02-03 Thread Hongyan Xia
available, which is not enough for nested page table walks. We need to increase the number of slots in config.h. Signed-off-by: Hongyan Xia --- xen/arch/x86/domain.c| 5 +- xen/arch/x86/domain_page.c | 229 +++ xen/include/asm-x86/config.h | 2 +- xen

<    1   2   3   >