From patchwork Wed Jul 10 23:42:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13729881 Return-Path: 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 338E8C3DA41 for ; Wed, 10 Jul 2024 23:46:20 +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=M0Yr0VzVLlHnBy7TTzGiqxJ6wuwWaRwmTmvFlX0dIWg=; b=2XHrZrNSpIs6j4VXyQBX3dYa58 Btk3W7+vzWmf/Sw7oobL9R4j03t6h/e8h5mssVvoZzFsZo4YCq470BOzBiQyihX9HnPn7K/BvknVY igUJ/UVIm4npCO9BKnBtK5aguJ0lL9GkossNlpuBHXr0wDm7U4F1QXQY+VouL8zRxSjpdAu6FN7e8 oV7C5fiGIsn9T2iT2UO1Oc+Kj3wj3ReYiI+limcZSGWRhjtv8HyfqFfHBuYv+yQuePvryg1L8HWaD Jucl6iA/Ub5ngxciTpRxgR8A6sYO4DPwxn/P/YTxyv/ohyQI8cW49OeOEWPrxlvNmc32+tWP6SgJ8 9f9vC6VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRh0l-0000000C92T-0dBg; Wed, 10 Jul 2024 23:46:11 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRgxW-0000000C7El-2oRY for linux-arm-kernel@lists.infradead.org; Wed, 10 Jul 2024 23:42:52 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e057ae54529so423094276.2 for ; Wed, 10 Jul 2024 16:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720654969; x=1721259769; 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=M0Yr0VzVLlHnBy7TTzGiqxJ6wuwWaRwmTmvFlX0dIWg=; b=FV+m3BtIhe1fsmcn+VmmIo+UmYvfgP3qq/u55COxkx+CBqF6lSt+RGq4n4PL1uBIPs XD0asKhTXE9Db4u/vDkmreULV8fJYbj8utsR3sHqemaJ2Nxr7wt8KwukmPIF41yFSHCt YKL/6892sQL3vExJ/R22mkL9SB1pUtV9tNf24txpYVlxmVleAEOA8oELakR1yIXZdQi9 VXUdg9syF8jGk9G0Qddejz+tuTyD0OJEb5MnfP+rNI78DLBGNW/bgrBGP09cO/Onj8Fw laQif+W+Y1bvT0eP1/pcsS+6dtKqOrRETzYCVjzAlj44FLQUBH0fdsFE360LxdOL89NJ Pb9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720654969; x=1721259769; 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=M0Yr0VzVLlHnBy7TTzGiqxJ6wuwWaRwmTmvFlX0dIWg=; b=iUEerEEVxm2RB+nvZw4TRK5S1BRMqZoi3y4xtLBHKCHQv9eh+QABrUvgk78EVfI31s trLYlEUjKrP3yWhmquqBGsy8Jpy7sCXyD53GCUB8FhIs3AwCsBhFl8PMiQw3tMjL6Ip0 DtljlPazLeynt61p/GQUwW4ps/Y251Q91UzCC3jTpp67CI+s1xl1RtBHkUM++n7Reao/ NPqpLkP7ykK0SNXi6lvjmTsmSeH+/KtSXGIIQmKXuOfdz4J0GYnCHMrl7/b8PeOnpunu KUDg9zhweFfg3c2p9CX3dJLV69s1jAD7PKHvDZp4ikxP7iZG9I4MR5YxNCGc7Fh5JbJ4 TezQ== X-Forwarded-Encrypted: i=1; AJvYcCXHMKBBbzicf1unP8mTXYDJmZr9P0tPaK8Z3rHGcBFL3sC/edCNjAiI1cIn78LAz4edS8D2yi6VL5//0JJmD370NhM5tcwzFvhux7U6xLuGlO3QqOw= X-Gm-Message-State: AOJu0YziDu1F7z0s5KxerP/ku6I7N3nIYrBJHY8WebqErpOi79qlIaka s8jylYSvd8Kd5jcZf+zzPthm0g/c6ELQ5p6kckGqIJvxxlYqlF7JdNBRuYsLsZUo9NPxnwuuR/G ujGdGyN9R2mPWlq6c1g== X-Google-Smtp-Source: AGHT+IEnfc9JNyCNV09EBc2D+TZxXa8AOYJGFkqDSB6HeXipR+uC/GqUScItBcKVfj4YhKzC1lFukBy8dAilrvDh X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:154c:b0:de5:2694:45ba with SMTP id 3f1490d57ef6-e041af3e29emr358942276.0.1720654968877; Wed, 10 Jul 2024 16:42:48 -0700 (PDT) Date: Wed, 10 Jul 2024 23:42:15 +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-12-jthoughton@google.com> Subject: [RFC PATCH 11/18] KVM: arm64: Add vCPU memory fault fast-path for Userfault From: James Houghton To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Sean Christopherson , Shuah Khan , Peter Xu , Axel Rasmussen , David Matlack , James Houghton , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240710_164250_890880_56E6C71C X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make this optimization for the same reason we make it for x86: because it necessary for sufficient post-copy performance when scaling up to hundreds of cores (even though KVM Userfault today doesn't scale very well). Signed-off-by: James Houghton --- arch/arm64/kvm/mmu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index ac283e606516..c84633c9ab98 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1488,6 +1488,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, mmu_seq = vcpu->kvm->mmu_invalidate_seq; mmap_read_unlock(current->mm); + if (gfn_has_userfault(memslot->kvm, gfn)) { + kvm_prepare_memory_fault_exit(vcpu, gfn << PAGE_SHIFT, + PAGE_SIZE, write_fault, + /*exec=*/false, + /*private=*/false, + /*userfault=*/true); + return -EFAULT; + } + pfn = __gfn_to_pfn_memslot(memslot, gfn, false, false, NULL, write_fault, &writable, NULL); if (pfn == KVM_PFN_ERR_HWPOISON) {