xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Shin <jacob.shin@amd.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Andre Przywara <andre.przywara@amd.com>,
	Jan Beulich <JBeulich@suse.com>,
	mingo@elte.hu, jeremy@goop.org, tglx@linutronix.de,
	xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
	hpa@zytor.com
Subject: Re: [Xen-devel] [PATCH] x86/amd: fix crash as Xen Dom0 on AMD Trinity systems
Date: Wed, 30 May 2012 10:03:34 -0500	[thread overview]
Message-ID: <20120530150334.GA13349@jshin-Toonie> (raw)
In-Reply-To: <20120530145005.GI3207@phenom.dumpdata.com>

On Wed, May 30, 2012 at 10:50:05AM -0400, Konrad Rzeszutek Wilk wrote:
> On Wed, May 30, 2012 at 09:48:51AM -0500, Jacob Shin wrote:
> > On Wed, May 30, 2012 at 04:02:48PM +0200, Andre Przywara wrote:
> > > On 05/30/2012 03:33 PM, Jan Beulich wrote:
> > > >>>>On 30.05.12 at 15:10, Andre Przywara<andre.przywara@amd.com>  wrote:
> > > >>Because we are behind a family check before tweaking the topology
> > > >>bit, we can use the standard rd/wrmsr variants for the CPUID feature
> > > >>register.
> > > >>This fixes a crash when using the kernel as a Xen Dom0 on affected
> > > >>Trinity systems. The wrmsrl_amd_safe is not properly paravirtualized
> > > >>yet (this will be fixed in another patch).
> > > >
> > > >I'm not following: If the AMD variants (putting a special value into
> > > >%edi) can be freely replaced by the non-AMD variants, why did
> > > >the AMD special ones get used in the first place?
> > > 
> > > Older CPUs (K8) needed the AMD variants, starting with family 10h we
> > > can use the normal versions.
> > > 
> > > >Further, I can't see how checking_wrmsrl() is being paravirtualized
> > > >any better than wrmsrl_amd_safe() - both have nothing but an
> > > >exception handling fixup attached to the wrmsr invocation. Care
> > > >to point out what actual crash it is that was seen?
> > > 
> > > AFAIK, the difference is between the "l" and the regs version for
> > > rd/wrmsr. We have a patch already here to fix this. Will send it out
> > > soon. Jacob, can you comment on this?
> > 
> > Right, the checking_wrmsrl turns into wrmsr_safe which is paravirtualized
> > but the rdmsrl_amd_safe which turns into rdmsr_regs is not paravirtualized
> > by enlighten.
> 
> So would a patch to implements the rdmsr_regs fix this crash?

Yes, the following patch also fixed the crash for us:

Implement rdmsr_regs and wrmsr_regs for Xen pvops.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Cc: stable@vger.kernel.org # 3.4+

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 75f33b2..f3ae5ec 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -945,9 +945,12 @@ static void xen_write_cr4(unsigned long cr4)
 	native_write_cr4(cr4);
 }
 
-static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
+static int xen_wrmsr_safe_regs(u32 regs[8])
 {
 	int ret;
+	unsigned int msr = regs[1];
+	unsigned low = regs[0];
+	unsigned high = regs[2];
 
 	ret = 0;
 
@@ -985,12 +988,23 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
 		break;
 
 	default:
-		ret = native_write_msr_safe(msr, low, high);
+		ret = native_wrmsr_safe_regs(regs);
 	}
 
 	return ret;
 }
 
+static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
+{
+	u32 regs[8] = { 0 };
+
+	regs[0] = low;
+	regs[1] = msr;
+	regs[2] = high;
+
+	return xen_wrmsr_safe_regs(regs);
+}
+
 void xen_setup_shared_info(void)
 {
 	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
@@ -1116,7 +1130,9 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
 	.wbinvd = native_wbinvd,
 
 	.read_msr = native_read_msr_safe,
+	.rdmsr_regs = native_rdmsr_safe_regs,
 	.write_msr = xen_write_msr_safe,
+	.wrmsr_regs = xen_wrmsr_safe_regs,
 	.read_tsc = native_read_tsc,
 	.read_pmc = native_read_pmc,
 

  reply	other threads:[~2012-05-30 15:03 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 13:10 [PATCH] x86/amd: fix crash as Xen Dom0 on AMD Trinity systems Andre Przywara
2012-05-30 13:33 ` Jan Beulich
2012-05-30 14:02   ` Andre Przywara
2012-05-30 14:23     ` Jan Beulich
2012-05-30 14:42       ` [Xen-devel] " H. Peter Anvin
2012-05-30 14:49         ` Konrad Rzeszutek Wilk
2012-05-30 15:12           ` Borislav Petkov
2012-05-30 15:40             ` Jan Beulich
2012-05-30 15:45               ` H. Peter Anvin
2012-05-30 15:58               ` Borislav Petkov
2012-05-30 14:48     ` Jacob Shin
2012-05-30 14:50       ` Konrad Rzeszutek Wilk
2012-05-30 15:03         ` Jacob Shin [this message]
2012-05-30 17:17           ` Konrad Rzeszutek Wilk
2012-05-30 17:31             ` H. Peter Anvin
2012-05-30 22:23               ` Konrad Rzeszutek Wilk
2012-05-30 17:32             ` Borislav Petkov
2012-05-30 17:47               ` [PATCH] x86, AMD: Fix " Borislav Petkov
2012-05-30 17:47               ` [Xen-devel] [PATCH] x86/amd: fix " H. Peter Anvin
2012-05-30 17:51                 ` Borislav Petkov
2012-05-30 18:00                   ` H. Peter Anvin
2012-05-30 18:17                     ` Borislav Petkov
2012-05-30 18:19                       ` Borislav Petkov
2012-05-30 18:21                         ` H. Peter Anvin
2012-05-30 18:29                           ` Borislav Petkov
2012-05-30 18:20                       ` H. Peter Anvin
2012-05-30 22:33                         ` Konrad Rzeszutek Wilk
2012-05-30 23:09                           ` H. Peter Anvin
2012-06-06  9:27                             ` Ingo Molnar
2012-06-06  9:42                               ` Borislav Petkov
2012-06-06  9:45                                 ` Ingo Molnar
2012-05-31 12:24                           ` Andre Przywara
2012-05-31 15:27                             ` [Xen-devel] " Konrad Rzeszutek Wilk
2012-05-31  7:39                       ` Jan Beulich
2012-05-31 16:55                         ` Borislav Petkov
2012-05-31  7:17             ` Jan Beulich
2012-05-31 15:59               ` H. Peter Anvin
2012-05-30 14:39 ` Konrad Rzeszutek Wilk
2012-05-30 14:50   ` H. Peter Anvin
2012-05-30 14:51     ` Konrad Rzeszutek Wilk
2012-05-30 15:08     ` Jan Beulich
2012-05-30 15:15       ` H. Peter Anvin
2012-05-30 15:35         ` Jan Beulich
2012-05-30 16:48           ` Konrad Rzeszutek Wilk
2012-05-30 14:42 ` H. Peter Anvin
2012-05-30 14:55   ` Borislav Petkov
2012-05-30 14:58     ` H. Peter Anvin
2012-05-30 15:00       ` Borislav Petkov
2012-05-30 15:01         ` H. Peter Anvin
2012-05-30 15:05           ` Borislav Petkov
2012-05-30 23:31 ` 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=20120530150334.GA13349@jshin-Toonie \
    --to=jacob.shin@amd.com \
    --cc=JBeulich@suse.com \
    --cc=andre.przywara@amd.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --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 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).