From patchwork Thu Feb 29 23:43:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13577755 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 41550C48BF6 for ; Thu, 29 Feb 2024 23:43:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0CF06B0074; Thu, 29 Feb 2024 18:43:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABC796B00AD; Thu, 29 Feb 2024 18:43:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 936856B008A; Thu, 29 Feb 2024 18:43:24 -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 78E9F6B00AD for ; Thu, 29 Feb 2024 18:43:24 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3B94D14042D for ; Thu, 29 Feb 2024 23:43:24 +0000 (UTC) X-FDA: 81846470328.04.CAE0B2A Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf28.hostedemail.com (Postfix) with ESMTP id 70B60C0002 for ; Thu, 29 Feb 2024 23:43:22 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hH6POHJM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.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=1709250202; 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=NzHHSXtSLrv/NknHpxtBThbqiIeWhWk4Z2HCRi70who=; b=3ceCZYwbAZWtZwfVMoiTutOdfi4RFi4wYyprft0vpSfDDOsBwItXueDfw6pvsoIRA3cahP L/H9wsKl8RZ6xdVY4xyMUJMfpS9EoqBzM/rxSF6z+w5znoLRAz5WExh/DNOYU0tyIHYPdV DFnoCAVyrd9gjDzxc2Yb2e2XUxzU8zw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hH6POHJM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709250202; a=rsa-sha256; cv=none; b=1sgIG+P3vSAtURnz4pL7BYcSXys3NXoqapl3CbeD3gG9WgH4vxUDn81v74TaITmLi6Zwiu xbKsqcWbekK8+ru774MkMC/npHF6tToW3fP7027joqQnLuGq+HMWfU0y3kRNONKRXCJHoc Y/8tz564MlrBsUJsRPLsuH61wiItv5c= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d95d67ff45so13073165ad.2 for ; Thu, 29 Feb 2024 15:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709250201; x=1709855001; 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=NzHHSXtSLrv/NknHpxtBThbqiIeWhWk4Z2HCRi70who=; b=hH6POHJM+787+nFZwYAWUeCaRX9lMDRKYWqcDhIiI80Yq+IgKNmLPQgvQ+XMX22y7N ro8eu27rehE/ZKa4d+lsPHPpcUdF/qsjOxKN1iJxeu7yM8+QfxJuzymEEWP54RRskvpx SJJ7+4iRbrKe0gY3dpcMIUPvzGie7XttRYmAhy5iZVljaPI/mPI24YCSzdWVuuBjPs6G 9M0JsQzH2BYgpbYby0TAy/NBWAFB5e0y1UBbhWRaQa0H/YfqLrHX0IV3jJxxEWn5KmmB Rzuz2Fb2L7K1kMR2uS6ksg34FmMf7mV7n/v1EsbHsziYcfSQDNmO8Noqo14aL0yLHKJ3 6Dgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709250201; x=1709855001; 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=NzHHSXtSLrv/NknHpxtBThbqiIeWhWk4Z2HCRi70who=; b=n76tsI/GG+BULxb6TKyo2cY3+mbCLj/uW91TfC7LwBECqekyGPNvXkMCSzOOoAcTr0 jWfsH6mkNNmkAfFsZ4V3WdH9jeHRRg6hjAs7oD49pOl66vyn5DtcsnuYP3sjPQDVoPNG iaaxgueuSMzvoQrrXpoY5NNQ9B3LElJMX68wFYhTfJwgyZkv/WvkF5zmq8Js+gRj57O6 GTuVWUCxi3ozLpgVAUPQpUiUqXvXzUa6rXHZkSedTYDCgJBi/6gWyZINu9Ng8TIM7HzQ fSGDqYLPsf7HtJSFxfrApOYAogbmFKFJuOiGbAR0dNz4EPihEEl6f/e7N+fohkXVd4ZO ZUkg== X-Forwarded-Encrypted: i=1; AJvYcCXwdN3grqbrSwe/gVUtmPn5bYC1pMXnghjz/gSng3jEG1rn23AMHs2L2d9fNr6Dv8ChFgpjW0e0kBoTRwnldmnotk0= X-Gm-Message-State: AOJu0YzeO4uh81vw6hmJelvrM8xthST8CiZpu+eDhp+UKpFT3EO+AXol qL02H0cRl9I5OaCChhtXK2BQRuSSsl9dPg7ajSvosewIsAhAvMPT X-Google-Smtp-Source: AGHT+IGfl0YdKr5QO4H+FovdTc3eTEo8Q94QPX7tglxTnGBDlmv4twi/rgWyLSio1iEhhbNejBslzA== X-Received: by 2002:a17:902:d511:b0:1db:be69:d037 with SMTP id b17-20020a170902d51100b001dbbe69d037mr22315plg.46.1709250201120; Thu, 29 Feb 2024 15:43:21 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:8f17]) by smtp.gmail.com with ESMTPSA id l8-20020a170903120800b001dcc129cc2esm2079055plh.60.2024.02.29.15.43.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Feb 2024 15:43:20 -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 0/3] mm: Cleanup and identify various users of kernel virtual address space Date: Thu, 29 Feb 2024 15:43:13 -0800 Message-Id: <20240229234316.44409-1-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 X-Rspamd-Queue-Id: 70B60C0002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: qkayrasg78rttj5ttza1j78yd7zirppc X-HE-Tag: 1709250202-981089 X-HE-Meta: U2FsdGVkX1/A8gDwqfvXcnXj2Csta3RvMUtztbdgecjWJLmyO3lmzeBiWSkbSNTxiZX3P3WS13EnDnCi/oKysTF655GfC/RzSd2zuwTXbXXqBKFDepMPfuXlRkFlS0qgVsc8yOZZHyLMWnIyA3sn5yEokPQYQNqCl/cZaU6OYgcmyvGDiyvHyXjny2d5TadTdsfi+XXponq+Q/Al1JAaZdigkkYIP7sEMioQFUAtsmLLWTdiH5cPECZ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FvdLFaATh8EzaJqsaPbDS9yu48qBiaZSQKJ6snOsesy52DUV7OQVklINxJynYLnpxeLglum/K9VOFzLuO3tSk0OntBK9xJfimbQi6gsu7C26hD5nCijoVICUmnRRFNYBJw3KuMZfxdZzFZGj84EMcIXG9QUdSyyW+tsdmkwTrzcIi2m/gzT1hFuUUM= 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 v2 -> v3 - added Christoph's reviewed-by to patch 1 - cap commit log lines to 75 chars - factored out common checks in patch 3 into helper - made vm_area_unmap_pages() return void 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 | 6 +++ mm/vmalloc.c | 75 +++++++++++++++++++++++++++++- 4 files changed, 81 insertions(+), 4 deletions(-)