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

Re: [PATCH 3/8] x86/paging: move update_paging_modes() hook


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Wed, 21 Dec 2022 17:43:51 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=zChxmQqnmqDAaMmujjd1cviuq1JES5gpKWZtot9D8FY=; b=G+VWT/g8iXf6oHKC+yN5BazXJ2jCuEF+D6fjl5iwWg81YxCSs729h0GUUQ9Xj16Uaj7aslaIagTiiXxWxMYFpjsPvwJYmZZ/9ukNaw6Ng51KyfG2u9vV9UBvLAaTh4J0p/RZ8M+/l1B0AlOo1P8gySL7qp43TeOhza5SJVBRfvVX9uP8IDx0NIOoMY0q2IdxSUTSGETvac1Ne6re5FIRRWSdiqyPp5QUNhnW3vvYOX59dm91w9TgkP4lkyxjbRMDYxLx0abSLS0/BU+skgBIHaiqX2UHzT52OT1B63xyCgG+d+lv5D2YnWQdlf4sB7jCqmdLkF5ZwZR454frQ9sFdQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OaOivxo5G38x4WBmm53ifGSnk3iGdJgl8PdPcqWKhwTG4v222c2fgYs1z0CshX31nPC4nhBx4Y8sjI/2kl+Xhx1/Ohb/cUwi+SrDxeXpW3fK4VPaDQmSVLXWcYeA9j6hwavX/SxTNDOQe8P3kT3fVmD70QhfKPPjFgL0aVO6gfuDvumFA4O6S02DAqAH2x728OtCM/vUyFgZ1bcoOydpdCsCBfGsYu/fGwfgaZbeZsmLxlJnhuwPK+Z4RawJfdstO28BEcb3Wv3kp3OiWqALaNBlQi6RgTfs2bzWonuWpZ6eFEtyFj59V4pzerTaS+ViAWCokpYSKU0RhG42do2eUQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>, "Tim (Xen.org)" <tim@xxxxxxx>
  • Delivery-date: Wed, 21 Dec 2022 17:44:17 +0000
  • Ironport-data: A9a23:XNJ8lqpnBTW+JAHAlBjwL2IN8F1eBmIoZBIvgKrLsJaIsI4StFCzt garIBmOMvqLZzb0fY1ybInk8ktUv5+En4dhG1c6/HhnF3wW8JuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpAFc+E0/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06W1wUmAWP6gR5gaEzSBNV/rzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAHdKaS2Imtyo+7Oydapu35UoNtHqFoxK7xmMzRmBZRonabbqZvyToPV+jHI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeiraYSEEjCJbZw9ckKwj 2TK5WnmRDodM8SS02Gt+XOwnO7f2yj8Xer+EZXop68z2wTOmwT/DjVVDEWkq+aTjXXhXo0DO kIo/zMFgpY9oRnDot7VGkfQTGS/lhwWVsdUEuY6wBqQ0aeS6AGcbkAUQzgEZNE4ucseQT0xy kTPj97vHSZosrCeVTSa7Lj8hSy2ETgYKykFfyBsZRcE5vHzrYd1iQjAJuuPC4awh9zxXDv2k zaDqXFng61J1JBakaKm4VrAnjSg4IDTSRI47RnWWWTj6R5lYImiZMqj7l2zAet8Ebt1h2Kp5 BAs8/VyJshUUvlhSATlrD0xIYyU
  • Ironport-hdrordr: A9a23:WREr8qvXU+gZl/rIlDlGPRmO7skDSdV00zEX/kB9WHVpmwKj5r mTdZUgpGfJYVMqMk3I9urwXZVoLUmsl6KdpLNhXotKPzOGhILLFvAH0WKK+VSJcBEWtNQ86U 4KSdkYNDSfNykdsS842mWF+hQbreVvPJrGuQ4W9RlQcT0=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZFT/G4QjmyfM5nk+WhnK7qSG8yq54nRIA
  • Thread-topic: [PATCH 3/8] x86/paging: move update_paging_modes() hook

On 21/12/2022 1:25 pm, Jan Beulich wrote:
> The hook isn't mode dependent, hence it's misplaced in struct
> paging_mode. (Or alternatively I see no reason why the alloc_page() and
> free_page() hooks don't also live there.) Move it to struct
> paging_domain.
>
> While there rename the hook and HAP's as well as shadow's hook functions
> to use singular; I never understood why plural was used. (Renaming in
> particular the wrapper would be touching quite a lot of other code.)

There are always two modes; Xen's, and the guest's.

This was probably more visible back in the 32-bit days, but remnants of
it are still around with the fact that struct vcpu needs to be below the
4G boundary for the PDPTRs for when the guest isn't in Long Mode.

HAP also hides it fairly well given the uniformity of EPT/NPT (and
always 4 levels in a 64-bit Xen), but I suspect it will become more
visible again when we start supporting LA57.


All of that said, I have debated the utility of this hook.  It mixes up
various concepts including the singleton construction of monitor
tables,  and TLB flushing (which should not happen for a mov cr3 with
NOFLUSH set), and with those concepts abstracted properly, the only
remaining action is caching the right ops pointer.

I'm not convinced it will survive a concerned attempt to fix the HVM p2m
vs guest tlb flushing confusion.

> --- a/xen/arch/x86/mm/shadow/none.c
> +++ b/xen/arch/x86/mm/shadow/none.c
> @@ -27,6 +32,9 @@ int shadow_domain_init(struct domain *d)
>      };
>  
>      paging_log_dirty_init(d, &sh_none_ops);
> +
> +    d->arch.paging.update_paging_mode = _update_paging_mode;
> +
>      return is_hvm_domain(d) ? -EOPNOTSUPP : 0;

I know you haven't changed the logic here, but this hook looks broken. 
Why do we fail it right at the end for HVM domains?

~Andrew

 


Rackspace

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