From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH kvm-unit-tests 3/4] Add rdpmc instruction accessor Date: Mon, 13 Jun 2011 15:28:46 +0300 Message-ID: <1307968127-22440-4-git-send-email-avi@redhat.com> References: <1307968127-22440-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65305 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752304Ab1FMM2v (ORCPT ); Mon, 13 Jun 2011 08:28:51 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5DCSpND018445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jun 2011 08:28:51 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5DCSo8f021806 for ; Mon, 13 Jun 2011 08:28:50 -0400 In-Reply-To: <1307968127-22440-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- lib/x86/processor.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/lib/x86/processor.h b/lib/x86/processor.h index f69f9ff..c7e1afb 100644 --- a/lib/x86/processor.h +++ b/lib/x86/processor.h @@ -2,6 +2,7 @@ #define LIBCFLAT_PROCESSOR_H #include "libcflat.h" +#include struct descriptor_table_ptr { u16 limit; @@ -99,6 +100,13 @@ static inline void wrmsr(u32 index, u64 val) asm volatile ("wrmsr" : : "a"(a), "d"(d), "c"(index) : "memory"); } +static inline uint64_t rdpmc(uint32_t index) +{ + uint32_t a, d; + asm volatile ("rdpmc" : "=a"(a), "=d"(d) : "c"(index)); + return a | ((uint64_t)d << 32); +} + static inline void write_cr0(ulong val) { asm volatile ("mov %0, %%cr0" : : "r"(val) : "memory"); -- 1.7.5.3