Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1267581pxb; Sun, 21 Feb 2021 18:49:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqWYy2nY2bO55e8qx27MsioYkAOBvBVoBEhIV7xS6HMmUwFU9J39grqlezI5wa0kLWypQJ X-Received: by 2002:a17:906:b047:: with SMTP id bj7mr19020845ejb.335.1613962194029; Sun, 21 Feb 2021 18:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613962194; cv=none; d=google.com; s=arc-20160816; b=gdYUySrppiM1e5IE0VajdLreTKllyz8D5YH6wRX8e1hvNSGdVP/uGoHh74hmLM8oX0 sVmGWp2C2E+5O6NhHNSbyu0LlxvIrgiEm/d86lxjrZv0YSSEVkRWIod5HNrEqz18tXTw cu6tycb6r18hgIZJ4uEkkas7yfVe0vgxv+/82X1LOf9MuRSPMuksbscQqhWO1FGyGCSs 3ePX9CrOE2Gj84vNvjTvp8+PYtWYBSnMVuKe8F0ejW94xF/AuWo5QpTqmhYqQdNhATPI eM+VtWDQeWM7oi4L85vnN6h4SCD1S6UNXPYZwG/UG8TMRw2p7pa0ApCBUHkFPyxjFFfk ueWg== 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=YI7HyzDG3owLPU4UQfa7tiUEs9jP6yMxkdlolNtJ+LQ=; b=n5BjXPXMLqh6bYEXhWhHQ4wBmo7rKn6HgsTBKLFswEOMQoAgpdFsHWit+TNrF9rdu1 fpq8lDjD3iGjcAN98SZeCjR7Rv6yeeONFT7DHfaJS6nZhzRvvoSbTHuu4C63Mfsx8OpF H6PaICzAyJNvOkjJCQlPKMo8puMlwyv2+tkf8FK/Vh4f+93Kk2id7qRRkbv7IeniPR/G rjSbe61q20/wpdeV3SYnVIHGRDfItb3i8kldHCkW+r7MQk4UgAt0P1WOn5wtZTprkYOr ux0d1zHzeYud6MJl2aOcJX1dGoR3TWreqp/GV0ddGbsxSEHXIsxScN+9RNE8XCwlDV8V XKXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oFZXsVYa; 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 e1si11162976edy.163.2021.02.21.18.49.31; Sun, 21 Feb 2021 18:49:54 -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=oFZXsVYa; 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 S231774AbhBVCrF (ORCPT + 99 others); Sun, 21 Feb 2021 21:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbhBVCrA (ORCPT ); Sun, 21 Feb 2021 21:47:00 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76F8BC061797 for ; Sun, 21 Feb 2021 18:45:48 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id w18so3690975plc.12 for ; Sun, 21 Feb 2021 18:45:48 -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=YI7HyzDG3owLPU4UQfa7tiUEs9jP6yMxkdlolNtJ+LQ=; b=oFZXsVYacLQwXAQgBXWMVNd4tYXERP+aOxK5JtlWHh10GwD8sUEk2xy3lHQcfTdxNJ A6c9eWv3q8ddSG8D4h1LqOoseHnCbmYkxklZ6Xfy3SnqUUMRHonQ6E6OabJC+EI947OM +XuAC7e32rEtYRhECOHtBOFGA47fYnVe624N4= 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=YI7HyzDG3owLPU4UQfa7tiUEs9jP6yMxkdlolNtJ+LQ=; b=hzJAdbV/6kFhfJIwhA3fgAoJPfYiHJ0i9y861omZ1SJ065cu6KB7L7JmyF2/kCAg0X i7cNiovJ3RFbe8qCCR9hw4WKrLUIpkEt88d76pIy07jcmMW/uGuQDUutRcq0r+L//ggk 1ho8WTnOrYAVQC3ursuvzsnlzVwV2pTZfMZhYO/OJJDI+Nold5pY1bGvRAKt31Bc5gaC r9zGd9VkRJQAy5K+EaoojU+juMHkfcdro6K2fKdghNinDtOPOPMlZGVbNqSqXIHEE8wt eITc9bdXpGocWkmgQiJid4yKeI/v0zNHCy+1qJA6ExWGlGbcNZkac639adYLMaKg7SLZ ZdhQ== X-Gm-Message-State: AOAM531IfyIZgaJIrvsCgbGC8ttZnJNRlqL/WHKSy+YuSNReSOtv7JFG CUbBc/fngfA++kcgbmQAWTE7aw== X-Received: by 2002:a17:90a:4882:: with SMTP id b2mr20682824pjh.78.1613961947967; Sun, 21 Feb 2021 18:45:47 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:11b3:5e1a:7cb:7e1f]) by smtp.gmail.com with UTF8SMTPSA id y2sm15413682pjw.36.2021.02.21.18.45.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Feb 2021 18:45:47 -0800 (PST) From: David Stevens X-Google-Original-From: David Stevens To: Sean Christopherson , Paolo Bonzini Cc: 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 v4 1/2] KVM: x86/mmu: Skip mmu_notifier check when handling MMIO page fault Date: Mon, 22 Feb 2021 11:45:21 +0900 Message-Id: <20210222024522.1751719-2-stevensd@google.com> X-Mailer: git-send-email 2.30.0.617.g56c4b15f3c-goog In-Reply-To: <20210222024522.1751719-1-stevensd@google.com> References: <20210222024522.1751719-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.617.g56c4b15f3c-goog