Received: by 10.223.164.202 with SMTP id h10csp275019wrb; Thu, 30 Nov 2017 10:06:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMa+dPHIZ6ontlabDCm8FLewQOzLgndCJp0CM0llIR3Tsvjoth1bx043+FrldNbjSSREefUE X-Received: by 10.84.168.193 with SMTP id f59mr3450380plb.251.1512065198476; Thu, 30 Nov 2017 10:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512065198; cv=none; d=google.com; s=arc-20160816; b=o2y+3LWVigDT7+sEGXiEeUz5WCqfHcEMTZuL578YBLJVHmFX1FyUYZBxwsT1Ma8sbu 7COj/6U/4RYVmA8t2WvEcvN58J5h+J2oa3EBlU1cR/BrI5OWY0wcEqWWcAWNC0pjneWQ +/AaB8G1AYra3i1MNNxaKHirYUpEONecyPkcZLOKLQBU4eX8ryjx3+uY8JjVik7btD5q bMIbU061TfmwyO66f8tTVlP8w22dO/I03pqqIlH2WMKU0q9TOBXEjtVn3nsymSIPxWdW +NGFXbWKSxMeH0Ee/HeVZSjwu7Y9jlh26sl7KMD6bZyzCk0+eVJ4CqA0U8lUnFHj98bM n/TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Dg/5IYfdFJ19VRb2vDIHw65VVlyBrtyiZJJRDQyY+Jk=; b=FeWR7YlS2pY4E6JID3sh5nRwNUgaFrYfdck2fdV04mOsaeCgZXb2zyf/ECW/ROzrOD fl2h18OvNTaBactlP+KGVZNh3uV++zHwXsdErDbBKXaGB4LtIfsdwdaS0XBgbYMR9iLJ E6jtrIwJH9RMcEE1rsJQugEUxwQ5aIHiWfmoxKfkmBVug7yX0j40eAWOTNlrHwGhLoW9 ztp/HyB8wkxtrobCAJSlezEmAYmPMIPTS9kDufpvRFqcIk38Ho83neMipFz7jvXQIby6 de5c1sxVkqSXxSoXnhydON7+zWl9Jk8sxM/epv1I6JfikPQy4A2YcdOAvlG0zUAsOXRM bgBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si3327710pgz.111.2017.11.30.10.06.24; Thu, 30 Nov 2017 10:06:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753694AbdK3SGG (ORCPT + 99 others); Thu, 30 Nov 2017 13:06:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55966 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbdK3SGE (ORCPT ); Thu, 30 Nov 2017 13:06:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A863E883D8; Thu, 30 Nov 2017 18:06:04 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 30061620B3; Thu, 30 Nov 2017 18:06:00 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 30 Nov 2017 19:05:59 +0100 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, Paolo Bonzini , Andrea Arcangeli , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= Subject: [PATCH 1/2] KVM: x86: fix APIC page invalidation Date: Thu, 30 Nov 2017 19:05:45 +0100 Message-Id: <20171130180546.4331-1-rkrcmar@redhat.com> In-Reply-To: <20171130161933.GB1606@flask> References: <20171130161933.GB1606@flask> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 30 Nov 2017 18:06:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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ář --- 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 From 1585229288716126163@xxx Mon Nov 27 14:20:58 +0000 2017 X-GM-THRID: 1572551346346816613 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread