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

Re: [PATCH] x86/hvm: print valid CR4 bits in case of error


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 7 Jun 2023 16:48:42 +0100
  • 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=GtwyNaqKcRRK4Ez0+YYUwPrhpl8Qdy0sMv26mhKpbDg=; b=SvqdsKBeiJGRtgHhFFX1SiDd0rxmBBhF4iDm6rv11l6J1sgWbuC6dYQCx574lztuHCyzg6oIwb7oG0y79k54Xu9ptZMX1FyTZpJr2mXX7TVJoY4/YzCekVi5JdPw+grn7f3OP2alPco+XvWYyBgFG2NzQljmFAK7KG17CT+94o75KtDnhoeyDkAiNMq1hbTsX9s/NlDYbe2xEQcBcOvpB6w8YZfmJmlhzq2wb3xzvXGHlNu3CohhANavaBOG63h/DpQUfbS6B8g00YKOqZxHzeC4gwMFRnCzuchFH5XuU1DnFvqbPOhj0wYcisZ5yvA01KqP0Of97uzRyFIiR7554Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mu/R4EnV2IodtKaDGeS3eYZwgBX+ndAnrXrvw0f7RVR5e6xdI3O7PrMT8AEaIOwzFEvDJTJbHaIxOGZgsUhVsF1V3quO7/Z5iPVibU4H+PkJm8Dfv4m2RskWcoLCs4WpZnik5vYXZQa/jEasZudlWqlXqTwTojwrQU+TvUj6qYUOOBjIC+chqvuHJYF+u9XqeyFDY04EuN5Ff/fs1Y2vTkZTwoGFqz/SKbU4k9xHPYoxyH9Jiw6KeatYso77rbm3WYnwnMmYPgetpviFQNZknZwJpXFOdi65pPtIY8hUCl1qxKPR9nAVcuSdTIdEq8PjSmlTJqVT0xFngHtcmaczSg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 07 Jun 2023 15:49:10 +0000
  • Ironport-data: A9a23:22auzKCHAP6gIxVW/wTiw5YqxClBgxIJ4kV8jS/XYbTApDsi1D1Ux mJKWmCCPfeJajP0eI9za4u1p0IC7MWDy9FhQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMs8pvlDs15K6p4G1A4QRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw3uVmA3pe8 eEkJiEIVE6Pq8/q/bnkc7w57igjBJGD0II3nFhFlGicJtF/BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI++xuvDK7IA9ZidABNPL8fNCQSNoTtUGfv m/cpEzyAw0ANczZwj2Amp6prraWxHmlAd9DRNVU8NZBuAWY3kkWEiEaFkuQ++uVqFe0AtRQf hl8Fi0G6PJaGFaQZsnwWVi0rWCJujYYWsFMCKsq5QeV0K3W7g2FQG8eQVZpatYrqcs3TjwCz UKSkpXiAjkHmKKRYWKQ8PGTtzzaBMQOBWoLZCtBRgxc5dDm+dg3lkiWEYwlF7OphNroHz222 yqNsCU1m7QUi4gMyrm/+lfExTmro/AlUzII2+keZUr9hisRWWJvT9bABYTzhRqYELukcw==
  • Ironport-hdrordr: A9a23:8VQ9Walg9m5vTV0GNS3Lhcks4FbpDfM4iWdD5ihNYBxZY6Wkfp +V/MjzhCWUtN9OYh8dcIi7SdS9qXO1z+8T3WBjB8bfYOCGghrlEGgG1+HfKlLbalbDH4JmpM JdmstFeZLN5DpB/LzHCWCDer5KrbXpgcPY59s2pE0dKz2CHpsQlzuRfTzra3GeKjM2YaYRJd 653I5qtjCgcXMYYoCQHX8eRdXOoNXNidbPfQMGLwRP0njOsRqYrJrBVzSI1BYXVD1ChZ0493 LergD/7qK/99mm1x7n0XPJ5Zg+oqqg9jIDPr3OtiEmEESotu+aXvUkZ1REhkFznAib0idprD ALmWZnAy080QKJQoj/m2qT5+Cp6kdR15al8y7XvVLT5fXjQjQ0EsxAgp8cXCf4xiMbzYpB+Z MO5nmesZVPCxPGgWDa3PjnEz9Xtmfcmwt7rQY050YvDLf2rIUh97A37QdbFowNEzn9751iGO 5yDNvE7PITal+CaWvF11Mfi+BE8U5Daytub3Jy8/B96QIm1ExR3g8d3ogSj30A/JUyR91N4P nFKL1hkPVLQtUNZaxwCe8dSY/vY1a9DC7kISaXOxDqBasHM3XCp9r+56g0/vijfNgNwIEpkJ rMXVtEvSo5el7oC8eJwJpXmyq9ClmVTHDo0IVT9pJ5srrzSP7iNjCCUkknl4+6r/AWEqTgKo COEYMTB+WmIXrlGI5P0QG7UZFWJX4SWNZQoNohW16V5sLNMJDjsebWNPbfTYCdYQrMmlmPdU frcAKDVvmotHrbK0MQqCKhKE/Fawjg4Iw1HK3WltJjvLQwCg==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07/06/2023 2:46 pm, Roger Pau Monne wrote:
> Some of the current users of hvm_cr4_guest_valid_bits() to check
> whether a CR4 value is correct don't print the valid mask, and thus
> the resulting error messages are not as helpful as they could be.
>
> Amend callers to always print the value of hvm_cr4_guest_valid_bits(),
> and take the opportunity of also adjusting all the users to use the
> same print formatter.
>
> No functional change intended.
>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
>  xen/arch/x86/hvm/domain.c       | 4 ++--
>  xen/arch/x86/hvm/hvm.c          | 8 ++++----
>  xen/arch/x86/hvm/svm/svmdebug.c | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/domain.c b/xen/arch/x86/hvm/domain.c
> index deec74fdb4f5..8951230a9f52 100644
> --- a/xen/arch/x86/hvm/domain.c
> +++ b/xen/arch/x86/hvm/domain.c
> @@ -266,8 +266,8 @@ int arch_set_info_hvm_guest(struct vcpu *v, const 
> vcpu_hvm_context_t *ctx)
>  
>      if ( v->arch.hvm.guest_cr[4] & ~hvm_cr4_guest_valid_bits(d) )
>      {
> -        gprintk(XENLOG_ERR, "Bad CR4 value: %#016lx\n",
> -                v->arch.hvm.guest_cr[4]);
> +        gprintk(XENLOG_ERR, "Bad CR4 value: %#016lx (valid: %016lx)\n",
> +                v->arch.hvm.guest_cr[4], hvm_cr4_guest_valid_bits(d));

I suspect you want to call this once and store it in a variable.

It's a non-inline function which also isn't marked attr_const, so it
will get called twice.

Also, if you're extending like this, then you actually want

(valid %lx, rejected %lx)

passing in cr4 ^ valid for rejected.  It's almost always 1 bit which is
rejected at a time, and the xor form is easier to read, not least
because it matches the X86_CR4_blah constant of the bad feature.

~Andrew



 


Rackspace

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