From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Jan Beulich <JBeulich@novell.com>,
the arch/x86 maintainers <x86@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Xen-devel <xen-devel@lists.xensource.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [Xen-devel] Re: [GIT PULL] xen /proc/mtrr implementation
Date: Wed, 20 May 2009 09:35:26 -0700 [thread overview]
Message-ID: <4A14314E.7030406@goop.org> (raw)
In-Reply-To: <20090519110837.GA10548@elte.hu>
Ingo Molnar wrote:
> * Jan Beulich <JBeulich@novell.com> wrote:
>
>
>>>>> Ingo Molnar <mingo@elte.hu> 19.05.09 11:59 >>>
>>>>>
>>> Exactly what is 'bizarre' about using the API defined by the
>>> _CPU_ already, without adding any ad-hoc hypecall? Catch the
>>> dom0 WRMSRs, filter out the MTRR indices - that's it.
>>>
>> But that is *not* the same as using the hypercalls: The hypercall
>> tells Xen "Change all CPUs' MTRRs with the indicated index to the
>> indicated value", while the MSR write says "Change the MTRR with
>> the given index on the physical CPU the current virtual CPU
>> happens to run on to the given value". [...]
>>
>
> The change of MTRR's on _any_ of the guest CPUs in a dom0 context
> should immediately be refected on all CPUs. Assymetric MTRR settings
> are madness.
>
> ( And the thing is, changing MTRRs is fragile and racy on native
> Linux no matter what - even without any hypervisors - due to SMM
> contexts possibly relying on them etc. )
>
>
>> [...] A write-base/write-mask pair may happen to get interrupted
>> (preempted) by the hypervisor, and hence the two writes may happen
>> on different pCPU-s. Teaching the hypervisor to (correctly!) guess
>> what the guest meant in that situation isn't trivial, as then it
>> needs to handle all possible situations (and it can never know
>> whether Dom0 really intended to do something that may look
>> bogus/inconsistent at the first glance). [...]
>>
>
> None of this is a problem really if a sane approach is used: a
> change to the MTRR state on dom0 is applied symmetrically on all
> CPUs.
>
> Or, alternatively, the hypervisor can expose its own administrative
> interface to manage MTRRs.
>
> There's no need to fuglify the Linux kernel for that.
I'm not sure what you mean by that, other than as a description of the
current case. The Xen MTRR hypercall:
1. treats MTRR ranges as allocatable resources, and keep track of how
many uses there are of each
2. updates all physical cpus synchronously (ie, the MTRR is not
presented as a property of dom0's virtual CPU, but as a
system-wide resource)
3. prevents guests from setting inconsistent or conflicting MTRRs
Mapping from MSR writes to this interface is moderately complex, because
it requires a mapping from a low-semantic-content interface to a
high-semantic-content interface. It essentially requires parsing the
MSR writes to map them back to the relatively high-level operations at
the mtrr_ops interface and then present that to Xen.
There are at least a couple of secondary issues which arise from that
approach:
* mtrr/generic.c also has to do a number of other things like
disabling caching, tlb flushes, etc. That adds complexity because
Xen guests are never allowed to globally disable caching, so we'd
have to add additional filtering to remove those cr0 writes
* As we've discussed, we'd need to make the mtrr writes implicitly
change all cpus atomically, as the dom0 kernel can't see physical cpus
The net effect would be that we would be making a pile of apparently
generic CPU operations (MSR writes, control register writes) actually
feed a fairly complex parser, increasing the difference between the Xen
and native cases even more.
mtrr/generic.c about 730 lines of fairly intricate arch-specific code.
mtrr/xen.c is 120 lines of straightforward hypercalls. The mtrr_ops
interface and the Xen hypercall interface are a close semantic match, so
there's very little glue code in there.
But that said, this a huge distraction, an unbelievable amount of noise
for a fairly minor point. We can live without these changes, and
they're certainly easy enough to carry out of tree in the meantime. If
you can't live with these changes, then drop them and we'll work out
something else.
J
next prev parent reply other threads:[~2009-05-20 16:35 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 23:27 [GIT PULL] xen /proc/mtrr implementation Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 1/6] xen: set cpu_callout_mask to make mtrr work Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 2/6] xen mtrr: Use specific cpu_has_foo macros instead of generic cpu_has() Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 3/6] xen mtrr: Use generic_validate_add_page() Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 4/6] xen mtrr: Implement xen_get_free_region() Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 5/6] xen mtrr: Add xen_{get,set}_mtrr() implementations Jeremy Fitzhardinge
2009-05-12 23:27 ` [PATCH 6/6] xen mtrr: Kill some unnecessary includes Jeremy Fitzhardinge
2009-05-13 13:30 ` [GIT PULL] xen /proc/mtrr implementation Ingo Molnar
2009-05-13 14:39 ` Jeremy Fitzhardinge
2009-05-15 18:27 ` Ingo Molnar
2009-05-15 20:09 ` Jeremy Fitzhardinge
2009-05-15 23:26 ` Eric W. Biederman
2009-05-15 23:49 ` Jeremy Fitzhardinge
2009-05-16 3:22 ` Jesse Barnes
2009-05-16 4:26 ` Eric W. Biederman
2009-05-16 18:22 ` Jesse Barnes
2009-05-18 5:02 ` Jeremy Fitzhardinge
2009-05-18 4:57 ` Jeremy Fitzhardinge
2009-05-18 8:59 ` Ingo Molnar
2009-05-18 13:17 ` [Xen-devel] " Jan Beulich
2009-05-18 17:51 ` Chris Wright
2009-05-18 18:07 ` Jeremy Fitzhardinge
2009-05-19 9:59 ` Ingo Molnar
2009-05-19 10:22 ` [Xen-devel] " Jan Beulich
2009-05-19 11:08 ` Ingo Molnar
2009-05-19 12:04 ` Gerd Hoffmann
2009-05-19 12:26 ` Ingo Molnar
2009-05-19 12:32 ` Alan Cox
2009-05-19 12:37 ` Ingo Molnar
2009-05-19 13:21 ` Gerd Hoffmann
2009-05-19 13:31 ` Ingo Molnar
2009-05-19 13:51 ` Gerd Hoffmann
2009-05-19 14:17 ` Ingo Molnar
2009-05-19 14:55 ` Gerd Hoffmann
2009-05-19 15:24 ` Ingo Molnar
2009-05-20 8:01 ` Gerd Hoffmann
2009-05-20 16:35 ` Jeremy Fitzhardinge [this message]
2009-05-20 16:12 ` Jeremy Fitzhardinge
2009-05-20 8:16 ` Andi Kleen
2009-05-20 16:39 ` Jeremy Fitzhardinge
2009-05-20 22:52 ` Andi Kleen
2009-05-20 22:49 ` Jeremy Fitzhardinge
2009-05-20 23:03 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2009-05-25 8:42 [Xen-devel] " Tomasz Chmielewski
2009-05-25 9:15 ` Andi Kleen
2009-05-25 9:31 ` Jan Beulich
2009-05-25 9:47 ` Andi Kleen
2009-05-25 16:05 ` H. Peter Anvin
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=4A14314E.7030406@goop.org \
--to=jeremy@goop.org \
--cc=JBeulich@novell.com \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.com \
/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.