From patchwork Fri Feb 23 23:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13570152 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 E7882C5478C for ; Fri, 23 Feb 2024 23:57:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C7CB6B0075; Fri, 23 Feb 2024 18:57:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34D546B007B; Fri, 23 Feb 2024 18:57:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C6B46B007D; Fri, 23 Feb 2024 18:57:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 08D516B0075 for ; Fri, 23 Feb 2024 18:57:36 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AEEE1C124F for ; Fri, 23 Feb 2024 23:57:35 +0000 (UTC) X-FDA: 81824733270.11.07E7FE8 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf17.hostedemail.com (Postfix) with ESMTP id 1382B40012 for ; Fri, 23 Feb 2024 23:57:33 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FoCZpFUg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.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=1708732654; 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:references:dkim-signature; bh=DSYW/f6ddyBB9WtPg1xLnsJlpquY1/ikpKTyYScqzh0=; b=13Qw9d8gL857/DCK3JY+t/eM1oe/taQv0vwDcL6xjtz53G49m4PNOaraoYt0KHoySXSa+C pmi54DRA1lyqG4qEOmBJ+uk2lSGfrZOX4vHPVB9L2dGvdCut/al79fVMRu02gKfuEg44rv QWsSEAkkb/U3W7y3vK8mRdlLbIOz12M= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FoCZpFUg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.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=1708732654; a=rsa-sha256; cv=none; b=j4tVlf6bodsNBZ7O7ZHgg3havemSksLQadWo9k9KZyL7wdLM3wGjX6iIO7sf5b9AMo2Uze q0I4QVoQQmyCo36putJyHN4sKj2J+pZ3vDnSgPLNNzx0+vE5TYZlolywzDwapZizlw6OHZ tJyhhLgpY2a8oPfg0eI8mwBz0dt3XMw= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so6029735ad.3 for ; Fri, 23 Feb 2024 15:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708732653; x=1709337453; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DSYW/f6ddyBB9WtPg1xLnsJlpquY1/ikpKTyYScqzh0=; b=FoCZpFUgge4ioVdN7q+q7tXX7Y1AXNJJIo5wIXiu8edshqbgavkbVJELaDGBTdyvSn 6m0Gw6aJtfLUZ9SHajO8UpzcPuTuim8OD4rs2occtxVFTKLtTYmEnxWg8C9eLXwUzi0O UI8YNYuevkAas/aQOsatn7k8U2cSQe5Do5QaG2SWG2D6fdQj7YD7RxW6eYsGXEgWuQpS wrrBaIvlvQaod8ZmfX7aKVTPE4aU7jHWfu687DEoWHeTLNKDkEGNe4S8PAFuvXElWW/v oOxbq4heqGSU7zhuWwnlt7i5WjZXA2AuSk9s5iX2nyowaYvEUohJD8nz2G3AcczhcMnl 0OMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708732653; x=1709337453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DSYW/f6ddyBB9WtPg1xLnsJlpquY1/ikpKTyYScqzh0=; b=EVCKhMXXrmWlF/ZXjLAB/9i3xwCX58HMjb5q97XvaQw4VjYhUwlWCxvIlb6nnSo++c m3pB5jHXf0PPHkf7OUls9/2HsGLvLx9lnoGVo0IZi0RiThSig+H1TfursgIc3243lT+r hvHHcZmXIHzQG9EfUyENz81ZAGf+rip6X27ptPJXaeu9gR3wrj/vGS4aJApH4/RSSv9/ /FMBbyrBGNL0iCpL00B4U9ATTu6YdWbleVGx5YHY7sKEiyBPUPLgVtNOtB5wYnM6hwz9 vRxh3cjKS7YnG9wCJpAV9iVubFzbGK1lMa470h30UEG2fFI5fXruj/P3QpOFySpZWKv8 TAtw== X-Forwarded-Encrypted: i=1; AJvYcCX02Rwz0j/6ShlW9kv6zadHc1a6NT8wLwgbT96MuZvtHSk+3xO/RwTh2DY6ESgGc83SsraIZy2vEVHxq+of3YOxb6c= X-Gm-Message-State: AOJu0YwENtO1efwMVUjk7JEBtEticQbAoHU/yglCPA7rrk15hNYMuJQr 6lqYOxQ7/1nKmMT9vWx6lBTR53g9/XPAP0ypbIPBs1e54euGdq74 X-Google-Smtp-Source: AGHT+IF03Ip9HN7hOBgclqSMTFdHG7TNdTZF9AvtgtNN5+5+EnBr4r8zdxXO0SElDm498lBK65E9Ag== X-Received: by 2002:a17:902:d2c4:b0:1db:5213:222 with SMTP id n4-20020a170902d2c400b001db52130222mr1899819plc.5.1708732652680; Fri, 23 Feb 2024 15:57:32 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::4:45de]) by smtp.gmail.com with ESMTPSA id o16-20020a17090323d000b001d9edac54b1sm12313162plh.171.2024.02.23.15.57.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 15:57:31 -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 v2 bpf-next 0/3] mm: Cleanup and identify various users of kernel virtual address space Date: Fri, 23 Feb 2024 15:57:25 -0800 Message-Id: <20240223235728.13981-1-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1382B40012 X-Stat-Signature: sq4nk3s7g84bxt19o9k7c7c9ph69er7f X-Rspam-User: X-HE-Tag: 1708732653-940536 X-HE-Meta: U2FsdGVkX19H0zBdINvZiS/Jv7DzxCzH+bFVLz0huibfm1S4QAU9QcO3iHRZU957nC8UzULW6YBPAh4S5A8ueDn7VJ6yjNymk4d2VKy28bliC5/3tRZ8xUZ4rrnrJ5+Gex1HPknBJ63N18+lrfS+iPGqi61010CARkfUI0ZANJWeta3u8+MtIp0M+QDC2n+gsJ7wSgN1iAdfFiwhb7sK7sWZPXIbjYmex6mvkaCYPprS+L3TdKp8bzVhBWOvbPDlb/aEnTwx5LgQviBxN+FiOhnUc80EDiWmmatdvnT3eQfxjKOmqRgLmPvtA4yQDi34gqbXMH/jNKPakhRSi9lKmZ6wTd4T9XWn4YckVtsfG6Fzd8EOf/Xb7+UdoN1T9F8BZiqe1OnCt0Kv6S5JjA5cpXCamEk1xGyu/sHJxoTqobCrD/KtTeKuBPp4G09oRQLNEE8+83cSWTnf7h4dZ4USLUtloUIIs+riYSIoRhgFxEcSEJQlO0gucaFxvy0dUREcUZIx2xeYHtZXvQTMCnCWV635kVF1w3RXij5gtRhp4JPuCFPYeHpFfN/ZPx2mrAHDxxIADbQOGOsG2FSW4yAojF8VDhRB2/Q4Qbdac2yE//899vtUSyIy5MUt69BVCTDVqxjDnQ1kj8dqaOs+qWw9WdPyEJ6arZR3Ct0DMu8XJW1mI+C9/ZdflUOW3poelc9fP16o/UUyZe6Rn+pC1SnLSkqUa9B4hE2YWMk1UmEtW5YJb3YFABgGCbssQYCwhZHJ4jXogu1urqWQrCrDyCPt0bjbEsSnazB8UOmPxVjJlZ1ummUzFaW0Aqbmga5megf+72v+o91B4YYpmw5c6TaZv0GXNEj8kGcLkWWOqXcPX2pyxTDicsGW/oCYhd641NFUH0PbXNpyLRZZHr3LGIYgoHE+nUnwzRn5hxj1DEOTrRKCLapKi8B9BpD2rnlSUxKtdC2jRBVUYYv7j586sO8 pJiZO9D/ IH/DSN4Lqu0mUsj6NEyNpVMTJQO+bXvkUfqLCJvgNDOeTDQkltXelbXnZJfECVWOs7H4wlgves7+wbZxVCGvwnWnntMdcYWkTnAKz0WuE9QVyqqr1Q8St1HvDEdrtuNQVR8Fl2TkAmr8h7LhhEiup5eAkRA== 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 kernel virtual address space: vmalloc, vmap, ioremap, xen. - vmalloc use case dominates the usage. Such vm areas have VM_ALLOC flag and these areas are treated differently by KASAN. - the areas created by vmap() function should be tagged with VM_MAP (as majority of the users do). - ioremap areas are tagged with VM_IOREMAP and vm area start is aligned to size of the area unlike vmalloc/vmap. - there is also xen usage that is marked as VM_IOREMAP, but it doesn't call ioremap_page_range() unlike all other VM_IOREMAP users. To clean this up: 1. Enforce that ioremap_page_range() checks the range and VM_IOREMAP flag. 2. Introduce VM_XEN flag to separate xen us cases from ioremap. In addition BPF would like to reserve regions of kernel virtual address space and populate it lazily, similar to xen use cases. For that reason, introduce VM_SPARSE flag and vm_area_[un]map_pages() helpers to populate this sparse area. In the end the /proc/vmallocinfo will show "vmalloc" "vmap" "ioremap" "xen" "sparse" categories for different kinds of address regions. ioremap, xen, sparse will return zero when dumped through /proc/kcore Alexei Starovoitov (3): mm: Enforce VM_IOREMAP flag and range in ioremap_page_range. mm, xen: Separate xen use cases from ioremap. mm: Introduce VM_SPARSE kind and vm_area_[un]map_pages(). arch/x86/xen/grant-table.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 2 +- include/linux/vmalloc.h | 5 +++ mm/vmalloc.c | 71 +++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 4 deletions(-)