Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4817364imb; Thu, 7 Mar 2019 00:59:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzNeEmS2DlIMcwpNNQ47d2FjNuDyxG/+QFHTX0MTlK/C1eZCwMyLrH/wPKZ7LBdid/BiazN X-Received: by 2002:a17:902:681:: with SMTP id 1mr11721327plh.185.1551949181036; Thu, 07 Mar 2019 00:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551949181; cv=none; d=google.com; s=arc-20160816; b=U5MLs77FcrS0SamCongFOpUNICy4pga6/OEy5Fo04Rdr8TyaXHVQ/ZWa9qRg0HD+IA KZmUxzlOnwl8h7HOaMkdrOJp0NeFXdifJVQ6xpkcyPfDg/RGD/eqcKrOUbtgCkvZW0kW sS/lNgkR14PLlqM5cooy3JKNV+18E7F4T0clczAF6NXkf7nlx8o8ylIiuv9aicbVshUI 9TmucrxuQdgcF3fMSLCaLPCgZnG4Vbfnkngqtxq1/CH1yRq97xGDR0/wFBNChYYYur6x kjh4+VzYQNprU99cRMuFHIxPB5/ytkB9vEG1q+ARMwIvFkbZB8eA5TLPQjudjlVKLYxo a46w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=kzfE04vMH7gLJVW787Hjtm/7lSGeh2p+9g333/HMtVs=; b=ngMJaOlzeC7hY1kiBlgl8F65ausjAsQicdsfWBplJEvVwMSeF0501OQbde3jbiK/7w I+im1ahOdNOkmrN1XSN+Gqi/ujH5djPpzOnQElo7kc61zaGsTyrTpHD3/TMsSe+uQk3J DarWh/s8Pw0nkEoYwG/w3HpARwpouNG4tpVAqhFUP8wt6c58txhnpSAdLWNx7rjfO69n /lpJy2SlfPHrAJMv2/6bYQf3m0rHospBbNTu1br+dJeeX6sbUZIvBFw9AHMXwWuY2hg5 hxH3pAkC8wl/JIX8SPiZvOjQySq8LpA+/3fHb63atu2NvopppeIfIH9hj+iVwiB9z9ot 0qbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si3463152pgd.106.2019.03.07.00.59.25; Thu, 07 Mar 2019 00:59:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbfCGI6i (ORCPT + 99 others); Thu, 7 Mar 2019 03:58:38 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:34342 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfCGI6h (ORCPT ); Thu, 7 Mar 2019 03:58:37 -0500 Received: by mail-ua1-f67.google.com with SMTP id a42so9950505uad.1; Thu, 07 Mar 2019 00:58:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kzfE04vMH7gLJVW787Hjtm/7lSGeh2p+9g333/HMtVs=; b=mlcCQ9nizPyltaPtWgfxxkAZk4bUhlYWDPgZbec4d6RgcNAhCno+8tG1cYtUeuRCgQ bHuwmsX9a8tcmopd6tXHaiP6GIJyOX1mdox1EZ1g2U0hKJvHzyC/xIKM2w9ySul9fGvn TJAy+sOdO58/MWhol2nQ8Pk/r0K8DwNvuGtI/0zEgy9m6qsIpj8vgX3LxDnnfCfcL0rP kywgI26knh8fcer9A3wzh9mDqv7OFHIM4kezJgnkWS1mQSUAhhiOgua4cZ4HNOFmXZF5 +qIg5/8JUa3MT//HNqVLA5uf43KT47tpnUV/pKJjl7a8dE+T6Z2r3tFAOviY7IufD/OH LKvQ== X-Gm-Message-State: APjAAAX1E2/9UhylZZ2edTLM05ndzSSZEKpKLHI5qVWAoGGYjBiI3RaV 2yafkfkYpiXVdSSHXW3gJeZq/mRIbMp2D8zwSUM= X-Received: by 2002:ab0:6419:: with SMTP id x25mr6308005uao.20.1551949115911; Thu, 07 Mar 2019 00:58:35 -0800 (PST) MIME-Version: 1.0 References: <20190301160856.129678-1-joel@joelfernandes.org> In-Reply-To: <20190301160856.129678-1-joel@joelfernandes.org> From: Geert Uytterhoeven Date: Thu, 7 Mar 2019 09:58:24 +0100 Message-ID: Subject: Re: [PATCH v4 1/2] Provide in-kernel headers for making it easy to extend the kernel To: "Joel Fernandes (Google)" Cc: Linux Kernel Mailing List , Andrew Morton , Alexei Starovoitov , atishp04@gmail.com, dancol@google.com, Dan Williams , Dietmar Eggemann , Greg KH , Guenter Roeck , Jonathan Corbet , karim.yaghmour@opersys.com, Kees Cook , Android Kernel Team , "open list:DOCUMENTATION" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-trace-devel@vger.kernel.org, Manoj Rao , Masahiro Yamada , Masami Hiramatsu , qais.yousef@arm.com, Randy Dunlap , Steven Rostedt , Shuah Khan , yhs@fb.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joel, On Fri, Mar 1, 2019 at 5:10 PM Joel Fernandes (Google) wrote: > Introduce in-kernel headers and other artifacts which are made available > as an archive through proc (/proc/kheaders.tar.xz file). This archive makes > it possible to build kernel modules, run eBPF programs, and other > tracing programs that need to extend the kernel for tracing purposes > without any dependency on the file system having headers and build > artifacts. > > On Android and embedded systems, it is common to switch kernels but not > have kernel headers available on the file system. Raw kernel headers > also cannot be copied into the filesystem like they can be on other > distros, due to licensing and other issues. There's no linux-headers > package on Android. Further once a different kernel is booted, any > headers stored on the file system will no longer be useful. By storing > the headers as a compressed archive within the kernel, we can avoid these > issues that have been a hindrance for a long time. > > The feature is also buildable as a module just in case the user desires > it not being part of the kernel image. This makes it possible to load > and unload the headers on demand. A tracing program, or a kernel module > builder can load the module, do its operations, and then unload the > module to save kernel memory. The total memory needed is 3.8MB. > > The code to read the headers is based on /proc/config.gz code and uses > the same technique to embed the headers. > > To build a module, the below steps have been tested on an x86 machine: > modprobe kheaders > rm -rf $HOME/headers > mkdir -p $HOME/headers > tar -xvf /proc/kheaders.tar.xz -C $HOME/headers >/dev/null > cd my-kernel-module > make -C $HOME/headers M=$(pwd) modules > rmmod kheaders As the usage pattern will be accessing the individual files, what about implementing a file system that provides read-only access to the internal kheaders archive? mount kheaders $HOME/headers -t kheaders Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds