Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add a version argument, set to 1, and check it in usr.bin/pm...
details: https://anonhg.NetBSD.org/src/rev/5e7ff724a7b7
branches: trunk
changeset: 351973:5e7ff724a7b7
user: maxv <maxv%NetBSD.org@localhost>
date: Wed Mar 08 16:42:27 2017 +0000
description:
Add a version argument, set to 1, and check it in usr.bin/pmc. Use uint32_t
instead uint8_t since we now need 12bit selectors (10h family). And while
here KNF.
diffstat:
sys/arch/i386/i386/pmc.c | 9 +-
sys/arch/x86/include/sysarch.h | 104 ++++++++++++++++++++--------------------
usr.bin/pmc/pmc.c | 6 +-
3 files changed, 61 insertions(+), 58 deletions(-)
diffs (225 lines):
diff -r 61b79f0c5e61 -r 5e7ff724a7b7 sys/arch/i386/i386/pmc.c
--- a/sys/arch/i386/i386/pmc.c Wed Mar 08 16:09:27 2017 +0000
+++ b/sys/arch/i386/i386/pmc.c Wed Mar 08 16:42:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmc.c,v 1.23 2017/02/18 15:56:03 maxv Exp $ */
+/* $NetBSD: pmc.c,v 1.24 2017/03/08 16:42:27 maxv Exp $ */
/*
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.23 2017/02/18 15:56:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.24 2017/03/08 16:42:27 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -275,6 +275,7 @@
memset(&rv, 0, sizeof(rv));
+ rv.vers = PMC_VERSION;
rv.type = pmc_type;
rv.flags = pmc_flags;
@@ -297,7 +298,7 @@
if (error)
return error;
- if (args.counter < 0 || args.counter >= pmc_ncounters)
+ if (args.counter >= pmc_ncounters)
return EINVAL;
start = (args.flags & (PMC_SETUP_KERNEL|PMC_SETUP_USER)) != 0;
@@ -338,7 +339,7 @@
if (error)
return error;
- if (args.counter < 0 || args.counter >= pmc_ncounters)
+ if (args.counter >= pmc_ncounters)
return EINVAL;
pmc = &pmc_state[args.counter];
diff -r 61b79f0c5e61 -r 5e7ff724a7b7 sys/arch/x86/include/sysarch.h
--- a/sys/arch/x86/include/sysarch.h Wed Mar 08 16:09:27 2017 +0000
+++ b/sys/arch/x86/include/sysarch.h Wed Mar 08 16:42:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysarch.h,v 1.9 2010/07/07 01:14:53 chs Exp $ */
+/* $NetBSD: sysarch.h,v 1.10 2017/03/08 16:42:27 maxv Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -34,62 +34,62 @@
#define X86_GET_LDT 0
#define X86_SET_LDT 1
-#define X86_IOPL 2
-#define X86_GET_IOPERM 3
-#define X86_SET_IOPERM 4
-#define X86_OLD_VM86 5
-#define X86_PMC_INFO 8
-#define X86_PMC_STARTSTOP 9
-#define X86_PMC_READ 10
+#define X86_IOPL 2
+#define X86_GET_IOPERM 3
+#define X86_SET_IOPERM 4
+#define X86_OLD_VM86 5
+#define X86_PMC_INFO 8
+#define X86_PMC_STARTSTOP 9
+#define X86_PMC_READ 10
#define X86_GET_MTRR 11
#define X86_SET_MTRR 12
-#define X86_VM86 13
-#define X86_GET_GSBASE 14
-#define X86_GET_FSBASE 15
-#define X86_SET_GSBASE 16
-#define X86_SET_FSBASE 17
+#define X86_VM86 13
+#define X86_GET_GSBASE 14
+#define X86_GET_FSBASE 15
+#define X86_SET_GSBASE 16
+#define X86_SET_FSBASE 17
#ifdef _KERNEL
-#define _X86_SYSARCH_L(x) x86_##x
-#define _X86_SYSARCH_U(x) X86_##x
+#define _X86_SYSARCH_L(x) x86_##x
+#define _X86_SYSARCH_U(x) X86_##x
#elif defined(__i386__)
-#define _X86_SYSARCH_L(x) i386_##x
-#define _X86_SYSARCH_U(x) I386_##x
+#define _X86_SYSARCH_L(x) i386_##x
+#define _X86_SYSARCH_U(x) I386_##x
#define I386_GET_LDT X86_GET_LDT
#define I386_SET_LDT X86_SET_LDT
-#define I386_IOPL X86_IOPL
-#define I386_GET_IOPERM X86_GET_IOPERM
-#define I386_SET_IOPERM X86_SET_IOPERM
-#define I386_OLD_VM86 X86_OLD_VM86
-#define I386_PMC_INFO X86_PMC_INFO
-#define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
-#define I386_PMC_READ X86_PMC_READ
+#define I386_IOPL X86_IOPL
+#define I386_GET_IOPERM X86_GET_IOPERM
+#define I386_SET_IOPERM X86_SET_IOPERM
+#define I386_OLD_VM86 X86_OLD_VM86
+#define I386_PMC_INFO X86_PMC_INFO
+#define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
+#define I386_PMC_READ X86_PMC_READ
#define I386_GET_MTRR X86_GET_MTRR
#define I386_SET_MTRR X86_SET_MTRR
-#define I386_VM86 X86_VM86
-#define I386_GET_GSBASE X86_GET_GSBASE
-#define I386_GET_FSBASE X86_GET_FSBASE
-#define I386_SET_GSBASE X86_SET_GSBASE
-#define I386_SET_FSBASE X86_SET_FSBASE
+#define I386_VM86 X86_VM86
+#define I386_GET_GSBASE X86_GET_GSBASE
+#define I386_GET_FSBASE X86_GET_FSBASE
+#define I386_SET_GSBASE X86_SET_GSBASE
+#define I386_SET_FSBASE X86_SET_FSBASE
#else
-#define _X86_SYSARCH_L(x) x86_64_##x
-#define _X86_SYSARCH_U(x) X86_64_##x
+#define _X86_SYSARCH_L(x) x86_64_##x
+#define _X86_SYSARCH_U(x) X86_64_##x
#define X86_64_GET_LDT X86_GET_LDT
#define X86_64_SET_LDT X86_SET_LDT
-#define X86_64_IOPL X86_IOPL
-#define X86_64_GET_IOPERM X86_GET_IOPERM
-#define X86_64_SET_IOPERM X86_SET_IOPERM
-#define X86_64_OLD_VM86 X86_OLD_VM86
-#define X86_64_PMC_INFO X86_PMC_INFO
-#define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
-#define X86_64_PMC_READ X86_PMC_READ
+#define X86_64_IOPL X86_IOPL
+#define X86_64_GET_IOPERM X86_GET_IOPERM
+#define X86_64_SET_IOPERM X86_SET_IOPERM
+#define X86_64_OLD_VM86 X86_OLD_VM86
+#define X86_64_PMC_INFO X86_PMC_INFO
+#define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
+#define X86_64_PMC_READ X86_PMC_READ
#define X86_64_GET_MTRR X86_GET_MTRR
#define X86_64_SET_MTRR X86_SET_MTRR
-#define X86_64_VM86 X86_VM86
+#define X86_64_VM86 X86_VM86
#define X86_64_GET_GSBASE X86_GET_GSBASE
-#define X86_64_GET_FSBASE X86_GET_FSBASE
+#define X86_64_GET_FSBASE X86_GET_FSBASE
#define X86_64_SET_GSBASE X86_SET_GSBASE
-#define X86_64_SET_FSBASE X86_SET_FSBASE
+#define X86_64_SET_FSBASE X86_SET_FSBASE
#endif
/*
@@ -131,30 +131,30 @@
};
struct _X86_SYSARCH_L(pmc_info_args) {
- int type;
- int flags;
+ int vers;
+ int type;
+ int flags;
};
+#define PMC_VERSION 1
+
#define PMC_TYPE_NONE 0
#define PMC_TYPE_I586 1
#define PMC_TYPE_I686 2
#define PMC_TYPE_K7 3
+#define PMC_TYPE_F10H 4
#define PMC_INFO_HASTSC 0x01
-#ifdef __i386__
#define PMC_NCOUNTERS 4
-#else
-#define PMC_NCOUNTERS 2
-#endif
struct _X86_SYSARCH_L(pmc_startstop_args) {
- int counter;
+ uint32_t counter;
uint64_t val;
- uint8_t event;
- uint8_t unit;
- uint8_t compare;
- uint8_t flags;
+ uint32_t event;
+ uint32_t unit;
+ uint32_t compare;
+ uint32_t flags;
};
#define PMC_SETUP_KERNEL 0x01
diff -r 61b79f0c5e61 -r 5e7ff724a7b7 usr.bin/pmc/pmc.c
--- a/usr.bin/pmc/pmc.c Wed Mar 08 16:09:27 2017 +0000
+++ b/usr.bin/pmc/pmc.c Wed Mar 08 16:42:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmc.c,v 1.18 2017/02/18 16:48:38 maxv Exp $ */
+/* $NetBSD: pmc.c,v 1.19 2017/03/08 16:42:27 maxv Exp $ */
/*
* Copyright 2000 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pmc.c,v 1.18 2017/02/18 16:48:38 maxv Exp $");
+__RCSID("$NetBSD: pmc.c,v 1.19 2017/03/08 16:42:27 maxv Exp $");
#endif
#include <sys/types.h>
@@ -426,6 +426,8 @@
if (x86_pmc_info(&pmcinfo) < 0)
errx(2, "PMC support is not compiled into the kernel");
+ if (pmcinfo.vers != 1)
+ errx(2, "Wrong PMC version");
pncp = pmc_lookup_cpu(pmcinfo.type);
if (pncp == NULL)
Home |
Main Index |
Thread Index |
Old Index