lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5368F620.5000306@windriver.com>
Date:	Tue, 6 May 2014 10:48:00 -0400
From:	Paul Gortmaker <paul.gortmaker@...driver.com>
To:	Liu ShuoX <shuox.liu@...el.com>, <linux-kernel@...r.kernel.org>
CC:	<yanmin_zhang@...ux.intel.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	"maintainer:X86 ARCHITECTURE..." <x86@...nel.org>,
	Anton Vorontsov <anton@...msg.org>,
	Colin Cross <ccross@...roid.com>,
	Kees Cook <keescook@...omium.org>,
	Tony Luck <tony.luck@...el.com>,
	Matt Fleming <matt.fleming@...el.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Borislav Petkov <bp@...e.de>, Yinghai Lu <yinghai@...nel.org>,
	Dave Young <dyoung@...hat.com>,
	Tang Chen <tangchen@...fujitsu.com>,
	Linn Crosetto <linn@...com>
Subject: Re: [PATCH] [NOMERGE] reserved ram for pstore on PC (applied on top
 of new pstore patch)

On 14-05-06 01:03 AM, Liu ShuoX wrote:
> for pstore record test.

I don't know what kind of cc mechanism you were manually deploying
when using git send-email here, but it is customary to actually
ensure that the 0/N summary also appears in the inbox of anyone
who is cc'd on any of the patches, so they have some context.

Not writing a four line commit log is also a good way to add
extra context too.

Paul.
--

