Message ID | 20241010085930.1546800-10-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 0CBADCF07D9 for <linux-mm@archiver.kernel.org>; Thu, 10 Oct 2024 09:00:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0B7C6B009F; Thu, 10 Oct 2024 04:59:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABDB66B00A0; Thu, 10 Oct 2024 04:59:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90F2D6B00A1; Thu, 10 Oct 2024 04:59:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7185F6B009F for <linux-mm@kvack.org>; Thu, 10 Oct 2024 04:59:59 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 55ED841010 for <linux-mm@kvack.org>; Thu, 10 Oct 2024 08:59:56 +0000 (UTC) X-FDA: 82657095276.27.CCF57DA Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf17.hostedemail.com (Postfix) with ESMTP id C5D3B40004 for <linux-mm@kvack.org>; Thu, 10 Oct 2024 08:59:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HBYW68yD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3i5cHZwUKCBgHyzzy4CC492.0CA96BIL-AA8Jy08.CF4@flex--tabba.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3i5cHZwUKCBgHyzzy4CC492.0CA96BIL-AA8Jy08.CF4@flex--tabba.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728550769; a=rsa-sha256; cv=none; b=fGaL8t/k12fz0TLz93Qj7f+enkpuil/gjaWOdAcxwJT+SOMBic31ETDo1jHCLv4+CgQpif sLR0VBc/bvsQ2bv/pZo7rJNa2hfyqp/NeywUN9jWWq8rQdwlPZRa6ctTW1RyyHLFlzDoe6 e18zorZ28zGUj/98a5U4edhmC4w71Ig= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HBYW68yD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3i5cHZwUKCBgHyzzy4CC492.0CA96BIL-AA8Jy08.CF4@flex--tabba.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3i5cHZwUKCBgHyzzy4CC492.0CA96BIL-AA8Jy08.CF4@flex--tabba.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728550769; 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=HM7gsmExGCXNNGDXzdybypu9GrQXN1fbuf2tdqrKB/Q=; b=sBDDVIOKF63n7aNdltRTSs/IWX8q0Xr8q8AgOiqOKdGbdbW99TiQpTHdcdwcAHExU/3aIp uMu/iWRlM6Ip7xGUb4qBFiTJpS9uimY7Q8T2TzCRKGwyLZdqM4WZ89rpmlU4BJsMOlg8jd pTVfiBkd5esi8QG196IRSEsQKziCy58= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e24a31ad88aso807764276.1 for <linux-mm@kvack.org>; Thu, 10 Oct 2024 01:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728550796; x=1729155596; 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=HM7gsmExGCXNNGDXzdybypu9GrQXN1fbuf2tdqrKB/Q=; b=HBYW68yDcOaLUQ/tlEBYS3lsTAX/BqUsEQ8NmkfGZ4JhRWQuKmlyW0j7KBXcA6Uf6F Flj5/my/3HvqoUTRuBnEcpkWVzasRe2UAdNhG2cOdK3F3IxdRbFiHpwp1UxKSFmNKxhE hx6lbjS7uFeeQs00E4UiPAz69lLhrngfu05WqtjVzSSKavORpYHvLB+EPXMj4HUyPeYY eYFISUtITCWbhyVjDZmsngNcad6sZJps08qIXPHHYiSY/bg0RTP3fM7PIxU2TZ1QP/ll 37JlyfhLonVigZ6Ekbm6OfSAVRCeS3X41ZvgsPT27EJYu0rG8FADO3jiKA475v7UtWtE nCkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728550796; x=1729155596; 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=HM7gsmExGCXNNGDXzdybypu9GrQXN1fbuf2tdqrKB/Q=; b=dFbkYL0OMnDvN3X87jvZTpBlEeaqpcNKUooWwa4nPphThupEfLqMEfn29uClhrW4md JSwLXYmLw8frakd5iYZUCaneMetIWWWNaaSwkrwzRYn0CRB7wL4LGfEbKV05mYk3g7wJ QynCtQNY3gbl4UKLkdkWszPeSP0FP/abAE7rH0+KKe0DvOJ6IypeHF2suwpnyuTRTky2 BXyeEievKtPeQHhalaiOZ+A80SJ/BltUPvJ3LyHpl+H9rycHizPicji9ASTVWJiYSY70 kiDznv271/5fhI5zKUNTaAvWp78qrgMTde7r/UjE0oYaUTfXZp5MVw2lWpnLDCOouxRY h8VQ== X-Forwarded-Encrypted: i=1; AJvYcCVk0NWO0BmzLK+u3S3xVl4G5c3m9QnOo+eySw6HmcewY3hFBdzSguCBSb0KT4kz1ZUJ6XA+dAAVSA==@kvack.org X-Gm-Message-State: AOJu0Yx4WPphOyzHhpX+zbg+ZHXd6PRbS8VrYaZLJlzHdejwA4IFQz0I DBJCqqswrGYQLNTCIqoxNt/AzhpKQgCZi1Z6xMaPt35jSAo0dsVweB8/7ObfcBTOfMgpwU+3BA= = X-Google-Smtp-Source: AGHT+IGFCUFcocuEb3ihc+miy+ZJ2j+wkfEPTs51cWpXQxawruWfXPnQR4cYRFEkkX27O5wF5IDqGcOMOg== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a25:b205:0:b0:e27:3e6a:345 with SMTP id 3f1490d57ef6-e28fe6935c6mr3791276.10.1728550795821; Thu, 10 Oct 2024 01:59:55 -0700 (PDT) Date: Thu, 10 Oct 2024 09:59:28 +0100 In-Reply-To: <20241010085930.1546800-1-tabba@google.com> Mime-Version: 1.0 References: <20241010085930.1546800-1-tabba@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241010085930.1546800-10-tabba@google.com> Subject: [PATCH v3 09/11] 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-Stat-Signature: dtpks9jfuq3dng6h1wd511h9swuhgi4e X-Rspamd-Queue-Id: C5D3B40004 X-Rspamd-Server: rspam02 X-HE-Tag: 1728550795-686915 X-HE-Meta: U2FsdGVkX1+06rzpyIEMm/CDR/c+U1iSikqCB2yp+NoGc4MSXScVWDL3mw55V6utQn+gWoyZHGDNm3+ZP4nLD2PY8kokCF4ECVwdivFaTdlUt07nZyvevkjjMdtVf3bEsBTcQp3Zy0/UO6Po2zrgMyDMGkxvQ7gsNYKiAi1RV9WGKBm5vW5AGooYwmqeJae2rX+PFd071Jl0NYgSrSWoUYBmBbJIAV+2oDzFnj/vZK5ZMg1RsJmGs2i/K628zS3nVkmpLT5aUKgQxJuY1AAUMeS4VlabC1q41GiUg/CkbRoOv/Xx6g3jfMt6Cach5ax2fxvpz6Z6CcVTKCXxl2se+jWFzfhonOTmqKEztEVd1p9DjLFID2+qPN7ipWL3VGD6XyFniJjLryPaQko+vlacIwYHkTdY0zuGkU333irCc/MhgSEUelUTC0MmuqRltLpopVGIAwsZRtCzOTNb+vrY74/vvUGGuQaxB9EpDZUVP9l160rRDYQw/kkxOp2vxZttu/nHNSIHdS0WvJRSO/+GEVMcQP3SLT7Yzcx4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000006, 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 a509b63bd4dd..71ceea661701 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -987,6 +987,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 @@ -2126,6 +2130,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(+)