Deleted Added
full compact
hwpmc_piv.c (145338) hwpmc_piv.c (145615)
1/*-
2 * Copyright (c) 2003-2005 Joseph Koshy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003-2005 Joseph Koshy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_piv.c 145338 2005-04-20 20:26:39Z marcel $");
28__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_piv.c 145615 2005-04-28 08:13:19Z jkoshy $");
29
30#include <sys/param.h>
31#include <sys/lock.h>
32#include <sys/mutex.h>
33#include <sys/pmc.h>
34#include <sys/pmckern.h>
35#include <sys/smp.h>
36#include <sys/systm.h>

--- 536 unchanged lines hidden (view full) ---

573 return 0;
574}
575
576/*
577 * Context switch in.
578 */
579
580static int
29
30#include <sys/param.h>
31#include <sys/lock.h>
32#include <sys/mutex.h>
33#include <sys/pmc.h>
34#include <sys/pmckern.h>
35#include <sys/smp.h>
36#include <sys/systm.h>

--- 536 unchanged lines hidden (view full) ---

573 return 0;
574}
575
576/*
577 * Context switch in.
578 */
579
580static int
581p4_switch_in(struct pmc_cpu *pc)
581p4_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
582{
583 (void) pc;
582{
583 (void) pc;
584
585 PMCDBG(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp,
586 (pp->pp_flags & PMC_FLAG_ENABLE_MSR_ACCESS) != 0);
587
584 /* enable the RDPMC instruction */
588 /* enable the RDPMC instruction */
585 load_cr4(rcr4() | CR4_PCE);
589 if (pp->pp_flags & PMC_FLAG_ENABLE_MSR_ACCESS)
590 load_cr4(rcr4() | CR4_PCE);
591
592 PMCDBG(MDP,SWI,2, "cr4=0x%x", rcr4());
593
586 return 0;
587}
588
589/*
590 * Context switch out.
591 */
592
593static int
594 return 0;
595}
596
597/*
598 * Context switch out.
599 */
600
601static int
594p4_switch_out(struct pmc_cpu *pc)
602p4_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
595{
596 (void) pc;
603{
604 (void) pc;
597 /* disallow RDPMC instruction */
605 (void) pp; /* can be null */
606
607 PMCDBG(MDP,SWO,1, "pc=%p pp=%p", pc, pp);
608
609 /* always disallow the RDPMC instruction */
598 load_cr4(rcr4() & ~CR4_PCE);
610 load_cr4(rcr4() & ~CR4_PCE);
611
612 PMCDBG(MDP,SWO,2, "cr4=0x%x", rcr4());
613
599 return 0;
600}
601
602/*
603 * Read a PMC
604 */
605
606static int

--- 807 unchanged lines hidden (view full) ---

1414 */
1415
1416static int
1417p4_get_msr(int ri, uint32_t *msr)
1418{
1419 KASSERT(ri >= 0 && ri < P4_NPMCS,
1420 ("[p4,%d] ri %d out of range", __LINE__, ri));
1421
614 return 0;
615}
616
617/*
618 * Read a PMC
619 */
620
621static int

--- 807 unchanged lines hidden (view full) ---

1429 */
1430
1431static int
1432p4_get_msr(int ri, uint32_t *msr)
1433{
1434 KASSERT(ri >= 0 && ri < P4_NPMCS,
1435 ("[p4,%d] ri %d out of range", __LINE__, ri));
1436
1422 *msr = p4_pmcdesc[ri].pm_pmc_msr;
1437 *msr = p4_pmcdesc[ri].pm_pmc_msr - P4_PERFCTR_MSR_FIRST;
1438
1439 PMCDBG(MDP,OPS, 1, "ri=%d getmsr=0x%x", ri, *msr);
1440
1423 return 0;
1424}
1425
1426
1427int
1428pmc_initialize_p4(struct pmc_mdep *pmc_mdep)
1429{
1430 struct p4_event_descr *pe;

--- 50 unchanged lines hidden ---
1441 return 0;
1442}
1443
1444
1445int
1446pmc_initialize_p4(struct pmc_mdep *pmc_mdep)
1447{
1448 struct p4_event_descr *pe;

--- 50 unchanged lines hidden ---