[PATCH V4 14/15] xen/arm64: Implement a mapcache for arm64

2024-11-11 Thread Elias El Yandouzi
. This will change in a follow-up patch. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi There are a few TODOs: - It is becoming more critical to fix the mapcache implementation (this is not compliant with the Arm Arm) - Evaluate the performance diff

[PATCH V4 00/15] Remove the directmap

2024-11-11 Thread Elias El Yandouzi
Hi all, A few years ago, Wei Liu implemented a PoC to remove the directmap from Xen. The last version was sent by Hongyan Xia [1]. I will start with thanking both Wei and Hongyan for the initial work to upstream the feature. A lot of patches already went in and this is the last few patches missin

[PATCH V4 13/15] xen/arm64: mm: Use per-pCPU page-tables

2024-11-11 Thread Elias El Yandouzi
ified. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changelog since v1: * Rebase * Fix typoes diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index 671eaadbc1d5..c1c6450ca2e3 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/

[PATCH V4 03/15] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-11-11 Thread Elias El Yandouzi
From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. Use the pages as they should be. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V4: * Reduce the scope of l{1,2,4}start_mfn

[PATCH V4 12/15] xen/arm32: mm: Rename 'first' to 'root' in init_secondary_pagetables()

2024-11-11 Thread Elias El Yandouzi
From: Julien Grall The arm32 version of init_secondary_pagetables() will soon be re-used for arm64 as well where the root table starts at level 0 rather than level 1. So rename 'first' to 'root'. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V4 15/15] xen/arm64: Allow the admin to enable/disable the directmap

2024-11-11 Thread Elias El Yandouzi
From: Julien Grall Implement the same command line option as x86 to enable/disable the directmap. By default this is kept enabled. Also modify setup_directmap_mappings() to populate the L0 entries related to the directmap area. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V4 10/15] xen/page_alloc: vmap heap nodes when they are outside the direct map

2024-11-11 Thread Elias El Yandouzi
allocation. Since we now have early vmap, vmap the metadata locally in the new node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v4: * Change type of the parameters to paddr_t * Use clear_domain_page() instead of

[PATCH V4 02/15] x86/pv: Use copy_domain_page() to manage domheap pages during initrd relocation

2024-11-11 Thread Elias El Yandouzi
From: Wei Liu Replace the manual copying logic with a call to `copy_domain_page()` while relocating intird which map and unmap pages accordingly. Signed-off-by: Wei Liu Signed-off-by: Wei Wang Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V4

[PATCH V4 09/15] x86/setup: Leave early boot slightly earlier

2024-11-11 Thread Elias El Yandouzi
, we already have enough memory in the heap allocator in the 1st node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v4: * Fix indentation * Refactor the code to reduce code duplication diff --git a/xen/arch/x86

[PATCH V4 11/15] x86/setup: Do not create valid mappings when directmap=no

