Message ID | 20240801090117.3841080-7-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 5E927C3DA64 for <linux-mm@archiver.kernel.org>; Thu, 1 Aug 2024 09:01:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C80B86B009C; Thu, 1 Aug 2024 05:01:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C082F6B009D; Thu, 1 Aug 2024 05:01:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5B2E6B009E; Thu, 1 Aug 2024 05:01:38 -0400 (EDT) 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 837CD6B009C for <linux-mm@kvack.org>; Thu, 1 Aug 2024 05:01:38 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3B7F8160960 for <linux-mm@kvack.org>; Thu, 1 Aug 2024 09:01:38 +0000 (UTC) X-FDA: 82403083476.09.37B0B1F Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 6DBF218002E for <linux-mm@kvack.org>; Thu, 1 Aug 2024 09:01:36 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Sj7U9gOR; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3706rZgUKCHYnUVVUaiiafY.Wigfchor-ggepUWe.ila@flex--tabba.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3706rZgUKCHYnUVVUaiiafY.Wigfchor-ggepUWe.ila@flex--tabba.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722502854; a=rsa-sha256; cv=none; b=1clkGozriL281SCB9Qpd8YO+E6zGNUptM61PPGuE9CF2wkqlcy0NNyvwVlPAp61BKPmU75 MBniP4CY/gacJkiXOrlEGX2ZQtaJue3xKbFu1zvXkymuUls4cl5rMhF3Nv2dgcnllznsFW Gjp/dTL6T5gO+wpSz3WOfYBf86a/IpE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Sj7U9gOR; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3706rZgUKCHYnUVVUaiiafY.Wigfchor-ggepUWe.ila@flex--tabba.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3706rZgUKCHYnUVVUaiiafY.Wigfchor-ggepUWe.ila@flex--tabba.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722502854; 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=eynVCV8vS5USu2ZyXSA4dI0KQ06/f9GaXl4H1mlHW7I=; b=4Hojrf8dDPf0DCD6+piMy7UclAb5MpdTUeoL8mW/MpjKb3xjP1/R/LaS74NEKXOA7Qqau/ 7z1q3sidqaPtdWfMZkSJkmjveVtL1QThBsAPlnWp8le1T5mjeI3EzTB6FE/cULXcKK8aRD eB4FyThARvz7XWN7kQGB0yMNZtQqbyQ= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64b70c4a269so125586217b3.1 for <linux-mm@kvack.org>; Thu, 01 Aug 2024 02:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722502895; x=1723107695; 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=eynVCV8vS5USu2ZyXSA4dI0KQ06/f9GaXl4H1mlHW7I=; b=Sj7U9gORJu90+EmEB+udJu5F/lSVfCrFyAlkiRBbEeI6pXHk1SPZlq8SZGvliOENlT VfVUfL6Ung7tjA2Vj0ypeYhH4D5fhM/FouRdBlxhFLOnhn0f6uMRXGVOGgnvZ67fHXiS E8rLsT3J0iBhiq+tmNwHWAxPPSqkLl4O+KikXxSBzSRGVMr/NNQbUDRVkeMurnHYx1u8 d2KqshdFCCP62pnM58KEapecYGibUQox9zdPCYUAfvt0u2dcc3f1HoTlvZ8jZGiNvd91 wGY55FzDHr7OEpDnJetr0Q3SrlQS3VBseeS3IidmJtHXafdhz4SWwNDuJrI5bKZ1mRTz l0Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722502895; x=1723107695; 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=eynVCV8vS5USu2ZyXSA4dI0KQ06/f9GaXl4H1mlHW7I=; b=OE4JpT8qZGYq6d2DfkdbVwRMAzTkAjqJDuTKWMBNRa7Zs7RhkYXkQ1VrOkidtbJ0LG ugE9/oLU/0aECN+L6m54FDrsym17WdkoCTP14iTkloO45/cdIyX3poKcw3/c/5UkORo/ f7f5nxucJrZo+VEMEom9Ly8itdfwiOZ5Oe3zXNcL6grXZtTUwBj0kC3GLbxKMNeRDUOY ForDT4zgIxMN6GXhDNE4ax+wXsMgRMueVJuGn1Pob3dcN9WfS4DpZTn3gpgHnMKLV7Md y6EV3LcauG5r8LAn0BcPIMclJyZ29EhQrVsV1UCNOIW/Oy2CM29xlcd/fEVdRctqCYVb pRGg== X-Forwarded-Encrypted: i=1; AJvYcCVwhjzrc/NGG36+wR2z2Ocz9xJum02aStXwpAvdlz6FUE3j0RhF7qepQG5Lf1iSIJy1Sz5RGD0iRU6w+H/Fv4tpdn4= X-Gm-Message-State: AOJu0YwHbqJz7Z15uxnpRM6Vq2ssNTcNcxsCQT1uLWlPssBWGleUe5Dx 4YnrGNM2/UO6blkU4MNAVsMLal90pCwEJZgnuCGklk42GfDFwCMJyf+/8ErC51+ftgjCQ8iuCg= = X-Google-Smtp-Source: AGHT+IGMIr1XUVhclOFb55aW6DOFYObKwVO0wQH5tDUYBTBbgfFm+mNN9/WDhRbYaQh1Bw5e40TmTstGTw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:2190:b0:e0b:bafe:a7ff with SMTP id 3f1490d57ef6-e0bcd21d5e4mr2642276.6.1722502895329; Thu, 01 Aug 2024 02:01:35 -0700 (PDT) Date: Thu, 1 Aug 2024 10:01:13 +0100 In-Reply-To: <20240801090117.3841080-1-tabba@google.com> Mime-Version: 1.0 References: <20240801090117.3841080-1-tabba@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240801090117.3841080-7-tabba@google.com> Subject: [RFC PATCH v2 06/10] 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, tabba@google.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 6DBF218002E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bsyfba3oi6fgnyfn74uckh7usfcqmagf X-HE-Tag: 1722502896-507450 X-HE-Meta: U2FsdGVkX1/c8yXzBKo8bI7W8kYoXlTMSDr8NCIppx8myDyp9oKxuzxL6s+h57xlXwk4MqAA96UL2Ie0jPrcSlhiBLYZz+Gl4Tb6szx/t0JkFSnf+e+8EnL8/fZ9yEt9ozH1/QvAhcLtf21lpmF5yR/YTSBBKeWPYRSWtOa1skK3aPlijzzRVgEQ84pIuWxMrQ+KfLoC2ERNUERNlKx4zGPHjk5HkRUblIkHGBtZFn3nKxknXQczaeE7uyCBPc79BG6rRqHHLy1BIRvd+em7D61xfrA5CfL6uZ+GZW6pZ33t390TqYK2m4YDOxdJaVNlPTo8+Sp2u+5oht7TEdMlfsHeMzCm2GkHM0qMfMNsBNvGhSpRuje1i7ptHDXlITK3IfYtTrxWCd7VxtrD/5v+7WpdbV4cAptxVCoYgwQv40kZ1P3UEEz8LzLcCmzJyczoEOx1e4yhkox+LE4dfzWHW4Je2ZsU0MLIkxaL+Xbm5L9A/tKidWXmdPYnOpTxm+qGjGHAGKyB96SVFioQTv0FHFCEv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ner-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 pKVM/arm64 support
|
expand
|
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 8bcab0cc3fe9..e632e10ea395 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -948,6 +948,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 @@ -1976,6 +1980,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(+)