[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/ept: limit calls to memory_type_changed()


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 22 Sep 2022 21:21:59 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=RyZNMrj8cvt+y2w2yr3PUS/ScdXrCb9S/TOIQmJ/6jc=; b=Cr54wxPN19AxAs0VS9dqMWufzRj1scgiCWqq4tLA9a8S0meBCOhtDewfGfOz5jMHsAOvmBWysT073R0ZyDt2lBBbN0RR1qbgswNhqmJ1l8vRWnWAmQB5VDkaKZLBioMZ8Sry/4AbXV5QGRnyQOb3faFlsYBMD8a3o7izSn/gd3rTjt4BLxFKTHZQyGaRo+iSyPZmf40Lu3W0m1zwKvyrIK6pEVBNCHaLAnazR8rYW9yKPPbqfVwES0wq+REEr/pQ+IeFRqunyh9Eau1/1F8btRR+4wKDJ2lOEZVFd+mmjXWg+QlKoHqMoxSjuvOif6KpIY8rjpFQ9voCmPQtT68Ogw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P9b3EuY3RU2vIMp8jtEPxO0YkT64p2gETVTXxbsk9uztCLlvoWM1pXGN31mhQ8mVL7XJN1rrEQagq5fXYIUuFqNJrk0aN7bQhPLD42JQ16rf26erMcgpkgWDgoBEIWu3pJNw87zGkhpJBSBhP28vjFBn02iF+sk7PyTp3i3T+H6bOpHz4jNXZRjcKZEX14YedR7KiHJHxGpirBPKV2jjYTa/noBX7ncGci4x4nGfEuzQY/1YQc0Lsx0EdL0nj7N5EUVB0q9ygNhMbnN/hsZusnqdfKxITlKOqB0BHqyoLrpHELNy+L8bzjC2ESn2WZJUPgtyw+epcK9AI7les4LRHg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 22 Sep 2022 19:22:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.09.2022 18:05, 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.

I certainly agree - this was an oversight when the two aspects were
split. One might argue this is a (performance) fix to the earlier
commit, and hence might want to go on its own with a Fixes: tag.

> Calls to memory_type_changed() resulting from changes to the domain
> iomem_caps or ioport_caps ranges are only relevant for EMT
> calculations if the IOMMU is not enabled, and the call has resulted in
> a change to the return value of cache_flush_permitted().

I'm less certain here: These shouldn't be frequent operations, so
their impact on the guest should be limited?

And if we were to restrict the calls, I think we need to clearly
tie together the various places which need updating together in
case e.g. the condition in epte_get_entry_emt() is changed.
Minimally by way of comments, but maybe by way of a small helper
function (for which I can't seem to be able to think of a good
name) sitting next to epte_get_entry_emt().

> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> I feel it's a bit weird to have calls to memory_type_changed() in
> common domctl code - for once the domctl that trigger the call doesn't
> change memory types, just adds or removes ranges from iomem_caps
> (which in turn affects the behaviour of epte_get_entry_emt()).

Do you have a better suggestion?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.