2024-11-11 Thread Elias El Yandouzi
ongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4e258419ac34..1633ed0302b1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1022,6 +1022,56 @@ static struct domain *__init create_dom0(cons

[PATCH V4 04/15] x86: Initialize mapcache for PV, HVM, and idle domains

2024-11-11 Thread Elias El Yandouzi
Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V4: * Reword the commit message * Rebase it on top of staging * The logic for the creation of the domain has been reworked so introduced

[PATCH V4 01/15] x86: Create per-domain mapping for guest_root_pt

2024-11-11 Thread Elias El Yandouzi
. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V4: * Fix over-allocation issue * Update the mappings when switching from kernel to user-mode Changes in V3: * Rename SHADOW_ROOT * Haven't addresse

[PATCH V4 06/15] xen/x86: Add support for the PMAP

2024-11-11 Thread Elias El Yandouzi
Signed-off-by: Elias El Yandouzi The PMAP infrastructure was upstream separately for Arm since Hongyan sent the secret-free hypervisor series. So this is a new patch to plumb the feature on x86. Changes in v4: * Select PMAP KConfig option iff ONDEMAND_DIRECTMAP is used

[PATCH V4 08/15] xen/page_alloc: Add a path for xenheap when there is no direct map

2024-11-11 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi I have left the call to map_pages_to_xen() and

[PATCH V4 05/15] x86: Add a boot option to enable and disable the direct map

2024-11-11 Thread Elias El Yandouzi
-up patches. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V4: * Rename the Kconfig options * Set opt_directmap to true if CONFIG_HAS_ONDEMAND_DIRECTMAP is not enabled Changes in V2: * Introduce a

[PATCH V4 07/15] x86/domain_page: Remove the fast paths when mfn is not in the directmap

2024-11-11 Thread Elias El Yandouzi
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_mfns_in_direct_map(mfn, 1) because these two are equivalent. The extra comparison in arch_mfns_in_direct_map() looks different but b

Re: [PATCH V3 (resend) 03/19] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-07-16 Thread Elias El Yandouzi
Hi Jan, On 14/05/2024 16:03, Jan Beulich wrote: On 13.05.2024 15:40, Elias El Yandouzi wrote: --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -382,6 +382,10 @@ int __init dom0_construct_pv(struct domain *d, l3_pgentry_t *l3tab = NULL, *l3start = NULL

Re: [PATCH V3 (resend) 01/19] x86: Create per-domain mapping of guest_root_pt

2024-06-13 Thread Elias El Yandouzi
Hi Jan, On 16/05/2024 08:17, Jan Beulich wrote: On 15.05.2024 20:25, Elias El Yandouzi wrote: However, I noticed quite a weird bug while doing some testing. I may need your expertise to find the root cause. Looks like you've overflowed the dom0 kernel stack, most likely because of recu

Re: [PATCH V3 (resend) 01/19] x86: Create per-domain mapping of guest_root_pt

2024-05-15 Thread Elias El Yandouzi
Hi Jan, On 14/05/2024 15:51, Jan Beulich wrote: On 13.05.2024 15:40, Elias El Yandouzi wrote: From: Hongyan Xia Create a per-domain mapping of PV guest_root_pt as direct map is being removed. Note that we do not map and unmap root_pgt for now since it is still a xenheap page. Signed-off-by

Re: [PATCH V3 01/19] x86: Create per-domain mapping of guest_root_pt

2024-05-14 Thread Elias El Yandouzi
Hi Roger, On 13/05/2024 16:27, Roger Pau Monné wrote: diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c index 2a445bb17b..1b025986f7 100644 --- a/xen/arch/x86/pv/domain.c +++ b/xen/arch/x86/pv/domain.c @@ -288,6 +288,21 @@ static void pv_destroy_gdt_ldt_l1tab(struct vcpu *v)

[PATCH V3 (resend) 17/19] xen/arm64: mm: Use per-pCPU page-tables

2024-05-13 Thread Elias El Yandouzi
ified. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changelog since v1: * Rebase * Fix typoes diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index 293acb67e0..2ec1ffe1dc 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/arm6

[PATCH V3 (resend) 14/19] Rename mfn_to_virt() calls

2024-05-13 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mfn_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to mfn_to_directmap_virt() to flag them and prevent further use of mfn_to_virt(). Signed-off-by: Elias El Yandouzi diff --git

[PATCH V3 (resend) 18/19] xen/arm64: Implement a mapcache for arm64

2024-05-13 Thread Elias El Yandouzi
. This will change in a follow-up patch. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi There are a few TODOs: - It is becoming more critical to fix the mapcache implementation (this is not compliant with the Arm Arm) - Evaluate the performance diff

[PATCH V3 (resend) 16/19] xen/arm32: mm: Rename 'first' to 'root' in init_secondary_pagetables()

2024-05-13 Thread Elias El Yandouzi
From: Julien Grall The arm32 version of init_secondary_pagetables() will soon be re-used for arm64 as well where the root table starts at level 0 rather than level 1. So rename 'first' to 'root'. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V3 (resend) 19/19] xen/arm64: Allow the admin to enable/disable the directmap

2024-05-13 Thread Elias El Yandouzi
From: Julien Grall Implement the same command line option as x86 to enable/disable the directmap. By default this is kept enabled. Also modify setup_directmap_mappings() to populate the L0 entries related to the directmap area. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V3 (resend) 15/19] Rename maddr_to_virt() calls

