Message ID | 20240710234222.2333120-10-jthoughton@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84097C3DA42 for <linux-arm-kernel@archiver.kernel.org>; Wed, 10 Jul 2024 23:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=45lnTGeGmxXRWR2sOGpDAv49wjAnxo1Jn2Fj4ejBtf8=; b=KLXUlIo+ee7yrrRS2jOWj1tVe8 k/Q+OP1mfpsB3Mriy8DxObbdqq3R9Ov+Rbmd/Edb2dJmJn0PDS6vNCx7yYzttUEIrKWc1Hbz6WJcV LJVPMW6ktJ4v83+1Xpr0/V5ISz55Utl5yyhiywTzhZb1QCR4BULgkByWApDc6ZBKDQeAfn7Zrqnt3 mAiNX+hbMkvxkTQStJy5k7dc43TeSeMGhU65uVAc8kRvjQ9DTfAjKON7Y5S1dvN7ba2d+mLrdWz5m rMPql0tSO78Y6oLjkQ5J5nIyaZ+EDsY/G9bPbeAZWPLo7sLQE5kAV3kKDpoxCgkcwBY+075ren/gz Gh3D+BuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRh0F-0000000C8kI-1Rrf; Wed, 10 Jul 2024 23:45:39 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRgxU-0000000C7DD-2q4J for linux-arm-kernel@lists.infradead.org; Wed, 10 Jul 2024 23:42:50 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e03fe45dc0bso527097276.0 for <linux-arm-kernel@lists.infradead.org>; Wed, 10 Jul 2024 16:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720654967; x=1721259767; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=45lnTGeGmxXRWR2sOGpDAv49wjAnxo1Jn2Fj4ejBtf8=; b=US+xWvwnoLF+D75C0q98iz5zn4WZ92gMoFsTmRtc5byP5X1t9J7Ek4V7XtbZIaX8qC ERrK2NXOq62QltNfKZw/cgFMA6ZUkdWtYUlICO/ZDhDiNIktStrSC3RncWatUGwKcPZE Juuj9vpEYnEBleE9uIjQ6BOetayvP9BPq3cttia74zKr+f+qSXW6/g79YR5wVAES70UB XH7Hda5wSbSCYQZAnooDJDXbX8jXWb0RCtB8wZ0VBn5CiLUEbzNUFnfebT5NwGTM8Jfc PU1iXxwQYDCIAZLbDZbKxE7UHMkf9cWIV12vGV4HoLGpF6Ymgi4XftnRpRF2s3PpY9OV flFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720654967; x=1721259767; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=45lnTGeGmxXRWR2sOGpDAv49wjAnxo1Jn2Fj4ejBtf8=; b=r2sCBYPQLTHyqo5cs9mCY9yT9r1TRbYOYRyB9JaRmqx2kcuMupzGteMJibDsFFAdbl LqlxYqPhqa/9Q76A4g6LeBwlhrii9LqMycRqNzzRwEp/pGyTKpmWt7rPGVEr/GIESvK7 dBmiK0xDzShuVb2MLgIHKLHeqM3EpCEjbUz+lwECXGSi/iudKWO62TUPdUoQVz5G/Ns5 6dP1EC26aIfhHkpho0UuECCnJ1cLUhsarnkP3toJL17SfLIxbDY0/kxWn1LnNW4lJioe 6D5zi3iao6gz1qBUU99YFzLX5rpC/A0GmofXrX09U+NXI4HvXJ8FhveZjDfle0sAp2ol X3pg== X-Forwarded-Encrypted: i=1; AJvYcCVGwaQL+VBxFDsy+0NtqPCjZMs0yMrFYftZTINircTSGOqFIQ5pz2QKRPOMLz1QN2SNioysX8mON9btdeQgFFAhqWDzyG72ZgLacmU6GFsSOvxW7To= X-Gm-Message-State: AOJu0Yw9K0zaT85Dkb9KoGjdsAo07+ZeNrKhrbciYGRimKDWiMZmIzWl Ux9hUYXYrgZCbxgX/EhR6KoOaQZQwUGepk5ouZsQHOo/GmK76hbLxSiyRkYXMMKtSb1WjE2ki0q /nabxo6+TYbRlRsmWrA== X-Google-Smtp-Source: AGHT+IFCxPs0hzUflzzz70jRYwVRx4Gd4jDUqm7Yw06oBbmfCbRIBM9zwU8x8QPsTa/dYviA394CpxXkoxFldKzv X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:2381:b0:e05:65b7:32d9 with SMTP id 3f1490d57ef6-e0565b7352bmr91773276.6.1720654966908; Wed, 10 Jul 2024 16:42:46 -0700 (PDT) Date: Wed, 10 Jul 2024 23:42:13 +0000 In-Reply-To: <20240710234222.2333120-1-jthoughton@google.com> Mime-Version: 1.0 References: <20240710234222.2333120-1-jthoughton@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Message-ID: <20240710234222.2333120-10-jthoughton@google.com> Subject: [RFC PATCH 09/18] KVM: x86: Add vCPU fault fast-path for Userfault From: James Houghton <jthoughton@google.com> To: Paolo Bonzini <pbonzini@redhat.com> Cc: Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Zenghui Yu <yuzenghui@huawei.com>, Sean Christopherson <seanjc@google.com>, Shuah Khan <shuah@kernel.org>, Peter Xu <peterx@redhat.org>, Axel Rasmussen <axelrasmussen@google.com>, David Matlack <dmatlack@google.com>, James Houghton <jthoughton@google.com>, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240710_164248_756066_01A3660F X-CRM114-Status: GOOD ( 10.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: Post-copy live migration for guest_memfd
|
expand
|
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6b6a053758ec..f0dbc3c68e5c 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4380,6 +4380,13 @@ static int __kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault if (fault->is_private) return kvm_faultin_pfn_private(vcpu, fault); + /* Pre-check for userfault and bail out early. */ + if (gfn_has_userfault(fault->slot->kvm, fault->gfn)) { + fault->pfn = KVM_PFN_ERR_USERFAULT; + kvm_mmu_prepare_memory_fault_exit(vcpu, fault); + return -EFAULT; + } + async = false; fault->pfn = __gfn_to_pfn_memslot(fault->slot, fault->gfn, false, false, &async, fault->write,
Without this fast-path, we will take the asynchronous userfault path every time, which is inefficient. As implemented today, KVM Userfault isn't well optimized at all, but I'm providing this optimization because something like this will be required to significantly improve post-copy performance. Memory fault exits for userfaultfd were proposed for the same reason[1]. [1]: https://lore.kernel.org/kvm/20240215235405.368539-7-amoorthy@google.com/ Signed-off-by: James Houghton <jthoughton@google.com> --- arch/x86/kvm/mmu/mmu.c | 7 +++++++ 1 file changed, 7 insertions(+)