All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 37/47] KVM: introduce module parameter for ignoring unknown MSRs accesses
Date: Wed, 19 Aug 2009 16:02:33 +0300	[thread overview]
Message-ID: <1250686963-8357-38-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1250686963-8357-1-git-send-email-avi@redhat.com>

From: Andre Przywara <andre.przywara@amd.com>

KVM will inject a #GP into the guest if that tries to access unhandled
MSRs. This will crash many guests. Although it would be the correct
way to actually handle these MSRs, we introduce a runtime switchable
module param called "ignore_msrs" (defaults to 0). If this is Y, unknown
MSR reads will return 0, while MSR writes are simply dropped. In both cases
we print a message to dmesg to inform the user about that.

You can change the behaviour at any time by saying:

 # echo 1 > /sys/modules/kvm/parameters/ignore_msrs

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6aace61..0be75d5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -83,6 +83,9 @@ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
 struct kvm_x86_ops *kvm_x86_ops;
 EXPORT_SYMBOL_GPL(kvm_x86_ops);
 
+int ignore_msrs = 0;
+module_param_named(ignore_msrs, ignore_msrs, bool, S_IRUGO | S_IWUSR);
+
 struct kvm_stats_debugfs_item debugfs_entries[] = {
 	{ "pf_fixed", VCPU_STAT(pf_fixed) },
 	{ "pf_guest", VCPU_STAT(pf_guest) },
@@ -930,8 +933,15 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 			"0x%x data 0x%llx\n", msr, data);
 		break;
 	default:
-		pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n", msr, data);
-		return 1;
+		if (!ignore_msrs) {
+			pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n",
+				msr, data);
+			return 1;
+		} else {
+			pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n",
+				msr, data);
+			break;
+		}
 	}
 	return 0;
 }
@@ -1078,8 +1088,14 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
 		return get_msr_mce(vcpu, msr, pdata);
 	default:
-		pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
-		return 1;
+		if (!ignore_msrs) {
+			pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
+			return 1;
+		} else {
+			pr_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr);
+			data = 0;
+		}
+		break;
 	}
 	*pdata = data;
 	return 0;
