Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp756013pxb; Wed, 27 Jan 2021 22:07:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfyWJluMFiW1ZylCXkDx9PF3ttfRBBuC5j/5uTbKWGXZZMXLQsDQny73WtmSBcSithjRgx X-Received: by 2002:a17:906:5043:: with SMTP id e3mr9721478ejk.260.1611814066122; Wed, 27 Jan 2021 22:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611814066; cv=none; d=google.com; s=arc-20160816; b=bdKbMh1jH1xO/jgSzX0TZUNW6sB2AdIyvYlQ27Yj4pjEjAy8odZ/QDzUvHBxnHmJFS 82nyZYXeu+lyzLQs5XcPUSvgC6WbV0s03BRBxgZol0/WFaCtinc933dq8OtsJBQK65yP xPsu2CUqkbJQscx+eCiZtKtRfsM48QgWLwPVnGAqxJlJse03wW+4HTxlzUfUtvSM73r4 bzAABl74ryDxPsRgv1/es00mg0z1o7hPdpvhuLz2Z8NJ/IFyahUAVJxFwuDhPvJ02YJM FUMUK9X2DZ95AEbqaFvsDcXYXNBIiNB+h0rRcN/YU6F4+T/vhIOW7tZIiLpXGCoV+tj5 DlBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UygKOqEf59SFJHMhhfR+HLz4CGF5Uv9S4hRfcJbt+yk=; b=kDWJiO2NsTQNjIQahihGmyq2MZpkRmtWxIuBamX7QOr28Mwg5wR3QqFOXZCA+0MzT9 qxCOF3YohTT82SsKOy6vHtib++D6dmO6O8D5KzJoT0mt7/QkslA1OZEAXxqlX1sC537+ Xw/gpJtboY9uF0tgF8SvE/qXWPHRXv8vjnVrqxlczYYDGaQaz5oSVqZ/s3yNgZXSzWIF ld19dwS2cq0oOBBeH1lywYIW1f5vbluKleby0hNDgdHAebOk6FTusC5q/FRwarcl6ktL kKgylEhzS9AyQzy0zrTq1qh8bKeEBiFbnE6SVFlR8uam0kC3Eevyt2RPF/GnvnWYrIiW DklA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Qh8VODAi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si2687107edn.311.2021.01.27.22.07.22; Wed, 27 Jan 2021 22:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Qh8VODAi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbhA1GGU (ORCPT + 99 others); Thu, 28 Jan 2021 01:06:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbhA1GGQ (ORCPT ); Thu, 28 Jan 2021 01:06:16 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC63C061788 for ; Wed, 27 Jan 2021 22:05:36 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id w14so3328406pfi.2 for ; Wed, 27 Jan 2021 22:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UygKOqEf59SFJHMhhfR+HLz4CGF5Uv9S4hRfcJbt+yk=; b=Qh8VODAieLH4894A4MDu3uPPXE5kLO4XxZpYmBxJ82EmJjvCd38+PvJXeC7WfYCIBI 64aPWxpI+2Wuja2TEV1w1O7J/k/33st78VPhJvOw7GI1Ov6clXkA1iu5LQJ5MR4dUH8V v91cI0vNifEcoZnWwsn/8BSJmyZEYnqUhOWFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UygKOqEf59SFJHMhhfR+HLz4CGF5Uv9S4hRfcJbt+yk=; b=P5npYJrxS5yuV8OCq2Gf8MXLP51gjtY5Io3kgMEUFWeIWWeGVfiYW4gYyfHTletsZE ONjTXb/NRwPF9yepLT98RGw0I1dveX2nFJRWTUDSdcqVqIYzFEaXljuKWnvb5F7Czdri ikLuvOHzUKobfNVm7XUvhVHu02CLn5aX2EGX4yBeg2qI6qey9UDy/1pB4J5acU/MXAYw RnoJcWZEQ5vXG0ZplDu3W6j+AVBvoFoEdJt01e8Gjf2cY0yw2UHK2CDZJyqtwhFhrvQ9 DSNcybxXtjhHYhL6FPUvbPf+F6k06ELHPJUt+oOxtRNDH3jIpGlHbrkg+q6Yn+Idte+U MOTA== X-Gm-Message-State: AOAM530+zmBF2upPgupee4PnL90XrRcy+hNcQzmyP1KlUSy2PhPqsdfF pSnSypfYREjQoNE1C0/ladlvrA== X-Received: by 2002:a62:bd05:0:b029:1ab:6d2:5edf with SMTP id a5-20020a62bd050000b02901ab06d25edfmr14361887pff.32.1611813935673; Wed, 27 Jan 2021 22:05:35 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:919f:d6:7815:52bc]) by smtp.gmail.com with ESMTPSA id s73sm4388027pgc.46.2021.01.27.22.05.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Jan 2021 22:05:35 -0800 (PST) From: David Stevens X-Google-Original-From: David Stevens To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Huacai Chen , Aleksandar Markovic , linux-mips@vger.kernel.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda Subject: [PATCH v3 1/2] KVM: x86/mmu: Skip mmu_notifier check when handling MMIO page fault Date: Thu, 28 Jan 2021 15:05:14 +0900 Message-Id: <20210128060515.1732758-2-stevensd@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210128060515.1732758-1-stevensd@google.com> References: <20210128060515.1732758-1-stevensd@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Don't retry a page fault due to an mmu_notifier invalidation when handling a page fault for a GPA that did not resolve to a memslot, i.e. an MMIO page fault. Invalidations from the mmu_notifier signal a change in a host virtual address (HVA) mapping; without a memslot, there is no HVA and thus no possibility that the invalidation is relevant to the page fault being handled. Note, the MMIO vs. memslot generation checks handle the case where a pending memslot will create a memslot overlapping the faulting GPA. The mmu_notifier checks are orthogonal to memslot updates. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/mmu/paging_tmpl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6d16481aa29d..9ac0a727015d 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3725,7 +3725,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, r = RET_PF_RETRY; spin_lock(&vcpu->kvm->mmu_lock); - if (mmu_notifier_retry(vcpu->kvm, mmu_seq)) + if (!is_noslot_pfn(pfn) && mmu_notifier_retry(vcpu->kvm, mmu_seq)) goto out_unlock; r = make_mmu_pages_available(vcpu); if (r) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 50e268eb8e1a..ab54263d857c 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -869,7 +869,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, r = RET_PF_RETRY; spin_lock(&vcpu->kvm->mmu_lock); - if (mmu_notifier_retry(vcpu->kvm, mmu_seq)) + if (!is_noslot_pfn(pfn) && mmu_notifier_retry(vcpu->kvm, mmu_seq)) goto out_unlock; kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT); -- 2.30.0.280.ga3ce27912f-goog