From: George Dunlap <george.dunlap@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH] xen/x86: Fix errors arising from c/s dab76ff
Date: Mon, 15 Feb 2016 15:15:31 +0000 [thread overview]
Message-ID: <56C1EB93.4020003@citrix.com> (raw)
In-Reply-To: <1455289189-32425-1-git-send-email-andrew.cooper3@citrix.com>
[-- Attachment #1: Type: text/plain, Size: 2971 bytes --]
On 12/02/16 14:59, Andrew Cooper wrote:
> Coverity correctly identifies that the changes in mtrr_attrib_to_str()
> introduce dead code. strings[] is a 2d array, rather than an array of
> strings, which means that strings[x] will never be a NULL pointer.
>
> Adjust the check to compenstate, by looking for a NUL in strings[x][0]
> instead.
>
> Curiously, Coverity did not notice the same error with memory_type_to_str().
> There was also a further error; the strings were not NULL terminated, which
> made the return type of memory_type_to_str() erronious.
>
> Bump the 2D array to 3 characters, so the strings retain their NUL characters,
> and introduce an ASSERT() as requested on one thread of the original patch.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
What about something like this instead? (Ported to be on top of this
patch, since it's already been committed.)
-George
[PATCH] xen/p2m: Make dump table printing less clever
Rather than detecting whether to print out the numerical value of the
memory type based on whether
the second byte of the stringified value is a null character, just
always print out both.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
---
xen/arch/x86/mm/p2m-ept.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 3cb6868..be528e7 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1204,7 +1204,7 @@ void ept_p2m_uninit(struct p2m_domain *p2m)
static const char *memory_type_to_str(unsigned int x)
{
- static const char memory_types[8][3] = {
+ static const char *memory_types[8] = {
[MTRR_TYPE_UNCACHABLE] = "UC",
[MTRR_TYPE_WRCOMB] = "WC",
[MTRR_TYPE_WRTHROUGH] = "WT",
@@ -1262,14 +1262,13 @@ static void ept_dump_p2m_table(unsigned char key)
if ( ept_entry->sa_p2mt == p2m_populate_on_demand )
printk("gfn: %13lx order: %2d PoD\n", gfn, order);
else
- printk("gfn: %13lx order: %2d mfn: %13lx %c%c%c
%c%c%c\n",
+ printk("gfn: %13lx order: %2d mfn: %13lx %c%c%c
%s(%d)%c\n",
gfn, order, ept_entry->mfn + 0UL,
ept_entry->r ? 'r' : ' ',
ept_entry->w ? 'w' : ' ',
ept_entry->x ? 'x' : ' ',
- memory_type_to_str(ept_entry->emt)[0],
- memory_type_to_str(ept_entry->emt)[1]
- ?: ept_entry->emt + '0',
+ memory_type_to_str(ept_entry->emt),
+ ept_entry->emt,
c ?: ept_entry->ipat ? '!' : ' ');
if ( !(record_counter++ % 100) )
--
2.1.4
[-- Attachment #2: 0001-xen-p2m-Make-dump-table-printing-less-clever.patch --]
[-- Type: text/x-patch, Size: 2232 bytes --]
>From b9d1d77c001507c4c414b83666a3f59e327364c3 Mon Sep 17 00:00:00 2001
From: George Dunlap <george.dunlap@eu.citrix.com>
Date: Mon, 15 Feb 2016 14:58:29 +0000
Subject: [PATCH] xen/p2m: Make dump table printing less clever
Rather than detecting whether to print out the numerical value of the memory type based on whether
the second byte of the stringified value is a null character, just always print out both.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
---
xen/arch/x86/mm/p2m-ept.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 3cb6868..be528e7 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1204,7 +1204,7 @@ void ept_p2m_uninit(struct p2m_domain *p2m)
static const char *memory_type_to_str(unsigned int x)
{
- static const char memory_types[8][3] = {
+ static const char *memory_types[8] = {
[MTRR_TYPE_UNCACHABLE] = "UC",
[MTRR_TYPE_WRCOMB] = "WC",
[MTRR_TYPE_WRTHROUGH] = "WT",
@@ -1262,14 +1262,13 @@ static void ept_dump_p2m_table(unsigned char key)
if ( ept_entry->sa_p2mt == p2m_populate_on_demand )
printk("gfn: %13lx order: %2d PoD\n", gfn, order);
else
- printk("gfn: %13lx order: %2d mfn: %13lx %c%c%c %c%c%c\n",
+ printk("gfn: %13lx order: %2d mfn: %13lx %c%c%c %s(%d)%c\n",
gfn, order, ept_entry->mfn + 0UL,
ept_entry->r ? 'r' : ' ',
ept_entry->w ? 'w' : ' ',
ept_entry->x ? 'x' : ' ',
- memory_type_to_str(ept_entry->emt)[0],
- memory_type_to_str(ept_entry->emt)[1]
- ?: ept_entry->emt + '0',
+ memory_type_to_str(ept_entry->emt),
+ ept_entry->emt,
c ?: ept_entry->ipat ? '!' : ' ');
if ( !(record_counter++ % 100) )
--
2.1.4
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-02-15 15:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 14:59 [PATCH] xen/x86: Fix errors arising from c/s dab76ff Andrew Cooper
2016-02-12 15:13 ` Jan Beulich
2016-02-12 15:23 ` Andrew Cooper
2016-02-15 15:15 ` George Dunlap [this message]
2016-02-15 16:52 ` Jan Beulich
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=56C1EB93.4020003@citrix.com \
--to=george.dunlap@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).