Skip to content

RFC altp2m: Move altp2m routines to common code and add ARM support

Rose Spangler xen-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v6 RFC Latest29 of 43 patches 0 repliesNew

29 of 43 patches are in this archive. The cover letter announces 43.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/43altp2m: Add template common altp2m.c/altp2m.hxen/common/Makefile xen/common/altp2m.c xen/include/xen/altp2m.h+18 -00 replies
2/43altp2m: Move altp2m_active to common domain structxen/arch/x86/hvm/emulate.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/monitor.c +14 more+40 -280 replies
3/43altp2m: Move altp2m_p2m to common domain structxen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/include/asm/domain.h xen/arch/x86/include/asm/p2m.h +7 more+33 -330 replies
4/43x86/altp2m: Rename hvm_altp2m_supported to altp2m_supportedxen/arch/x86/domain.c xen/arch/x86/hvm/hvm.c xen/arch/x86/include/asm/hvm/hvm.h +3 more+12 -120 replies
5/43altp2m: Move altp2m_supported to arch headerxen/arch/x86/domain.c xen/arch/x86/include/asm/altp2m.h xen/arch/x86/include/asm/hvm/hvm.h +1 more+19 -110 replies
6/43arm/altp2m: Add template arch-specific altp2m.c/altp2m.hxen/arch/arm/Makefile xen/arch/arm/altp2m.c xen/arch/arm/include/asm/Makefile +1 more+54 -10 replies
7/43arm/altp2m: Introduce CONFIG_ALTP2M Kconfig optionxen/arch/arm/Kconfig xen/arch/arm/altp2m.c xen/arch/arm/include/asm/altp2m.h+36 -20 replies
8/43altp2m: Rename p2m_*_altp2m functions and move declarations out of p2m.hxen/arch/arm/altp2m.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/monitor.c +10 more+186 -1830 replies
9/43altp2m: Move do_altp2m_op to common codexen/arch/x86/hvm/hvm.c xen/common/altp2m.c xen/include/xen/altp2m.h+424 -4000 replies
10/43altp2m: Add ARM support to do_altp2m_opxen/arch/arm/hvm.c xen/common/altp2m.c+23 -150 replies
11/43arm/altp2m: Add support for HVMOP_altp2m_get_domain_statexen/common/altp2m.c+1 -10 replies
12/43x86/p2m: Move p2m_{init,free}_one declarations to arch headerxen/arch/x86/include/asm/p2m.h xen/arch/x86/mm/p2m.h+3 -30 replies
13/43x86/altp2m: Add lock functions accessible from common codexen/arch/x86/include/asm/altp2m.h xen/arch/x86/mm/altp2m.c+31 -150 replies
14/43altp2m: Move altp2m_{init,teardown} to common codexen/arch/x86/include/asm/altp2m.h xen/arch/x86/mm/altp2m.c xen/arch/x86/mm/p2m-basic.c +2 more+63 -530 replies
15/43arm/p2m: Allocate hostp2m with xzallocxen/arch/arm/domain.c xen/arch/arm/include/asm/domain.h xen/arch/arm/include/asm/p2m.h +6 more+32 -110 replies
16/43arm/p2m: Cosmetic fix - substitute _gfn(ULONG_MAX) for INVALID_GFNxen/arch/arm/mmu/p2m.c+1 -10 replies
17/43arm/p2m: Move hostp2m init/teardown to individual functionsxen/arch/arm/include/asm/p2m.h xen/arch/arm/mmu/p2m.c+65 -240 replies
18/43arm/p2m: Invalidate root page table entries and flush TLB in p2m_flush_tablexen/arch/arm/mmu/p2m.c+13 -30 replies
19/43arm/p2m: Change function prototype of p2m_alloc_tablexen/arch/arm/mmu/p2m.c+2 -40 replies
20/43arm/p2m: Rename parameter in p2m_alloc_vmidxen/arch/arm/p2m.c+6 -60 replies
21/43arm/p2m: Change func prototype and impl of p2m_{alloc,free}_vmidxen/arch/arm/include/asm/p2m.h xen/arch/arm/mmu/p2m.c xen/arch/arm/p2m.c+14 -210 replies
22/43arm/p2m: Introduce p2m_is_{hostp2m,altp2m}xen/arch/arm/include/asm/p2m.h+18 -00 replies
23/43arm/altp2m: Add support for altp2m init/teardown routinesxen/arch/arm/include/asm/altp2m.h xen/arch/arm/include/asm/domain.h xen/arch/arm/include/asm/p2m.h +3 more+60 -50 replies
24/43altp2m: Move altp2m_{get,set}_altp2m to common codexen/arch/x86/include/asm/altp2m.h xen/arch/x86/include/asm/domain.h xen/common/altp2m.c +1 more+43 -380 replies
25/43arm/altp2m: Add altp2m index to arch_vcpuxen/arch/arm/include/asm/altp2m.h xen/arch/arm/include/asm/domain.h+6 -30 replies
26/43altp2m: Add altp2m_set_vcpu_idxxen/arch/arm/include/asm/altp2m.h xen/arch/x86/include/asm/altp2m.h+10 -00 replies
27/43arm/altp2m: Add support for altp2m_{get,set}_altp2mxen/include/xen/altp2m.h+4 -50 replies
28/43altp2m: Move altp2m_vcpu_{initialise,destroy} to common codexen/arch/x86/include/asm/altp2m.h xen/arch/x86/mm/altp2m.c xen/common/altp2m.c +1 more+47 -470 replies
29/43arm/altp2m: Add support for altp2m_vcpu_{initialise,destroy}xen/common/altp2m.c xen/include/xen/altp2m.h+10 -60 replies

Reviews trailers per patch

1 of 29 patches has a Reviewed-by or Acked-by.

PatchJulien Grall
1/43
2/43
3/43
4/43
5/43
6/43
7/43
8/43
9/43
10/43
11/43
12/43
13/43
14/43
15/43
16/43
17/43
18/43
19/43A-b
20/43
21/43
22/43
23/43
24/43
25/43
26/43
27/43
28/43
29/43

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [RESEND RFC PATCH v6 00/43] altp2m: Move altp2m routines to common code and add ARM support

Hi all,

For the past few months, myself and Aqib Javid have been working to port altp2m to ARM with support from Stewart Hildebrand and Stefano Stabellini. At the recent Spring Xen Summit, Aqib and Stewart gave a presentation which discussed the motivation behind this, along with an overview of the rebasing and testing process. While this effort started as a rebase[1] of the v5 patch series[2] by Sergej Proskurin and Tamas Lengyel, I have been reworking the branch to make most of the altp2m code common between x86 and ARM. This should address the major concerns that came up during review of the original patch series. For a quick overview of altp2m functionality and scope of the patch series, here's an excerpt from Sergej's cover letter:

Quoted 10 lines

In this patch series, we provide an implementation of the altp2m subsystem for ARM. Our implementation is based on the altp2m subsystem for x86, providing additional --alternate-- views on the guest's physical memory by means of the ARM 2nd stage translation mechanism. The patches introduce new HVMOPs and extend the p2m subsystem. [...] To be more precise, altp2m allows to create and switch to additional p2m views (i.e. gfn to mfn mappings). These views can be manipulated and activated as will through the provided HVMOPs. In this way, the active guest instance in question can seamlessly proceed execution without noticing that anything has changed.

As of right now, I've reworked patch series up through the HVMOP_altp2m_set_domain_state command and plan to continue implementing the remaining altp2m features. I've continued the patch series versioning by labeling my notes as v6, and the patch notes from v1-v5 have been preserved where applicable. I am hoping for some feedback on the general approach I've taken with this patch series, and I can incorporate any changes requested into the actual patch series submission.

This is a pretty big patch series, so I've tried to make it as easy as possible to follow. I've tried to minimize the number of changes in each patch; there are quite a lot of patches so if it would be preferred to combine some patches I can do so. Here is the general approach I used throughout the patch series to turn x86 altp2m code into common altp2m code with ARM support:

