aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2012-08-20 23:02:51 -0400
committerAvi Kivity <avi@redhat.com>2012-08-22 08:09:03 -0400
commit4d8b81abc47b83a1939e59df2fdb0e98dfe0eedd (patch)
tree47ea77cb4f77a2884a0478ecf84f62e32e5661ee /arch/x86
parent7068d0971524dd47a38f44f6020ba133432871ca (diff)
KVM: introduce readonly memslot
In current code, if we map a readonly memory space from host to guest and the page is not currently mapped in the host, we will get a fault pfn and async is not allowed, then the vm will crash We introduce readonly memory region to map ROM/ROMD to the guest, read access is happy for readonly memslot, write access on readonly memslot will cause KVM_EXIT_MMIO exit Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/kvm.h1
-rw-r--r--arch/x86/kvm/mmu.c9
-rw-r--r--arch/x86/kvm/x86.c1
3 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index 246617efd67..521bf252e34 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -25,6 +25,7 @@
25#define __KVM_HAVE_DEBUGREGS 25#define __KVM_HAVE_DEBUGREGS
26#define __KVM_HAVE_XSAVE 26#define __KVM_HAVE_XSAVE
27#define __KVM_HAVE_XCRS 27#define __KVM_HAVE_XCRS
28#define __KVM_HAVE_READONLY_MEM
28 29
29/* Architectural interrupt line count. */ 30/* Architectural interrupt line count. */
30#define KVM_NR_INTERRUPTS 256 31#define KVM_NR_INTERRUPTS 256
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 5548971ae80..8e312a2e141 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2647,6 +2647,15 @@ static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct *
2647 2647
2648static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, pfn_t pfn) 2648static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, pfn_t pfn)
2649{ 2649{
2650 /*
2651 * Do not cache the mmio info caused by writing the readonly gfn
2652 * into the spte otherwise read access on readonly gfn also can
2653 * caused mmio page fault and treat it as mmio access.
2654 * Return 1 to tell kvm to emulate it.
2655 */
2656 if (pfn == KVM_PFN_ERR_RO_FAULT)
2657 return 1;
2658
2650 if (pfn == KVM_PFN_ERR_HWPOISON) { 2659 if (pfn == KVM_PFN_ERR_HWPOISON) {
2651 kvm_send_hwpoison_signal(gfn_to_hva(vcpu->kvm, gfn), current); 2660 kvm_send_hwpoison_signal(gfn_to_hva(vcpu->kvm, gfn), current);
2652 return 0; 2661 return 0;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 704680d0fa3..42bbf4187d2 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2175,6 +2175,7 @@ int kvm_dev_ioctl_check_extension(long ext)
2175 case KVM_CAP_GET_TSC_KHZ: 2175 case KVM_CAP_GET_TSC_KHZ:
2176 case KVM_CAP_PCI_2_3: 2176 case KVM_CAP_PCI_2_3:
2177 case KVM_CAP_KVMCLOCK_CTRL: 2177 case KVM_CAP_KVMCLOCK_CTRL:
2178 case KVM_CAP_READONLY_MEM:
2178 r = 1; 2179 r = 1;
2179 break; 2180 break;
2180 case KVM_CAP_COALESCED_MMIO: 2181 case KVM_CAP_COALESCED_MMIO: