From: Chao Peng Subject: [PATCH v4 1/5] x86: allow reading MSR_IA32_TSC with XENPF_resource_op Date: Tue, 20 Jan 2015 17:45:53 +0800 Message-ID: <1421747157-29191-2-git-send-email-chao.p.peng@linux.intel.com> References: <1421747157-29191-1-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421747157-29191-1-git-send-email-chao.p.peng@linux.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, will.auld@intel.com, JBeulich@suse.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org Memory bandwidth monitoring requires timestamp returned along with the monitoring counter to verify the correctness of the counter value. Allow MSR_IA32_TSC to be read and increase RESOURCE_ACCESS_MAX_ENTRIES to 3. Signed-off-by: Chao Peng --- xen/arch/x86/platform_hypercall.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c index 32f39b2..e80b857 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -61,14 +61,14 @@ long cpu_down_helper(void *data); long core_parking_helper(void *data); uint32_t get_cur_idle_nums(void); -#define RESOURCE_ACCESS_MAX_ENTRIES 2 +#define RESOURCE_ACCESS_MAX_ENTRIES 3 struct xen_resource_access { unsigned int nr_done; unsigned int nr_entries; xenpf_resource_entry_t *entries; }; -static bool_t allow_access_msr(unsigned int msr) +static bool_t allow_access_msr(unsigned int msr, unsigned int cmd) { switch ( msr ) { @@ -76,6 +76,8 @@ static bool_t allow_access_msr(unsigned int msr) case MSR_IA32_CMT_EVTSEL: case MSR_IA32_CMT_CTR: return 1; + case MSR_IA32_TSC: + return cmd == XEN_RESOURCE_OP_MSR_READ; } return 0; @@ -102,7 +104,7 @@ static void check_resource_access(struct xen_resource_access *ra) case XEN_RESOURCE_OP_MSR_WRITE: if ( entry->idx >> 32 ) ret = -EINVAL; - else if ( !allow_access_msr(entry->idx) ) + else if ( !allow_access_msr(entry->idx, entry->u.cmd) ) ret = -EACCES; break; default: -- 1.9.1