2024-05-13 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mmaddr_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to maddr_to_directmap_virt() to flag them and prevent further use of maddr_to_virt(). Signed-off-by: Elias El Yandouzi diff

[PATCH V3 (resend) 13/19] x86/setup: Do not create valid mappings when directmap=no

2024-05-13 Thread Elias El Yandouzi
ongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f26c9799e4..919347d8c2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -978,6 +978,57 @@ static struct domain *__init create_dom0(const module

[PATCH V3 (resend) 10/19] xen/page_alloc: Add a path for xenheap when there is no direct map

2024-05-13 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi I have left the call to map_pages_to_xen() and

[PATCH V3 (resend) 08/19] xen/x86: Add build assertion for fixmap entries

2024-05-13 Thread Elias El Yandouzi
The early fixed addresses must all fit into the static L1 table. Introduce a build assertion to this end. Signed-off-by: Elias El Yandouzi Changes in v2: * New patch diff --git a/xen/arch/x86/include/asm/fixmap.h b/xen/arch/x86/include/asm/fixmap.h index a7ac365fc6

[PATCH V3 (resend) 12/19] x86/setup: vmap heap nodes when they are outside the direct map

2024-05-13 Thread Elias El Yandouzi
allocation. Since we now have early vmap, vmap the metadata locally in the new node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: * vmap_contig_pages() was renamed to vmap_contig() * Fix indentation and coding

[PATCH V3 (resend) 01/19] x86: Create per-domain mapping of guest_root_pt

2024-05-13 Thread Elias El Yandouzi
From: Hongyan Xia Create a per-domain mapping of PV guest_root_pt as direct map is being removed. Note that we do not map and unmap root_pgt for now since it is still a xenheap page. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in

[PATCH V3 (resend) 11/19] x86/setup: Leave early boot slightly earlier

2024-05-13 Thread Elias El Yandouzi
, we already have enough memory in the heap allocator in the 1st node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index bd6b1184f5..f26c9799e4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86

[PATCH V3 (resend) 06/19] x86: Add a boot option to enable and disable the direct map

2024-05-13 Thread Elias El Yandouzi
there remains some users of the directmap at this point. The option is introduced now as it will be needed in follow-up patches. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Introduce a Kconfig option * Reword

[PATCH V3 (resend) 05/19] x86/mapcache: Initialise the mapcache for the idle domain

2024-05-13 Thread Elias El Yandouzi
alised the mapcache for HVM domains. With this patch, PV, HVM, idle domains now all initialise the mapcache. Signed-off-by: Wei Wang Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Free resources if mapcache initialisa

[PATCH V3 (resend) 07/19] xen/x86: Add support for the PMAP

2024-05-13 Thread Elias El Yandouzi
Signed-off-by: Elias El Yandouzi The PMAP infrastructure was upstream separately for Arm since Hongyan sent the secret-free hypervisor series. So this is a new patch to plumb the feature on x86. Changes in v2: * Declare PMAP entries earlier in fixed_addresses

[PATCH V3 (resend) 04/19] x86: Lift mapcache variable to the arch level

2024-05-13 Thread Elias El Yandouzi
From: Wei Liu It is going to be needed by HVM and idle domain as well, because without the direct map, both need a mapcache to map pages. This commit lifts the mapcache variable up and initialise it a bit earlier for PV and HVM domains. Signed-off-by: Wei Liu Signed-off-by: Wei Wang Signed-of

[PATCH V3 (resend) 09/19] x86/domain_page: Remove the fast paths when mfn is not in the directmap

2024-05-13 Thread Elias El Yandouzi
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_mfns_in_direct_map(mfn, 1) because these two are equivalent. The extra comparison in arch_mfns_in_direct_map() looks different but b

[PATCH V3 (resend) 03/19] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-05-13 Thread Elias El Yandouzi
From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. Use the pages as they should be. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V3: * Fold following patch 'x86/pv: M

[PATCH V3 (resend) 00/19] Remove the directmap

2024-05-13 Thread Elias El Yandouzi
ic?). === Future of secret-free hypervisor === There are some information in an e-mail from Andrew a few years ago: https://lore.kernel.org/xen-devel/e3219697-0759-39fc-2486-715cdec1c...@citrix.com/ Cheers, [1] https://lore.kernel.org/xen-devel/cover.1588278317.git.hongy...@amazon.com/ *** BLUR

