Re: [RFC PATCH v7 03/14] x86/domain: Defer domain iommu initialization.

Teddy Astie <[email protected]>
Newsgroups org.xenproject.lists.xen-devel
Message-ID <1787220651.8631fc262581453bbf619ec5b2062170.1a01ea6ee71000c4f3@vates.tech>
Le 19/08/2026 à 17:10, Jan Beulich a écrit :
> On 20.11.2025 12:09, Teddy Astie wrote:
>> For the IOMMU redesign, the iommu context pagetable is defined once during
>> initialization. When reusing P2M pagetable, we want to ensure that this
>> pagetable is properly initialized.
>>
>> Signed-off-by Teddy Astie <[email protected]>
> 
>  From what is said, I for one cannot deduce why the move is (a) necessary and
> (b) correct / safe to do.
> 
> Jan
> 
>> --- a/xen/arch/x86/domain.c
>> +++ b/xen/arch/x86/domain.c
>> @@ -927,9 +927,6 @@ int arch_domain_create(struct domain *d,
>>       if ( (rc = init_domain_irq_mapping(d)) != 0 )
>>           goto fail;
>>   
>> -    if ( (rc = iommu_domain_init(d, config->iommu_opts)) != 0 )
>> -        goto fail;
>> -
>>       psr_domain_init(d);
>>   
>>       if ( is_hvm_domain(d) )
>> @@ -948,6 +945,9 @@ int arch_domain_create(struct domain *d,
>>       else
>>           ASSERT_UNREACHABLE(); /* Not HVM and not PV? */
>>   
>> +    if ( (rc = iommu_domain_init(d, config->iommu_opts)) != 0 )
>> +        goto fail;
>> +
>>       if ( (rc = tsc_set_info(d, XEN_CPUID_TSC_MODE_DEFAULT, 0, 0, 0)) != 0 )
>>       {
>>           ASSERT_UNREACHABLE();
> 

(a)

For now in Xen, iommu_domain_init() doesn't create or reuse any 
pagetable (for hap_pt_share) *yet*, this is deferred to 
per-implementation code that is called much later.

The end idea is to move some of the pagetable initialization/tracking to 
iommu_domain_init() (then to iommu_context_init()), but in the 
hap_pt_share case, the P2M needs to be initialized first (e.g through 
paging_enable).

(b)

There is no dependency of iommu_domain_init() to be called before 
hvm_domain_initialise()/pv_domain_initialise(). In particular, we're not 
adding new p2m entries to the guest that would require IOMMU mappings.

So I don't see any issue moving the call later.

AIA, it's mostly preparatory patches (to avoid making the next ones more 
complex than they already are); it's not necessarily useful on its own.

Teddy
OpenPGP_signature.asc (application/pgp-signature, 665 B)
-----BEGIN PGP SIGNATURE-----

wsD5BAABCAAjFiEEGAIew9LzHY3pdrqtZg+p0QLLz9AFAmqG0qoFAwAAAAAACgkQZg+p0QLLz9DQ
9Qv/Sap6WTImu6WRERId9yjur0naFGd+6P9WGDszUb+YyxpKO6L9KNJUckNrrHljxejkxz3CdJU+
0PKHbPje7mIpyWoaRivjBgMJPlMu8V0i5GuBc3kWzmrWAdWosUaF6OJ/l42rX8n3P1d8VMFPsyt8
OAs2BowZSANmPH8tJFdzQ9MjTSpwkMb/CxXg2cbsyi4Y92/ltqYJyY+v42tOYEy6+f2Vc6+VvUGE
9DYLDtWQqjMFtPF4ZUh8eXK1cDQq7SDIAwsmIFyrKoe9xQ+pMyduELasxy0Yaw7dHD+x7nT6fZg0
QqW0sf8S80CaImFul2BZh/zerMpz+IBHcFlCZnm4Ye89sR/+cZQrpGGJJThi+4/TR81GCe8B85Iz
PA/FFjozxcN6+w0jnn3B+PBbfi1qlutrlW8/TykcNocjFzlzpbgfKBPdyS/arsyUJ/0Q4jwjsECq
JM3rlpyiqn9Dv5bdt3Aote8Jd25F29A1jEUWxV2+tOroj7NefxSYS8Ut8tb1
=iB/S
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.