From patchwork Thu Feb 29 23:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13577756 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 CE929C54798 for ; Thu, 29 Feb 2024 23:43:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 603696B00AF; Thu, 29 Feb 2024 18:43:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 58EB56B00B0; Thu, 29 Feb 2024 18:43:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4307D6B00B1; Thu, 29 Feb 2024 18:43:30 -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 1BAEE6B00AF for ; Thu, 29 Feb 2024 18:43:30 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EF2FF16041B for ; Thu, 29 Feb 2024 23:43:29 +0000 (UTC) X-FDA: 81846470538.28.BD05E4A Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf03.hostedemail.com (Postfix) with ESMTP id 20CFC20008 for ; Thu, 29 Feb 2024 23:43:27 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PuvTyAPh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709250208; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZYaENkYQ4G5HZw66zLSCBAz4c9QdNSpOW86RMIeSYNk=; b=HPauMpzKfLFVV9DX/UzpqKhMw2+Eh+El/kakgG3EyTxBIZS7qGjSTmwI1TaDGxq77TxZtD wMizWNi+VZ2fUnSXaGYV7GeKqD5Zr0S3HF6fxO2J39XqX1N5uULRPip0FIhEthzLa6EoB9 NB9YOHuLkJtifmjZel/xkqaOQ10kBEg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PuvTyAPh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709250208; a=rsa-sha256; cv=none; b=KiqtQ0ETLl3ZyOHvcO1b7BgcVuUJa34SEfYcu189p8wyBuTKn/Hxnp8mK3HaAL4CyorZNC mUg92EmD0DXQRI6ER/CWYp54+12uktYfcum7AQ4fO4t2M7PmOl+RlQ/8XXZIrqGPi6xJ4R 6ePXRQET8o4jvpkJ7rE51aHoR0QCKxg= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dc09556599so14088305ad.1 for ; Thu, 29 Feb 2024 15:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709250207; x=1709855007; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZYaENkYQ4G5HZw66zLSCBAz4c9QdNSpOW86RMIeSYNk=; b=PuvTyAPhKomVGEGPJKwTS9ZJ35xi5DY0+CRw65JFTzNzNtUZwnneQ4GzLZfsA9aZa/ RU6HteCAT2kZaMIY8w5+2wBDv0Is9H53TXm5p4EfuJBjJsR94EkebMQ+HyQ54xnmpVNe lb6Zd1Ddm0Pu6fX8DKvFp0evW4VXUx6CX/+vcVx6EWNvv5pt/2uamfTu7sJu8CCOpVmf wFlYGaJ/caNwfiMFtq1nggdC3Z6M0ujSAONZwJo+wYNubMiwLbN57ZrY56PNiv6SuUr8 /7GFlQbpSacdl9awUFBUuOulMDk5Jna0cAlQUWsuEDrS3zdbGVv0Pba8qdLsVESLzAGd x0jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709250207; x=1709855007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZYaENkYQ4G5HZw66zLSCBAz4c9QdNSpOW86RMIeSYNk=; b=UJvjMoxWImnozcl8JktacFsxyCeTjBi0GmzTJFJ8dWo+fUc227YkuKIwbGRSUQCAmZ llCyoHCVYdyaCk9Z+h9CQD8s0Pj2NZnNzXQn9hafi5/Jl8w+VhlBseOIoWSj48itGifP g5UgxNgVdwgPwVENvTQCzYHnJjc+O1D3oS+aTDmcA7/xc/C1MzDQGwLlyDbKDADSBWL2 HHBnVv7Fm4TRWitLmMu8zsB/pZ2JaWMlbJePV+MldBBAtoDFT+uiwD2tsaFZetGy2L43 oMt7Quiu/UhDgVk2/vFEDJSDggKMvoiggomcNVC8pbTQMhJHOTmOZQB/Tf8WGIKjm+yu N77Q== X-Forwarded-Encrypted: i=1; AJvYcCVTScECkyg2fFq1HNGQiVMP/LtzaEi+bZFBCgTZFuLMy3lHTQThhVIBwIQEA9LDDwCkgKA1kAmOIWS8B6PiZscoLsk= X-Gm-Message-State: AOJu0Yyp8UDWbbbPppLiPx+6dsn/xzGF3ryO4xLcL/WFdiSYTwo85YD1 BQpP33TLhbP9o3LT5UMzL2/lUCoA3f7JwR0WH7yU/66EaO0x1MSD X-Google-Smtp-Source: AGHT+IGkWYefSAJiD6V3UAHJP4h3dcMjAtD7ol2bRxxY1LAVjzWJTomMlC/1P8AOvCsvxgL62Mpd0g== X-Received: by 2002:a17:902:6847:b0:1dc:8790:6824 with SMTP id f7-20020a170902684700b001dc87906824mr50051pln.15.1709250204830; Thu, 29 Feb 2024 15:43:24 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:8f17]) by smtp.gmail.com with ESMTPSA id e12-20020a17090301cc00b001d90a67e10bsm2081312plh.109.2024.02.29.15.43.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Feb 2024 15:43:24 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, torvalds@linux-foundation.org, brho@google.com, hannes@cmpxchg.org, lstoakes@gmail.com, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, boris.ostrovsky@oracle.com, sstabellini@kernel.org, jgross@suse.com, linux-mm@kvack.org, xen-devel@lists.xenproject.org, kernel-team@fb.com Subject: [PATCH v3 bpf-next 1/3] mm: Enforce VM_IOREMAP flag and range in ioremap_page_range. Date: Thu, 29 Feb 2024 15:43:14 -0800 Message-Id: <20240229234316.44409-2-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240229234316.44409-1-alexei.starovoitov@gmail.com> References: <20240229234316.44409-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 20CFC20008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ej4hf76ssqojths1fhstbi9pa8wg6hmb X-HE-Tag: 1709250207-894728 X-HE-Meta: U2FsdGVkX1+aRUEjD3feTabd3g+9ROgT0AeRr8YnvyoCQrQG+mMzax09QTDAQyQfExTwt6XQeiY8als2inX8gfWiqfrLty1i5nrIPJttlw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UndVQWHGTLJdKqeJB/RrLUoAPsVlaFioSVknM9/Fo0DCEQIlFqlE9RfoudJ1n7vY8dAXvep2tQchomATWqI2DTVpyuC6q5RRJ+pc+Vtza2GXII07svWwvWYAnrsHTNiKwvYUNZEkP6G7L6l+nYt/1aYtnN4n/7uxq97sMn2RTcFU2MMhfiPsxUkNxytCBH0wU3HvOHevH+Z/JvEOBTL+RzXWqrOM41YIT0cj/nHSNhLhMmYzosjROGViYKQ0U7dqGLunrlNZfsmJZoyWYLnbS+RCT4wll6n9Etuu0YOSe4y83gfT23ulA6fNTt60RjpNtAMJMBA9vquzEeEYJO6FhKFcAcN6a3Ttf4tyjdgNc7k8wUbPR4vEgFKwgFEwOKttNjunp7/LwMqYw0oK/L0KjLyebk+NBpIloghRgAgzvbG+Nbi+NtYXWz7bgIH+R/CHbZ7Lo0eBR3w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov There are various users of get_vm_area() + ioremap_page_range() APIs. Enforce that get_vm_area() was requested as VM_IOREMAP type and range passed to ioremap_page_range() matches created vm_area to avoid accidentally ioremap-ing into wrong address range. Reviewed-by: Christoph Hellwig Signed-off-by: Alexei Starovoitov --- mm/vmalloc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d12a17fc0c17..f42f98a127d5 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -307,8 +307,21 @@ static int vmap_range_noflush(unsigned long addr, unsigned long end, int ioremap_page_range(unsigned long addr, unsigned long end, phys_addr_t phys_addr, pgprot_t prot) { + struct vm_struct *area; int err; + area = find_vm_area((void *)addr); + if (!area || !(area->flags & VM_IOREMAP)) { + WARN_ONCE(1, "vm_area at addr %lx is not marked as VM_IOREMAP\n", addr); + return -EINVAL; + } + if (addr != (unsigned long)area->addr || + (void *)end != area->addr + get_vm_area_size(area)) { + WARN_ONCE(1, "ioremap request [%lx,%lx) doesn't match vm_area [%lx, %lx)\n", + addr, end, (long)area->addr, + (long)area->addr + get_vm_area_size(area)); + return -ERANGE; + } err = vmap_range_noflush(addr, end, phys_addr, pgprot_nx(prot), ioremap_max_page_shift); flush_cache_vmap(addr, end); From patchwork Thu Feb 29 23:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13577757 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 27C6AC54798 for ; Thu, 29 Feb 2024 23:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FB96B00B1; Thu, 29 Feb 2024 18:43:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E81F6B00B2; Thu, 29 Feb 2024 18:43:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 762E86B00B3; Thu, 29 Feb 2024 18:43:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 613AA6B00B1 for ; Thu, 29 Feb 2024 18:43:33 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 21FBA8041E for ; Thu, 29 Feb 2024 23:43:33 +0000 (UTC) X-FDA: 81846470706.07.8B16CC4 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf25.hostedemail.com (Postfix) with ESMTP id 7E77BA0009 for ; Thu, 29 Feb 2024 23:43:31 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xx06TLdG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709250211; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=zoqQb3w2QP0cOeCaDt+WydAeVy+Zx43vw0QahaRLcW+1gtQttRizRXE+9o0xJ1Lk/FZMWi abn+h76WtTmE6yZMNycmdct7TkX/gyrUzq3OKfqcKBdXmu619W7wtrOKGK1EIwJWUUYDkS bBvO4wj1PuLdvKAHbdq8yjL2iK1ILg8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xx06TLdG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709250211; a=rsa-sha256; cv=none; b=Gw2Tw6pp2MxD1kSj1s72fgKYNmFR+oyqOy3XaleyddHWgW8Uai4XLq6rX1P4ZYbzoddC0h b+JXclJUlgvvS9aV3+fsbrMkpqqmnuQAwFJfyfybT9noIcbmDJUVO1U3HJFrvn+NJo0oYd ungvl3quR1r6t0aIXzIBDrrwcEERaB0= Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3657c437835so4862385ab.2 for ; Thu, 29 Feb 2024 15:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709250210; x=1709855010; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=Xx06TLdGK0yl4P7DWL/cckhUVwqB7nZbDSx1MfCw3MNaJV5IevzHly0Dlx0/TrU5Be sR52T/ESxjdQroKzgMI5bt/3Wia9jbwip8y26ZwXbDKu/MPTLiztnLCvbv3HYT7Jr1EA LdmFdxr062wRS8yW5V0ajJ3ipmbuQXQ2AkOSbqtLQR/jiL1xR389AF+gzPxK6Bu5rPk9 IpiUKd5LnaUf7oZCsQC6eIdGU4nJCIbqPhORoROJ5AVJJn6v0EFYeX1MHds4nJVPoPEy t4siKHnakGRXCBcchS2tF0YVagWNvmbAFJP0ukPfve7Yx24LqrYX/wiHg6kwHqew7A8Z +yBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709250210; x=1709855010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=fBUctFhZkPoxg8VB7f14hEvIWb/8H+g2aZRSrod9L9mz53ySoJqj8YpzljPsTejW2g s1X3g6DK9ljZpQzXJVgYx2+naw7NHHoQsm2YZQys/dx/GVibPWJH3Z7SNt1IwfrJkZR3 jWS+apNyGsLG/4gpwTrn9LiOl69UXPF1EuHSbsZJ4/jRiXRTYpZKvy67mWdp1CWhWRom 1s3U+zcO9Dr2SYNKJscg+5vJGhSmrpAgWJ3E3K/d/6cBttfkYuvxHy5yCJ4QzsVqxmxi HK7vD4idY3aaufotKItyC6qRpQfXMcRgh4yhEGn9FfVWxlMw1Hi1cOmMi52ZXSxRVkpa xvtQ== X-Forwarded-Encrypted: i=1; AJvYcCWtATw8oFV4mdZJmvPDNa63sz6CmssWFUXfYdVyTbnCCzmCOHPU0X6xPrxZY0zkD57ipnhc4grL0eRvZ+rnAqY+nk4= X-Gm-Message-State: AOJu0YwMxdiNyFmTiHMpseM01OeH7+iGxWJv8MK1DEX0LZwkKval4jf9 PYqUfx4erumdl09QZDky40Pj8BuyCVZD7SuJCub7CgDxH6eZeaAs X-Google-Smtp-Source: AGHT+IEjOcNXmJRmdRJJTTrs5fHGw0wy4T92DO/fjxQ1ryFJYxgxzO1wRU4PulyZo16hmDAMpzbQcA== X-Received: by 2002:a05:6e02:148e:b0:365:a6a2:24b with SMTP id n14-20020a056e02148e00b00365a6a2024bmr273922ilk.17.1709250210665; Thu, 29 Feb 2024 15:43:30 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:8f17]) by smtp.gmail.com with ESMTPSA id r19-20020aa78453000000b006e4dad633e1sm1850278pfn.177.2024.02.29.15.43.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Feb 2024 15:43:30 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, torvalds@linux-foundation.org, brho@google.com, hannes@cmpxchg.org, lstoakes@gmail.com, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, boris.ostrovsky@oracle.com, sstabellini@kernel.org, jgross@suse.com, linux-mm@kvack.org, xen-devel@lists.xenproject.org, kernel-team@fb.com Subject: [PATCH v3 bpf-next 2/3] mm, xen: Separate xen use cases from ioremap. Date: Thu, 29 Feb 2024 15:43:15 -0800 Message-Id: <20240229234316.44409-3-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240229234316.44409-1-alexei.starovoitov@gmail.com> References: <20240229234316.44409-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7E77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SGOlANCklJv0/GUyMwqD9xDvgPEaNr5xYg8cD3ADgJJh058wMZuNrBgfhJI7kXK2lRZsP6vPebz6AzSVNzEbwpsih73KOctawTHdoA6fCBtK0k5z9CoI50PlSMdLYZ2YkYZ2XJF0f/A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov xen grant table and xenbus ring are not ioremap the way arch specific code is using it, so let's add VM_XEN flag to separate these use cases from VM_IOREMAP users. xen will not and should not be calling ioremap_page_range() on that range. /proc/vmallocinfo will print such regions as "xen" instead of "ioremap". Signed-off-by: Alexei Starovoitov --- arch/x86/xen/grant-table.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 2 +- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 7 +++++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c index 1e681bf62561..b816db0349c4 100644 --- a/arch/x86/xen/grant-table.c +++ b/arch/x86/xen/grant-table.c @@ -104,7 +104,7 @@ static int arch_gnttab_valloc(struct gnttab_vm_area *area, unsigned nr_frames) area->ptes = kmalloc_array(nr_frames, sizeof(*area->ptes), GFP_KERNEL); if (area->ptes == NULL) return -ENOMEM; - area->area = get_vm_area(PAGE_SIZE * nr_frames, VM_IOREMAP); + area->area = get_vm_area(PAGE_SIZE * nr_frames, VM_XEN); if (!area->area) goto out_free_ptes; if (apply_to_page_range(&init_mm, (unsigned long)area->area->addr, diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 32835b4b9bc5..b9c81a2d578b 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -758,7 +758,7 @@ static int xenbus_map_ring_pv(struct xenbus_device *dev, bool leaked = false; int err = -ENOMEM; - area = get_vm_area(XEN_PAGE_SIZE * nr_grefs, VM_IOREMAP); + area = get_vm_area(XEN_PAGE_SIZE * nr_grefs, VM_XEN); if (!area) return -ENOMEM; if (apply_to_page_range(&init_mm, (unsigned long)area->addr, diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c720be70c8dd..71075ece0ed2 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -28,6 +28,7 @@ struct iov_iter; /* in uio.h */ #define VM_FLUSH_RESET_PERMS 0x00000100 /* reset direct map and flush TLB on unmap, can't be freed in atomic context */ #define VM_MAP_PUT_PAGES 0x00000200 /* put pages and free array in vfree */ #define VM_ALLOW_HUGE_VMAP 0x00000400 /* Allow for huge pages on archs with HAVE_ARCH_HUGE_VMALLOC */ +#define VM_XEN 0x00000800 /* xen grant table and xenbus use cases */ #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \ !defined(CONFIG_KASAN_VMALLOC) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index f42f98a127d5..d53ece3f38ee 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3822,9 +3822,9 @@ long vread_iter(struct iov_iter *iter, const char *addr, size_t count) if (flags & VMAP_RAM) copied = vmap_ram_vread_iter(iter, addr, n, flags); - else if (!(vm && (vm->flags & VM_IOREMAP))) + else if (!(vm && (vm->flags & (VM_IOREMAP | VM_XEN)))) copied = aligned_vread_iter(iter, addr, n); - else /* IOREMAP area is treated as memory hole */ + else /* IOREMAP | XEN area is treated as memory hole */ copied = zero_iter(iter, n); addr += copied; @@ -4415,6 +4415,9 @@ static int s_show(struct seq_file *m, void *p) if (v->flags & VM_IOREMAP) seq_puts(m, " ioremap"); + if (v->flags & VM_XEN) + seq_puts(m, " xen"); + if (v->flags & VM_ALLOC) seq_puts(m, " vmalloc"); From patchwork Thu Feb 29 23:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13577758 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 35A9CC54798 for ; Thu, 29 Feb 2024 23:43:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAAA06B00B3; Thu, 29 Feb 2024 18:43:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B32386B00B4; Thu, 29 Feb 2024 18:43:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ABE56B00B5; Thu, 29 Feb 2024 18:43:37 -0500 (EST) 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 869486B00B3 for ; Thu, 29 Feb 2024 18:43:37 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 600981C0F7C for ; Thu, 29 Feb 2024 23:43:37 +0000 (UTC) X-FDA: 81846470874.14.84A544A Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf24.hostedemail.com (Postfix) with ESMTP id 9AB7E180012 for ; Thu, 29 Feb 2024 23:43:35 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VsVfDCbZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709250215; a=rsa-sha256; cv=none; b=YfqAnhOIolZ1qgzbz/HfcEEVXmn834BVRjbo82D3ds+ASUl4RQQVBSkOEnP6ot9BD7+Shd q7rATdU+PEslHp7GGYIwZpp2tgKlHLHfyoXXXx5Orr5OuNB+R7aSMPOe+s5XA5jQ4lKFO0 A3LsLxX06/RFrqBsnwnMh8sjutxUlsw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VsVfDCbZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709250215; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GGmuzG0BuzfpsyKgKDkTT6Enikl3D6AjMcJQdJLpWcI=; b=ZYgGZ/Fat74JrtD6AAxsPvVqF+KBsadu/XeeXUL7jDAGSc5c7h4pgrwxaksBkuk4eb8hDz wEMvjlAkH5Lc9uqilPSJ3FnQ6nfAyaCH3xhY6e+ywEH6ss/Zi0f4ngRjwIOz8tD5JE8+iF Xy6Zy9Gk6iUjPgnoWuJrYBNe5SnN+zQ= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e57a3bf411so940755b3a.0 for ; Thu, 29 Feb 2024 15:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709250214; x=1709855014; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GGmuzG0BuzfpsyKgKDkTT6Enikl3D6AjMcJQdJLpWcI=; b=VsVfDCbZurLOqHVhRwAg7bnuniokJg8wDNHIajb9LexO4oC1Fb8ZyYGjhR/xvqcb5d 5zcqPKYsYfkoUNpQzLjnA+IHW8FBtZsTzzwr1gJ0fzSfZgOzFpGp75I97tjgONYXpbXU sl14rbXYy7xZwXxiJ4xjAThAoTAcoiJmwqkUS10Iscz2ZDppPuOk6QAotCVD/JF8HdEu K0U31ue2JZjkS1b5317vNuLbIiyQk2HnhSdFXPrR2mivaezVi+hYsylo9tK6F8tBp26S /PKq9rL/0AP+NVSqvlTecD69rVYvXgCCKYVOAFgGf5ER54wpf6vjQJvOmg9m1MyApYf2 QbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709250214; x=1709855014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GGmuzG0BuzfpsyKgKDkTT6Enikl3D6AjMcJQdJLpWcI=; b=vaZ1H8AA0FG2hUyB/jGBU8ePRtyc3rqWJOrwgveSHthmn09Tj/eIgcf6uTtuPvMKMV BWGFOyFpDFyfjlgd+SiVcbU+3EwtNpRtz0rN2Y9zJFUEs6cdTdXwTspvn973ic/d9uAg gRDMYqw8RI5o3fc4tzKqfFQFyUv+sdlet9vAdupfD8HaGGSsl9W8j9UVxd4uiK7PIs4w ES1MnhW2qUPJ0NA/12V0GDO39GIjzneuO3QV8qJmQ+EUADgSym5kLC0JO4D1JJwGT36d HruSbvmnpIjkvstxwzloGEdSqNctlhO3KJ9U3So6/Mcuue7Dow2uP7bSERTTC5BLyVrK 63Ag== X-Forwarded-Encrypted: i=1; AJvYcCUl+B754ON3p3zBxX6ijGZHWEQg3pjxg4PVE6NIYCerMkHwpJzUoqVYHRG/JEJMyo/2aQLUkHFs/GkF6gsD4qsQVzw= X-Gm-Message-State: AOJu0YzpxWIeaxfWQcZOFnZmXiNqWLxgNeJBaNfI+X6sjKtRAlzyZokU 4Z68g7LnCZJpveP9MenejMtBR1zgv+tz3OEapoM6yPPpAIs5gqI2 X-Google-Smtp-Source: AGHT+IHI1rET3Z0/K8864m6GkWZwYbKsdcM+bbhi3ZQPOLm9p/XFzMkvrTJzDnJ+bGJeFJuwnOye6Q== X-Received: by 2002:a05:6a00:92a2:b0:6e4:84db:e30e with SMTP id jw34-20020a056a0092a200b006e484dbe30emr186581pfb.32.1709250214399; Thu, 29 Feb 2024 15:43:34 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:8f17]) by smtp.gmail.com with ESMTPSA id r8-20020aa79ec8000000b006e50cedb59bsm1850608pfq.16.2024.02.29.15.43.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Feb 2024 15:43:33 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, torvalds@linux-foundation.org, brho@google.com, hannes@cmpxchg.org, lstoakes@gmail.com, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, boris.ostrovsky@oracle.com, sstabellini@kernel.org, jgross@suse.com, linux-mm@kvack.org, xen-devel@lists.xenproject.org, kernel-team@fb.com Subject: [PATCH v3 bpf-next 3/3] mm: Introduce VM_SPARSE kind and vm_area_[un]map_pages(). Date: Thu, 29 Feb 2024 15:43:16 -0800 Message-Id: <20240229234316.44409-4-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240229234316.44409-1-alexei.starovoitov@gmail.com> References: <20240229234316.44409-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9AB7E180012 X-Stat-Signature: x3z8r3wuyybeo4s8te845q7wdsmxrtha X-HE-Tag: 1709250215-937003 X-HE-Meta: U2FsdGVkX1/l5IzBrEpcrfZSb2+T7qmwUpp4W5p1wlNGU+WvtRjthBJ9A1xPimefhxGwuN7Zcnh5I0M6cd0Sqeq/yzLi/oWQ9nsKrw5sYTx6Joj7ugT4Cdpun5dc6n4zSp9l93U7V6aj5QC91eBRiLIS8dNPN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kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov vmap/vmalloc APIs are used to map a set of pages into contiguous kernel virtual space. get_vm_area() with appropriate flag is used to request an area of kernel address range. It'se used for vmalloc, vmap, ioremap, xen use cases. - vmalloc use case dominates the usage. Such vm areas have VM_ALLOC flag. - the areas created by vmap() function should be tagged with VM_MAP. - ioremap areas are tagged with VM_IOREMAP. - xen use cases are VM_XEN. BPF would like to extend the vmap API to implement a lazily-populated sparse, yet contiguous kernel virtual space. Introduce VM_SPARSE flag and vm_area_map_pages(area, start_addr, count, pages) API to map a set of pages within a given area. It has the same sanity checks as vmap() does. It also checks that get_vm_area() was created with VM_SPARSE flag which identifies such areas in /proc/vmallocinfo and returns zero pages on read through /proc/kcore. The next commits will introduce bpf_arena which is a sparsely populated shared memory region between bpf program and user space process. It will map privately-managed pages into a sparse vm area with the following steps: // request virtual memory region during bpf prog verification area = get_vm_area(area_size, VM_SPARSE); // on demand vm_area_map_pages(area, kaddr, kend, pages); vm_area_unmap_pages(area, kaddr, kend); // after bpf program is detached and unloaded free_vm_area(area); Signed-off-by: Alexei Starovoitov --- include/linux/vmalloc.h | 5 ++++ mm/vmalloc.c | 59 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 71075ece0ed2..dfbcfb9f9a08 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -29,6 +29,7 @@ struct iov_iter; /* in uio.h */ #define VM_MAP_PUT_PAGES 0x00000200 /* put pages and free array in vfree */ #define VM_ALLOW_HUGE_VMAP 0x00000400 /* Allow for huge pages on archs with HAVE_ARCH_HUGE_VMALLOC */ #define VM_XEN 0x00000800 /* xen grant table and xenbus use cases */ +#define VM_SPARSE 0x00001000 /* sparse vm_area. not all pages are present. */ #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \ !defined(CONFIG_KASAN_VMALLOC) @@ -233,6 +234,10 @@ static inline bool is_vm_area_hugepages(const void *addr) } #ifdef CONFIG_MMU +int vm_area_map_pages(struct vm_struct *area, unsigned long start, + unsigned long end, struct page **pages); +void vm_area_unmap_pages(struct vm_struct *area, unsigned long start, + unsigned long end); void vunmap_range(unsigned long addr, unsigned long end); static inline void set_vm_flush_reset_perms(void *addr) { diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d53ece3f38ee..dae98b1f78a8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -648,6 +648,58 @@ static int vmap_pages_range(unsigned long addr, unsigned long end, return err; } +static int check_sparse_vm_area(struct vm_struct *area, unsigned long start, + unsigned long end) +{ + might_sleep(); + if (WARN_ON_ONCE(area->flags & VM_FLUSH_RESET_PERMS)) + return -EINVAL; + if (WARN_ON_ONCE(area->flags & VM_NO_GUARD)) + return -EINVAL; + if (WARN_ON_ONCE(!(area->flags & VM_SPARSE))) + return -EINVAL; + if ((end - start) >> PAGE_SHIFT > totalram_pages()) + return -E2BIG; + if (start < (unsigned long)area->addr || + (void *)end > area->addr + get_vm_area_size(area)) + return -ERANGE; + return 0; +} + +/** + * vm_area_map_pages - map pages inside given sparse vm_area + * @area: vm_area + * @start: start address inside vm_area + * @end: end address inside vm_area + * @pages: pages to map (always PAGE_SIZE pages) + */ +int vm_area_map_pages(struct vm_struct *area, unsigned long start, + unsigned long end, struct page **pages) +{ + int err; + + err = check_sparse_vm_area(area, start, end); + if (err) + return err; + + return vmap_pages_range(start, end, PAGE_KERNEL, pages, PAGE_SHIFT); +} + +/** + * vm_area_unmap_pages - unmap pages inside given sparse vm_area + * @area: vm_area + * @start: start address inside vm_area + * @end: end address inside vm_area + */ +void vm_area_unmap_pages(struct vm_struct *area, unsigned long start, + unsigned long end) +{ + if (check_sparse_vm_area(area, start, end)) + return; + + vunmap_range(start, end); +} + int is_vmalloc_or_module_addr(const void *x) { /* @@ -3822,9 +3874,9 @@ long vread_iter(struct iov_iter *iter, const char *addr, size_t count) if (flags & VMAP_RAM) copied = vmap_ram_vread_iter(iter, addr, n, flags); - else if (!(vm && (vm->flags & (VM_IOREMAP | VM_XEN)))) + else if (!(vm && (vm->flags & (VM_IOREMAP | VM_XEN | VM_SPARSE)))) copied = aligned_vread_iter(iter, addr, n); - else /* IOREMAP | XEN area is treated as memory hole */ + else /* IOREMAP | XEN | SPARSE area is treated as memory hole */ copied = zero_iter(iter, n); addr += copied; @@ -4418,6 +4470,9 @@ static int s_show(struct seq_file *m, void *p) if (v->flags & VM_XEN) seq_puts(m, " xen"); + if (v->flags & VM_SPARSE) + seq_puts(m, " sparse"); + if (v->flags & VM_ALLOC) seq_puts(m, " vmalloc");