All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>
Subject: [PATCH v3 4/8] x86/svm: handle BU_CFG and BU_CFG2 with cases
Date: Tue, 1 Sep 2020 12:54:41 +0200	[thread overview]
Message-ID: <20200901105445.22277-5-roger.pau@citrix.com> (raw)
In-Reply-To: <20200901105445.22277-1-roger.pau@citrix.com>

Move the special handling of reads to it's own switch case, and also
add support for BU_CFG2. On the write side ignore writes if the MSR is
readable, otherwise return a #GP.

This is in preparation for changing the default MSR read/write
behavior, which will instead return #GP on not explicitly handled
cases.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v2:
 - Move the handling of reads to it's own case.
 - Drop writes if the MSR is readable, else return a #GP.

Changes since v1:
 - New in this version.
---
 xen/arch/x86/hvm/svm/svm.c | 43 ++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index af584ff5d1..0e43154c7e 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1864,6 +1864,30 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         *msr_content = 1ULL << 61; /* MC4_MISC.Locked */
         break;
 
+    case MSR_F10_BU_CFG:
+        if ( !rdmsr_safe(msr, *msr_content) )
+            break;
+
+        if ( boot_cpu_data.x86 == 0xf )
+        {
+            /*
+             * Win2k8 x64 reads this MSR on revF chips, where it wasn't
+             * publically available; it uses a magic constant in %rdi as a
+             * password, which we don't have in rdmsr_safe().  Since we'll
+             * ignore the later writes, just use a plausible value here (the
+             * reset value from rev10h chips) if the real CPU didn't provide
+             * one.
+             */
+            *msr_content = 0x0000000010200020ull;
+            break;
+        }
+        goto gpf;
+
+    case MSR_F10_BU_CFG2:
+        if ( rdmsr_safe(msr, *msr_content) )
+            goto gpf;
+        break;
+
     case MSR_IA32_EBC_FREQUENCY_ID:
         /*
          * This Intel-only register may be accessed if this HVM guest
@@ -1942,19 +1966,6 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
     default:
         if ( rdmsr_safe(msr, *msr_content) == 0 )
             break;
-
-        if ( boot_cpu_data.x86 == 0xf && msr == MSR_F10_BU_CFG )
-        {
-            /* Win2k8 x64 reads this MSR on revF chips, where it
-             * wasn't publically available; it uses a magic constant
-             * in %rdi as a password, which we don't have in
-             * rdmsr_safe().  Since we'll ignore the later writes,
-             * just use a plausible value here (the reset value from
-             * rev10h chips) if the real CPU didn't provide one. */
-            *msr_content = 0x0000000010200020ull;
-            break;
-        }
-
         goto gpf;
     }
 
@@ -2110,6 +2121,12 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)
         nsvm->ns_msr_hsavepa = msr_content;
         break;
 
+    case MSR_F10_BU_CFG:
+    case MSR_F10_BU_CFG2:
+        if ( rdmsr_safe(msr, msr_content) )
+            goto gpf;
+        break;
+
     case MSR_AMD64_TSC_RATIO:
         if ( msr_content & TSC_RATIO_RSVD_BITS )
             goto gpf;
-- 
2.28.0



  parent reply	other threads:[~2020-09-01 11:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 10:54 [PATCH v3 0/8] x86: switch default MSR behavior Roger Pau Monne
2020-09-01 10:54 ` [PATCH v3 1/8] x86/vmx: handle writes to MISC_ENABLE MSR Roger Pau Monne
2020-09-04  8:34   ` Jan Beulich
2020-09-07  3:25   ` Tian, Kevin
2020-09-07  7:22     ` Jan Beulich
2020-09-01 10:54 ` [PATCH v3 2/8] x86/svm: silently drop writes to SYSCFG and related MSRs Roger Pau Monne
2020-09-04  8:36   ` Jan Beulich
2020-09-04  9:47     ` Andrew Cooper
2020-09-01 10:54 ` [PATCH v3 3/8] x86/msr: explicitly handle AMD DE_CFG Roger Pau Monne
2020-09-02 20:49   ` Andrew Cooper
2020-09-01 10:54 ` Roger Pau Monne [this message]
2020-09-02 21:02   ` [PATCH v3 4/8] x86/svm: handle BU_CFG and BU_CFG2 with cases Andrew Cooper
2020-09-03  8:15     ` Roger Pau Monné
2020-09-04  8:39       ` Jan Beulich
2020-09-03  8:29     ` Jan Beulich
2020-09-01 10:54 ` [PATCH v3 5/8] x86/pv: allow reading FEATURE_CONTROL MSR Roger Pau Monne
2020-09-02 20:56   ` Andrew Cooper
2020-09-03 13:33     ` Roger Pau Monné
2020-09-03 14:06       ` Andrew Cooper
2020-09-03 14:10         ` Roger Pau Monné
2020-09-01 10:54 ` [PATCH v3 6/8] x86/pv: disallow access to unknown MSRs Roger Pau Monne
2020-09-01 10:54 ` [PATCH v3 7/8] x86/hvm: Disallow " Roger Pau Monne
2020-09-04  8:53   ` Jan Beulich
2020-09-04  9:44     ` Andrew Cooper
2020-09-04  9:58       ` Jan Beulich
2020-09-04 11:13     ` Roger Pau Monné
2020-09-07  3:31   ` Tian, Kevin
2020-09-01 10:54 ` [PATCH v3 8/8] x86/msr: Drop compatibility #GP handling in guest_{rd, wr}msr() Roger Pau Monne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901105445.22277-5-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.