public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Vivek Goyal <vgoyal@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	Junjie Mao <eternal.n08@gmail.com>
Subject: Re: [PATCH] x86, boot: add hex output for debugging
Date: Fri, 31 Oct 2014 10:19:22 -0700	[thread overview]
Message-ID: <5453C49A.2000500@infradead.org> (raw)
In-Reply-To: <20141031162037.GA26233@www.outflux.net>

On 10/31/14 09:20, Kees Cook wrote:
> This is useful for reporting various addresses or other values while
> debugging early boot.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  arch/x86/boot/compressed/misc.c | 19 +++++++++++++++++++
>  arch/x86/boot/compressed/misc.h |  5 +++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
> index 30dd59a9f0b4..1b105664f720 100644
> --- a/arch/x86/boot/compressed/misc.c
> +++ b/arch/x86/boot/compressed/misc.c
> @@ -220,6 +220,25 @@ void __putstr(const char *s)
>  	outb(0xff & (pos >> 1), vidport+1);
>  }
>  
> +void __puthex(unsigned long value)
> +{
> +	char alpha[2] = "0";
> +	int bits;
> +	unsigned char byte;

what is 'byte' for?  (unused)

> +
> +	__putstr("0x");
> +	for (bits = sizeof(value) * 8 - 4; bits >= 0; bits -= 4) {
> +		unsigned long digit = (value >> bits) & 0xf;
> +
> +		if (digit < 0xA)
> +			alpha[0] = '0' + digit;
> +		else
> +			alpha[0] = 'a' + (digit - 0xA);
> +
> +		__putstr(alpha);
> +	}
> +}
> +
>  static void error(char *x)
>  {
>  	error_putstr("\n\n");
> diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
> index 24e3e569a13c..6056d339fb17 100644
> --- a/arch/x86/boot/compressed/misc.h
> +++ b/arch/x86/boot/compressed/misc.h
> @@ -34,16 +34,21 @@ extern memptr free_mem_ptr;
>  extern memptr free_mem_end_ptr;
>  extern struct boot_params *real_mode;		/* Pointer to real-mode data */
>  void __putstr(const char *s);
> +void __puthex(unsigned long value);
>  #define error_putstr(__x)  __putstr(__x)
> +#define error_puthex(__x)  __puthex(__x)
>  
>  #ifdef CONFIG_X86_VERBOSE_BOOTUP
>  
>  #define debug_putstr(__x)  __putstr(__x)
> +#define debug_puthex(__x)  __puthex(__x)
>  
>  #else
>  
>  static inline void debug_putstr(const char *s)
>  { }
> +static inline void debug_puthex(const char *s)
> +{ }
>  
>  #endif
>  
> 


-- 
~Randy

  reply	other threads:[~2014-10-31 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31 16:20 [PATCH] x86, boot: add hex output for debugging Kees Cook
2014-10-31 17:19 ` Randy Dunlap [this message]
2014-10-31 17:42   ` Andi Kleen
2014-10-31 20:11     ` Vivek Goyal
2014-10-31 20:15       ` H. Peter Anvin
2014-10-31 20:33 ` josh
2014-10-31 20:55   ` Kees Cook
2014-10-31 23:56     ` Josh Triplett

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=5453C49A.2000500@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=ak@linux.intel.com \
    --cc=eternal.n08@gmail.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    --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