From: Chao Fan <fanc.fnst@cn.fujitsu.com>
To: Borislav Petkov <bp@alien8.de>, <linux-kernel@vger.kernel.org>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>, <hpa@zytor.com>,
<x86@kernel.org>, <kirill.shutemov@linux.intel.com>,
<hjl.tools@gmail.com>, Ruan Shiyang <ruansy.fnst@cn.fujitsu.com>
Subject: Re: [PATCH] x86/boot: Expand __puthex() to print 64-bit value in i386-PAE
Date: Fri, 1 Feb 2019 09:21:03 +0800 [thread overview]
Message-ID: <20190201012102.GB17551@localhost.localdomain> (raw)
In-Reply-To: <20190131212013.GN6749@zn.tnic>
On Thu, Jan 31, 2019 at 10:20:13PM +0100, Borislav Petkov wrote:
>On Thu, Jan 31, 2019 at 04:39:46PM +0800, Chao Fan wrote:
>> __puthex() is the only method to print value in compressed boot stage.
>> But in i386-PAE, sizeof(unsigned long) is 4, so that the value of
>> 64-bit is cut and print a wrong value. That will mislead developers
>> when debugging.
>> Expand the type to unsigned long long to print the right value.
>>
>> Suggested-by: Ruan Shiyang <ruansy.fnst@cn.fujitsu.com>
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>> Here is my PATCHSET:
>> https://lkml.org/lkml/2019/1/23/266
>> When debugging, I need to print the memory address and length then
>> check the value is right or not. They may exceed 4G in i386-PAE,
>> but the upper half was cut because unsigned long is not enough.
>>
>> A same condition fix after start_kernel() in ACPI has been merged:
>> commit b9ced18acf68dffebe6888c7ec765a2b1db7a039
>> Author: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> Date: Wed Dec 26 11:34:50 2018 +0800
>>
>> ACPI: NUMA: Use correct type for printing addresses on i386-PAE
>> ---
>> arch/x86/boot/compressed/misc.c | 2 +-
>> arch/x86/boot/compressed/misc.h | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
>> index 8dd1d5ccae58..30fb8abdb154 100644
>> --- a/arch/x86/boot/compressed/misc.c
>> +++ b/arch/x86/boot/compressed/misc.c
>> @@ -153,7 +153,7 @@ void __putstr(const char *s)
>> outb(0xff & (pos >> 1), vidport+1);
>> }
>>
>> -void __puthex(unsigned long value)
>> +void __puthex(unsigned long long value)
>
>Not enough because debug_putaddr() still converts it to unsigned long.
>So you get (still truncated) values with 8 preceding zeroes:
Yes, so sometimes it's better to use debug_puthex().
>
>input_data: 0x00000000036bf100
>input_len: 0x00000000005b694b
>output: 0x0000000001000000
>output_len: 0x0000000000bfba30
>kernel_total_size: 0x0000000002c92000
>beefy: 0x00000000cafebabe
>
>beefy is a test variable I declared:
>
>u64 beefy = 0xdeadbeefcafebabe;
>
>If anything, there should be a separate set of helpers which take 64-bit
>quantities as arguments. But I don't see any need for them now.
It's not used for existing code, it's used to help developers debug.
Just in my RSDP PATCHSET, I need to print the memory regions from SRAT
and check the value, then I found the value of memory regions in last
2 nodes are always wrong, I though there are some problems in my code.
Later I found the value was cut and neither debug_putaddr() nor
debug_puthex() is enough to use, then I change them to unsigned
long long in my local code and continue to debug.
So I send the change as PATCH and to see if later developers need the
debug tool.
Thanks,
Chao Fan
>
>--
>Regards/Gruss,
> Boris.
>
>Good mailing practices for 400: avoid top-posting and trim the reply.
>
>
parent reply other threads:[~2019-02-01 1:22 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20190131212013.GN6749@zn.tnic>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190201012102.GB17551@localhost.localdomain \
--to=fanc.fnst@cn.fujitsu.com \
--cc=bp@alien8.de \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=ruansy.fnst@cn.fujitsu.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox