All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Alexey Dobriyan <adobriyan@openvz.org>
Cc: ak@suse.de, akpm@osdl.org, linux-kernel@vger.kernel.org,
	davej@codemonkey.org.uk, devel@vger.kernel.org
Subject: Re: [PATCH] rdmsr_on_cpu, wrmsr_on_cpu
Date: Thu, 18 Jan 2007 14:14:05 -0800	[thread overview]
Message-ID: <45AFF12D.2070901@zytor.com> (raw)
In-Reply-To: <20070118144527.GA6021@localhost.sw.ru>

Alexey Dobriyan wrote:
> There was OpenVZ specific bug rendering some cpufreq drivers unusable
> on SMP. In short, when cpufreq code thinks it confined itself to
> needed cpu by means of set_cpus_allowed() to execute rdmsr, some
> "virtual cpu" feature can migrate process to anywhere. This triggers
> bugons and does wrong things in general.
> 
> This got fixed by introducing rdmsr_on_cpu and wrmsr_on_cpu executing
> rdmsr and wrmsr on given physical cpu by means of
> smp_call_function_single().
> 
> Dave Jones mentioned cpufreq might be not only user of rdmsr_on_cpu()
> and wrmsr_on_cpu(), so I'm going to put them into arch/i386/lib/
> (after patch gets some more testing othen than compile and UP run)

The CPUID and MSR drivers need something like this.

HOWEVER -- and this is where things get gnarly -- the CPUID and MSR 
drivers would really like to be able to execute CPUID, WRMSR and RDMSR 
with the entire GPR register set (except the stack pointer) pre-set and 
post-captured, since it's highly likely that there are going to be 
nonstandard MSRs and CPUID levels (already witness Intel breaking the 
CPUID architecture by introducing %ecx dependencies.)

So I would like to see:

/* It probably makes sense to use the same structure on x86 and
    x86-64 */
struct x86_gpr_regs {
	u64 rax, rcx, rdx, rbx;
	u64 rsp, rbp, rsi, rdi;
	u64 r8, r9, r10, r11;
	u64 r12, r13, r14, r15;
};

void rdmsr_on_cpu(unsigned cpu,
	const struct x86_gpr_regs *in, struct x86_gpr_regs *out);
void wrmsr_on_cpu(unsigned cpu,
	const struct x86_gpr_regs *in, struct x86_gpr_regs *out);
void cpuid_on_cpu(unsigned cpu,
	const struct x86_gpr_regs *in, struct x86_gpr_regs *out);

This requires assembly to do in the nonparavirtualized case, of course. 
  I'll try to get that written up in the next day or so.

	-hpa

  reply	other threads:[~2007-01-18 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18 14:45 [PATCH] rdmsr_on_cpu, wrmsr_on_cpu Alexey Dobriyan
2007-01-18 22:14 ` H. Peter Anvin [this message]
2007-01-18 23:21   ` Andi Kleen
2007-01-18 23:40     ` H. Peter Anvin
2007-01-19  0:40       ` Andi Kleen
2007-01-19  0:45         ` 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=45AFF12D.2070901@zytor.com \
    --to=hpa@zytor.com \
    --cc=adobriyan@openvz.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=davej@codemonkey.org.uk \
    --cc=devel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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.