Message ID | 20171130180546.4331-1-rkrcmar@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Nov 30, 2017 at 07:05:45PM +0100, Radim Krčmář wrote: > Implementation of the unpinned APIC page didn't update the VMCS address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from ...range_start. > > Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") > Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Thanks for the fast reaction! Some initial test rounds with just Patch 1 applied on top of 4.13.8 show no blue screens, will do more tests also with 4.14.3 on Monday and report back. 4.15-rc1 crashes for unrelated reasons, but I can re-run the tests once a stable-enough rc has been cut..
On 30/11/2017 19:05, Radim Krčmář wrote: > Implementation of the unpinned APIC page didn't update the VMCS address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from ...range_start. > > Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") > Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> > --- > arch/x86/include/asm/kvm_host.h | 3 +++ > arch/x86/kvm/x86.c | 14 ++++++++++++++ > virt/kvm/kvm_main.c | 8 ++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 977de5fb968b..c16c3f924863 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) > #define put_smstate(type, buf, offset, val) \ > *(type *)((buf) + (offset) - 0x7e00) = val > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end); > + > #endif /* _ASM_X86_KVM_HOST_H */ > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index eee8e7faf1af..a219974cdb89 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) > kvm_x86_ops->tlb_flush(vcpu); > } > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > + unsigned long apic_address; > + > + /* > + * The physical address of apic access page is stored in the VMCS. > + * Update it when it becomes invalid. > + */ > + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); > + if (start <= apic_address && apic_address < end) > + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); > +} > + > void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) > { > struct page *page = NULL; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index c01cff064ec5..b7f4689e373f 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); > static unsigned long long kvm_createvm_count; > static unsigned long long kvm_active_vms; > > +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > +} > + > bool kvm_is_reserved_pfn(kvm_pfn_t pfn) > { > if (pfn_valid(pfn)) > @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > kvm_flush_remote_tlbs(kvm); > > spin_unlock(&kvm->mmu_lock); > + > + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); > + > srcu_read_unlock(&kvm->srcu, idx); > } > > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
On Thu, Nov 30, 2017 at 07:05:45PM +0100, Radim Krčmář wrote: > Implementation of the unpinned APIC page didn't update the VMCS address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from ...range_start. Reviewed-by: Andrea Arcangeli <aarcange@redhat.com> Cc: <stable@vger.kernel.org> Thanks, Andrea
2017-12-01 2:05 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>: > Implementation of the unpinned APIC page didn't update the VMCS address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from ...range_start. > > Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") > Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Tested-by: Wanpeng Li <wanpeng.li@hotmail.com> I observe the windows 2016 guest hang during boot on a heavy memory overcommit host, and this commit fixes it. Regards, Wanpeng Li > --- > arch/x86/include/asm/kvm_host.h | 3 +++ > arch/x86/kvm/x86.c | 14 ++++++++++++++ > virt/kvm/kvm_main.c | 8 ++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 977de5fb968b..c16c3f924863 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) > #define put_smstate(type, buf, offset, val) \ > *(type *)((buf) + (offset) - 0x7e00) = val > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end); > + > #endif /* _ASM_X86_KVM_HOST_H */ > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index eee8e7faf1af..a219974cdb89 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) > kvm_x86_ops->tlb_flush(vcpu); > } > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > + unsigned long apic_address; > + > + /* > + * The physical address of apic access page is stored in the VMCS. > + * Update it when it becomes invalid. > + */ > + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); > + if (start <= apic_address && apic_address < end) > + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); > +} > + > void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) > { > struct page *page = NULL; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index c01cff064ec5..b7f4689e373f 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); > static unsigned long long kvm_createvm_count; > static unsigned long long kvm_active_vms; > > +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > +} > + > bool kvm_is_reserved_pfn(kvm_pfn_t pfn) > { > if (pfn_valid(pfn)) > @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > kvm_flush_remote_tlbs(kvm); > > spin_unlock(&kvm->mmu_lock); > + > + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); > + > srcu_read_unlock(&kvm->srcu, idx); > } > > -- > 2.14.2 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
On Thu, Nov 30, 2017 at 07:05:45PM +0100, Radim Krčmář wrote: > Implementation of the unpinned APIC page didn't update the VMCS address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from ...range_start. > > Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") > Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Tested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> no further issues observed with this patch applied on top of 4.13 and 4.14 - thanks! > --- > arch/x86/include/asm/kvm_host.h | 3 +++ > arch/x86/kvm/x86.c | 14 ++++++++++++++ > virt/kvm/kvm_main.c | 8 ++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 977de5fb968b..c16c3f924863 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) > #define put_smstate(type, buf, offset, val) \ > *(type *)((buf) + (offset) - 0x7e00) = val > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end); > + > #endif /* _ASM_X86_KVM_HOST_H */ > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index eee8e7faf1af..a219974cdb89 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) > kvm_x86_ops->tlb_flush(vcpu); > } > > +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > + unsigned long apic_address; > + > + /* > + * The physical address of apic access page is stored in the VMCS. > + * Update it when it becomes invalid. > + */ > + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); > + if (start <= apic_address && apic_address < end) > + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); > +} > + > void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) > { > struct page *page = NULL; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index c01cff064ec5..b7f4689e373f 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); > static unsigned long long kvm_createvm_count; > static unsigned long long kvm_active_vms; > > +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, > + unsigned long start, unsigned long end) > +{ > +} > + > bool kvm_is_reserved_pfn(kvm_pfn_t pfn) > { > if (pfn_valid(pfn)) > @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, > kvm_flush_remote_tlbs(kvm); > > spin_unlock(&kvm->mmu_lock); > + > + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); > + > srcu_read_unlock(&kvm->srcu, idx); > } > > -- > 2.14.2 > >
2017-12-06 3:32 GMT+01:00 Wanpeng Li <kernellwp@gmail.com>: > 2017-12-01 2:05 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>: >> Implementation of the unpinned APIC page didn't update the VMCS address >> cache when invalidation was done through range mmu notifiers. >> This became a problem when the page notifier was removed. >> >> Re-introduce the arch-specific helper and call it from ...range_start. >> >> Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") >> Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") >> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> So the patch should be backport to v3.18+? Thanks, Jack > > Tested-by: Wanpeng Li <wanpeng.li@hotmail.com> > > I observe the windows 2016 guest hang during boot on a heavy memory > overcommit host, and this commit fixes it. > > Regards, > Wanpeng Li > >> --- >> arch/x86/include/asm/kvm_host.h | 3 +++ >> arch/x86/kvm/x86.c | 14 ++++++++++++++ >> virt/kvm/kvm_main.c | 8 ++++++++ >> 3 files changed, 25 insertions(+) >> >> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h >> index 977de5fb968b..c16c3f924863 100644 >> --- a/arch/x86/include/asm/kvm_host.h >> +++ b/arch/x86/include/asm/kvm_host.h >> @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) >> #define put_smstate(type, buf, offset, val) \ >> *(type *)((buf) + (offset) - 0x7e00) = val >> >> +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >> + unsigned long start, unsigned long end); >> + >> #endif /* _ASM_X86_KVM_HOST_H */ >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index eee8e7faf1af..a219974cdb89 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) >> kvm_x86_ops->tlb_flush(vcpu); >> } >> >> +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >> + unsigned long start, unsigned long end) >> +{ >> + unsigned long apic_address; >> + >> + /* >> + * The physical address of apic access page is stored in the VMCS. >> + * Update it when it becomes invalid. >> + */ >> + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); >> + if (start <= apic_address && apic_address < end) >> + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); >> +} >> + >> void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) >> { >> struct page *page = NULL; >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index c01cff064ec5..b7f4689e373f 100644 >> --- a/virt/kvm/kvm_main.c >> +++ b/virt/kvm/kvm_main.c >> @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); >> static unsigned long long kvm_createvm_count; >> static unsigned long long kvm_active_vms; >> >> +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >> + unsigned long start, unsigned long end) >> +{ >> +} >> + >> bool kvm_is_reserved_pfn(kvm_pfn_t pfn) >> { >> if (pfn_valid(pfn)) >> @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, >> kvm_flush_remote_tlbs(kvm); >> >> spin_unlock(&kvm->mmu_lock); >> + >> + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); >> + >> srcu_read_unlock(&kvm->srcu, idx); >> } >> >> -- >> 2.14.2 >> >> -- >> To unsubscribe, send a message with 'unsubscribe linux-mm' in >> the body to majordomo@kvack.org. For more info on Linux MM, >> see: http://www.linux-mm.org/ . >> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
On 06/12/2017 10:50, 王金浦 wrote: > 2017-12-06 3:32 GMT+01:00 Wanpeng Li <kernellwp@gmail.com>: >> 2017-12-01 2:05 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>: >>> Implementation of the unpinned APIC page didn't update the VMCS address >>> cache when invalidation was done through range mmu notifiers. >>> This became a problem when the page notifier was removed. >>> >>> Re-introduce the arch-specific helper and call it from ...range_start. >>> >>> Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") >>> Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") >>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> > So the patch should be backport to v3.18+? In practice the invalidate_page callback was enough because the APIC page is allocated with alloc_page(). But it doesn't hurt. Paolo > Thanks, > Jack >> >> Tested-by: Wanpeng Li <wanpeng.li@hotmail.com> >> >> I observe the windows 2016 guest hang during boot on a heavy memory >> overcommit host, and this commit fixes it. >> >> Regards, >> Wanpeng Li >> >>> --- >>> arch/x86/include/asm/kvm_host.h | 3 +++ >>> arch/x86/kvm/x86.c | 14 ++++++++++++++ >>> virt/kvm/kvm_main.c | 8 ++++++++ >>> 3 files changed, 25 insertions(+) >>> >>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h >>> index 977de5fb968b..c16c3f924863 100644 >>> --- a/arch/x86/include/asm/kvm_host.h >>> +++ b/arch/x86/include/asm/kvm_host.h >>> @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) >>> #define put_smstate(type, buf, offset, val) \ >>> *(type *)((buf) + (offset) - 0x7e00) = val >>> >>> +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >>> + unsigned long start, unsigned long end); >>> + >>> #endif /* _ASM_X86_KVM_HOST_H */ >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >>> index eee8e7faf1af..a219974cdb89 100644 >>> --- a/arch/x86/kvm/x86.c >>> +++ b/arch/x86/kvm/x86.c >>> @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) >>> kvm_x86_ops->tlb_flush(vcpu); >>> } >>> >>> +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >>> + unsigned long start, unsigned long end) >>> +{ >>> + unsigned long apic_address; >>> + >>> + /* >>> + * The physical address of apic access page is stored in the VMCS. >>> + * Update it when it becomes invalid. >>> + */ >>> + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); >>> + if (start <= apic_address && apic_address < end) >>> + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); >>> +} >>> + >>> void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) >>> { >>> struct page *page = NULL; >>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >>> index c01cff064ec5..b7f4689e373f 100644 >>> --- a/virt/kvm/kvm_main.c >>> +++ b/virt/kvm/kvm_main.c >>> @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); >>> static unsigned long long kvm_createvm_count; >>> static unsigned long long kvm_active_vms; >>> >>> +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >>> + unsigned long start, unsigned long end) >>> +{ >>> +} >>> + >>> bool kvm_is_reserved_pfn(kvm_pfn_t pfn) >>> { >>> if (pfn_valid(pfn)) >>> @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, >>> kvm_flush_remote_tlbs(kvm); >>> >>> spin_unlock(&kvm->mmu_lock); >>> + >>> + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); >>> + >>> srcu_read_unlock(&kvm->srcu, idx); >>> } >>> >>> -- >>> 2.14.2 >>> >>> -- >>> To unsubscribe, send a message with 'unsubscribe linux-mm' in >>> the body to majordomo@kvack.org. For more info on Linux MM, >>> see: http://www.linux-mm.org/ . >>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
On Thu, 2017-11-30 at 19:05 +0100, Radim Krčmář wrote: > Implementation of the unpinned APIC page didn't update the VMCS > address > cache when invalidation was done through range mmu notifiers. > This became a problem when the page notifier was removed. > > Re-introduce the arch-specific helper and call it from > ...range_start. > > Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") > Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic > v2") > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> > --- > arch/x86/include/asm/kvm_host.h | 3 +++ > arch/x86/kvm/x86.c | 14 ++++++++++++++ > virt/kvm/kvm_main.c | 8 ++++++++ > 3 files changed, 25 insertions(+) Thanks for this. I've been chasing APIC related hangs booting images with qemu-system-x86_64 on 4.13 and 4.14 host kernels where the guest doesn't have x2apic enabled. I can confirm this fixes issues the Yocto Project automated testing infrastructure was seeing. I'd like to add support for backporting this in stable. Tested-by: Richard Purdie <richard.purdie@linuxfoundation.org> Cheers, Richard
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 977de5fb968b..c16c3f924863 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1435,4 +1435,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) #define put_smstate(type, buf, offset, val) \ *(type *)((buf) + (offset) - 0x7e00) = val +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, + unsigned long start, unsigned long end); + #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index eee8e7faf1af..a219974cdb89 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6778,6 +6778,20 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu) kvm_x86_ops->tlb_flush(vcpu); } +void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, + unsigned long start, unsigned long end) +{ + unsigned long apic_address; + + /* + * The physical address of apic access page is stored in the VMCS. + * Update it when it becomes invalid. + */ + apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); + if (start <= apic_address && apic_address < end) + kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); +} + void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) { struct page *page = NULL; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c01cff064ec5..b7f4689e373f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -135,6 +135,11 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm); static unsigned long long kvm_createvm_count; static unsigned long long kvm_active_vms; +__weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, + unsigned long start, unsigned long end) +{ +} + bool kvm_is_reserved_pfn(kvm_pfn_t pfn) { if (pfn_valid(pfn)) @@ -360,6 +365,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, kvm_flush_remote_tlbs(kvm); spin_unlock(&kvm->mmu_lock); + + kvm_arch_mmu_notifier_invalidate_range(kvm, start, end); + srcu_read_unlock(&kvm->srcu, idx); }
Implementation of the unpinned APIC page didn't update the VMCS address cache when invalidation was done through range mmu notifiers. This became a problem when the page notifier was removed. Re-introduce the arch-specific helper and call it from ...range_start. Fixes: 38b9917350cb ("kvm: vmx: Implement set_apic_access_page_addr") Fixes: 369ea8242c0f ("mm/rmap: update to new mmu_notifier semantic v2") Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/x86.c | 14 ++++++++++++++ virt/kvm/kvm_main.c | 8 ++++++++ 3 files changed, 25 insertions(+)