Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp48147imb; Thu, 28 Feb 2019 15:35:28 -0800 (PST) X-Google-Smtp-Source: APXvYqw6cz5ZVvq3owTKY694N4s3dAE4X6XIaFdlsGe/TFTFwc2bFT2P+CVco6ehLZd+rplh4kvR X-Received: by 2002:a63:e14e:: with SMTP id h14mr1735043pgk.184.1551396928300; Thu, 28 Feb 2019 15:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551396928; cv=none; d=google.com; s=arc-20160816; b=VAkCOEAJVYeKiKi+cfMcgHmzMT7pP+CJ0sGRLwTmT2gwZs5x+7yy2+aYvxXOpxnxWp bBy7K30X9eyucK8zbV10FKZ/hlPytqiyvfi7or5lJLrcpBqfBeQXiiSd02eoFXwUOcyS Yjv57Ok5/KS/tkIUHQo+zFPCy7UTGuYM/j1sA0sb+ExJXaEN/OId08OyQk1y9Wzc1rB2 +R/OBxdb+QYwK73bTaukpjB28scRYiEuC6wKAL0xspCx7F+qM8WcOVkpN/+9Aa8tyRVu GecXnQFhcg7u/QsnqfHlDrvgWT1IbVf1Ir4VIggYVHctYeRRHV5wGeT2fGWS0nS9woYA U4LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xWDbgPyPORkCT+/xgiItSx7wHOtxmHnj4rSzLgtTLKc=; b=QhMEpQuELkDUjy3wcdRX71E/kAkYQJjF76XHDdlZVBMuX0Dck150s73PtGvgVlV7C8 VD/TuB24N/xEQ3KryBx/VGn/sXBog9REruZGifDXJmFjMoaY9sdheUM0g+keYxGYodKc COJWxtY9x5792/BCqRrd9adYEb47rX9sBPBOQT2K7QtRizxeMgiMr3XK9+crGkoww73/ aB2qJsqyxWz4ppHRctrPqyr4fbOcXDJITbb8JBx64KeDDeo1WaCfdtKnzcORFVAF9Mj3 UwyrNAk/HaU1ASAGiqwpMJd4RHZQ1bc36nq4ENhOZ3OCT/4TBJaYXEYZwHRIJpqEONhD LkBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=G1RQ+ECQ; 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 h18si18581991pgj.479.2019.02.28.15.35.12; Thu, 28 Feb 2019 15:35:28 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=G1RQ+ECQ; 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 S1731039AbfB1X1z (ORCPT + 99 others); Thu, 28 Feb 2019 18:27:55 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33642 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729374AbfB1X1y (ORCPT ); Thu, 28 Feb 2019 18:27:54 -0500 Received: by mail-qt1-f193.google.com with SMTP id z39so25754334qtz.0 for ; Thu, 28 Feb 2019 15:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xWDbgPyPORkCT+/xgiItSx7wHOtxmHnj4rSzLgtTLKc=; b=G1RQ+ECQeMr60kO4r1ZkhYD+3Ntx/+zn5QM6zXYoPKZ1+Ypta9xmQK7xgJ8MqBSAnz 7096XDsMJfXisgLXhRMSwWz7wTTlyRPys+wGUrVghyI5CG2fHkhMGoZi5R+9MisQLz5C 1ypSB6uaLK0iR3hZqBgOY10fRnfgMBqfIBIG4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xWDbgPyPORkCT+/xgiItSx7wHOtxmHnj4rSzLgtTLKc=; b=kZSrDF/6ByCooHtMXxEp09RWM/pdxeB4w3EhnkW4wHlnl7lNDIAsE3B8G/56FOnKEB bfGehhJZQB8NDGKOT+pUYnHqqNfYx3k1KbP/qUw87I+eIowVcW10KgbCQs0G5z+nnXZI jNdnFKMzDaUA7Yb61mG05ygK8Ojmd3ifEnCKBGEl2yeScjcKyYpPLIBAUSKZQAlaD3tf 9JwQT9lQpGqjZKfuKdWtbCtmRPfWIudQaIEhb3KIEp2wL7akS4U4HSzW+A6Z+Sfr3ANc FlztDl5JWbKB9hGH5G97oGKaOVcdDbcoDDNrdJXkUj6ktkyk+cnomaIFPWqF98G+vT8U LAWQ== X-Gm-Message-State: APjAAAWeY3tJ1bLWP5Zi+ltkBZYKZMoRpZ65uq+6WDR731iJBIT02atz i3HwgcxXNSUvYK5YMWcOXmD/ZV0Zj2Q= X-Received: by 2002:ac8:19f5:: with SMTP id s50mr1580095qtk.25.1551396473234; Thu, 28 Feb 2019 15:27:53 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id l16sm11523673qke.20.2019.02.28.15.27.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 15:27:51 -0800 (PST) Date: Thu, 28 Feb 2019 18:27:51 -0500 From: Joel Fernandes To: Masahiro Yamada Cc: Linux Kernel Mailing List , Andrew Morton , Alexei Starovoitov , atish patra , Daniel Colascione , Dan Williams , Greg Kroah-Hartman , Guenter Roeck , Jonathan Corbet , Karim Yaghmour , Kees Cook , kernel-team@android.com, "open list:DOCUMENTATION" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-trace-devel@vger.kernel.org, Manoj Rao , Masami Hiramatsu , Paul McKenney , "Peter Zijlstra (Intel)" , qais.yousef@arm.com, Randy Dunlap , Steven Rostedt , Shuah Khan , Thomas Gleixner , Yonghong Song Subject: Re: [PATCH v3 1/2] Provide in-kernel headers for making it easy to extend the kernel Message-ID: <20190228232751.GA218988@google.com> References: <20190227193748.132301-1-joel@joelfernandes.org> <20190228144306.GA138215@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190228144306.GA138215@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 28, 2019 at 09:43:06AM -0500, Joel Fernandes wrote: > On Thu, Feb 28, 2019 at 11:17:51AM +0900, Masahiro Yamada wrote: > > Hi Joel, > > > > > > On Thu, Feb 28, 2019 at 4:40 AM 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. > > > > > > > > Please let me ask a question about the actual use-case. > > > > > > To build embedded systems including Android, > > I use an x86 build machine. > > > > In other words, I cross-compile vmlinux and in-tree modules. > > So, > > > > target-arch: arm64 > > host-arch: x86 > > > > > > > The other way we can make this work is using x86 usermode emulation inside a > chroot on the Android device which will make the earlier commands work. I verified the steps to build a module on my Pixel 3 (arm64) with Linux kernel for arm64 compiled on my x86 host: After building the headers, the steps were something like: 1.Build an x86 debian image with cross-gcc: sudo qemu-debootstrap --arch amd64 --include=make,gcc,gcc-aarch64-linux-gnu,perl,libelf1,python --variant=minbase $DIST $RUN_DIR http://ftp.us.debian.org/debian 2. Push qemu-x86_64-static (which I downloaded from the web) onto the device. 3. Tell binfmt_misc about qemu: echo ':qemu-x86_64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00: \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/qemu-x86_64-static:OC' > /proc/sys/fs/binfmt_misc/register 4. adb shell and then chroot into the image 5. follow all the steps in the commit message but set ARCH and CROSS_COMPILE appropriately. After Make, kernel module is cooked and ready :) thanks, - Joel