[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 2/2] x86/ept: limit calls to memory_type_changed()
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Thu, 29 Sep 2022 12:08:01 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bNYnYCt5wgmdmTpjs8A09erpqq+3ycDz7WjGP6Qvkyc=; b=TSesAkwLL8y6RGexku4G3pRVcIWcM/igMOx9BIVBieFckspn/CqUlYlSwTqOh2EwgDc+BpnmVvc5H5pROXBNUeYlETknrm+rSTmn18JRbL1Rv8xiL5lKibKaIU0Hn5y0Hfv0QbpHymjRGtQzuc4jdmerV75mbCA3g0Na35lvo5VqyacK8TKGFCryI7EhptXvFJcE2q0cT0eGrSFZsvcTYBBz/NWPZZlMoUrcdz9YCGur6aR70chMl8d28Djcn6H7WTGs2L7er3NYEYypVBTp7cSWOsVKwFYw9misd4FX4Q3fNH9xhVAwahOOzIoZeYk9mW7n3U+7T5ioAfQCTG/8sg==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bNYnYCt5wgmdmTpjs8A09erpqq+3ycDz7WjGP6Qvkyc=; b=LmhbobdKD+L19OvKHH8rmMK2yvJapAr99678BImqR5lBHhyIzezJqP+1gZWUXLrpIIrRtB8wkXsdm+DYmW6ti0rE/1+61Rkrs3+8Fvvjxp24vsHcZXDmXHAqQIAHDdbwK2ADgOhqChJupr3gYkeJRWk1S9rL9Z3uyrh+PMBBrOpWLu17MhZV+4gEnwr3nFhrYKtyCUGKEB+MBFT8bY4Kw7gUZz9FN/zD1iiiRiQx3ys9FipIyKNWW88+c7o79PEgWTjz6OLcSc7qdID0Iv2hJL0a0Cipbjmg9lRfCFZj/t++512OThtX1kpMM3+vekDLWzidGTxpI2fAdyvcD4A6+Q==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=KsRYhraHtBLQWR+tc7+CGVxQttQnjlHd228DMD+EXLoNFatvEZdTp6XU5NilEq+JnIcNZJAV6gDYW+0DtbuCQXEMW+njNc6z9JZ+pPjKYYiSmqSm8jek/A80Ze1mXXHElofQAWP5wwCn7MW4/Gvei9+77QFjygdYTj2yJZZIa3B2T296okSubylEA3noFCPgPMr72PBx7+gvtAU3imhqOEcRnRRHObiP5BezU0YmLA0WRL+uzDecsX0VXffstkuAQDzuIQGWxDZqAzy6MNRNPy23gYSbFEHz1/OOPt6Izya98Rc9RFPi6NKaGoku4rilw55ohKaANeyKw5b9oJ0GdA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IefyNYxyP218Q+Mp7WaJ8Q2eRZIaGvnprB2PFntuGDnk6jC5uD8rkVA3hfiNVgTMQh9moXr9eneei3V8OauB95SClpTM+o28BVZZwSFO1iUY9vJYjZcBFrmGnqdqbesC1U27B7928I/mtDzLC5jwNWqzambz45BV6bauFelSEIUEXuxYxALV7PG0mKVXe+zc4tjmQr8G9X+vwbezeOQn6vIymJu+YTIQN+bf0nDJZU9TBnWHxgM/zRjdKrLRgYQOp4a44U/69Ik/maryHc+FB9lfXfG/8+WxM2eD6fiWk+40zAIJ+88aLp+iBSEy/1vbomzqhtyoQ8RadgzSSaTYug==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 29 Sep 2022 12:08:31 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHY00RZ62t9oHqr90W0wJ20vCS6F632MZIAgAAgIIA=
- Thread-topic: [PATCH v3 2/2] x86/ept: limit calls to memory_type_changed()
Hi Han,
> On 29 Sep 2022, at 12:13, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>
> On 28.09.2022 16:11, Roger Pau Monne wrote:
>> memory_type_changed() is currently only implemented for Intel EPT, and
>> results in the invalidation of EMT attributes on all the entries in
>> the EPT page tables. Such invalidation causes EPT_MISCONFIG vmexits
>> when the guest tries to access any gfns for the first time, which
>> results in the recalculation of the EMT for the accessed page. The
>> vmexit and the recalculations are expensive, and as such should be
>> avoided when possible.
>>
>> Remove the call to memory_type_changed() from
>> XEN_DOMCTL_memory_mapping: there are no modifications of the
>> iomem_caps ranges anymore that could alter the return of
>> cache_flush_permitted() from that domctl.
>>
>> Encapsulate calls to memory_type_changed() resulting from changes to
>> the domain iomem_caps or ioport_caps ranges in the helpers themselves
>> (io{ports,mem}_{permit,deny}_access()), and add a note in
>> epte_get_entry_emt() to remind that changes to the logic there likely
>> need to be propagaed to the IO capabilities helpers.
>>
>> Note changes to the IO ports or memory ranges are not very common
>> during guest runtime, but Citrix Hypervisor has an use case for them
>> related to device passthrough.
>>
>> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> with one minor remark at the end, which can be taken care of while committing.
>
>> ---
>> Changes since v2:
>> - Split the Arm side changes into a pre-patch.
>
> Despite this I'd prefer to have an Arm maintainer view on this as well. As
> previously pointed out the resulting code is going to be sub-optimal there.
On arm none of those will be called at runtime, it happens only during guest
creation
so the potential performance impact is very reduce.
Cheers
Bertrand
>
>> --- a/xen/include/xen/iocap.h
>> +++ b/xen/include/xen/iocap.h
>> @@ -7,13 +7,43 @@
>> #ifndef __XEN_IOCAP_H__
>> #define __XEN_IOCAP_H__
>>
>> +#include <xen/sched.h>
>> #include <xen/rangeset.h>
>> #include <asm/iocap.h>
>> +#include <asm/p2m.h>
>> +
>> +static inline int iomem_permit_access(struct domain *d, unsigned long s,
>> + unsigned long e)
>> +{
>> + bool flush = cache_flush_permitted(d);
>> + int ret = rangeset_add_range(d->iomem_caps, s, e);
>> +
>> + if ( !ret && !is_iommu_enabled(d) && !flush )
>> + /*
>> + * Only flush if the range(s) are empty before this addition and
>> + * IOMMU is not enabled for the domain, otherwise it makes no
>> + * difference for effective cache attribute calculation purposes.
>> + */
>> + memory_type_changed(d);
>> +
>> + return ret;
>> +}
>> +static inline int iomem_deny_access(struct domain *d, unsigned long s,
>
> A blank line would be nice between these two (and similarly for the
> x86-only pair). Omitting such blank lines is imo advisable only for
> trivial inline functions.
>
> Jan
|