-- 
1.6.3.3


  parent reply	other threads:[~2009-08-19 13:07 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19 13:01 [PATCH 00/47] KVM updates for 2.6.32 merge window (2/4) Avi Kivity
2009-08-19 13:01 ` [PATCH 01/47] KVM: Return to userspace on emulation failure Avi Kivity
2009-08-19 13:01 ` [PATCH 02/47] KVM: MMU: introduce is_last_spte helper Avi Kivity
2009-08-19 13:01 ` [PATCH 03/47] KVM: MMU audit: update count_writable_mappings / count_rmaps Avi Kivity
2009-08-19 13:02 ` [PATCH 04/47] KVM: MMU audit: update audit_write_protection Avi Kivity
2009-08-19 13:02 ` [PATCH 05/47] KVM: MMU audit: nontrapping ptes in nonleaf level Avi Kivity
2009-08-19 13:02 ` [PATCH 06/47] KVM: MMU audit: audit_mappings tweaks Avi Kivity
2009-08-19 13:02 ` [PATCH 07/47] KVM: MMU audit: largepage handling Avi Kivity
2009-08-19 13:02 ` [PATCH 08/47] KVM: Move performance counter MSR access interception to generic x86 path Avi Kivity
2009-08-19 13:02 ` [PATCH 09/47] KVM: VMX: more MSR_IA32_VMX_EPT_VPID_CAP capability bits Avi Kivity
2009-08-19 13:02 ` [PATCH 10/47] KVM: MMU: make for_each_shadow_entry aware of largepages Avi Kivity
2009-08-19 13:02 ` [PATCH 11/47] KVM: MMU: add kvm_mmu_get_spte_hierarchy helper Avi Kivity
2009-08-19 13:02 ` [PATCH 12/47] KVM: VMX: EPT misconfiguration handler Avi Kivity
2009-08-19 13:02 ` [PATCH 13/47] KVM: VMX: conditionally disable 2M pages Avi Kivity
2009-08-19 13:02 ` [PATCH 14/47] KVM: Replace pending exception by PF if it happens serially Avi Kivity
2009-08-19 13:02 ` [PATCH 15/47] KVM: Optimize searching for highest IRR Avi Kivity
2009-08-19 13:02 ` [PATCH 16/47] KVM: Fix racy event propagation in timer Avi Kivity
2009-08-19 13:02 ` [PATCH 17/47] KVM: Drop useless atomic test from timer function Avi Kivity
2009-08-19 13:02 ` [PATCH 18/47] KVM: VMX: Only reload guest cr2 if different from host cr2 Avi Kivity
2009-08-19 13:02 ` [PATCH 19/47] KVM: SVM: Don't save/restore " Avi Kivity
2009-08-19 13:02 ` [PATCH 20/47] x86: Add definition for IGNNE MSR Avi Kivity
2009-08-19 13:02 ` [PATCH 21/47] KVM: Implement MSRs used by Hyper-V Avi Kivity
2009-08-19 13:02 ` [PATCH 22/47] KVM: SVM: Implement INVLPGA Avi Kivity
2009-08-19 13:02 ` [PATCH 23/47] KVM: SVM: Improve nested interrupt injection Avi Kivity
2009-08-19 13:02 ` [PATCH 24/47] KVM: convert custom marker based tracing to event traces Avi Kivity
2009-08-19 13:02 ` [PATCH 25/47] KVM: Allow emulation of syscalls instructions on #UD Avi Kivity
2009-08-19 13:02 ` [PATCH 26/47] KVM: x86 emulator: Add missing EFLAGS bit definitions Avi Kivity
2009-08-19 13:02 ` [PATCH 27/47] KVM: x86 emulator: Prepare for emulation of syscall instructions Avi Kivity
2009-08-19 13:02 ` [PATCH 28/47] KVM: x86 emulator: add syscall emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 29/47] KVM: x86 emulator: Add sysenter emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 30/47] KVM: x86 emulator: Add sysexit emulation Avi Kivity
2009-08-19 13:02 ` [PATCH 31/47] KVM: s390: Fix memslot initialization for userspace_addr != 0 Avi Kivity
2009-08-19 13:02 ` [PATCH 32/47] hugetlbfs: export vma_kernel_pagsize to modules Avi Kivity
2009-08-19 13:02 ` [PATCH 33/47] KVM: Prepare memslot data structures for multiple hugepage sizes Avi Kivity
2009-08-19 13:02 ` [PATCH 34/47] KVM: x86: missing locking in PIT/IRQCHIP/SET_BSP_CPU ioctl paths Avi Kivity
2009-08-19 13:02 ` [PATCH 35/47] KVM: ignore AMDs HWCR register access to set the FFDIS bit Avi Kivity
2009-08-19 13:02 ` [PATCH 36/47] KVM: ignore reads from AMDs C1E enabled MSR Avi Kivity
2009-08-19 13:02 ` Avi Kivity [this message]
2009-08-19 13:02 ` [PATCH 38/47] KVM: powerpc: convert marker probes to event trace Avi Kivity
2009-08-19 13:02 ` [PATCH 39/47] KVM: remove old KVMTRACE support code Avi Kivity
2009-08-19 13:02 ` [PATCH 40/47] KVM: use vcpu_id instead of bsp_vcpu pointer in kvm_vcpu_is_bsp Avi Kivity
2009-08-19 13:02 ` [PATCH 41/47] KVM: document locking for kvm_io_device_ops Avi Kivity
2009-08-19 13:02 ` [PATCH 42/47] KVM: switch coalesced mmio changes to slots_lock Avi Kivity
2009-08-19 13:02 ` [PATCH 43/47] KVM: switch pit creation " Avi Kivity
2009-08-19 13:02 ` [PATCH 44/47] KVM: convert bus " Avi Kivity
2009-08-19 13:02 ` [PATCH 45/47] KVM: remove in_range from io devices Avi Kivity
2009-08-19 13:02 ` [PATCH 46/47] KVM: document lock nesting rule Avi Kivity
2009-08-19 13:02 ` [PATCH 47/47] KVM: fix lock imbalance Avi Kivity

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=1250686963-8357-38-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@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.