From patchwork Wed Jan 22 15:27:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13947432 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCDBBC02182 for ; Wed, 22 Jan 2025 15:27:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F28486B0096; Wed, 22 Jan 2025 10:27:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED3846B0098; Wed, 22 Jan 2025 10:27:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D748E6B0099; Wed, 22 Jan 2025 10:27:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AF2506B0096 for ; Wed, 22 Jan 2025 10:27:52 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 690BB1C643A for ; Wed, 22 Jan 2025 15:27:52 +0000 (UTC) X-FDA: 83035467984.22.2ED17AE Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf11.hostedemail.com (Postfix) with ESMTP id 981E140016 for ; Wed, 22 Jan 2025 15:27:50 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=dKhPmb04; spf=pass (imf11.hostedemail.com: domain of 3dQ6RZwUKCBoJ01106EE6B4.2ECB8DKN-CCAL02A.EH6@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3dQ6RZwUKCBoJ01106EE6B4.2ECB8DKN-CCAL02A.EH6@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737559670; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=shrLyHvMMRQKlPtYXYDSAaDe6YKxFfwFxlxNmwxqD3g=; b=irwxOC2OdPes8HchfBN1KAedIl1gzH7Gpl/KA/PubeEa8OVZin865ZsHxbyzLKLIM9ahPW 5lHsbk+7ZnpMs33+5ccczXQACN2Ps+SVcRRjxSVAv4EnebASfIM/fwu0QCmmhohsJf/9Ra iyUbvu4BlrJ0ZgJZDsgjO6bzLN9LLIU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737559670; a=rsa-sha256; cv=none; b=RMNVDljCce8yGiluQg4Y7zJawUPoaPf2rLaK8f+XVJzsy0R2/qAx5XjHkA/58ilHnx+doe AwREsOj26bFTe3mkehsXLIi0dKeisal3qn+sRtWav7BCm6vBwoPQzQCtxxjjWTLyA9RJKX eVXq4q0to1Nri5NfAumNy7FEG85Xkuo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=dKhPmb04; spf=pass (imf11.hostedemail.com: domain of 3dQ6RZwUKCBoJ01106EE6B4.2ECB8DKN-CCAL02A.EH6@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3dQ6RZwUKCBoJ01106EE6B4.2ECB8DKN-CCAL02A.EH6@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4361c040ba8so38966425e9.1 for ; Wed, 22 Jan 2025 07:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737559669; x=1738164469; darn=kvack.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=shrLyHvMMRQKlPtYXYDSAaDe6YKxFfwFxlxNmwxqD3g=; b=dKhPmb0412eZ55hfyRMfphpH6CeyGP84GgxR+Iw2zOs8+FaXcelUr8HNgzMHUcNrI1 dmWb5wGNclo6teaawqlichw0tZW9a9OMDgfjYcRIkPlMAGdq/a8X2sMswmoGqGtknfBc oNvfnB9C9/Io+wnOnWt/rIO4ZDvdoDMrvEWcCIS+JHF3xsm+RGmJOC22O4+gvSM4Lkn1 1aWBDJY0/UfcBkJCdXCYy7d9P6KZ5oWkqFnl/zTHl58uEQpiqgeV0lfK48Zaag8EG9v3 R3NRBKgNmY7yyxbgCi2lO7VUkXT5taPIgur4+VinzCy1x1w8/wbUymFR51yC/lJ17vD6 1rTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737559669; x=1738164469; 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=shrLyHvMMRQKlPtYXYDSAaDe6YKxFfwFxlxNmwxqD3g=; b=LVQifRMMimsSx7B0t4WHcobCpIxPEMTdiq0V0gTYUfdHkpi4rbn0/H9yZEwJQlMUiH cbcJaXc926+5dMf/bG6uwRLNb2bUwtBqFPjM3Qhljyrct1Q3PMRsqhrcd9rLlkjQ9+4T R89ubyq0wgFnMvJA5+5xyJZm4Aw3LW0h+xVWTExhCD4a8jHRmUkCp5n84ENFa9+plEWD DHxXD4J95DsDLIOBrJC/d2QBcexA71PSDzecgZqJWGz6jjoISYIu6Ff3oLtKTEvCatiN 4XOJxF4ho/5FwowQvK9OC2VZBCk90R7PjAdIwGGRFQ8mYfYBhLjzej4JRbtDXTz2RswN yflA== X-Forwarded-Encrypted: i=1; AJvYcCVS8Qb+yrAUnXe3V8jujH7LsqsLpLPaD6jD0B0Rs/6RgYhUGntSN/FewpNN7tuheuHblqUzyeeUOg==@kvack.org X-Gm-Message-State: AOJu0YwQC2RhYlPva7Q7JiEGxWTe9sJjuQcM2TKfeU3IKWBkXWcFfeQK xRrkH8L3k5AUeI00RdYay79vF/tDwxbvGTz/vy4PKcoER+Eej2l4JcKyNMlvtgYc3LFaS/+hRQ= = X-Google-Smtp-Source: AGHT+IHTlIkTn1+cn775KydFPeyXeNoykYbZ6JOdiKLvBv9T8k9MPGDx/xX8UX12ynhVUVVwAikKzSjQIA== X-Received: from wmee10.prod.google.com ([2002:a05:600c:218a:b0:434:f1d0:7dc9]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3585:b0:434:f297:8e85 with SMTP id 5b1f17b1804b1-438913d5da1mr237493785e9.10.1737559669276; Wed, 22 Jan 2025 07:27:49 -0800 (PST) Date: Wed, 22 Jan 2025 15:27:33 +0000 In-Reply-To: <20250122152738.1173160-1-tabba@google.com> Mime-Version: 1.0 References: <20250122152738.1173160-1-tabba@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250122152738.1173160-5-tabba@google.com> Subject: [RFC PATCH v1 4/9] KVM: arm64: Skip VMA checks for slots without userspace address From: Fuad Tabba To: kvm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mm@kvack.org Cc: pbonzini@redhat.com, chenhuacai@kernel.org, mpe@ellerman.id.au, anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org, xiaoyao.li@intel.com, yilun.xu@intel.com, chao.p.peng@linux.intel.com, jarkko@kernel.org, amoorthy@google.com, dmatlack@google.com, yu.c.zhang@linux.intel.com, isaku.yamahata@intel.com, mic@digikod.net, vbabka@suse.cz, vannapurve@google.com, ackerleytng@google.com, mail@maciej.szmigiero.name, david@redhat.com, michael.roth@amd.com, wei.w.wang@intel.com, liam.merwick@oracle.com, isaku.yamahata@gmail.com, kirill.shutemov@linux.intel.com, suzuki.poulose@arm.com, steven.price@arm.com, quic_eberman@quicinc.com, quic_mnalajal@quicinc.com, quic_tsoni@quicinc.com, quic_svaddagi@quicinc.com, quic_cvanscha@quicinc.com, quic_pderrin@quicinc.com, quic_pheragu@quicinc.com, catalin.marinas@arm.com, james.morse@arm.com, yuzenghui@huawei.com, oliver.upton@linux.dev, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, roypat@amazon.co.uk, shuah@kernel.org, hch@infradead.org, jgg@nvidia.com, rientjes@google.com, jhubbard@nvidia.com, fvdl@google.com, hughd@google.com, jthoughton@google.com, tabba@google.com X-Stat-Signature: 6x65wmeku5oagefgdrxa4p9xxukhm63k X-Rspamd-Queue-Id: 981E140016 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1737559670-653114 X-HE-Meta: U2FsdGVkX19kWkGeXnLte8tclUc9gvDd2BlTboGEiCQrGM2VWq4FQ1iWrxSqKF9zOQPGxT0OP4zlJ2k/ZwyHmo/SgL+8hxYQ9RHeIbiWLFW7VrHCE0IUHWfrWurdKEX3J65yFfl2dxjVP2DQwL8ArseW/AYzxA3DJNZ/FrLvfHMY/ATQonZKxxrlabuSr5x1uonKgobPv1JBKoK0JZe8YAIaT3e3cfrVaZJdN4Ayvm1DjT9KeCfnpHDNaJdUFH2QuJLIR2skQ7e6AgzWIz/gaYwZ42RaZahhQSRk8DAzA4ZiIxOKzeU+J8ZkQqh/Xd+FctY0FIEXBbseUsIN8RH00/Ptq0KsrHlXAzFXCp4i/Z6LGbJXLKuEl1WO0dWFLi3bZ0FV/eiJ+BT2Hz9TpDD3jcP5EDFYQJt/b67b2EMLFLmJQCUI51EJGGZ/BIyUsyTF/XU2KYUNRPEhQxRoEzqy308yCSDruwzsvXro8WU6WH3Yf8IOUEsZaLOWpINDe/AThX9CQcJb7JK1acNYZo7BzpW1XxByuZyu7V7kZ5dU+gn3n4fGyFaSadNxSyG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: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Memory slots backed by guest memory might be created with no intention of being mapped by the host. These are recognized by not having a userspace address in the memory slot. VMA checks are neither possible nor necessary for this kind of slot, so skip them. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/mmu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index c9d46ad57e52..342a9bd3848f 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -988,6 +988,10 @@ static void stage2_unmap_memslot(struct kvm *kvm, phys_addr_t size = PAGE_SIZE * memslot->npages; hva_t reg_end = hva + size; + /* Host will not map this private memory without a userspace address. */ + if (kvm_slot_can_be_private(memslot) && !hva) + return; + /* * A memory region could potentially cover multiple VMAs, and any holes * between them, so iterate over all of them to find out if we should @@ -2133,6 +2137,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, hva = new->userspace_addr; reg_end = hva + (new->npages << PAGE_SHIFT); + /* Host will not map this private memory without a userspace address. */ + if ((kvm_slot_can_be_private(new)) && !hva) + return 0; + mmap_read_lock(current->mm); /* * A memory region could potentially cover multiple VMAs, and any holes