diff options
author | Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> | 2012-08-20 23:02:51 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-08-22 08:09:03 -0400 |
commit | 4d8b81abc47b83a1939e59df2fdb0e98dfe0eedd (patch) | |
tree | 47ea77cb4f77a2884a0478ecf84f62e32e5661ee /arch/x86/kvm | |
parent | 7068d0971524dd47a38f44f6020ba133432871ca (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/kvm')
-rw-r--r-- | arch/x86/kvm/mmu.c | 9 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 5548971ae80d..8e312a2e1412 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 | ||
2648 | static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, pfn_t pfn) | 2648 | static 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 704680d0fa3e..42bbf4187d20 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: |