Skip to contentSkip to conversation

x86, amd: Check X86_FEATURE_OSVW bit before accessing OSVW MSRs

PATCH Superseded Andreas Herrmann 1 participant 2 messages Apr 27, 2010 – May 13, 2010 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, amd: Check X86_FEATURE_OSVW bit before accessing OSVW MSRs

If host CPU is exposed to a guest the OSVW MSRs are not guaranteed to be present and a GP fault occurs. Thus checking the feature flag is essential.

---
 arch/x86/kernel/process.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/process.c +7 -5
index 28ad9f4..0415c3e 100644
@@ -546,11 +546,13 @@ static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
 		 * check OSVW bit for CPUs that are not affected
 		 * by erratum #400
 		 */
-		rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
-		if (val >= 2) {
-			rdmsrl(MSR_AMD64_OSVW_STATUS, val);
-			if (!(val & BIT(1)))
-				goto no_c1e_idle;
+		if (cpu_has(c, X86_FEATURE_OSVW)) {
+			rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
+			if (val >= 2) {
+				rdmsrl(MSR_AMD64_OSVW_STATUS, val);
+				if (!(val & BIT(1)))
+					goto no_c1e_idle;
+			}
 		}
 		return 1;
 	}
Signature · 1 line
1.6.4.4
#1 lore raw
Commit-ID:  f01487119dda3d9f58c9729c7361ecc50a61c188
Gitweb:     http://git.kernel.org/tip/f01487119dda3d9f58c9729c7361ecc50a61c188
Author:     Andreas Herrmann <[email protected]>
AuthorDate: Tue, 27 Apr 2010 12:13:48 +0200
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Thu, 13 May 2010 16:21:20 -0700

x86, amd: Check X86_FEATURE_OSVW bit before accessing OSVW MSRs

If host CPU is exposed to a guest the OSVW MSRs are not guaranteed to be present and a GP fault occurs. Thus checking the feature flag is essential.

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/process.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/process.c +7 -5
index 28ad9f4..0415c3e 100644
@@ -546,11 +546,13 @@ static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
 		 * check OSVW bit for CPUs that are not affected
 		 * by erratum #400
 		 */
-		rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
-		if (val >= 2) {
-			rdmsrl(MSR_AMD64_OSVW_STATUS, val);
-			if (!(val & BIT(1)))
-				goto no_c1e_idle;
+		if (cpu_has(c, X86_FEATURE_OSVW)) {
+			rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
+			if (val >= 2) {
+				rdmsrl(MSR_AMD64_OSVW_STATUS, val);
+				if (!(val & BIT(1)))
+					goto no_c1e_idle;
+			}
 		}
 		return 1;
 	}