- Move function(s) from arch/x86/mm/altp2m.c to common/altp2m.c, gating declarations/definitions with #ifdef CONFIG_X86
- Add any additional features to ARM code needed to implement these functions
- Make any changes necessary to functions to support ARM, and remove #ifdef CONFIG_X86

This approach makes it possible to separate out code movement patches from the actual changes needed to support ARM. Furthermore, each patch in the patch series still compiles for both x86 and ARM.

Additionally, I've split the patch series into a number of "phases" to make it easier to understand the context of each patch. Each patch description indicates which phase it's a part of.
- Preparation (8 commits)
- Common do_altp2m_op (2 commits)
- get_domain_state (1 commit)
- altp2m_{init,teardown} routines (12 commits)
- altp2m_{get,set}_altp2m (4 commits)
- Needed for altp2m_vcpu_{initialise,destroy}
- altp2m_vcpu_{initialise,destroy} (2 commits)
- Needed for HVMOP_set_domain_state
- altp2m view visibility (5 commits)
- Needed for altp2m_init_by_id, altp2m_flush
- altp2m_activate_altp2m (2 commits)
- Needed for altp2m_init_by_id
- altp2m_init_by_id (2 commits)
- Needed for HVMOP_altp2m_set_domain_state
- altp2m_reset_altp2m (2 commits)
- Needed for altp2m_flush
- altp2m_flush (2 commits)
- Needed for HVMOP_altp2m_set_domain_state
- set_domain_state (1 commit)

The code for this patch series can also be found on GitLab:
https://gitlab.com/xen-project/people/elektrobit/xen/-/tree/altp2m-arm-rework-rfc

Best,
Rose Spangler

[1] Rebase of original patch series:
https://gitlab.com/xen-project/people/elektrobit/xen/-/commits/altp2m-arm-rebase

[2] Original patch series:
v1: https://lore.kernel.org/xen-devel/[email protected]/
v2: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v4: https://lore.kernel.org/xen-devel/[email protected]/
v5 was never submitted to mailing list, but is available on GitHub:
https://github.com/sergej-proskurin/xen/tree/arm-altp2m-v5

(Resend due to threading issues in first send attempt)

Rose Spangler (38):
altp2m: Add template common altp2m.c/altp2m.h
altp2m: Move altp2m_active to common domain struct
altp2m: Move altp2m_p2m to common domain struct x86/altp2m: Rename hvm_altp2m_supported to altp2m_supported
altp2m: Move altp2m_supported to arch header arm/altp2m: Add template arch-specific altp2m.c/altp2m.h arm/altp2m: Introduce CONFIG_ALTP2M Kconfig option
altp2m: Rename p2m_*_altp2m functions and move declarations out of

    p2m.h

altp2m: Move do_altp2m_op to common code
altp2m: Add ARM support to do_altp2m_op
arm/altp2m: Add support for HVMOP_altp2m_get_domain_state x86/p2m: Move p2m_{init,free}_one declarations to arch header x86/altp2m: Add lock functions accessible from common code
altp2m: Move altp2m_{init,teardown} to common code arm/p2m: Allocate hostp2m with xzalloc
arm/p2m: Move hostp2m init/teardown to individual functions arm/p2m: Invalidate root page table entries and flush TLB in
p2m_flush_table
arm/altp2m: Add support for altp2m init/teardown routines
altp2m: Move altp2m_{get,set}_altp2m to common code arm/altp2m: Add altp2m index to arch_vcpu
altp2m: Add altp2m_set_vcpu_idx
arm/altp2m: Add support for altp2m_{get,set}_altp2m
altp2m: Move altp2m_vcpu_{initialise,destroy} to common code arm/altp2m: Add support for altp2m_vcpu_{initialise,destroy} arm/altp2m: Add altp2m view validity/visibility indicator
altp2m: Add altp2m_view_is_{valid,visible}
x86/altp2m: Add altp2m_set_view_visibility_locked arm/altp2m: Add altp2m_set_view_visibility{,_locked} support arm/altp2m: Add support for HVMOP_altp2m_set_visibility x86/altp2m: Add altp2m_activate_altp2m declaration to arch header arm/altp2m: Add support for altp2m_activate_altp2m
altp2m: Move altp2m_init_by_id to common code arm/altp2m: Add support for altp2m_init_by_id x86/altp2m: Add altp2m_reset_altp2m declaration to arch header arm/altp2m: Add altp2m_reset_altp2m routine
altp2m: Move altp2m_flush to common code
arm/altp2m: Add support for altp2m_flush
arm/p2m: Add support for HVMOP_altp2m_set_domain_state