[PATCH V3 (resend) 02/19] x86/pv: Domheap pages should be mapped while relocating initrd

2024-05-13 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V3: * Rename commit title * R

[PATCH V3 19/19] xen/arm64: Allow the admin to enable/disable the directmap

2024-05-13 Thread Elias El Yandouzi
From: Julien Grall Implement the same command line option as x86 to enable/disable the directmap. By default this is kept enabled. Also modify setup_directmap_mappings() to populate the L0 entries related to the directmap area. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V3 09/19] x86/domain_page: Remove the fast paths when mfn is not in the directmap

2024-05-13 Thread Elias El Yandouzi
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_mfns_in_direct_map(mfn, 1) because these two are equivalent. The extra comparison in arch_mfns_in_direct_map() looks different but b

[PATCH V3 08/19] xen/x86: Add build assertion for fixmap entries

2024-05-13 Thread Elias El Yandouzi
The early fixed addresses must all fit into the static L1 table. Introduce a build assertion to this end. Signed-off-by: Elias El Yandouzi Changes in v2: * New patch diff --git a/xen/arch/x86/include/asm/fixmap.h b/xen/arch/x86/include/asm/fixmap.h index a7ac365fc6

[PATCH V3 14/19] Rename mfn_to_virt() calls

2024-05-13 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mfn_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to mfn_to_directmap_virt() to flag them and prevent further use of mfn_to_virt(). Signed-off-by: Elias El Yandouzi diff --git

[PATCH V3 17/19] xen/arm64: mm: Use per-pCPU page-tables

2024-05-13 Thread Elias El Yandouzi
ified. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changelog since v1: * Rebase * Fix typoes diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index 293acb67e0..2ec1ffe1dc 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/arm6

[PATCH V3 10/19] xen/page_alloc: Add a path for xenheap when there is no direct map

2024-05-13 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi I have left the call to map_pages_to_xen() and

[PATCH V3 16/19] xen/arm32: mm: Rename 'first' to 'root' in init_secondary_pagetables()

2024-05-13 Thread Elias El Yandouzi
From: Julien Grall The arm32 version of init_secondary_pagetables() will soon be re-used for arm64 as well where the root table starts at level 0 rather than level 1. So rename 'first' to 'root'. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH V3 13/19] x86/setup: Do not create valid mappings when directmap=no

