From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH 2/5] hvm/mtrr: use the hardware number of variable ranges for Dom0
Date: Thu, 10 May 2018 18:15:02 +0100 [thread overview]
Message-ID: <20180510171505.37309-3-roger.pau@citrix.com> (raw)
In-Reply-To: <20180510171505.37309-1-roger.pau@citrix.com>
Expand the size of the variable ranges array to match the size of the
underlying hardware, this is a preparatory change for copying the
hardware MTRR state for Dom0.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/hvm/mtrr.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
index b3c08c3977..95a3deabea 100644
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -154,14 +154,17 @@ uint8_t pat_type_2_pte_flags(uint8_t pat_type)
int hvm_vcpu_cacheattr_init(struct vcpu *v)
{
struct mtrr_state *m = &v->arch.hvm_vcpu.mtrr;
+ unsigned int num_var_ranges =
+ is_hardware_domain(v->domain) ? (mtrr_state.mtrr_cap & 0xff)
+ : MTRR_VCNT;
memset(m, 0, sizeof(*m));
- m->var_ranges = xzalloc_array(struct mtrr_var_range, MTRR_VCNT);
+ m->var_ranges = xzalloc_array(struct mtrr_var_range, num_var_ranges);
if ( m->var_ranges == NULL )
return -ENOMEM;
- m->mtrr_cap = (1u << 10) | (1u << 8) | MTRR_VCNT;
+ m->mtrr_cap = (1u << 10) | (1u << 8) | num_var_ranges;
v->arch.hvm_vcpu.pat_cr =
((uint64_t)PAT_TYPE_WRBACK) | /* PAT0: WB */
@@ -683,6 +686,9 @@ static int hvm_save_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
| (mtrr_state->enabled << 10);
hw_mtrr.msr_mtrr_cap = mtrr_state->mtrr_cap;
+ if ( (mtrr_state->mtrr_cap & 0xff) != MTRR_VCNT )
+ return -EINVAL;
+
for ( i = 0; i < MTRR_VCNT; i++ )
{
/* save physbase */
@@ -727,6 +733,9 @@ static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
mtrr_state->mtrr_cap = hw_mtrr.msr_mtrr_cap;
+ if ( (mtrr_state->mtrr_cap & 0xff) != MTRR_VCNT )
+ return -EINVAL;
+
for ( i = 0; i < NUM_FIXED_MSR; i++ )
mtrr_fix_range_msr_set(d, mtrr_state, i, hw_mtrr.msr_mtrr_fixed[i]);
--
2.17.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-05-10 17:15 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 17:15 [PATCH 0/5] PVH MTRR initial state Roger Pau Monne
2018-05-10 17:15 ` [PATCH 1/5] hvm/mtrr: add emacs local variables block with formatting info Roger Pau Monne
2018-05-10 17:15 ` Roger Pau Monne [this message]
2018-05-14 14:14 ` [PATCH 2/5] hvm/mtrr: use the hardware number of variable ranges for Dom0 Jan Beulich
2018-05-10 17:15 ` [PATCH 3/5] hvm/mtrr: copy hardware state " Roger Pau Monne
2018-05-14 14:26 ` Jan Beulich
2018-05-14 16:33 ` Roger Pau Monné
2018-05-15 7:52 ` Jan Beulich
2018-05-15 8:35 ` Roger Pau Monné
2018-05-15 8:48 ` Jan Beulich
2018-05-15 9:16 ` Roger Pau Monné
2018-05-15 9:50 ` Jan Beulich
2018-05-10 17:15 ` [PATCH 4/5] libxc/pvh: set default MTRR type to write-back Roger Pau Monne
2018-05-14 16:00 ` Wei Liu
2018-05-14 16:02 ` Roger Pau Monné
2018-05-14 16:42 ` Wei Liu
2018-05-14 16:50 ` Wei Liu
2018-05-14 16:53 ` Roger Pau Monné
2018-05-15 11:43 ` Wei Liu
2018-05-15 12:22 ` Jan Beulich
2018-05-10 17:15 ` [PATCH 5/5] docs/pvh: document initial MTRR state Roger Pau Monne
2018-05-14 16:03 ` Wei Liu
2018-05-14 16:13 ` Jan Beulich
2018-05-14 16:18 ` Wei Liu
2018-05-15 7:51 ` Jan Beulich
2018-05-15 8:30 ` Wei Liu
2018-05-15 8:30 ` Roger Pau Monné
2018-05-15 8:38 ` Jan Beulich
2018-05-14 16:16 ` Roger Pau Monné
2018-05-14 16:27 ` Wei Liu
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=20180510171505.37309-3-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).