From: Julien Grall <julien.grall@arm.com>
To: Sergej Proskurin <proskurin@sec.in.tum.de>,
xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v2 07/25] arm/altp2m: Add altp2m init/teardown routines.
Date: Wed, 3 Aug 2016 19:12:45 +0100 [thread overview]
Message-ID: <df0fb0fb-4e71-b1cf-878f-dee73bc114b2@arm.com> (raw)
In-Reply-To: <20160801171028.11615-8-proskurin@sec.in.tum.de>
Hello Sergej,
On 01/08/16 18:10, Sergej Proskurin wrote:
> The p2m initialization now invokes initialization routines responsible
> for the allocation and initialization of altp2m structures. The same
> applies to teardown routines. The functionality has been adopted from
> the x86 altp2m implementation.
>
> Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Julien Grall <julien.grall@arm.com>
> ---
> v2: Shared code between host/altp2m init/teardown functions.
> Added conditional init/teardown of altp2m.
> Altp2m related functions are moved to altp2m.c
> ---
> xen/arch/arm/Makefile | 1 +
> xen/arch/arm/altp2m.c | 71 ++++++++++++++++++++++++++++++++++++++++++++
> xen/arch/arm/p2m.c | 28 +++++++++++++----
> xen/include/asm-arm/altp2m.h | 6 ++++
> xen/include/asm-arm/domain.h | 4 +++
> xen/include/asm-arm/p2m.h | 5 ++++
> 6 files changed, 110 insertions(+), 5 deletions(-)
> create mode 100644 xen/arch/arm/altp2m.c
>
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 23aaf52..4a7f660 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -5,6 +5,7 @@ subdir-$(CONFIG_ARM_64) += efi
> subdir-$(CONFIG_ACPI) += acpi
>
> obj-$(CONFIG_ALTERNATIVE) += alternative.o
> +obj-y += altp2m.o
> obj-y += bootfdt.o
> obj-y += cpu.o
> obj-y += cpuerrata.o
> diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
> new file mode 100644
> index 0000000..abbd39a
> --- /dev/null
> +++ b/xen/arch/arm/altp2m.c
> @@ -0,0 +1,71 @@
> +/*
> + * arch/arm/altp2m.c
> + *
> + * Alternate p2m
> + * Copyright (c) 2016 Sergej Proskurin <proskurin@sec.in.tum.de>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License, version 2,
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT ANY
> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
> + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
> + * details.
> + *
> + * You should have received a copy of the GNU General Public License along with
> + * this program; If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <asm/p2m.h>
> +#include <asm/altp2m.h>
> +
> +int altp2m_init(struct domain *d)
> +{
> + unsigned int i;
> +
> + spin_lock_init(&d->arch.altp2m_lock);
> +
> + for ( i = 0; i < MAX_ALTP2M; i++ )
> + {
> + d->arch.altp2m_p2m[i] = NULL;
> + d->arch.altp2m_vttbr[i] = INVALID_VTTBR;
I don't think altp2m_vttbr is useful. There is no real performance
impact to free the whole altp2m if the altp2m is destroyed (see
altp2m_destroy_by_id) and re-allocated afterwards.
The code will actually much simpler. With this solution you will be able
to detect if an altp2m is available by testin altp2m_p2m[i] is NULL.
> + }
> +
> + return 0;
> +}
> +
> +void altp2m_teardown(struct domain *d)
> +{
> + unsigned int i;
> + struct p2m_domain *p2m;
> +
> + altp2m_lock(d);
The lock is not necessary here.
> +
> + for ( i = 0; i < MAX_ALTP2M; i++ )
> + {
> + if ( !d->arch.altp2m_p2m[i] )
> + continue;
> +
> + p2m = d->arch.altp2m_p2m[i];
> + p2m_free_one(p2m);
> + xfree(p2m);
> +
> + d->arch.altp2m_vttbr[i] = INVALID_VTTBR;
> + d->arch.altp2m_p2m[i] = NULL;
The domain will never be used afterward, so there is no point to set
altp2m_vttbr and altp2m_p2m.
> + }
> +
> + d->arch.altp2m_active = false;
Ditto.
> +
> + altp2m_unlock(d);
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * tab-width: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index ff9c0d1..29ec5e5 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -14,6 +14,8 @@
> #include <asm/hardirq.h>
> #include <asm/page.h>
>
> +#include <asm/altp2m.h>
> +
> #ifdef CONFIG_ARM_64
> static unsigned int __read_mostly p2m_root_order;
> static unsigned int __read_mostly p2m_root_level;
> @@ -1392,7 +1394,7 @@ void p2m_flush_table(struct p2m_domain *p2m)
> free_domheap_page(pg);
> }
>
> -static inline void p2m_free_one(struct p2m_domain *p2m)
> +void p2m_free_one(struct p2m_domain *p2m)
Please expose p2m_free_one in patch #4.
> {
> p2m_flush_table(p2m);
>
> @@ -1415,9 +1417,13 @@ int p2m_init_one(struct domain *d, struct p2m_domain *p2m)
> rwlock_init(&p2m->lock);
> INIT_PAGE_LIST_HEAD(&p2m->pages);
>
> - rc = p2m_alloc_vmid(p2m);
> - if ( rc != 0 )
> - return rc;
> + /* Reused altp2m views keep their VMID. */
> + if ( p2m->vmid == INVALID_VMID )
> + {
> + rc = p2m_alloc_vmid(p2m);
> + if ( rc != 0 )
> + return rc;
> + }
My suggestion above will avoid this kind of hack.
>
> p2m->domain = d;
> p2m->access_required = false;
> @@ -1441,6 +1447,9 @@ static void p2m_teardown_hostp2m(struct domain *d)
>
> void p2m_teardown(struct domain *d)
> {
> + if ( altp2m_enabled(d) )
> + altp2m_teardown(d);
> +
> p2m_teardown_hostp2m(d);
> }
>
> @@ -1460,7 +1469,16 @@ static int p2m_init_hostp2m(struct domain *d)
>
> int p2m_init(struct domain *d)
> {
> - return p2m_init_hostp2m(d);
> + int rc;
> +
> + rc = p2m_init_hostp2m(d);
> + if ( rc )
> + return rc;
> +
> + if ( altp2m_enabled(d) )
I am a bit skeptical that you can fully use altp2m with this check.
p2m_init is created at the very beginning when the domain is allocated.
So the HVM_PARAM_ALTP2M will not be set.
> + rc = altp2m_init(d);
> +
> + return rc;
> }
>
> int relinquish_p2m_mapping(struct domain *d)
> diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
> index d47b249..79ea66b 100644
> --- a/xen/include/asm-arm/altp2m.h
> +++ b/xen/include/asm-arm/altp2m.h
> @@ -22,6 +22,9 @@
>
> #include <xen/sched.h>
>
> +#define altp2m_lock(d) spin_lock(&(d)->arch.altp2m_lock)
> +#define altp2m_unlock(d) spin_unlock(&(d)->arch.altp2m_lock)
> +
> #define altp2m_enabled(d) ((d)->arch.hvm_domain.params[HVM_PARAM_ALTP2M])
>
> /* Alternate p2m on/off per domain */
> @@ -38,4 +41,7 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
> return 0;
> }
>
> +int altp2m_init(struct domain *d);
> +void altp2m_teardown(struct domain *d);
> +
> #endif /* __ASM_ARM_ALTP2M_H */
> diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
> index cc4bda0..3c25ea5 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -129,6 +129,10 @@ struct arch_domain
>
> /* altp2m: allow multiple copies of host p2m */
> bool_t altp2m_active;
> + struct p2m_domain *altp2m_p2m[MAX_ALTP2M];
> + uint64_t altp2m_vttbr[MAX_ALTP2M];
> + /* Covers access to members of the struct altp2m. */
I cannot find any "struct altp2m" in the code.
> + spinlock_t altp2m_lock;
> } __cacheline_aligned;
>
> struct arch_vcpu
> diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
> index 1f9c370..24a1f61 100644
> --- a/xen/include/asm-arm/p2m.h
> +++ b/xen/include/asm-arm/p2m.h
> @@ -9,6 +9,8 @@
> #include <xen/p2m-common.h>
> #include <public/memory.h>
>
> +#define MAX_ALTP2M 10 /* ARM might contain an arbitrary number of
> + altp2m views. */
> #define paddr_bits PADDR_BITS
>
> /* Holds the bit size of IPAs in p2m tables. */
> @@ -212,6 +214,9 @@ void guest_physmap_remove_page(struct domain *d,
>
> mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn);
>
> +/* Release resources held by the p2m structure. */
> +void p2m_free_one(struct p2m_domain *p2m);
> +
> /*
> * Populate-on-demand
> */
>
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-03 18:12 UTC|newest]
Thread overview: 159+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 17:10 [PATCH v2 00/25] arm/altp2m: Introducing altp2m to ARM Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 01/25] arm/altp2m: Add first altp2m HVMOP stubs Sergej Proskurin
2016-08-03 16:54 ` Julien Grall
2016-08-04 16:01 ` Sergej Proskurin
2016-08-04 16:04 ` Julien Grall
2016-08-04 16:22 ` Sergej Proskurin
2016-08-04 16:51 ` Julien Grall
2016-08-05 6:55 ` Sergej Proskurin
2016-08-09 19:16 ` Tamas K Lengyel
2016-08-10 9:52 ` Julien Grall
2016-08-10 14:49 ` Tamas K Lengyel
2016-08-11 8:17 ` Julien Grall
2016-08-11 14:41 ` Tamas K Lengyel
2016-08-12 8:10 ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 02/25] arm/altp2m: Add HVMOP_altp2m_get_domain_state Sergej Proskurin
2016-08-01 17:21 ` Andrew Cooper
2016-08-01 17:34 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 03/25] arm/altp2m: Add struct vttbr Sergej Proskurin
2016-08-03 17:04 ` Julien Grall
2016-08-03 17:05 ` Julien Grall
2016-08-04 16:11 ` Sergej Proskurin
2016-08-04 16:15 ` Julien Grall
2016-08-06 8:54 ` Sergej Proskurin
2016-08-06 13:20 ` Julien Grall
2016-08-06 13:48 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 04/25] arm/altp2m: Move hostp2m init/teardown to individual functions Sergej Proskurin
2016-08-03 17:40 ` Julien Grall
2016-08-05 7:26 ` Sergej Proskurin
2016-08-05 9:16 ` Julien Grall
2016-08-06 8:43 ` Sergej Proskurin
2016-08-06 13:26 ` Julien Grall
2016-08-06 13:50 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 05/25] arm/altp2m: Rename and extend p2m_alloc_table Sergej Proskurin
2016-08-03 17:57 ` Julien Grall
2016-08-06 8:57 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 06/25] arm/altp2m: Cosmetic fixes - function prototypes Sergej Proskurin
2016-08-03 18:02 ` Julien Grall
2016-08-06 9:00 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 07/25] arm/altp2m: Add altp2m init/teardown routines Sergej Proskurin
2016-08-03 18:12 ` Julien Grall [this message]
2016-08-05 6:53 ` Sergej Proskurin
2016-08-05 9:20 ` Julien Grall
2016-08-06 8:30 ` Sergej Proskurin
2016-08-09 9:44 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 08/25] arm/altp2m: Add HVMOP_altp2m_set_domain_state Sergej Proskurin
2016-08-03 18:41 ` Julien Grall
2016-08-06 9:03 ` Sergej Proskurin
2016-08-06 9:36 ` Sergej Proskurin
2016-08-06 14:18 ` Julien Grall
2016-08-06 14:21 ` Julien Grall
2016-08-11 9:08 ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 09/25] arm/altp2m: Add altp2m table flushing routine Sergej Proskurin
2016-08-03 18:44 ` Julien Grall
2016-08-06 9:45 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 10/25] arm/altp2m: Add HVMOP_altp2m_create_p2m Sergej Proskurin
2016-08-03 18:48 ` Julien Grall
2016-08-06 9:46 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 11/25] arm/altp2m: Add HVMOP_altp2m_destroy_p2m Sergej Proskurin
2016-08-04 11:46 ` Julien Grall
2016-08-06 9:54 ` Sergej Proskurin
2016-08-06 13:36 ` Julien Grall
2016-08-06 13:51 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 12/25] arm/altp2m: Add HVMOP_altp2m_switch_p2m Sergej Proskurin
2016-08-04 11:51 ` Julien Grall
2016-08-06 10:13 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 13/25] arm/altp2m: Make p2m_restore_state ready for altp2m Sergej Proskurin
2016-08-04 11:55 ` Julien Grall
2016-08-06 10:20 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 14/25] arm/altp2m: Make get_page_from_gva " Sergej Proskurin
2016-08-04 11:59 ` Julien Grall
2016-08-06 10:38 ` Sergej Proskurin
2016-08-06 13:45 ` Julien Grall
2016-08-06 16:58 ` Sergej Proskurin
2016-08-11 8:33 ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 15/25] arm/altp2m: Extend __p2m_lookup Sergej Proskurin
2016-08-04 12:04 ` Julien Grall
2016-08-06 10:44 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 16/25] arm/altp2m: Make p2m_mem_access_check ready for altp2m Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 17/25] arm/altp2m: Cosmetic fixes - function prototypes Sergej Proskurin
2016-08-04 12:06 ` Julien Grall
2016-08-06 10:46 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 18/25] arm/altp2m: Add HVMOP_altp2m_set_mem_access Sergej Proskurin
2016-08-04 14:19 ` Julien Grall
2016-08-06 11:03 ` Sergej Proskurin
2016-08-06 14:26 ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 19/25] arm/altp2m: Add altp2m_propagate_change Sergej Proskurin
2016-08-04 14:50 ` Julien Grall
2016-08-06 11:26 ` Sergej Proskurin
2016-08-06 13:52 ` Julien Grall
2016-08-06 17:06 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 20/25] arm/altp2m: Add altp2m paging mechanism Sergej Proskurin
2016-08-04 13:50 ` Julien Grall
2016-08-06 12:51 ` Sergej Proskurin
2016-08-06 14:14 ` Julien Grall
2016-08-06 17:28 ` Sergej Proskurin
2016-08-04 16:59 ` Julien Grall
2016-08-06 12:57 ` Sergej Proskurin
2016-08-06 14:21 ` Julien Grall
2016-08-06 17:35 ` Sergej Proskurin
2016-08-10 9:32 ` Sergej Proskurin
2016-08-11 8:47 ` Julien Grall
2016-08-11 17:13 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 21/25] arm/altp2m: Add HVMOP_altp2m_change_gfn Sergej Proskurin
2016-08-04 14:04 ` Julien Grall
2016-08-06 13:45 ` Sergej Proskurin
2016-08-06 14:34 ` Julien Grall
2016-08-06 17:42 ` Sergej Proskurin
2016-08-11 9:21 ` Julien Grall
2016-08-01 17:10 ` [PATCH v2 22/25] arm/altp2m: Adjust debug information to altp2m Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 23/25] arm/altp2m: Extend libxl to activate altp2m on ARM Sergej Proskurin
2016-08-02 11:59 ` Wei Liu
2016-08-02 14:07 ` Sergej Proskurin
2016-08-11 16:00 ` Wei Liu
2016-08-15 16:07 ` Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 24/25] arm/altp2m: Extend xen-access for " Sergej Proskurin
2016-08-01 17:10 ` [PATCH v2 25/25] arm/altp2m: Add test of xc_altp2m_change_gfn Sergej Proskurin
2016-08-02 9:14 ` Razvan Cojocaru
2016-08-02 9:50 ` Sergej Proskurin
2016-08-01 18:15 ` [PATCH v2 00/25] arm/altp2m: Introducing altp2m to ARM Julien Grall
2016-08-01 19:20 ` Tamas K Lengyel
2016-08-01 19:55 ` Julien Grall
2016-08-01 20:35 ` Sergej Proskurin
2016-08-01 20:41 ` Tamas K Lengyel
2016-08-02 7:38 ` Julien Grall
2016-08-02 11:17 ` George Dunlap
2016-08-02 15:48 ` Tamas K Lengyel
2016-08-02 16:05 ` George Dunlap
2016-08-02 16:09 ` Tamas K Lengyel
2016-08-02 16:40 ` Julien Grall
2016-08-02 17:01 ` Tamas K Lengyel
2016-08-02 17:22 ` Tamas K Lengyel
2016-08-02 16:00 ` Tamas K Lengyel
2016-08-02 16:11 ` Julien Grall
2016-08-02 16:22 ` Tamas K Lengyel
2016-08-01 23:14 ` Andrew Cooper
2016-08-02 7:34 ` Julien Grall
2016-08-02 16:08 ` Andrew Cooper
2016-08-02 16:30 ` Tamas K Lengyel
2016-08-03 11:53 ` Julien Grall
2016-08-03 12:00 ` Andrew Cooper
2016-08-03 12:13 ` Julien Grall
2016-08-03 12:18 ` Andrew Cooper
2016-08-03 12:45 ` Sergej Proskurin
2016-08-03 14:08 ` Julien Grall
2016-08-03 14:17 ` Sergej Proskurin
2016-08-03 16:01 ` Tamas K Lengyel
2016-08-03 16:24 ` Julien Grall
2016-08-03 16:42 ` Tamas K Lengyel
2016-08-03 16:51 ` Julien Grall
2016-08-03 17:30 ` Andrew Cooper
2016-08-03 17:43 ` Tamas K Lengyel
2016-08-03 17:45 ` Julien Grall
2016-08-03 17:51 ` Tamas K Lengyel
2016-08-03 17:56 ` Julien Grall
2016-08-03 18:11 ` Tamas K Lengyel
2016-08-03 18:16 ` Julien Grall
2016-08-03 18:21 ` Tamas K Lengyel
2016-08-04 11:13 ` George Dunlap
2016-08-08 4:44 ` Tamas K Lengyel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=df0fb0fb-4e71-b1cf-878f-dee73bc114b2@arm.com \
--to=julien.grall@arm.com \
--cc=proskurin@sec.in.tum.de \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).