LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] add reporting of SVM flags to /proc/cpuinfo
@ 2007-03-05 14:36 Joerg Roedel
2007-03-05 14:39 ` [PATCH 1/2] x86_64: " Joerg Roedel
2007-03-05 14:42 ` [PATCH 2/2] i386: " Joerg Roedel
0 siblings, 2 replies; 8+ messages in thread
From: Joerg Roedel @ 2007-03-05 14:36 UTC (permalink / raw)
To: discuss; +Cc: Andi Kleen, linux-kernel
This small patch series introduces the reporting of the SVM revision,
the number of ASIDs and the flags in /proc/cpuinfo on SVM capable AMD
processors. The patches are for i386 and for x86_64 architectures.
--
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 14:36 [PATCH 0/2] add reporting of SVM flags to /proc/cpuinfo Joerg Roedel
@ 2007-03-05 14:39 ` Joerg Roedel
2007-03-05 14:46 ` Michael Tokarev
2007-03-05 15:25 ` Andi Kleen
2007-03-05 14:42 ` [PATCH 2/2] i386: " Joerg Roedel
1 sibling, 2 replies; 8+ messages in thread
From: Joerg Roedel @ 2007-03-05 14:39 UTC (permalink / raw)
To: discuss; +Cc: Andi Kleen, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 258 bytes --]
From: Joerg Roedel <joerg.roedel@amd.com>
This patch adds the advanced SVM reporting to /proc/cpuinfo on the x86_64
architecture.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
--
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
[-- Attachment #2: x86_64-report-svm-features.patch --]
[-- Type: text/plain, Size: 3028 bytes --]
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 3d98b69..4bd06a6 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -612,6 +612,13 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
/* RDTSC can be speculated around */
clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
+
+ /* SVM specific flags and information */
+ if (cpu_has(c, X86_FEATURE_SVM)) {
+ c->svm.svm_rev = (__u8)(cpuid_eax(0x8000000a) & 0xff);
+ c->svm.svm_asids = cpuid_ebx(0x8000000a);
+ c->svm.svm_flags = cpuid_edx(0x8000000a);
+ }
}
static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
@@ -992,6 +999,11 @@ static int show_cpuinfo(struct seq_file *m, void *v)
/* nothing */ /* constant_tsc - moved to flags */
};
+ static char *x86_svm_flags[] = {
+ "npt",
+ "lbrv",
+ "svmlock",
+ };
#ifdef CONFIG_SMP
if (!cpu_online(c-cpu_data))
@@ -1076,9 +1088,27 @@ static int show_cpuinfo(struct seq_file *m, void *v)
else
seq_printf(m, " [%d]", i);
}
+ seq_printf(m, "\n");
+ }
+
+ if (cpu_has(c, X86_FEATURE_SVM)) {
+ unsigned i, first=1;
+ seq_printf(m, "SVM features\t: rev=%hd #asids=%u flags=(",
+ c->svm.svm_rev, c->svm.svm_asids);
+ for (i=0;i<ARRAY_SIZE(x86_svm_flags);++i) {
+ if (c->svm.svm_flags & (1 << i)) {
+ seq_printf(m,"%s", first ? "" : " ");
+ first = 0;
+ if (x86_svm_flags[i])
+ seq_printf(m, "%s", x86_svm_flags[i]);
+ else
+ seq_printf(m, "[%d]", i);
+ }
+ }
+ seq_printf(m, ")\n");
}
- seq_printf(m, "\n\n");
+ seq_printf(m, "\n");
return 0;
}
diff --git a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
index 0b3c686..869d8a5 100644
--- a/include/asm-x86_64/cpufeature.h
+++ b/include/asm-x86_64/cpufeature.h
@@ -90,6 +90,7 @@
/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
+#define X86_FEATURE_SVM (6*32+ 2) /* Secure Virtual Machine */
#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index 76552d7..514520b 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -43,6 +43,15 @@
*/
#define current_text_addr() ({ void *pc; asm volatile("leaq 1f(%%rip),%0\n1:":"=r"(pc)); pc; })
+ /*
+ * SVM flags subtype - used in struct cpuinfo_x86
+ */
+struct cpu_svm_info {
+ __u8 svm_rev;
+ __u32 svm_asids;
+ __u32 svm_flags;
+};
+
/*
* CPU type and hardware bug flags. Kept separately for each CPU.
*/
@@ -73,6 +82,8 @@ struct cpuinfo_x86 {
__u8 booted_cores; /* number of cores as seen by OS */
__u8 phys_proc_id; /* Physical Processor id. */
__u8 cpu_core_id; /* Core id. */
+
+ struct cpu_svm_info svm; /* SVM specific feature flags */
#endif
} ____cacheline_aligned;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] i386: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 14:36 [PATCH 0/2] add reporting of SVM flags to /proc/cpuinfo Joerg Roedel
2007-03-05 14:39 ` [PATCH 1/2] x86_64: " Joerg Roedel
@ 2007-03-05 14:42 ` Joerg Roedel
1 sibling, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2007-03-05 14:42 UTC (permalink / raw)
To: discuss; +Cc: Andi Kleen, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
From: Joerg Roedel <joerg.roedel@amd.com>
This patch adds the advanced SVM reporting in /proc/cpuinfo to the i386
architecture.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
--
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
[-- Attachment #2: i386-report-svm-features.patch --]
[-- Type: text/plain, Size: 3421 bytes --]
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 41cfea5..768c221 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -241,6 +241,13 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
if (cpuid_eax(0x80000000) >= 0x80000006)
num_cache_leaves = 3;
+
+ /* SVM specific flags and information */
+ if (cpu_has(c, X86_FEATURE_SVM)) {
+ c->svm.svm_rev = (__u8)(cpuid_eax(0x8000000a) & 0xff);
+ c->svm.svm_asids = cpuid_ebx(0x8000000a);
+ c->svm.svm_flags = cpuid_edx(0x8000000a);
+ }
}
static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 47e3ebb..ddedf56 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -76,6 +76,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
NULL, /* constant_tsc - moved to flags */
/* nothing */
};
+
+ static char *x86_svm_flags[] = {
+ "npt",
+ "lbrv",
+ "svmlock",
+ };
+
struct cpuinfo_x86 *c = v;
int i, n = c - cpu_data;
int fpu_exception;
@@ -159,7 +166,25 @@ static int show_cpuinfo(struct seq_file *m, void *v)
seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
c->loops_per_jiffy/(500000/HZ),
(c->loops_per_jiffy/(5000/HZ)) % 100);
- seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
+ seq_printf(m, "clflush size\t: %u\n", c->x86_clflush_size);
+
+ if (cpu_has(c, X86_FEATURE_SVM)) {
+ unsigned i, first=1;
+ seq_printf(m, "SVM features\t: rev=%hd #asids=%u flags=(",
+ c->svm.svm_rev, c->svm.svm_asids);
+ for (i=0;i<ARRAY_SIZE(x86_svm_flags);++i) {
+ if (c->svm.svm_flags & (1 << i)) {
+ seq_printf(m,"%s", first ? "" : " ");
+ first = 0;
+ if (x86_svm_flags[i])
+ seq_printf(m, "%s", x86_svm_flags[i]);
+ else
+ seq_printf(m, "[%d]", i);
+ }
+ }
+ seq_printf(m, ")\n");
+ }
+ seq_printf(m, "\n");
return 0;
}
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index 3f92b94..4da2dba 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -101,6 +101,7 @@
/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
+#define X86_FEATURE_SVM (6*32+ 2) /* Secure Virtual Machine */
#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 11bf899..727c54f 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -41,6 +41,15 @@ struct desc_struct {
#define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
/*
+ * SVM flags subtype - used in struct cpuinfo_x86
+ */
+struct cpu_svm_info {
+ __u8 svm_rev;
+ __u32 svm_asids;
+ __u32 svm_flags;
+};
+
+/*
* CPU type and hardware bug flags. Kept separately for each CPU.
* Members of this structure are referenced in head.S, so think twice
* before touching them. [mj]
@@ -79,6 +88,7 @@ struct cpuinfo_x86 {
__u8 phys_proc_id; /* Physical processor id. */
__u8 cpu_core_id; /* Core id */
#endif
+ struct cpu_svm_info svm;
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
#define X86_VENDOR_INTEL 0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 14:39 ` [PATCH 1/2] x86_64: " Joerg Roedel
@ 2007-03-05 14:46 ` Michael Tokarev
2007-03-05 15:06 ` Joerg Roedel
2007-03-05 15:25 ` Andi Kleen
1 sibling, 1 reply; 8+ messages in thread
From: Michael Tokarev @ 2007-03-05 14:46 UTC (permalink / raw)
To: Joerg Roedel; +Cc: discuss, Andi Kleen, linux-kernel
Joerg Roedel wrote:
> +++ b/arch/x86_64/kernel/setup.c
> + static char *x86_svm_flags[] = {
> + "npt",
> + "lbrv",
> + "svmlock",
> + };
A nitpick:
static const char *const x86_svm_flags[] = ... ?
/mjt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 14:46 ` Michael Tokarev
@ 2007-03-05 15:06 ` Joerg Roedel
0 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2007-03-05 15:06 UTC (permalink / raw)
To: Michael Tokarev; +Cc: discuss, Andi Kleen, linux-kernel
On Mon, Mar 05, 2007 at 05:46:27PM +0300, Michael Tokarev wrote:
> Joerg Roedel wrote:
> > +++ b/arch/x86_64/kernel/setup.c
> > + static char *x86_svm_flags[] = {
> > + "npt",
> > + "lbrv",
> > + "svmlock",
> > + };
>
> A nitpick:
>
> static const char *const x86_svm_flags[] = ... ?
Right. Its better to mark the array as const. Will wait
for more comments and send an updated patch soon.
Thanks,
Joerg
--
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 14:39 ` [PATCH 1/2] x86_64: " Joerg Roedel
2007-03-05 14:46 ` Michael Tokarev
@ 2007-03-05 15:25 ` Andi Kleen
2007-03-05 15:58 ` [discuss] " Dave Jones
2007-03-06 12:46 ` Joerg Roedel
1 sibling, 2 replies; 8+ messages in thread
From: Andi Kleen @ 2007-03-05 15:25 UTC (permalink / raw)
To: Joerg Roedel; +Cc: discuss, linux-kernel
On Monday 05 March 2007 15:39, Joerg Roedel wrote:
> From: Joerg Roedel <joerg.roedel@amd.com>
>
> This patch adds the advanced SVM reporting to /proc/cpuinfo on the x86_64
> architecture.
Adding more fields to /proc/cpuinfo is always somewhat risky because
there are lots of badly written parsers for it.
I considered adding the SVM fields myself, but decided against it because
it didn't seem generally useful enough.
-Andi
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [discuss] [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 15:25 ` Andi Kleen
@ 2007-03-05 15:58 ` Dave Jones
2007-03-06 12:46 ` Joerg Roedel
1 sibling, 0 replies; 8+ messages in thread
From: Dave Jones @ 2007-03-05 15:58 UTC (permalink / raw)
To: Andi Kleen; +Cc: Joerg Roedel, discuss, linux-kernel
On Mon, Mar 05, 2007 at 04:25:31PM +0100, Andi Kleen wrote:
> On Monday 05 March 2007 15:39, Joerg Roedel wrote:
> > From: Joerg Roedel <joerg.roedel@amd.com>
> >
> > This patch adds the advanced SVM reporting to /proc/cpuinfo on the x86_64
> > architecture.
>
> Adding more fields to /proc/cpuinfo is always somewhat risky because
> there are lots of badly written parsers for it.
>
> I considered adding the SVM fields myself, but decided against it because
> it didn't seem generally useful enough.
Agreed. I'm more than happy to take patches to x86info however :)
Dave
--
http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86_64: add reporting of SVM flags to /proc/cpuinfo
2007-03-05 15:25 ` Andi Kleen
2007-03-05 15:58 ` [discuss] " Dave Jones
@ 2007-03-06 12:46 ` Joerg Roedel
1 sibling, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2007-03-06 12:46 UTC (permalink / raw)
To: Andi Kleen; +Cc: discuss, linux-kernel
On Mon, Mar 05, 2007 at 04:25:31PM +0100, Andi Kleen wrote:
> On Monday 05 March 2007 15:39, Joerg Roedel wrote:
> > From: Joerg Roedel <joerg.roedel@amd.com>
> >
> > This patch adds the advanced SVM reporting to /proc/cpuinfo on the x86_64
> > architecture.
>
> Adding more fields to /proc/cpuinfo is always somewhat risky because
> there are lots of badly written parsers for it.
Can you point me to some really broken parsers of /proc/cpuinfo to test
with?
> I considered adding the SVM fields myself, but decided against it because
> it didn't seem generally useful enough.
I don't see that this is less important than the power flags in that
file. Some users might be interested to see if their processor has npt
for example by simply looking into cpuinfo.
As I said, would be interested to know more about these badly written
parsers.
Joerg
--
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-03-06 12:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-05 14:36 [PATCH 0/2] add reporting of SVM flags to /proc/cpuinfo Joerg Roedel
2007-03-05 14:39 ` [PATCH 1/2] x86_64: " Joerg Roedel
2007-03-05 14:46 ` Michael Tokarev
2007-03-05 15:06 ` Joerg Roedel
2007-03-05 15:25 ` Andi Kleen
2007-03-05 15:58 ` [discuss] " Dave Jones
2007-03-06 12:46 ` Joerg Roedel
2007-03-05 14:42 ` [PATCH 2/2] i386: " Joerg Roedel
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).