2024-05-13 Thread Elias El Yandouzi
ongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f26c9799e4..919347d8c2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -978,6 +978,57 @@ static struct domain *__init create_dom0(const module

[PATCH V3 18/19] xen/arm64: Implement a mapcache for arm64

2024-05-13 Thread Elias El Yandouzi
. This will change in a follow-up patch. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi There are a few TODOs: - It is becoming more critical to fix the mapcache implementation (this is not compliant with the Arm Arm) - Evaluate the performance diff

[PATCH V3 12/19] x86/setup: vmap heap nodes when they are outside the direct map

2024-05-13 Thread Elias El Yandouzi
allocation. Since we now have early vmap, vmap the metadata locally in the new node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: * vmap_contig_pages() was renamed to vmap_contig() * Fix indentation and coding

[PATCH V3 15/19] Rename maddr_to_virt() calls

2024-05-13 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mmaddr_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to maddr_to_directmap_virt() to flag them and prevent further use of maddr_to_virt(). Signed-off-by: Elias El Yandouzi diff

[PATCH V3 03/19] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-05-13 Thread Elias El Yandouzi
From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. Use the pages as they should be. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V3: * Fold following patch 'x86/pv: M

[PATCH V3 06/19] x86: Add a boot option to enable and disable the direct map

2024-05-13 Thread Elias El Yandouzi
there remains some users of the directmap at this point. The option is introduced now as it will be needed in follow-up patches. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Introduce a Kconfig option * Reword

[PATCH V3 05/19] x86/mapcache: Initialise the mapcache for the idle domain

2024-05-13 Thread Elias El Yandouzi
alised the mapcache for HVM domains. With this patch, PV, HVM, idle domains now all initialise the mapcache. Signed-off-by: Wei Wang Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Free resources if mapcache initialisa

[PATCH V3 11/19] x86/setup: Leave early boot slightly earlier

2024-05-13 Thread Elias El Yandouzi
, we already have enough memory in the heap allocator in the 1st node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index bd6b1184f5..f26c9799e4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86

[PATCH V3 04/19] x86: Lift mapcache variable to the arch level

2024-05-13 Thread Elias El Yandouzi
From: Wei Liu It is going to be needed by HVM and idle domain as well, because without the direct map, both need a mapcache to map pages. This commit lifts the mapcache variable up and initialise it a bit earlier for PV and HVM domains. Signed-off-by: Wei Liu Signed-off-by: Wei Wang Signed-of

[PATCH V3 02/19] x86/pv: Domheap pages should be mapped while relocating initrd

2024-05-13 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V3: * Rename commit title * R

[PATCH V3 07/19] xen/x86: Add support for the PMAP

2024-05-13 Thread Elias El Yandouzi
Signed-off-by: Elias El Yandouzi The PMAP infrastructure was upstream separately for Arm since Hongyan sent the secret-free hypervisor series. So this is a new patch to plumb the feature on x86. Changes in v2: * Declare PMAP entries earlier in fixed_addresses

[PATCH V3 01/19] x86: Create per-domain mapping of guest_root_pt

2024-05-13 Thread Elias El Yandouzi
From: Hongyan Xia Create a per-domain mapping of PV guest_root_pt as direct map is being removed. Note that we do not map and unmap root_pgt for now since it is still a xenheap page. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in

[PATCH V3 00/19] Remove the directmap

2024-05-13 Thread Elias El Yandouzi
ic?). === Future of secret-free hypervisor === There are some information in an e-mail from Andrew a few years ago: https://lore.kernel.org/xen-devel/e3219697-0759-39fc-2486-715cdec1c...@citrix.com/ Cheers, [1] https://lore.kernel.org/xen-devel/cover.1588278317.git.hongy...@amazon.com/ *** BLUR

Re: [PATCH v2 (resend) 13/27] x86: Add a boot option to enable and disable the direct map

2024-05-13 Thread Elias El Yandouzi
On 20/02/2024 11:14, Jan Beulich wrote: On 16.01.2024 20:25, Elias El Yandouzi wrote: --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -29,6 +29,7 @@ config X86 select HAS_UBSAN select HAS_VPCI if HVM select NEEDS_LIBELF + select HAS_SECRET_HIDING

Re: [PATCH v2 (resend) 12/27] x86/mapcache: Initialise the mapcache for the idle domain

