Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3312325pxv; Sun, 4 Jul 2021 14:51:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4qZJPjfYX4UuKnWo069gMQuczTCOMA20rAn4B/o79xoh/Z2YbfypIG5cv8YYtHJ8EHohc X-Received: by 2002:a05:6402:1001:: with SMTP id c1mr12504992edu.26.1625435501907; Sun, 04 Jul 2021 14:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625435501; cv=none; d=google.com; s=arc-20160816; b=zsWRq3de5Da5BuYqLfRDhhaphH1sBRPqeN0xFmKFZ0utTzzt7H3rqmBZ8mzTL5kYYw x5WkndnkugoSF2M/EDomh7xDAmaS9HycEmtV50ep8xtKWeK6V0lJMlBcvK8VZ8Q6kqmF KAdgu39VvHfFUORoBknu/7R014dgliadLMXKBaxMuhWPNzXfiiHfsSuS91PJRo8g+IZ+ 8X114v5tV9ikSvhRUpPit93QP6oY4Wvfupju779k5l3F9U0P5DQUa2UUBkbFLFvljHOl MD4ln/AMUxAgIXU7oR2/ifPc/Rnmgb1utVk25BOGy/SkeV2/AZy1DLjsbq4uZzV68mOD LI5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Oaj3U1+AP1QRn36TkCjP5Uikk6j3AKL4RKYoX+nxYkQ=; b=UjQ8pKrPOgUZsa+6znqvczfWMXGHhkd4kRL6YOWPHI9Jtyn3jv8GMrMMa2uWwGeIxw Xm5giCPXFXfMtqhi7tu/CEqjXuxQGac84XBopZ+g18yykpxnEi6wDR/Qfhu/nSVvdva9 SVauyM0sI/yxQrBflSESfGvh4jaG/k4zHGryOmAZ9V5gNj6cgxrLrC9U042Iv09PdCwv A6q2fClpgA4/EjVrwfksH7cJT5Mias2XqNnTb3CFjyqjmRe7Z/ifuj4AKq3/CwTVNNOD 5L89cA3yjuGxpu1bkivi8HON04re+xZq5LsD3v2vovdPMdSl/llGYLM44a7OWdIR1WFD wzFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h4pWxTp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si9251470edq.416.2021.07.04.14.51.19; Sun, 04 Jul 2021 14:51:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h4pWxTp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbhGDVwN (ORCPT + 99 others); Sun, 4 Jul 2021 17:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhGDVwM (ORCPT ); Sun, 4 Jul 2021 17:52:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C662FC061574; Sun, 4 Jul 2021 14:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Oaj3U1+AP1QRn36TkCjP5Uikk6j3AKL4RKYoX+nxYkQ=; b=h4pWxTp3WJmDRuv7ij+7jkFeOd h8bugRYNxlsZiY52yeHYJD0EH/hkz/8G+pi9FE20Fymmnzf/fMOY6rX14SYmJPw4CMfl211jBm4+y s9DSaCqoBW+NB/o6H9Owt/hU90YQ+xiJH/qYFVFj+L1AmfdG2VO1nzHTz3RHLCGR8NEptsSu2GBlG 4v37WwjsUpz5yw7n5BbZt8NKaHlLmCxpqAFGQKcZdbRVFFrUh5V5UQshSoY/SayO5TSmOK03Arn6q UamjCEISRL35gEwz+WoHSfFgnafaQ8loDiestSTvrHhpDfRCxdx1v0U82TxAES/frPgZbVAFJS0MC 7PSjoCzA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m09zB-009cXO-4j; Sun, 04 Jul 2021 21:49:14 +0000 Date: Sun, 4 Jul 2021 22:49:09 +0100 From: Matthew Wilcox To: Miguel Ojeda Cc: Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux , Linux Kbuild mailing list , Linux Doc Mailing List , linux-kernel , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Subject: Re: [PATCH 01/17] kallsyms: support big kernel symbols (2-byte lengths) Message-ID: References: <20210704202756.29107-1-ojeda@kernel.org> <20210704202756.29107-2-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 04, 2021 at 10:33:39PM +0100, Matthew Wilcox wrote: > On Sun, Jul 04, 2021 at 11:17:50PM +0200, Miguel Ojeda wrote: > > On Sun, Jul 4, 2021 at 11:05 PM Matthew Wilcox wrote: > > > > > > What happened to my suggestion from last time of encoding symbols < 128 > > > as 0-127 and symbols larger than that as (data[0] - 128) * 256 + > > > data[1]) ? > > > > Nothing, sorry, we focused on other parts (e.g. the allocation panics) > > during this iteration. I can take a look for v2. > > Here's what I have. Build testing now. It seems to work. Sample output from kallsyms with the test forced to 'true': .byte 0x80 .byte 0x0a, 0x41, 0xff, 0x70, 0xf3, 0xd0, 0xb0, 0xf2, 0xfc, 0x72, 0x74 under normal circumstances, it omits that first line. I'm unfortunately in the middle of ripping apart and fixing up my test infrastructure, so I can't claim to have really tested it, and I don't have a module with a really large symbol anyway. But I'll submit this to you as a proper patch with changelog if that's enough testing for you. (now that i look at kallsyms, why on earth is it ripping the string apart and turning it into .byte instead of just using .ascii?) > > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c > index c851ca0ed357..0d45a6e5fdc3 100644 > --- a/kernel/kallsyms.c > +++ b/kernel/kallsyms.c > @@ -67,6 +67,14 @@ static unsigned int kallsyms_expand_symbol(unsigned int off, > len = *data; > data++; > > + /* lengths larger than 128 are encoded as two bytes */ > + if (len >= 128) { > + len -= 128; > + len *= 256; > + len += *data; > + data++; > + } > + > /* > * Update the offset to return the offset for the next symbol on > * the compressed stream. > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > index 54ad86d13784..701566e01a1d 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -467,10 +467,16 @@ static void write_src(void) > output_label("kallsyms_names"); > off = 0; > for (i = 0; i < table_cnt; i++) { > + int len = table[i]->len; > if ((i & 0xFF) == 0) > markers[i >> 8] = off; > > - printf("\t.byte 0x%02x", table[i]->len); > + if (len >= 128) { > + printf("\t.byte 0x%02x\n", len / 256 + 128); > + len %= 256; > + off++; > + } > + printf("\t.byte 0x%02x", len); > for (k = 0; k < table[i]->len; k++) > printf(", 0x%02x", table[i]->sym[k]); > printf("\n");