Linux virtualization list
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: virtualization@lists.linux-foundation.org
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Chris Wright <chrisw@sous-sol.org>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Alok Kataria <akataria@vmware.com>
Subject: [PATCH] x86, paravirt: BUG_ON on {rd,wr}msr exceptions
Date: Mon, 28 Jul 2014 16:04:38 -0300	[thread overview]
Message-ID: <1406574278-23946-1-git-send-email-ehabkost@redhat.com> (raw)

When CONFIG_PARAVIRT is enabled, the kernel is ignoring exceptions on
the {rd,wr}msr instructions. This makes serious issues (either on the
guest kernel, or on the host) be silently ignored, and is different from
the native MSR code (which does not ignore the exceptions).

As paravirt.h already includes linux/bug.h, I don't see what was the
original issue preventing BUG_ON from being used.

Change rdmsr(), wrmsr(), and rdmsrl() to BUG_ON() on errors.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
* Build-tested using allyesconfig, with no build errors.

* Tested by being able to detect the following host bug:
  https://bugzilla.redhat.com/show_bug.cgi?id=1025868
  (#GP exception on wrmsr(0x410, 0xfffffffffffffbff) during MCE
  initialization)
---
 arch/x86/include/asm/paravirt.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index cd6e161..7d42ca4 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -133,24 +133,27 @@ static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
 	return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
 }
 
-/* These should all do BUG_ON(_err), but our headers are too tangled. */
 #define rdmsr(msr, val1, val2)			\
 do {						\
 	int _err;				\
 	u64 _l = paravirt_read_msr(msr, &_err);	\
+	BUG_ON(_err);				\
 	val1 = (u32)_l;				\
 	val2 = _l >> 32;			\
 } while (0)
 
-#define wrmsr(msr, val1, val2)			\
-do {						\
-	paravirt_write_msr(msr, val1, val2);	\
+#define wrmsr(msr, val1, val2)				\
+do {							\
+	int _err;					\
+	_err = paravirt_write_msr(msr, val1, val2);	\
+	BUG_ON(_err);					\
 } while (0)
 
 #define rdmsrl(msr, val)			\
 do {						\
 	int _err;				\
 	val = paravirt_read_msr(msr, &_err);	\
+	BUG_ON(_err);				\
 } while (0)
 
 #define wrmsrl(msr, val)	wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32)
-- 
1.9.3

             reply	other threads:[~2014-07-28 19:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 19:04 Eduardo Habkost [this message]
2014-07-28 19:18 ` [PATCH] x86, paravirt: BUG_ON on {rd,wr}msr exceptions H. Peter Anvin
2014-07-28 20:39   ` Eduardo Habkost
2014-07-28 20:43     ` 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=1406574278-23946-1-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=akataria@vmware.com \
    --cc=chrisw@sous-sol.org \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox