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

Re: [PATCH 12/16] x86/shadow: make monitor table create/destroy more consistent


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 23 Mar 2023 18:28:12 +0000
  • 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=4WGZH1vW4lzrH+1zyZw9Ab0ewh+SjZa1gRO+RBef6Iw=; b=jJZjIhsysEkG1+SSepDsGeQccw0Wd4iytjtmCKs1a+62+uoCGBt8Kj1zGSej1ijNF4b9qd/4OEl/DuqVW+f0LtgxPsxPxsCCXduj+obc023AZj1V9VdVstf+G4bEWHq+9LJPVEQ0k1NK4XDEwTppmRogYFXXZmdkgm0jM1qDQwWmeWSaNHE3E+XqKBAsktsZMSKkNqybBOfRHT4+pTNE0lGhXdb+wcz13RxvBUSuLfw6xjzLv0WJ3PPwIYDgSd2+0p7qrSbX+hCgokjXjQk3e6YPDT0IdTzs8lAgoQENAbSTWjpeM9+3b7UObxhQxIpmQlRJBOsezxULrXwVGghqsQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h9w6IZuFTQCOU+rSpvYxkUuBCCJyAjWgacNju+mQA0n6XtNMAqXRD6eXLI20/T2JNmBQ0H8lU12ehhqozUS/26jpDqKEU6wTAApzo3ggkrtCpxusor6xzZS6or4+ql4fwcGOOFw/i9EufFICoq3pSR9b+LLdN+QTKoGhHx1I3fBeh/ffmY0Enc6H7p6rUncAficREEvfHaKNJHD+/7c0IdWi+Sr+r31JjN6fEdbN7jCwdB5DozUn/Nmz2ZxupgdU2wLOQ3+YeKphPBbm5kqnUzwLUDGqom9D6gWgNvJQJF1xcb3ZkFUHpvQroLK6Boe791KFGTCblKu7sORKvKnL9Q==
  • 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 Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>
  • Delivery-date: Thu, 23 Mar 2023 18:28:37 +0000
  • Ironport-data: A9a23:OfmTZKLOuklYmaYbFE+R4ZQlxSXFcZb7ZxGr2PjKsXjdYENS1TUHy 2QcXGyDMqzfazD2KYsia9zn/UNU6J6Ay95kTFRlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPTwP9TlK6q4mhA5QZlPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5qLlty5 ds6FwstVTTAv8O4w5njEe5F05FLwMnDZOvzu1lG5BSAVbMKZM6GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dnpTGLnGSd05C0WDbRUvWMSd9YgQCzo WXe8n6iKhobKMae2XyO9XfEaurnxHunBNNJTeLnnhJsqHuhxG06VFoHbwWAi9K/oReUdY8YF nVBr0LCqoB3riRHVOLVXRe1vXqFtR40QMdLHqsx7wTl4rrZ5UOVC3YJShZFacc6r4kmSDoyz FiLktj1Qzt1v9W9Vna15rqS6zSoNkA9MW4HTT8JS00C+daLnW0ophfGT9ImHKvriNTwQGn02 2rT9Hh4gKgPh8kW0an95UrAnz+nupnOSEgy+xnTWWWmqAh+YeZJerCV1LQS1t4YRK7xc7VLl CFsdxS2hAzWMaywqQ==
  • Ironport-hdrordr: A9a23:KUxqgKF3JQ9QHgL0pLqE+ceALOsnbusQ8zAXPiFKJCC9F/by/f xG88566faKskdyZJhNo7+90cq7LU80l6QFgrX5VI3KNDUO01HIEGgN1+XfKjTbakjDytI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22/03/2023 9:35 am, Jan Beulich wrote:
> While benign at present, it is still a little fragile to operate on a
> wrong "old_mode" value in sh_update_paging_modes(). This can happen when
> no monitor table was present initially - we'd create one for the new
> mode without updating old_mode. Correct this two ways, each of which

I think you mean "Correct this in two ways" ?

> would be sufficient on its own: Once by adding "else" to the second of
> the involved if()s in the function, and then by setting the correct
> initial mode for HVM domains in shadow_vcpu_init().
>
> Further use the same predicate (paging_mode_external()) consistently
> when dealing with shadow mode init/update/cleanup, rather than a mix of
> is_hvm_vcpu() (init), is_hvm_domain() (update), and
> paging_mode_external() (cleanup).
>
> Finally drop a redundant is_hvm_domain() from inside the bigger if()
> (which is being converted to paging_mode_external()) in
> sh_update_paging_modes().
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> --- a/xen/arch/x86/mm/shadow/common.c
> +++ b/xen/arch/x86/mm/shadow/common.c
> @@ -129,8 +129,8 @@ void shadow_vcpu_init(struct vcpu *v)
>      }
>  #endif
>  
> -    v->arch.paging.mode = is_hvm_vcpu(v) ?
> -                          &SHADOW_INTERNAL_NAME(sh_paging_mode, 3) :
> +    v->arch.paging.mode = paging_mode_external(v->domain) ?
> +                          &SHADOW_INTERNAL_NAME(sh_paging_mode, 2) :
>                            &SHADOW_INTERNAL_NAME(sh_paging_mode, 4);

As you're changing this, reposition the ? and : to the start of the
following lines?

But, is 2-level mode actually right?  It's better than 3 certainly, and
is what sh_update_paging_modes() selects, but isn't that only right for
the IDENT_PT case?

~Andrew



 


Rackspace

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