2024-05-13 Thread Elias El Yandouzi
On 20/02/2024 10:51, Jan Beulich wrote: On 16.01.2024 20:25, Elias El Yandouzi wrote: --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -750,9 +750,16 @@ int arch_domain_create(struct domain *d, spin_lock_init(&d->arch.e820_lock); +if ( (rc = mapcache_domain

Re: [PATCH v2 (resend) 12/27] x86/mapcache: Initialise the mapcache for the idle domain

2024-05-07 Thread Elias El Yandouzi
On 20/02/2024 10:51, Jan Beulich wrote: On 16.01.2024 20:25, Elias El Yandouzi wrote: --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -750,9 +750,16 @@ int arch_domain_create(struct domain *d, spin_lock_init(&d->arch.e820_lock); +if ( (rc = mapcache_domain

Re: [PATCH v2 (resend) 11/27] x86: Lift mapcache variable to the arch level

2024-05-07 Thread Elias El Yandouzi
This only lifts the mapcache variable up. Whether we populate the mapcache for a domain is unchanged in this patch. Is it? I wonder because of ... I agree, the commit message doesn't completely reflect the changes below. --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -843,6 +843

Re: [PATCH v2 (resend) 09/27] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-05-07 Thread Elias El Yandouzi
> On 20/02/2024 10:28, Jan Beulich wrote: On 16.01.2024 20:25, Elias El Yandouzi wrote: --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -382,6 +382,10 @@ int __init dom0_construct_pv(struct domain *d, l3_pgentry_t *l3tab = NULL, *l3start = NULL; l2_pgentr

Re: [PATCH v2 (resend) 07/27] x86: Map/unmap pages in restore_all_guests

2024-04-30 Thread Elias El Yandouzi
Hi Jan, From: Hongyan Xia Before, it assumed the pv cr3 could be accessed via a direct map. This is no longer true. There are a number of terminology issues here, starting with the title: Unlike (iirc) in an earlier version, no mapping/unmapping occurs in restore_all_guests itself anymore.

Re: [PATCH v2 (resend) 00/27] Remove the directmap

2024-02-05 Thread Elias El Yandouzi
Hi Jan, On 29/01/2024 08:28, Jan Beulich wrote: On 16.01.2024 20:25, Elias El Yandouzi wrote: Julien Grall (8): xen/vmap: Check the page has been mapped in vm_init_type() xen/vmap: Introduce vmap_size() and use it xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention

[PATCH v2 (resend) 21/27] x86/setup: Do not create valid mappings when directmap=no

2024-01-16 Thread Elias El Yandouzi
ongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3b698c8c41..84c496ac4a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -976,6 +976,57 @@ static struct domain *__init create_dom0(const module

[PATCH v2 (resend) 16/27] xen/x86: Add build assertion for fixmap entries

2024-01-16 Thread Elias El Yandouzi
The early fixed addresses must all fit into the static L1 table. Introduce a build assertion to this end. Signed-off-by: Elias El Yandouzi Changes in v2: * New patch diff --git a/xen/arch/x86/include/asm/fixmap.h b/xen/arch/x86/include/asm/fixmap.h index a7ac365fc6

[PATCH v2 (resend) 22/27] Rename mfn_to_virt() calls

2024-01-16 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mfn_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to mfn_to_directmap_virt() to flag them and prevent further use of mfn_to_virt(). Signed-off-by: Elias El Yandouzi diff --git

[PATCH v2 (resend) 27/27] xen/arm64: Allow the admin to enable/disable the directmap

2024-01-16 Thread Elias El Yandouzi
From: Julien Grall Implement the same command line option as x86 to enable/disable the directmap. By default this is kept enabled. Also modify setup_directmap_mappings() to populate the L0 entries related to the directmap area. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH v2 (resend) 20/27] x86/setup: vmap heap nodes when they are outside the direct map

2024-01-16 Thread Elias El Yandouzi
allocation. Since we now have early vmap, vmap the metadata locally in the new node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: * vmap_contig_pages() was renamed to vmap_contig() * Fix indentation and coding

[PATCH v2 (resend) 24/27] xen/arm32: mm: Rename 'first' to 'root' in init_secondary_pagetables()

2024-01-16 Thread Elias El Yandouzi
From: Julien Grall The arm32 version of init_secondary_pagetables() will soon be re-used for arm64 as well where the root table starts at level 0 rather than level 1. So rename 'first' to 'root'. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH v2 (resend) 23/27] Rename maddr_to_virt() calls

2024-01-16 Thread Elias El Yandouzi
Until directmap gets completely removed, we'd still need to keep some calls to mmaddr_to_virt() for xenheap pages or when the directmap is enabled. Rename the macro to maddr_to_directmap_virt() to flag them and prevent further use of maddr_to_virt(). Signed-off-by: Elias El Yandouzi diff

[PATCH v2 (resend) 18/27] xen/page_alloc: Add a path for xenheap when there is no direct map

2024-01-16 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi I have left the call to map_pages_to_xen() and

[PATCH v2 (resend) 19/27] x86/setup: Leave early boot slightly earlier

2024-01-16 Thread Elias El Yandouzi
, we already have enough memory in the heap allocator in the 1st node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b813ea75b5..3b698c8c41 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86

[PATCH v2 (resend) 26/27] xen/arm64: Implement a mapcache for arm64

2024-01-16 Thread Elias El Yandouzi
. This will change in a follow-up patch. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi There are a few TODOs: - It is becoming more critical to fix the mapcache implementation (this is not compliant with the Arm Arm) - Evaluate the performance diff

[PATCH v2 (resend) 25/27] xen/arm64: mm: Use per-pCPU page-tables

2024-01-16 Thread Elias El Yandouzi
ified. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changelog since v1: * Rebase * Fix typoes diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index d2651c9486..4f339efb7b 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/arm6

[PATCH v2 (resend) 17/27] x86/domain_page: Remove the fast paths when mfn is not in the directmap

2024-01-16 Thread Elias El Yandouzi
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_mfns_in_direct_map(mfn, 1) because these two are equivalent. The extra comparison in arch_mfns_in_direct_map() looks different but b

[PATCH v2 (resend) 13/27] x86: Add a boot option to enable and disable the direct map

2024-01-16 Thread Elias El Yandouzi
From: Hongyan Xia Also add a helper function to retrieve it. Change arch_mfns_in_direct_map to check this option before returning. This is added as a Kconfig option as well as a boot command line option. While being generic, the Kconfig option is only usable for x86 at the moment. Signed-off-by

[PATCH v2 (resend) 11/27] x86: Lift mapcache variable to the arch level

2024-01-16 Thread Elias El Yandouzi
From: Wei Liu It is going to be needed by HVM and idle domain as well, because without the direct map, both need a mapcache to map pages. This only lifts the mapcache variable up. Whether we populate the mapcache for a domain is unchanged in this patch. Signed-off-by: Wei Liu Signed-off-by: We

[PATCH v2 (resend) 12/27] x86/mapcache: Initialise the mapcache for the idle domain

2024-01-16 Thread Elias El Yandouzi
alised the mapcache for HVM domains. With this patch, PV, HVM, idle domains now all initialise the mapcache. Signed-off-by: Wei Wang Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Free resources if mapcache initialisa

[PATCH v2 (resend) 14/27] xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention

2024-01-16 Thread Elias El Yandouzi
are less change. So all the Arm fixmap slots will now be prefixed with FIX rather than FIXMAP. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Reviewed-by: Henry Wang Reviewed-by: Jan Beulich Reviewed-by: Stefano Stabellini Note that potentially more renaming that

[PATCH v2 (resend) 04/27] acpi: vmap pages in acpi_os_alloc_memory

2024-01-16 Thread Elias El Yandouzi
just the first page. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: * Rename vmap_contig_pages() to vmap_contig() * Rename nr_pages to nr to be consistent with vmap() parameters * Pass the whole regio

[PATCH v2 (resend) 06/27] x86/srat: vmap the pages for acpi_slit

2024-01-16 Thread Elias El Yandouzi
From: Hongyan Xia This avoids the assumption that boot pages are in the direct map. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi There was a discussion with Jan regarding early failure vs disable NUMA. I am strongly in favor of the

[PATCH v2 (resend) 09/27] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-01-16 Thread Elias El Yandouzi
From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. Use the pages as they should be. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Clarify the commit message

[PATCH v2 (resend) 05/27] xen/numa: vmap the pages for memnodemap

2024-01-16 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi See the

[PATCH v2 (resend) 15/27] xen/x86: Add support for the PMAP

2024-01-16 Thread Elias El Yandouzi
Signed-off-by: Elias El Yandouzi The PMAP infrastructure was upstream separately for Arm since Hongyan sent the secret-free hypervisor series. So this is a new patch to plumb the feature on x86. Changes in v2: * Declare PMAP entries earlier in fixed_addresses

[PATCH v2 (resend) 08/27] x86/pv: Domheap pages should be mapped while relocating initrd

2024-01-16 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in V2: * Get rid of mfn_to_virt *

[PATCH v2 (resend) 00/27] Remove the directmap

2024-01-16 Thread Elias El Yandouzi
ic?). === Future of secret-free hypervisor === There are some information in an e-mail from Andrew a few years ago: https://lore.kernel.org/xen-devel/e3219697-0759-39fc-2486-715cdec1c...@citrix.com/ Cheers, [1] https://lore.kernel.org/xen-devel/cover.1588278317.git.hongy...@amazon.com/ *** BLUR

[PATCH v2 (resend) 07/27] x86: Map/unmap pages in restore_all_guests

2024-01-16 Thread Elias El Yandouzi
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 Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi

[PATCH v2 (resend) 03/27] xen/vmap: Introduce vmap_size() and use it

2024-01-16 Thread Elias El Yandouzi
the given address. Take the opportunity to replace the open-coded version. Note that vfree() was storing the type of the area in a local variable. But this seems to have never been used (even when it was introduced). Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes

[PATCH v2 (resend) 02/27] x86/setup: Move vm_init() before acpi calls

2024-01-16 Thread Elias El Yandouzi
Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: - The return of map_pages_to_xen() is now checked in a separate patch - Clarify the commit message - Group the new boolean with the others diff --git a/xen/arch/arm/setup.c

[PATCH v2 (resend) 10/27] x86/pv: Map L4 page table for shim domain

2024-01-16 Thread Elias El Yandouzi
From: Hongyan Xia The root page table is allocated from the domheap and isn't mapped by default. Map it on demand to build pv shim domain. Signed-off-by: Hongyan Xia Signed-off-by: Elias El Yandouzi Changes in v2: * New patch diff --git a/xen/arch/x86/pv/dom0_build.c

[PATCH v2 (resend) 01/27] xen/vmap: Check the page has been mapped in vm_init_type()

2024-01-16 Thread Elias El Yandouzi
t all. As this is boot code, use BUG_ON() to check if map_pages_to_xen() has succeeded. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changes in v2: - New patch diff --git a/xen/common/vmap.c b/xen/common/vmap.c index 330e2ba897..830f64c5ef 100644 --- a/xen/c

Re: [PATCH v2] Remove the directmap

2024-01-16 Thread Elias El Yandouzi
Hi, Newbie mistake, I didn't number the patches, I'll resend the series. Sorry for the noise. On 16/01/2024 18:50, Elias El Yandouzi wrote: Hi all, A few years ago, Wei Liu implemented a PoC to remove the directmap from Xen. The last version was sent by Hongyan Xia [1]. I will

[PATCH v2] x86/domain_page: Remove the fast paths when mfn is not in the directmap

2024-01-16 Thread Elias El Yandouzi
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_mfns_in_direct_map(mfn, 1) because these two are equivalent. The extra comparison in arch_mfns_in_direct_map() looks different but b

[PATCH v2] x86/setup: Leave early boot slightly earlier

2024-01-16 Thread Elias El Yandouzi
, we already have enough memory in the heap allocator in the 1st node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b813ea75b5..3b698c8c41 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86

[PATCH v2] xen/arm64: mm: Use per-pCPU page-tables

2024-01-16 Thread Elias El Yandouzi
ified. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi Changelog since v1: * Rebase * Fix typoes diff --git a/xen/arch/arm/arm64/mmu/mm.c b/xen/arch/arm/arm64/mmu/mm.c index d2651c9486..4f339efb7b 100644 --- a/xen/arch/arm/arm64/mmu/mm.c +++ b/xen/arch/arm/arm6

[PATCH v2] x86/setup: Do not create valid mappings when directmap=no

2024-01-16 Thread Elias El Yandouzi
ongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3b698c8c41..84c496ac4a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -976,6 +976,57 @@ static struct domain *__init create_dom0(const module

  1   2   >