[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈
Hi Lijiang & guanyou & qiwu,
On Mon, Aug 26, 2024 at 3:08 PM lijiang <lijiang@redhat.com> wrote:
>
> On Tue, Aug 20, 2024 at 11:54 AM <devel-request@lists.crash-utility.osci.io> wrote:
>>
>> Date: Tue, 20 Aug 2024 03:53:16 -0000
>> From: chenguanyou9338@gmail.com
>> Subject: [Crash-utility] Re: [PATCH v2] arm64: fix regression for the
>> determination of section_size_bits
>> To: devel@lists.crash-utility.osci.io
>> Message-ID: <20240820035316.8055.4425@lists.crash-utility.osci.io>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi lianbo
>>
>> Base on qiwu's patch, is this attached patch OK ?
>>
>
> Sorry for the late reply.
>
> I'm worried that there will be more and more similar patches in the future, how should we handle them by then?
>
> Or leave it there for the time being until we find a better solution. Any thoughts from other reviewers?
>
Agreed. The patch is Android specific, which can only serve for
android, not for other distros.
Please correct me if I'm wrong. The android can be viewed as a distro,
similar to ubuntu/fedora etc. The distro specific change/code should
better go into distro packaging, like the one[1] for fedora, which may
have extra compiling hardening or other customizations required by
distro itself, hence these patches are maintained here other than
upstream.
I'm not a android guy and not familiar with how the andorid
commandline tools are maintained. AFAIK there are 3rd package systems
for android, such as termux [2]. IMHO the above change should go in
there instead. Any thoughts?
Thanks,
Tao Liu
[1]:
https://src.fedoraproject.org/rpms/crash/tree/rawhide
[2]:
https://github.com/termux/termux-packages
> Thanks
> Lianbo
>
>> >From 08d4af144b981daf292473303e08546ef1e81a04 Mon Sep 17 00:00:00 2001
>> From: chenguanyou <chenguanyou@xiaomi.com>
>> Date: Thu, 8 Aug 2024 17:35:07 +0800
>> Subject: [PATCH] arm64: fix regression for the determination of
>> section_size_bits
>>
>> The commit 568c6f04 will cause a regression issue for the determination of
>> section_size_bits on kernel version before android12-5.10 or Linux-v5.12.
>> The section_size_bits is supposed to be compatible with linux upstream and
>> android GKI version:
>> Before android12-5.10 or Linux-v5.12:
>> SECTION_SIZE_BITS = 30
>>
>> After android12-5.10 or Linux-v5.12:
>> SECTION_SIZE_BITS = 27 when defined 4K_PAGES or 16K_PAGES.
>> SECTION_SIZE_BITS = 29 when defined 64K_PAGES.
>>
>> Fixes: 568c6f04 ("arm64: section_size_bits compatible with macro definitions")
>> Change-Id: Ib6ec610753aabb52dfbafab65e1e6c04cbe65f72
>>
>> Signed-off-by: qiwu.chen <qiwu.chen@transsion.com>
>> Signed-off-by: chenguanyou <chenguanyou@xiaomi.com>
>> ---
>> arm64.c | 22 ++++++++++------------
>> defs.h | 10 ++++++++++
>> global_data.c | 7 +++++++
>> kernel.c | 23 +++++++++++++++++++++++
>> 4 files changed, 50 insertions(+), 12 deletions(-)
>>
>> diff --git a/arm64.c b/arm64.c
>> index 8ed1aaf..f0721b7 100644
>> --- a/arm64.c
>> +++ b/arm64.c
>> @@ -1667,30 +1667,28 @@ arm64_get_section_size_bits(void)
>> int ret;
>> char *string;
>>
>> - if (THIS_KERNEL_VERSION >= LINUX(5,12,0)) {
>> + if (arm64_get_vmcoreinfo(&machdep->section_size_bits, "NUMBER(SECTION_SIZE_BITS)", NUM_DEC))
>> + goto exit;
>> +
>> + if (THIS_KERNEL_VERSION >= LINUX(5,12,0)
>> + || (IS_ANDROID_KERNEL_REL
>> + && THIS_KERNEL_VERSION >= LINUX(5,10,0)
>> + && THIS_ANDROID_VERSION >= ANDROID(12,0)))
>> if (machdep->pagesize == 65536)
>> machdep->section_size_bits = _SECTION_SIZE_BITS_5_12_64K;
>> else
>> machdep->section_size_bits = _SECTION_SIZE_BITS_5_12;
>> - } else
>> + else
>> machdep->section_size_bits = _SECTION_SIZE_BITS;
>>
>> - if (arm64_get_vmcoreinfo(&machdep->section_size_bits, "NUMBER(SECTION_SIZE_BITS)", NUM_DEC)) {
>> - /* nothing */
>> - } else if (kt->ikconfig_flags & IKCONFIG_AVAIL) {
>> + if (kt->ikconfig_flags & IKCONFIG_AVAIL) {
>> if ((ret = get_kernel_config("CONFIG_MEMORY_HOTPLUG", NULL)) == IKCONFIG_Y) {
>> if ((ret = get_kernel_config("CONFIG_HOTPLUG_SIZE_BITS", &string)) == IKCONFIG_STR)
>> machdep->section_size_bits = atol(string);
>> }
>> -
>> - /* arm64: reduce section size for sparsemem */
>> - if ((ret = get_kernel_config("CONFIG_ARM64_4K_PAGES", NULL)) == IKCONFIG_Y
>> - || (ret = get_kernel_config("CONFIG_ARM64_16K_PAGES", NULL)) == IKCONFIG_Y)
>> - machdep->section_size_bits = _SECTION_SIZE_BITS_5_12;
>> - else if ((ret = get_kernel_config("CONFIG_ARM64_64K_PAGES", NULL)) == IKCONFIG_Y)
>> - machdep->section_size_bits = _SECTION_SIZE_BITS_5_12_64K;
>> }
>>
>> +exit:
>> if (CRASHDEBUG(1))
>> fprintf(fp, "SECTION_SIZE_BITS: %ld\n", machdep->section_size_bits);
>> }
>> diff --git a/defs.h b/defs.h
>> index 1b7649d..b0d3f8f 100644
>> --- a/defs.h
>> +++ b/defs.h
>> @@ -829,6 +829,15 @@ struct kernel_table { /* kernel data */
>> #define IS_KERNEL_STATIC_TEXT(x) (((ulong)(x) >= kt->stext) && \
>> ((ulong)(x) < kt->etext))
>>
>> +#define THIS_KERNEL_RELEASE (kt->utsname.release)
>> +
>> +struct android_table {
>> + uint android_version[2];
>> +};
>> +#define IS_ANDROID_KERNEL_REL (at->android_version[0] > 0)
>> +#define THIS_ANDROID_VERSION ((at->android_version[0] << 16) + (at->android_version[1]))
>> +#define ANDROID(x,y) (((uint)(x) << 16) + (uint)(y))
>> +
>> #define TASK_COMM_LEN 16 /* task command name length including NULL */
>>
>> struct task_context { /* context stored for each task */
>> @@ -5353,6 +5362,7 @@ extern struct vm_table vm_table, *vt;
>> extern struct machdep_table *machdep;
>> extern struct symbol_table_data symbol_table_data, *st;
>> extern struct extension_table *extension_table;
>> +extern struct android_table android_table, *at;
>>
>> /*
>> * Generated in build_data.c
>> diff --git a/global_data.c b/global_data.c
>> index f9bb7d0..dddde96 100644
>> --- a/global_data.c
>> +++ b/global_data.c
>> @@ -55,6 +55,13 @@ struct symbol_table_data *st = &symbol_table_data;
>> struct machdep_table machdep_table = { 0 };
>> struct machdep_table *machdep = &machdep_table;
>>
>> +/*
>> + * The same thing goes for accesses to the frequently-accessed android_table,
>> + * making the "at" pointers globally available.
>> + */
>> +struct android_table android_table = { 0, 0 };
>> +struct android_table *at = &android_table;
>> +
>> /*
>> * Command functions are entered with the args[] array and argcnt value
>> * pre-set for issuance to getopt().
>> diff --git a/kernel.c b/kernel.c
>> index adb19ad..814418c 100644
>> --- a/kernel.c
>> +++ b/kernel.c
>> @@ -104,6 +104,26 @@ static void check_vmcoreinfo(void);
>> static int is_pvops_xen(void);
>> static int get_linux_banner_from_vmlinux(char *, size_t);
>>
>> +/*
>> + * Determine Andriod GKI vmcore by reading "android" from ut->release.
>> + * The prefix of Andriod GKI release version is:
>> + * Kernel Version - Android release version
>> + * For example:
>> + * 5.10.209-android12, 5.10.209-android12.1, 5.15.148-android13
>> + */
>> +void
>> +parse_android_table(void)
>> +{
>> + char *p;
>> + if ((p = strstr(THIS_KERNEL_RELEASE, "android"))) {
>> + sscanf(p, "android%d.%d", &at->android_version[0], &at->android_version[1]);
>> +
>> + if (CRASHDEBUG(1))
>> + fprintf(fp, "andriod_version: andriod-%d.%d\n",
>> + at->android_version[0], at->android_version[1]);
>> + }
>> +}
>> +
>> /*
>> * popuplate the global kernel table (kt) with kernel version
>> * information parsed from UTSNAME/OSRELEASE string
>> @@ -298,6 +318,9 @@ kernel_init()
>> kt->utsname.domainname : "(not printable)");
>> }
>>
>> + // non-upstream rel
>> + parse_android_table();
>> +
>> strncpy(buf, kt->utsname.release, 65);
>> if (buf[64])
>> buf[64] = NULLCHAR;
>> --
>> 2.39.0
>
> --
> Crash-utility mailing list -- devel@lists.crash-utility.osci.io
> To unsubscribe send an email to devel-leave@lists.crash-utility.osci.io
>
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
> Contribution Guidelines:
https://github.com/crash-utility/crash/wiki
--
Crash-utility mailing list -- devel@lists.crash-utility.osci.io
To unsubscribe send an email to devel-leave@lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines:
https://github.com/crash-utility/crash/wiki