Message ID | 20241213164811.2006197-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 DFBE4E7717F for <linux-mm@archiver.kernel.org>; Fri, 13 Dec 2024 16:48:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF4956B00AE; Fri, 13 Dec 2024 11:48:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A07796B00AF; Fri, 13 Dec 2024 11:48:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8340D6B00B0; Fri, 13 Dec 2024 11:48:42 -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 62CF36B00AE for <linux-mm@kvack.org>; Fri, 13 Dec 2024 11:48:42 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2351112101F for <linux-mm@kvack.org>; Fri, 13 Dec 2024 16:48:42 +0000 (UTC) X-FDA: 82890517836.17.26945B0 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf14.hostedemail.com (Postfix) with ESMTP id D4AF010001A for <linux-mm@kvack.org>; Fri, 13 Dec 2024 16:48:11 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LihBLwQv; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3Z2VcZwUKCOQZGHHGMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3Z2VcZwUKCOQZGHHGMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--tabba.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734108508; a=rsa-sha256; cv=none; b=qsPdtjSf9fF3Hp5JMwWoaViRjQXJJ6CPjfMQsjvqnYHU0em1H62HN2bxqsuWZaJqFTxxJE 10Lfph9508vI5yN4CJVVACyzTGBG2HEiA69y5zpIQmV4yXrqkXg1kzenWMQ866vOxfafN8 8KXJWStbr3tcQqiMT276m+XCRUIXJIE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LihBLwQv; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3Z2VcZwUKCOQZGHHGMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3Z2VcZwUKCOQZGHHGMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--tabba.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734108508; 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=g2VJIq0JFQ/ZqzbxK3We3Qf3gNhX7/2qVuXpD8D4O2A=; b=G4oxldY4hGEpr+QrGYYBqxaSL9s/UlKhRy+D4Eoy00NlBGd/35UnZtfY5dc+PfmdrcWbfv HWr4WkZaJsG48Tx3mdGpBBXYiRX5BcW59WErH8MNPuZM9Jsok4lax+eHwcIOGB9MBsocrw jqGPOyIZGThp9iI93z9JiSCf4MPOOJI= Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-43623bf2a83so17816625e9.0 for <linux-mm@kvack.org>; Fri, 13 Dec 2024 08:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734108519; x=1734713319; 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=g2VJIq0JFQ/ZqzbxK3We3Qf3gNhX7/2qVuXpD8D4O2A=; b=LihBLwQvy7MuSeBdvS9ysETk9cVZJhDlU/8HwrofMXCHts+qqW6MBRpqAnN0brrK/l ert8iJfjspqqz+zJqw6Vwd3Dzm0JhtgO6Qi0WJq1lJu5v+TckWpO4ZC9FG8YNEJKvFSu ISKEe2iyt5nYG6UYhzM+oxmRhrGkMIwT39sR/U1KLN/jzWh2O2omRGO+UbXnjDUvTh8V OH0OR1ltzqBxxM00d2No3wtkqtwjIrN8re377UFkfHXV3carAExe6vUXy9PVYNt9ymk1 gDXAAwtxo9NEnOK0AjGnFAlCkpwzDEUwgqPbBAQMCxQRg7Xb+SBd5RqSMO/jtObo9x8l VzDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734108519; x=1734713319; 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=g2VJIq0JFQ/ZqzbxK3We3Qf3gNhX7/2qVuXpD8D4O2A=; b=MTA42BxzXj7plnui+t661P8QM/cxy/DdBW3L55/b2nH4U8kKyJLeGxuELUYQKfTcWz UmnloVf2PBvcTwtB9rvLbN73EFxiv1OSVm9+kyz7dogCkPJE0IaL/PcYTQdSNhdPZ/sT K8pdCtQ30ZPBr/ZtdvXDMie2EWQ7Nrx+U9daX3MEs08MLYRfkUtpvy5bbwfsnkk82SHy oLcTIOH3DZqJYSdCq/bsdSgpsqZZg9HugBikf1d0ywWD6vHRhxYiPQuNXiMftsJNamVt KybVfqWm1GV0CHDGoG+zEoj4foX4TaI+vSQKyf/dYVju1OcicoDmQdlvgGXMPCuZDkNw /kaA== X-Forwarded-Encrypted: i=1; AJvYcCXyAehktbv/ej3zwBZGjmri0tSQERdXUgRFG+jgkxvHhDJ5SLfbKoiK5e4g876njen/wGgi6zriZg==@kvack.org X-Gm-Message-State: AOJu0YxQFXnQetrk+jO4DeTBercF3uPOsB/QALBztelNJUjY/0Vx0vov zZCYnBU3uWCgPG4K5o0jxVPoTs/A7R5Gu+Fle5v3SPN7Ps0PfObyT5RtNdzu8fYztfSEgN5pXQ= = X-Google-Smtp-Source: AGHT+IEHYbi0erAT5PMhFOWMD98RX6BEQ5VdWuD/tN2fh0Tz16i8Z/iaZQVtS7R87H/i8b+meXfFpU9LHw== X-Received: from wmsn8.prod.google.com ([2002:a05:600c:3b88:b0:434:f018:dd30]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:34c2:b0:434:fddf:5c0a with SMTP id 5b1f17b1804b1-4362aa156a5mr33549795e9.3.1734108519019; Fri, 13 Dec 2024 08:48:39 -0800 (PST) Date: Fri, 13 Dec 2024 16:48:08 +0000 In-Reply-To: <20241213164811.2006197-1-tabba@google.com> Mime-Version: 1.0 References: <20241213164811.2006197-1-tabba@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213164811.2006197-13-tabba@google.com> Subject: [RFC PATCH v4 12/14] 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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D4AF010001A X-Stat-Signature: tss97on9bomurntnzpp8m558der5jhjj X-HE-Tag: 1734108491-597314 X-HE-Meta: U2FsdGVkX1+hAFSLMbp22WzjfSAJ5RzuoE41lOhb+Bl73Fo5bmSJ4nTQDSYBobQRmqCSVcXlu4HCsxmMjb1j0YbrPCwZpnLNfDVWiP8GGIrtFlkbsXeqSANn5TZBTu1U5S822mFjY4opJB4WqC6/rLIS/tiXLpqjpVD/2/GUhsKPVhMK4b7fGQFbxjU4YdAtGbo2SwMYHuNC/We7zXWlnllP1boxojEe+eAQHL0wbywF8t4IcQ8Q2vAOCStRc1O1T39GjcVPCAbYg3OsQF3rnqdMQf67kY4yBBioxah+tAKp+x1ykUwYc3mu9fkxXXeQFFlK+mbPLMtpI5EyyKTyZ0tmnD0tLxvPec9R12oh8kykdnXNLgILVx2X8OzTNwuw6Ylv0f8hQDwsSO8J72HDXiXw02edXBs7ZM1wOwJ7F0q6NqCjjkHlkpR1IXlhhEDSss/Jc7XdFYIFbLfopHV1x5TCF768RoDN+qIBPbKIFRbSHtnl9nUltFh8jqyEaUkFjFj1Ptt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osity: Ham, tests=bogofilter, spamicity=0.051949, version=1.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(+)