> 
> Signed-off-by: Liu ShuoX <shuox.liu@...el.com>
> ---
>  arch/x86/kernel/setup.c |   2 +
>  fs/pstore/Makefile      |   2 +-
>  fs/pstore/test.c        | 170 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 173 insertions(+), 1 deletion(-)
>  create mode 100644 fs/pstore/test.c
> 
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index 09c76d2..021b17a 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -854,6 +854,7 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
>   * Note: On x86_64, fixmaps are ready for use even before this is called.
>   */
>  
> +extern void pstore_ram_reserved_memory(void);
>  void __init setup_arch(char **cmdline_p)
>  {
>  	memblock_reserve(__pa_symbol(_text),
> @@ -1217,6 +1218,7 @@ void __init setup_arch(char **cmdline_p)
>  
>  	x86_init.resources.reserve_resources();
>  
> +	pstore_ram_reserved_memory();
>  	e820_setup_gap();
>  
>  #ifdef CONFIG_VT
> diff --git a/fs/pstore/Makefile b/fs/pstore/Makefile
> index 4c9095c..b2a961b 100644
> --- a/fs/pstore/Makefile
> +++ b/fs/pstore/Makefile
> @@ -7,5 +7,5 @@ obj-y += pstore.o
>  pstore-objs += inode.o platform.o
>  obj-$(CONFIG_PSTORE_FTRACE)	+= ftrace.o
>  
> -ramoops-objs += ram.o ram_core.o
> +ramoops-objs += ram.o ram_core.o test.o
>  obj-$(CONFIG_PSTORE_RAM)	+= ramoops.o
> diff --git a/fs/pstore/test.c b/fs/pstore/test.c
> new file mode 100644
> index 0000000..109c5a8
> --- /dev/null
> +++ b/fs/pstore/test.c
> @@ -0,0 +1,170 @@
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/string.h>
> +#include <linux/cpufreq.h>
> +#include <linux/seq_file.h>
> +#include <linux/pstore_ramoops.h>
> +#include <linux/platform_device.h>
> +#include <linux/memblock.h>
> +#include <linux/bootmem.h>
> +#include <linux/debugfs.h>
> +
> +struct norm_zone_test_record {
> +	unsigned long val;
> +	char str[32];
> +};
> +
> +static void print_record(struct seq_file *s, void *rec)
> +{
> +	struct norm_zone_test_record *record = rec;
> +	pstore_print(s, "%s: %ld\n",
> +		record->str, record->val);
> +}
> +
> +DEFINE_PSTORE_RAMZONE(test_zone) = {
> +	.size = 4096,
> +	.name = "test_zone",
> +	.item_size = sizeof(struct norm_zone_test_record),
> +	.print_record = print_record,
> +};
> +
> +DEFINE_PSTORE_RAMZONE(test_zone1) = {
> +	.size = 4096,
> +	.name = "test_zone1",
> +	.item_size = sizeof(struct norm_zone_test_record),
> +	.print_record = print_record,
> +};
> +
> +static void add_test_record(char *str, unsigned long val)
> +{
> +	struct norm_zone_test_record *record;
> +	record = persistent_ram_new_record(test_zone.prz);
> +	if (record) {
> +		record->val = val;
> +		strcpy(record->str, str);
> +	}
> +	record = persistent_ram_new_record(test_zone1.prz);
> +	if (record) {
> +		record->val = val;
> +		strcpy(record->str, str);
> +	}
> +}
> +
> +static int test_cpufreq_transition(struct notifier_block *nb,
> +		unsigned long event, void *data)
> +{
> +	add_test_record("cpufreq transition", event);
> +	return 0;
> +}
> +
> +static struct notifier_block freq_transition = {
> +	.notifier_call = test_cpufreq_transition,
> +};
> +
> +#define SZ_4K   0x00001000
> +#define SZ_2M   0x00200000
> +#define SZ_2_1M 0x00219000
> +#define SZ_16M  0x01000000
> +
> +#define PSTORE_RAM_START_DEFAULT        SZ_16M
> +#define PSTORE_RAM_SIZE_DEFAULT         SZ_2_1M
> +
> +#ifdef CONFIG_X86_32
> +#define RAM_MAX_MEM (max_low_pfn << PAGE_SHIFT)
> +#else
> +#define RAM_MAX_MEM (1 << 28)
> +#endif
> +
> +static struct ramoops_platform_data pstore_ram_data = { 
> +	.mem_size       = PSTORE_RAM_SIZE_DEFAULT,
> +	.mem_address    = PSTORE_RAM_START_DEFAULT,
> +	.record_size    = SZ_4K,
> +	.console_size   = SZ_2M,
> +	.dump_oops      = 1,
> +};
> +
> +static struct platform_device pstore_ram_dev = { 
> +	.name = "ramoops",
> +	.dev = { 
> +		.platform_data = &pstore_ram_data,
> +	},  
> +};
> +
> +static int __init pstore_ram_register(void)
> +{
> +	int ret;
> +
> +	ret = platform_device_register(&pstore_ram_dev);
> +	if (ret) {
> +		pr_err("%s: unable to register pstore_ram device: "
> +			"start=0x%llx, size=0x%lx, ret=%d\n", __func__,
> +			(unsigned long long)pstore_ram_data.mem_address,
> +			pstore_ram_data.mem_size, ret);
> +	}
> +
> +	return ret;
> +}
> +postcore_initcall(pstore_ram_register);
> +
> +void __init pstore_ram_reserved_memory(void)
> +{
> +	phys_addr_t mem;
> +	size_t size;
> +	int ret;
> +
> +	size = PSTORE_RAM_SIZE_DEFAULT;
> +	size += pstore_norm_zones_size(NULL);
> +	size = ALIGN(size, PAGE_SIZE);
> +	mem = memblock_find_in_range(0, RAM_MAX_MEM, size, PAGE_SIZE);
> +	if (!mem) {
> +		pr_err("Cannot find memblock range for pstore_ram\n");
> +		return;
> +	}
> +
> +	ret = memblock_reserve(mem, size);
> +	if (ret) {
> +		pr_err("Failed to reserve memory from 0x%llx-0x%llx\n",
> +				(unsigned long long)mem,
> +				(unsigned long long)(mem + size - 1));
> +		return;
> +	}
> +
> +	pstore_ram_data.mem_address = mem;
> +	pstore_ram_data.mem_size = size;
> +
> +	pr_info("reserved RAM buffer (0x%zx@...llx)\n",
> +			size, (unsigned long long)mem);
> +}
> +
> +static ssize_t pstore_ramoops_write(struct file *f, const char __user *buf,
> +		size_t count, loff_t *ppos)
> +{
> +	return 0;
> +}
> +
> +static ssize_t pstore_ramoops_read(struct file *f, char __user *buf,
> +		size_t count, loff_t *ppos)
> +{
> +	struct ramoops_zone *zone = (struct ramoops_zone *)f->private_data;
> +
> +	pstore_dump_records(zone);
> +	return 0;
> +}
> +
> +static const struct file_operations pstore_ramoops_fops = { 
> +	.open   = simple_open,
> +	.read   = pstore_ramoops_read,
> +	.write  = pstore_ramoops_write,
> +};
> +
> +
> +static int __init norm_zone_test_init(void)
> +{
> +	cpufreq_register_notifier(&freq_transition,
> +			CPUFREQ_TRANSITION_NOTIFIER);
> +	debugfs_create_file("zone_dump", 0660, NULL, (void *)&test_zone, &pstore_ramoops_fops);
> +	debugfs_create_file("zone1_dump", 0660, NULL, (void *)&test_zone1, &pstore_ramoops_fops);
> +
> +	return 0;
> +}
> +module_init(norm_zone_test_init);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