Message ID | 20250117163001.2326672-13-tabba@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CCECC02185 for <linux-mm@archiver.kernel.org>; Fri, 17 Jan 2025 16:30:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4274F6B00A4; Fri, 17 Jan 2025 11:30:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D4DD6B00A5; Fri, 17 Jan 2025 11:30:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24F276B00A6; Fri, 17 Jan 2025 11:30:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 004706B00A4 for <linux-mm@kvack.org>; Fri, 17 Jan 2025 11:30:32 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A3A78C05CD for <linux-mm@kvack.org>; Fri, 17 Jan 2025 16:30:32 +0000 (UTC) X-FDA: 83017481904.27.D561392 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf28.hostedemail.com (Postfix) with ESMTP id B987EC0008 for <linux-mm@kvack.org>; Fri, 17 Jan 2025 16:30:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=cw7WDe93; spf=pass (imf28.hostedemail.com: domain of 3pYWKZwUKCB4N4554AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--tabba.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3pYWKZwUKCB4N4554AIIAF8.6IGFCHOR-GGEP46E.ILA@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=1737131430; 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=sSlVlpenNui+ihtbrXTMc2wxhoMzaNJZlwReTVVguuQjlmIKTgiI1MRjq2lcYEiEHrJcBA qeqypOb8bUDbGb715AYgI6n2DMPXQWDfy1dVDx5kgPDgDwZ5wdvh24dzh/eaka9Q7eLT3W IWIO2Ft4/LsmRzajpekrLKyzxFcWhqA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737131430; a=rsa-sha256; cv=none; b=tmTECPWNyJZOsj8HfDvt1Xx7/TwADBYrO/CXGc0DNy4ZQAP7tkI5bUUsWe4v6W7H9WiBcm eaXUvUmFMHQccSrbCbk75C8WKvBFtct2w/zViPRa8R+FhA6W04R97XlDf9FkywGRF/Mx1x tziriBwP02F2nxANap085y0KphSteRM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=cw7WDe93; spf=pass (imf28.hostedemail.com: domain of 3pYWKZwUKCB4N4554AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--tabba.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3pYWKZwUKCB4N4554AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-43621907030so18987345e9.1 for <linux-mm@kvack.org>; Fri, 17 Jan 2025 08:30:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737131429; x=1737736229; 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=cw7WDe93zX0XHV/8biFz+LJ+2AUgoZOFWVx4XUYm1dllvbPfd+X1vEY5XL10QkBvK8 2VFFAOYTifkm+tvhy8ng9BTmob0P7eEHSNnboWJqX49PcKXAjgAEWprRWZErsSTIomvM ITMDM7CtzO/pmSdDF45Vndf4UIoF/m2fWrOmAq/Qu60b2xdC0C3YWMVIvfGy+HCLICQj 7fgOY9eQL6j6q+CknOZDz+Ro2KrAVEncmnfbHcqkYzKEvs/6xRMZhAFTFIgZ3JUvz1zr LfRcYX10Y5b5RRvOOl33Ck88iL8sqW9ia6leh4vDT5PPIBmvU2Oz+FyVAVuV5jkwEWsA LVbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737131429; x=1737736229; 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=Z1n2HCw7tSV9WKXn6yCPfT569HwuPoRk9QVcqEBpaazKw+03uGkG4r+4TpGLxoWANG 9Ya12f+2LWXeVcKhTMu/YT2Ub1+VivZcLPaxUFNFFw3f0ODkopd8VepFLY8F3RZbynL+ +N6RXGOaoa2weRl0jaod2ODeICplkoWcPRTY027RGQ1J+zx2u46VGyH+eAe6xq+PHZfl 2iikc3nF0jBi7ZOwCsGB2A2J99NFZmIFSBm2RiFdYimL1z4PwEaOqOilH4nkEg8UaVpd W9k7K1dXUniMvPF3VzK08tSC8sPro8Y9H3x5eeqz6WQkey7Ei6jRPCDhDuJsdlI6z1I8 sV7g== X-Forwarded-Encrypted: i=1; AJvYcCUYMlxsPIWVjEkLW+6xRL8Y37qw4iJceUKDLU59IMuD5mNMkUVNPvNd43C2GBeGyIL8jITOKP0yTg==@kvack.org X-Gm-Message-State: AOJu0Yx6w3N2MSKLL7klNMQkTY7bdLy/X41KlnLDq6rVm7QGOkGHCPcf vNwGqzS4X+PXkJP81xA/JhYgjURFNtQIsDRICbvZb9hvCwV3zsT9I+v3uwbXfjmy7Cb3S5yNRw= = X-Google-Smtp-Source: AGHT+IE3/c1HcXzGSPchtf4vKV9TLTAsRjAq6kyeRfhWxPrR5PiskpFVLxhd84Kq6MdjNi2BKyWHIITf2g== X-Received: from wmsp9.prod.google.com ([2002:a05:600c:1d89:b0:434:9da4:2fa5]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:35c3:b0:434:f131:1e71 with SMTP id 5b1f17b1804b1-438913cf2e0mr36260775e9.8.1737131429376; Fri, 17 Jan 2025 08:30:29 -0800 (PST) Date: Fri, 17 Jan 2025 16:29:58 +0000 In-Reply-To: <20250117163001.2326672-1-tabba@google.com> Mime-Version: 1.0 References: <20250117163001.2326672-1-tabba@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250117163001.2326672-13-tabba@google.com> Subject: [RFC PATCH v5 12/15] KVM: arm64: Skip VMA checks for slots without userspace address From: Fuad Tabba <tabba@google.com> 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 Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: y5bn89q53jfgwg7sh745nb5k57yto9yp X-Rspamd-Queue-Id: B987EC0008 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1737131430-106759 X-HE-Meta: U2FsdGVkX1+d0hBK75wvJLuhFi7MW2bzGPoQGyMVk5R6XgAw1B0BU0k5FLPyQGQ622/58cjq50eIXGUV6DtPc+6zZ7diG/JEDRAy0400qZmro34rP8RM+botegHca3A6qJ40lJM8ZqFa8Kp2D3n+NMcntavqYsppLiPAo8OYuotvSIAC8qT2zqzGiZ8H6IVyP/RGmZHiOi7yoYmZnWMwy3meY/OLi8OAMcLaEiMocYudjmXSY3E73m4NaIa7K72T9vTcpKwXsAEGLBFLdL7RpvdDmWobjVc+e2+lj79zO+vcFy+YOsXZQ0HlCNK2zgXC9y0nnYc6yfMiMSN7HPtkkkWiGGgG6agJoq205ryKMwOROlx0tJ6wqZedqMcnrmTRQl4HnODLLCeWTxOfN1MWz/QUbvH7JV1u8xdzA1PsRhCTlgQaitTUrrP6mjUYIobHp1NjnIj+cIleSTYSv+v+cux3BwwnrlTk6PgiYqdUttkyOLDOonG16Uu2leEJ82lOW2p/BJLB9OMQSklOu+VjHzDAQ458MD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.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
KVM: Restricted mapping of guest_memfd at the host and arm64 support
|
expand
|
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
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 <tabba@google.com> --- arch/arm64/kvm/mmu.c | 8 ++++++++ 1 file changed, 8 insertions(+)