From: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
To: Kees Cook <keescook@chromium.org>
Cc: jkenisto@linux.vnet.ibm.com, Tony Luck <tony.luck@intel.com>,
mahesh@linux.vnet.ibm.com, Colin Cross <ccross@android.com>,
LKML <linux-kernel@vger.kernel.org>,
linuxppc-dev@ozlabs.org, paulus@samba.org, anton@samba.org,
Anton Vorontsov <cbouatmailru@gmail.com>
Subject: Re: [PATCH v2 7/8] powerpc/pseries: Read of-config partition via pstore
Date: Thu, 25 Apr 2013 10:40:16 +0530 [thread overview]
Message-ID: <5178BAB8.6020001@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAGXu5jKCafNaLCOcvo2+eoVGuP0rGP3e_OOg-YdkCFT_zc8k9g@mail.gmail.com>
On Thursday 25 April 2013 02:13 AM, Kees Cook wrote:
Hi Kees,
> On Tue, Apr 23, 2013 at 11:20 PM, Aruna Balakrishnaiah
> <aruna@linux.vnet.ibm.com> wrote:
>> This patch set exploits the pstore subsystem to read details of
>> of-config partition in NVRAM to a separate file in /dev/pstore.
>> For instance, of-config partition details will be stored in a
>> file named [of-nvram-5].
>>
>> Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
>> Reviewed-by: Jim Keniston <jkenisto@us.ibm.com>
>> ---
>> arch/powerpc/platforms/pseries/nvram.c | 55 +++++++++++++++++++++++++++-----
>> fs/pstore/inode.c | 3 ++
>> include/linux/pstore.h | 1 +
>> 3 files changed, 50 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
>> index b118382..de448af 100644
>> --- a/arch/powerpc/platforms/pseries/nvram.c
>> +++ b/arch/powerpc/platforms/pseries/nvram.c
>> @@ -132,9 +132,16 @@ static size_t oops_data_sz;
>> static struct z_stream_s stream;
>>
>> #ifdef CONFIG_PSTORE
>> +static struct nvram_os_partition of_config_partition = {
>> + .name = "of-config",
>> + .index = -1,
>> + .os_partition = false
>> +};
>> +
>> static enum pstore_type_id nvram_type_ids[] = {
>> PSTORE_TYPE_DMESG,
>> PSTORE_TYPE_RTAS,
>> + PSTORE_TYPE_OF,
>> -1
>> };
>> static int read_type;
>> @@ -332,10 +339,15 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff,
>>
>> tmp_index = part->index;
>>
>> - rc = ppc_md.nvram_read((char *)&info, sizeof(struct err_log_info), &tmp_index);
>> - if (rc <= 0) {
>> - pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__, rc);
>> - return rc;
>> + if (part->os_partition) {
>> + rc = ppc_md.nvram_read((char *)&info,
>> + sizeof(struct err_log_info),
>> + &tmp_index);
>> + if (rc <= 0) {
>> + pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__,
>> + rc);
>> + return rc;
>> + }
>> }
>>
>> rc = ppc_md.nvram_read(buff, length, &tmp_index);
>> @@ -344,8 +356,10 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff,
>> return rc;
>> }
>>
>> - *error_log_cnt = info.seq_num;
>> - *err_type = info.error_type;
>> + if (part->os_partition) {
>> + *error_log_cnt = info.seq_num;
>> + *err_type = info.error_type;
>> + }
>>
>> return 0;
>> }
>> @@ -516,7 +530,7 @@ static int nvram_pstore_write(enum pstore_type_id type,
>> }
>>
>> /*
>> - * Reads the oops/panic report and ibm,rtas-log partition.
>> + * Reads the oops/panic report, rtas and of-config partition.
>> * Returns the length of the data we read from each partition.
>> * Returns 0 if we've been called before.
>> */
>> @@ -525,9 +539,11 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
>> struct pstore_info *psi)
>> {
>> struct oops_log_info *oops_hdr;
>> - unsigned int err_type, id_no;
>> + unsigned int err_type, id_no, size = 0;
>> struct nvram_os_partition *part = NULL;
>> char *buff = NULL;
>> + int sig = 0;
>> + loff_t p;
>>
>> read_type++;
>>
>> @@ -542,10 +558,29 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
>> time->tv_sec = last_rtas_event;
>> time->tv_nsec = 0;
>> break;
>> + case PSTORE_TYPE_OF:
>> + sig = NVRAM_SIG_OF;
>> + part = &of_config_partition;
>> + *type = PSTORE_TYPE_OF;
>> + *id = PSTORE_TYPE_OF;
>> + time->tv_sec = 0;
>> + time->tv_nsec = 0;
>> + break;
>> default:
>> return 0;
>> }
>>
>> + if (!part->os_partition) {
>> + p = nvram_find_partition(part->name, sig, &size);
>> + if (p <= 0) {
>> + pr_err("nvram: Failed to find partition %s, "
>> + "err %d\n", part->name, (int)p);
>> + return 0;
>> + }
>> + part->index = p;
>> + part->size = size;
>> + }
>> +
>> buff = kmalloc(part->size, GFP_KERNEL);
>>
>> if (!buff)
>> @@ -557,7 +592,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
>> }
>>
>> *count = 0;
>> - *id = id_no;
>> +
>> + if (part->os_partition)
>> + *id = id_no;
>>
>> if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) {
>> oops_hdr = (struct oops_log_info *)buff;
>> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
>> index ec24f9c..8d4fb65 100644
>> --- a/fs/pstore/inode.c
>> +++ b/fs/pstore/inode.c
>> @@ -327,6 +327,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
>> case PSTORE_TYPE_PPC_RTAS:
>> sprintf(name, "rtas-%s-%lld", psname, id);
>> break;
>> + case PSTORE_TYPE_PPC_OF:
>> + sprintf(name, "of-%s-%lld", psname, id);
>> + break;
>> case PSTORE_TYPE_UNKNOWN:
>> sprintf(name, "unknown-%s-%lld", psname, id);
>> break;
>> diff --git a/include/linux/pstore.h b/include/linux/pstore.h
>> index d7a8fe9..615dc18 100644
>> --- a/include/linux/pstore.h
>> +++ b/include/linux/pstore.h
>> @@ -37,6 +37,7 @@ enum pstore_type_id {
>> PSTORE_TYPE_FTRACE = 3,
>> /* PPC64 partition types */
>> PSTORE_TYPE_PPC_RTAS = 4,
>> + PSTORE_TYPE_PPC_OF = 5,
>> PSTORE_TYPE_UNKNOWN = 255
>> };
>>
>>
> Should this be named just "PSTORE_TYPE_OF" instead of "...PPC_OF"?
I renamed it from PSTORE_TYPE_OF to PSTORE_TYPE_PPC_OF as per Michael's
suggestion. But I have made a mistake of not changing the new name in nvram.c
file.
Will wait for other review comments and repost the patch.
>
> -Kees
>
> --
> Kees Cook
> Chrome OS Security
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
next prev parent reply other threads:[~2013-04-25 5:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 6:19 [PATCH v2 0/8] powerpc/pseries: Nvram-to-pstore Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 1/8] powerpc/pseries: Remove syslog prefix in uncompressed oops text Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 2/8] powerpc/pseries: Add version and timestamp to oops header Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 3/8] powerpc/pseries: Introduce generic read function to read nvram-partitions Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 4/8] powerpc/pseries: Read/Write oops nvram partition via pstore Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 5/8] powerpc/pseries: Read rtas " Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 6/8] powerpc/pseries: Distinguish between a os-partition and non-os partition Aruna Balakrishnaiah
2013-04-24 6:20 ` [PATCH v2 7/8] powerpc/pseries: Read of-config partition via pstore Aruna Balakrishnaiah
2013-04-24 20:43 ` Kees Cook
2013-04-25 5:10 ` Aruna Balakrishnaiah [this message]
2013-04-24 6:21 ` [PATCH v2 8/8] powerpc/pseries: Read common " Aruna Balakrishnaiah
2013-04-24 20:45 ` [PATCH v2 0/8] powerpc/pseries: Nvram-to-pstore Kees Cook
2013-04-25 5:53 ` Aruna Balakrishnaiah
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=5178BAB8.6020001@linux.vnet.ibm.com \
--to=aruna@linux.vnet.ibm.com \
--cc=anton@samba.org \
--cc=cbouatmailru@gmail.com \
--cc=ccross@android.com \
--cc=jkenisto@linux.vnet.ibm.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=tony.luck@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).