|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH for-4.19? v5 07/10] xen: Make the maximum number of altp2m views configurable for x86
On 02.06.2024 22:04, Petr Beneš wrote:
> @@ -5245,7 +5251,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t
> p2midx)
> if ( !hvm_is_singlestep_supported() )
> return;
>
> - if ( p2midx >= MAX_ALTP2M )
> + if ( p2midx >= v->domain->nr_altp2m )
> return;
As (iirc) indicated before, just like you don't add a d local variable
here or ...
> --- a/xen/arch/x86/include/asm/p2m.h
> +++ b/xen/arch/x86/include/asm/p2m.h
> @@ -887,7 +887,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct
> vcpu *v)
> if ( index == INVALID_ALTP2M )
> return NULL;
>
> - BUG_ON(index >= MAX_ALTP2M);
> + BUG_ON(index >= v->domain->nr_altp2m);
>
> return altp2m_get_p2m(v->domain, index);
> }
> @@ -898,7 +898,7 @@ static inline bool p2m_set_altp2m(struct vcpu *v,
> unsigned int idx)
> struct p2m_domain *orig;
> struct p2m_domain *ap2m;
>
> - BUG_ON(idx >= MAX_ALTP2M);
> + BUG_ON(idx >= v->domain->nr_altp2m);
>
> if ( idx == vcpu_altp2m(v).p2midx )
> return false;
... in either of these, I see little reason to have such ...
> --- a/xen/arch/x86/mm/altp2m.c
> +++ b/xen/arch/x86/mm/altp2m.c
> @@ -15,6 +15,11 @@
> void
> altp2m_vcpu_initialise(struct vcpu *v)
> {
> + struct domain *d = v->domain;
> +
> + if ( d->nr_altp2m == 0 )
> + return;
> +
> if ( v != current )
> vcpu_pause(v);
>
> @@ -30,8 +35,12 @@ altp2m_vcpu_initialise(struct vcpu *v)
> void
> altp2m_vcpu_destroy(struct vcpu *v)
> {
> + struct domain *d = v->domain;
> struct p2m_domain *p2m;
>
> + if ( d->nr_altp2m == 0 )
> + return;
> +
> if ( v != current )
> vcpu_pause(v);
... in both of these.
> @@ -122,7 +131,12 @@ int p2m_init_altp2m(struct domain *d)
> struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
>
> mm_lock_init(&d->arch.altp2m_list_lock);
> - for ( i = 0; i < MAX_ALTP2M; i++ )
> + d->arch.altp2m_p2m = xzalloc_array(struct p2m_domain *, d->nr_altp2m);
> +
> + if ( !d->arch.altp2m_p2m )
> + return -ENOMEM;
This isn't really needed, is it? Both ...
> + for ( i = 0; i < d->nr_altp2m; i++ )
... this and ...
> {
> d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d);
> if ( p2m == NULL )
> @@ -143,7 +157,10 @@ void p2m_teardown_altp2m(struct domain *d)
> unsigned int i;
> struct p2m_domain *p2m;
>
> - for ( i = 0; i < MAX_ALTP2M; i++ )
> + if ( !d->arch.altp2m_p2m )
> + return;
> +
> + for ( i = 0; i < d->nr_altp2m; i++ )
> {
> if ( !d->arch.altp2m_p2m[i] )
> continue;
> @@ -151,6 +168,8 @@ void p2m_teardown_altp2m(struct domain *d)
> d->arch.altp2m_p2m[i] = NULL;
> p2m_free_one(p2m);
> }
> +
> + XFREE(d->arch.altp2m_p2m);
> }
... this ought to be fine without?
> @@ -538,8 +538,8 @@ void hap_final_teardown(struct domain *d)
> unsigned int i;
>
> if ( hvm_altp2m_supported() )
> - for ( i = 0; i < MAX_ALTP2M; i++ )
> - p2m_teardown(d->arch.altp2m_p2m[i], true, NULL);
> + for ( i = 0; i < d->nr_altp2m; i++ )
> + p2m_teardown(altp2m_get_p2m(d, i), true, NULL);
Shouldn't the switch to altp2m_get_p2m() be part of the respective
earlier patch?
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |