Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470971

Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when resuming with inconsistent e820 map

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when resuming with inconsistent e820 map
Date 2016-08-26 22:00 +0200
Message-ID <savse-2Z5-19@gated-at.bofh.it> (permalink)
References <qlTYC-1xg-7@gated-at.bofh.it> <s9gvg-27c-23@gated-at.bofh.it> <s9gEW-2aI-15@gated-at.bofh.it> <s9vDX-3Ld-5@gated-at.bofh.it> <sa0y5-8ll-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi!

> > > > What's the progress of this patch? Looks already have experts review it.
> > > > Why this patch didn't accept?
> > > This patch is a little overkilled, and I have saved another simpler
> > > version to only check the md5 hash (as people suggested) for it. I can post it later.
> > > 
> > 
> > I am happy to test and review it.
> >
> Here it is. As Rafael is on travel, it would be grateful
> if you can give some advance on this, thanks!

Better than last one.

> +#ifdef CONFIG_HIBERNATION_CHECK_E820
> +#define MD5_HASH_SIZE 128
> +
> +/**
> + *	get_e820_md5 - calculate md5 according to struct e820map
> + *
> + *	@map: the e820 map to be calculated
> + *	@buf: the md5 result to be stored to
> + */
> +static int get_e820_md5(struct e820map *map, void *buf)
> +{
> +	struct scatterlist sg;
> +	struct crypto_ahash *tfm;
> +	struct ahash_request *req;
> +	int ret = 0;
> +
> +	tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
> +	if (IS_ERR(tfm))
> +		return -ENOMEM;
> +
> +	req = ahash_request_alloc(tfm, GFP_ATOMIC);

what context is this called from? GFP_ATOMIC allocations like to fail...

> +static int hibernation_e820_check(void *buf)
> +{
> +	int ret;
> +	char result[MD5_HASH_SIZE] = {0};
> +
> +	ret = get_e820_md5(&e820_saved, result);
> +	if (ret)
> +		return ret;
> +
> +	if (memcmp(result, buf, MD5_HASH_SIZE))
> +		e820_conflict = true;

Passing return value using global variable is ugly. Can you just print
the warning and kill the box here?
> +

> +	/*
> +	 * A page has been allocated previously to store the hibernation
> +	 * image header, so we can safely store the md5 result behind
> +	 * struct restore_data_record, with size of 128 bytes.
> +	 */
> +	hibernation_e820_save(addr + sizeof(struct restore_data_record));
> +

Please just allocate space in struct restore_data_record . And I don't
think md5 sum is 128 _bytes_.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when  resuming with inconsistent e820 map Chen Yu <yu.c.chen@intel.com> - 2016-08-25 13:00 +0200
  Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when  resuming with inconsistent e820 map Pavel Machek <pavel@ucw.cz> - 2016-08-26 22:00 +0200
    Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when  resuming with inconsistent e820 map Chen Yu <yu.c.chen@intel.com> - 2016-08-28 04:00 +0200
      Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when  resuming with inconsistent e820 map Pavel Machek <pavel@ucw.cz> - 2016-08-28 14:50 +0200
        RE: [PATCH][v6] PM / hibernate: Print the possible panic reason  when resuming with inconsistent e820 map "Chen, Yu C" <yu.c.chen@intel.com> - 2016-08-28 15:10 +0200
          Re: [PATCH][v6] PM / hibernate: Print the possible panic reason when  resuming with inconsistent e820 map Pavel Machek <pavel@ucw.cz> - 2016-08-28 15:20 +0200
            RE: [PATCH][v6] PM / hibernate: Print the possible panic reason  when resuming with inconsistent e820 map "Chen, Yu C" <yu.c.chen@intel.com> - 2016-08-28 15:40 +0200

csiph-web