From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, marcel@redhat.com,
mst@redhat.com, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 3/6] x86: fill high bits of mtrr mask
Date: Tue, 5 Jul 2016 09:39:20 +0100 [thread overview]
Message-ID: <20160705083919.GA2118@work-vm> (raw)
In-Reply-To: <20160704202148.GI4131@thinpad.lan.raisama.net>
* Eduardo Habkost (ehabkost@redhat.com) wrote:
> On Mon, Jul 04, 2016 at 08:16:06PM +0100, Dr. David Alan Gilbert (git) wrote:
> [...]
> > @@ -2084,6 +2085,27 @@ static int kvm_get_msrs(X86CPU *cpu)
> > }
> >
> > assert(ret == cpu->kvm_msr_buf->nmsrs);
> > + /*
> > + * MTRR masks: Each mask consists of 5 parts
> > + * a 10..0: must be zero
> > + * b 11 : valid bit
> > + * c n-1.12: actual mask bits
> > + * d 51..n: reserved must be zero
> > + * e 63.52: reserved must be zero
> > + *
> > + * 'n' is the number of physical bits supported by the CPU and is
> > + * apparently always <= 52. We know our 'n' but don't know what
> > + * the destinations 'n' is; it might be smaller, in which case
> > + * it masks (c) on loading. It might be larger, in which case
> > + * we fill 'd' so that d..c is consistent irrespetive of the 'n'
> > + * we're migrating to.
> > + */
> > + if (cpu->fill_mtrr_mask && cpu->phys_bits < 52) {
> > + mtrr_top_bits = MAKE_64BIT_MASK(cpu->phys_bits, 52 - cpu->phys_bits);
> > + } else {
> > + mtrr_top_bits = 0;
>
> How/where did you find this 52-bit limit? Is it documented
> somewhere?
It seems to come from AMDs original specification of AMD64; but you're
right we could do with a constant rather than the magical 52 everywhere.
Looking in AMD doc 24593 Rev 3.26 (AMD64 Arch Programmer's manual vol. 2)
p.191 Fig 7.6 MTRRphysBasen Register it shows it as PhysBase running from 51:32
and 63:52 being Reserved/MBZ;
The corresponding Intel doc (Intel 64 & IA-32 Architectures Dev manual 3A 11-25
fig 11-7) doesn't have that limit shown; however it does talk about 52-bit
physical addresses in a few places; e.g. 4.4 PAE paging talks about
'paging translates 32-bit linear addresses to 52-bit physical addresses'
I think the most relevant place in the Intel doc is 5.13.3 'Reserved Bit Checking'
which has a
Table 5-8 'IA-32e Mode Page Level Protection Matrix with Execute-Disable Bit Capability Enabled'
this is a table of reserved bit fields and for each of the
page tables it shows bits checked as [51:MAXPHYADDR].
Any suggestions for a name for the 52 constant? I guess MaxMaxPhyAddress?
I guess someone decided that 4PB ought to be enough for anyone.
Dave
>
> > + }
> > +
> > for (i = 0; i < ret; i++) {
> > uint32_t index = msrs[i].index;
> > switch (index) {
> > @@ -2279,7 +2301,8 @@ static int kvm_get_msrs(X86CPU *cpu)
> > break;
> > case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1):
> > if (index & 1) {
> > - env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data;
> > + env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data |
> > + mtrr_top_bits;
> > } else {
> > env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data;
> > }
> > --
> > 2.7.4
> >
>
> --
> Eduardo
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2016-07-05 8:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 19:16 [Qemu-devel] [PATCH v2 0/6] x86: Physical address limit patches Dr. David Alan Gilbert (git)
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 1/6] x86: Allow physical address bits to be set Dr. David Alan Gilbert (git)
2016-07-04 19:33 ` Eduardo Habkost
2016-07-05 13:43 ` Dr. David Alan Gilbert
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 2/6] x86: Mask mtrr mask based on CPU physical address limits Dr. David Alan Gilbert (git)
2016-07-04 20:02 ` Michael S. Tsirkin
2016-07-04 20:05 ` Eduardo Habkost
2016-07-04 22:37 ` Michael S. Tsirkin
2016-07-04 20:03 ` Eduardo Habkost
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 3/6] x86: fill high bits of mtrr mask Dr. David Alan Gilbert (git)
2016-07-04 20:03 ` Michael S. Tsirkin
2016-07-04 20:14 ` Eduardo Habkost
2016-07-04 20:21 ` Eduardo Habkost
2016-07-05 8:39 ` Dr. David Alan Gilbert [this message]
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 4/6] x86: Set physical address bits based on host Dr. David Alan Gilbert (git)
2016-07-04 20:27 ` Eduardo Habkost
2016-07-05 8:44 ` Dr. David Alan Gilbert
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 5/6] x86: fix up 32 bit phys_bits case Dr. David Alan Gilbert (git)
2016-07-05 9:42 ` Daniel P. Berrange
2016-07-05 11:29 ` Dr. David Alan Gilbert
2016-07-05 11:55 ` Daniel P. Berrange
2016-07-05 19:05 ` Dr. David Alan Gilbert
2016-07-04 19:16 ` [Qemu-devel] [PATCH v2 6/6] x86: Add sanity checks on phys_bits Dr. David Alan Gilbert (git)
2016-07-04 20:46 ` Eduardo Habkost
2016-07-05 10:40 ` Dr. David Alan Gilbert
2016-07-04 20:23 ` [Qemu-devel] [PATCH v2 0/6] x86: Physical address limit patches Michael S. Tsirkin
2016-07-05 9:33 ` Dr. David Alan Gilbert
2016-07-05 10:06 ` Michael S. Tsirkin
2016-07-05 10:13 ` Dr. David Alan Gilbert
2016-07-05 10:41 ` Michael S. Tsirkin
2016-07-05 10:59 ` Paolo Bonzini
2016-07-05 11:09 ` Michael S. Tsirkin
2016-07-05 11:46 ` Paolo Bonzini
2016-07-05 12:39 ` Michael S. Tsirkin
2016-07-05 12:41 ` Dr. David Alan Gilbert
2016-07-05 13:38 ` Michael S. Tsirkin
2016-07-05 9:46 ` Daniel P. Berrange
2016-07-05 9:49 ` Dr. David Alan Gilbert
2016-07-05 12:38 ` Eduardo Habkost
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=20160705083919.GA2118@work-vm \
--to=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).