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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 7 Jun 2023 15:46:38 +0200
  • 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=RS1NMkxzqfv1+nm1W4arEpqF7PXRDdlJ5L3ySeizlsM=; b=UIzi9qz1gGTHZ70oMy+uNfLPXzzYXj3Qcd+jGiRaryOafOM6l4ExJWCqP8zNVzQOLjKAigPotHSxf1xsDwIKhrFns4FWful/Jak0ejrfXr2gGHlgWx/oVZUrPP6Cvd/ZO9TooJsY14mGzKL5HbE5LDSubU3KR+DgRPgazU4aBRBrsdzDrl4YFUxCvtbte9mb90DcmBLZ37A0BR93PO5ZX1SeUqyGPy9KJZQ8m7dNr+2cAhlGmCIeZeGbC8qTxLcWI7PQdX5M88yn+8NlVXMH/39wdT1Q+2aY66BPekE3xj9nKusKf3/8z0BF1xsYAVjm5hyQBySPSGtLck1M7z/oEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGasqRTTFZ7FReM87rQowZ97S63kExs8z1ONHX/GpliuvPvNFd0J2fZDddUkb+NcHvVznLcASfij3i5OWe63mxF38voOnoNOsyEmikHxrbntc2Fp4AKtpU1di36SgtTVE/wYvfPbKmAXpHQ2Y3EMMZYyGX2HMtMmiMI/qDD9OGSts0fbE6lrA7tUdhg0MYeQc+/VcCeyQ0isqJrHZoDE4jtH4By/PqcjvfLJdfy1YsYs1cL+0zx8J9/LC4yEEVoh+5lt2zJzrKNLZPLvYYMCcNJZAIXxNajTc8xYhY7WGflA8ocK/YBT1hIrvi1W+IJe5mJ72GQwCgjPxrn8w2633w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 07 Jun 2023 13:47:13 +0000
  • Ironport-data: A9a23:4+gf566WyKD9TUvV3IcowQxRtB7GchMFZxGqfqrLsTDasY5as4F+v jYfDzqHPv+LMzemKtByPI6/9x4H68Tdn4BnGQU+qSoxHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU35JwehBtC5gZlPa4T4weE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m6 OMlEmFVcwC4qc2M4PGEdfFv2/wiM5y+VG8fkikIITDxK98DGMiGb4CUoNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6OnEooiOWF3Nn9I7RmQe1PmUmVv CTe9nnRCRAGLt2PjzGC9xpAg8eWxHqhBNtLTO3QGvhCmFaNmkcxUUUsZwWk/Of6r2OjUOlFJ BlBksYphe1onKCxdfHtUhv9rHOasxo0X9tLD/Z8+AyL0rDT4QuSGi4DVDEpQN4sudIyRDcq/ kSUhN6vDjtq2JWKTVqN+7HSqim9URX5NkcHbC4ACAcAvd/qpdhrigqVF44+VqmoktfyBDf8h SiQqzQzjKkSishN0Lin+VfAgHSnoZ2hohMJ2zg7l1mNtmtRDLNJraTygbQHxZ6s9Lqkc2Q=
  • Ironport-hdrordr: A9a23:bt6Oi6/CM0CuhTiuDvduk+AcI+orL9Y04lQ7vn2ZKSY5TiX4rb HKoB1/73XJYVkqN03I9ervBEDiewK/yXcW2+ks1N6ZNWGLhILBFupfBODZsl7d8kPFl9K01c 1bAtJD4N+bNykGsS4tijPIb+rJw7O8gd+Vbf+19QYIcenzAZsQlzuQDGygYypLbTgDP7UVPr yG6PFKojKxEE5nFfhSVhE+Lo7+T8SgruOeXSI7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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));
         return -EINVAL;
     }
 
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 2d6e4bb9c682..f27be2cefc0b 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1018,8 +1018,8 @@ static int cf_check hvm_load_cpu_ctxt(struct domain *d, 
hvm_domain_context_t *h)
 
     if ( ctxt.cr4 & ~hvm_cr4_guest_valid_bits(d) )
     {
-        printk(XENLOG_G_ERR "HVM%d restore: bad CR4 %#" PRIx64 "\n",
-               d->domain_id, ctxt.cr4);
+        printk(XENLOG_G_ERR "HVM%d restore: bad CR4 %#016lx (valid: %016lx)\n",
+               d->domain_id, ctxt.cr4, hvm_cr4_guest_valid_bits(d));
         return -EINVAL;
     }
 
@@ -2461,8 +2461,8 @@ int hvm_set_cr4(unsigned long value, bool may_defer)
     if ( value & ~hvm_cr4_guest_valid_bits(v->domain) )
     {
         HVM_DBG_LOG(DBG_LEVEL_1,
-                    "Guest attempts to set reserved bit in CR4: %lx",
-                    value);
+                    "Guest attempts to set reserved bit in CR4: %#016lx 
(valid: %#016lx)",
+                    value, hvm_cr4_guest_valid_bits(v->domain));
         return X86EMUL_EXCEPTION;
     }
 
diff --git a/xen/arch/x86/hvm/svm/svmdebug.c b/xen/arch/x86/hvm/svm/svmdebug.c
index 7d6dc9ef47db..df5da29f8fb3 100644
--- a/xen/arch/x86/hvm/svm/svmdebug.c
+++ b/xen/arch/x86/hvm/svm/svmdebug.c
@@ -124,7 +124,7 @@ bool svm_vmcb_isvalid(const char *from, const struct 
vmcb_struct *vmcb,
 
     valid = hvm_cr4_guest_valid_bits(v->domain);
     if ( cr4 & ~valid )
-        PRINTF("CR4: invalid bits are set (%#"PRIx64", valid: %#"PRIx64")\n",
+        PRINTF("CR4: invalid bits are set (%#016lx, valid: %#016lx)\n",
                cr4, valid);
 
     if ( vmcb_get_dr6(vmcb) >> 32 )
-- 
2.40.0




 


Rackspace

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