Sergej Proskurin (5):
arm/p2m: Cosmetic fix - substitute _gfn(ULONG_MAX) for INVALID_GFN arm/p2m: Change function prototype of p2m_alloc_table arm/p2m: Rename parameter in p2m_alloc_vmid
arm/p2m: Change func prototype and impl of p2m_{alloc,free}_vmid arm/p2m: Introduce p2m_is_{hostp2m,altp2m}

 xen/arch/arm/Kconfig                     |  11 +
 xen/arch/arm/Makefile                    |   1 +
 xen/arch/arm/altp2m.c                    | 122 +++++
 xen/arch/arm/domain.c                    |   2 +-
 xen/arch/arm/hvm.c                       |   9 +
 xen/arch/arm/include/asm/Makefile        |   1 -
 xen/arch/arm/include/asm/altp2m.h        |  84 ++++
 xen/arch/arm/include/asm/domain.h        |  19 +-
 xen/arch/arm/include/asm/p2m.h           |  41 +-
 xen/arch/arm/mm.c                        |   2 +-
 xen/arch/arm/mmu/p2m.c                   | 162 ++++++-
 xen/arch/arm/p2m.c                       |  31 +-
 xen/arch/arm/traps.c                     |   2 +-
 xen/arch/x86/domain.c                    |   3 +-
 xen/arch/x86/hvm/emulate.c               |   1 +
 xen/arch/x86/hvm/hvm.c                   | 413 +----------------
 xen/arch/x86/hvm/monitor.c               |   3 +-
 xen/arch/x86/hvm/vmx/vmx.c               |   9 +-
 xen/arch/x86/include/asm/altp2m.h        | 115 ++++-
 xen/arch/x86/include/asm/domain.h        |   5 -
 xen/arch/x86/include/asm/hvm/hvm.h       |  11 -
 xen/arch/x86/include/asm/p2m.h           | 112 +----
 xen/arch/x86/mm/altp2m.c                 | 242 +++-------
 xen/arch/x86/mm/hap/hap.c                |  17 +-
 xen/arch/x86/mm/mem_access.c             |  22 +-
 xen/arch/x86/mm/mem_sharing.c            |   3 +-
 xen/arch/x86/mm/p2m-basic.c              |   7 +-
 xen/arch/x86/mm/p2m-ept.c                |  13 +-
 xen/arch/x86/mm/p2m-pt.c                 |   1 +
 xen/arch/x86/mm/p2m.c                    |   9 +-
 xen/arch/x86/mm/p2m.h                    |   6 -
 xen/common/Makefile                      |   1 +
 xen/common/altp2m.c                      | 551 +++++++++++++++++++++++
 xen/common/monitor.c                     |   1 +
 xen/common/vm_event.c                    |   2 +-
 xen/drivers/passthrough/arm/ipmmu-vmsa.c |   2 +-
 xen/drivers/passthrough/arm/smmu-v3.c    |   2 +-
 xen/drivers/passthrough/arm/smmu.c       |   2 +-
 xen/include/asm-generic/altp2m.h         |   5 +-
 xen/include/xen/altp2m.h                 |  98 ++++
 xen/include/xen/p2m-common.h             |   2 +-
 xen/include/xen/sched.h                  |   3 +
 42 files changed, 1330 insertions(+), 818 deletions(-)
 create mode 100644 xen/arch/arm/altp2m.c
 create mode 100644 xen/arch/arm/include/asm/altp2m.h
 create mode 100644 xen/common/altp2m.c
 create mode 100644 xen/include/xen/altp2m.h
Signature · 1 line
2.34.1