From patchwork Thu Sep 1 14:10:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas Lengyel X-Patchwork-Id: 9309141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0CB0960756 for ; Thu, 1 Sep 2016 14:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5FF429438 for ; Thu, 1 Sep 2016 14:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAD432943A; Thu, 1 Sep 2016 14:13:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A13229438 for ; Thu, 1 Sep 2016 14:13:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfShP-0004sE-HL; Thu, 01 Sep 2016 14:10:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfShN-0004s8-W8 for xen-devel@lists.xenproject.org; Thu, 01 Sep 2016 14:10:34 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id D9/B2-11175-9D638C75; Thu, 01 Sep 2016 14:10:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42K5GHrNRfeG2Yl wg/XrtSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy161MLpqlWtPbOZGlgPCDbxcjFISQwg1Hi xpVJ7CAOi8AbFolXz1aygTgSAu9YJF5s28DYxcgJ5MRI9O2bwgRhV0lM7jrECmILCWhKHNxwh hli1AQmiSM978Aa2ASMJK5e7WEDsUUElCTurZrMBFLELHCISeJc81N2kISwgIfE1POnWEBsFg FViVP3foDZvAL2Em8OtbFBbJOTuLTtC/MERr4FjAyrGDWKU4vKUot0jQz0kooy0zNKchMzc3Q NDcz0clOLixPTU3MSk4r1kvNzNzECg4UBCHYw/loWcIhRkoNJSZRXLe54uBBfUn5KZUZicUZ8 UWlOavEhRhkODiUJ3nSTE+FCgkWp6akVaZk5wLCFSUtw8CiJ8E4FSfMWFyTmFmemQ6ROMRpzb Pl9bS0Tx7ap99YyCbHk5eelSonzrgQpFQApzSjNgxsEi6dLjLJSwryMQKcJ8RSkFuVmlqDKv2 IU52BUEua9AjKFJzOvBG7fK6BTmIBOKbl2HOSUkkSElFQDY83/Dtbzi6q3iexwc2k6ppO65q+ U7d05mku++fBu4fwlFPjiw5P4f58+F6bVftCTcPmQfpL5pckMeYlT/e9yc//PbfvnXaEk0aO5 aPrHX3cVNjVtuC5exb+ej/tWR8QW2d2NU+82zed4eO1MSUeS62yOdKvJxqxBV+TNtOeaHs1db vFZubZ0ohJLcUaioRZzUXEiAFXoUguiAgAA X-Env-Sender: tamas.lengyel@zentific.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1472739031!57134355!1 X-Originating-IP: [209.85.214.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17443 invoked from network); 1 Sep 2016 14:10:32 -0000 Received: from mail-it0-f68.google.com (HELO mail-it0-f68.google.com) (209.85.214.68) by server-6.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Sep 2016 14:10:32 -0000 Received: by mail-it0-f68.google.com with SMTP id g185so3555124ith.0 for ; Thu, 01 Sep 2016 07:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zentific-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=5oGk6kW83I8AO4N3oZMvQJj1O6BYUajKn+tifAQZSr4=; b=Lycj3VanxV6A95X4LVAH1tTdLVEErZjJyPMxtIBzkWxgvXEXlNQkoY8IPg5yF2ppRg YyjsLeLCeAbdNFxzi8f33wxeU2n4cSMlhkpMdSfvOIiY8oPm+enJ9UoJY6MhgB+SNzMq tmqQKU2NzsakT+dw3mTkbfwu4Li0pffsnh3CXvvWMPRTGm8y8kIo+Q+XlATNlRPz1Yt9 z8aFHbIqLsVvk+sMz7Jxv72ywf5qM9U8Y0HyLz3E6KKxqzGvItkk9PKC2N8L5u33Msyy w/cjDpoD75qqDuu7pSGVWom2dLKd2N/a8DFRTiVCO/HsKZUarHj4LhHvY2vW6vAtNowT mRWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5oGk6kW83I8AO4N3oZMvQJj1O6BYUajKn+tifAQZSr4=; b=fBQhApwK6CY+CeakjNymG2YLnyTFC1/QinTePkKP3h8Wp5mf47xF8axmZkqTrM5yvD URz/wp9Sbs94bJpuwXXlxtIk2K02ozZK/UswQJJ36iLMbRfsVhSI0aKMb4xw/HGB4tAL JvuUZdQBDoLpY6st341C3JNFmaw1FusD0nQdHkc8DMJre9GpoSSWj4Um2uvKjvRRMQtP G3aE/HtVWo0I6IOlBmwW9vUCXGBvdS7YerfVlNcg2A7BONNFY4g25FK7xS4sc+65CSa8 qs040zdI9qMDeECPB81uSyoRjV6jO0WPHcw8/Jt5yWJ0qAK20+hZokvqdNURDWMECiCm NG1A== X-Gm-Message-State: AE9vXwPT2+Hzuv65USYtmhzeWDxTIPBfNEyEoNKTClL+hObZ/05p0I0m/6VhaaF2dC61/Q== X-Received: by 10.36.25.144 with SMTP id b138mr37699586itb.29.1472739031266; Thu, 01 Sep 2016 07:10:31 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id q1sm16052175itb.2.2016.09.01.07.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 07:10:30 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Thu, 1 Sep 2016 08:10:25 -0600 Message-Id: <20160901141025.26611-1-tamas.lengyel@zentific.com> X-Mailer: git-send-email 2.9.3 Cc: Kevin Tian , Wei Liu , Jun Nakajima , Razvan Cojocaru , Tamas K Lengyel , Ian Jackson , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v2] x86/monitor: Include EAX/ECX in CPUID monitor events X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extend the CPUID monitor event to include EAX and ECX values that were used when CPUID was executed. This is useful in identifying which leaf was queried. We also adjust the xen-access output format to more closely resemble the output of the Linux cpuid tool's raw format. Signed-off-by: Tamas K Lengyel Reviewed-by: Andrew Cooper Acked-by: Razvan Cojocaru --- Cc: Razvan Cojocaru Cc: Ian Jackson Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: Jun Nakajima Cc: Kevin Tian v2: Rename eax/ecx to leaf and subleaf Correct typo --- tools/tests/xen-access/xen-access.c | 4 +++- xen/arch/x86/hvm/monitor.c | 5 ++++- xen/arch/x86/hvm/vmx/vmx.c | 6 +++++- xen/include/asm-x86/hvm/monitor.h | 3 ++- xen/include/public/vm_event.h | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index ebb63b1..ed18c71 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -735,10 +735,12 @@ int main(int argc, char *argv[]) break; case VM_EVENT_REASON_CPUID: printf("CPUID executed: rip=%016"PRIx64", vcpu %d. Insn length: %"PRIu32" " \ - "EAX: 0x%"PRIx64" EBX: 0x%"PRIx64" ECX: 0x%"PRIx64" EDX: 0x%"PRIx64"\n", + "0x%"PRIx32" 0x%"PRIx32": EAX=0x%"PRIx64" EBX=0x%"PRIx64" ECX=0x%"PRIx64" EDX=0x%"PRIx64"\n", req.data.regs.x86.rip, req.vcpu_id, req.u.cpuid.insn_length, + req.u.cpuid.leaf, + req.u.cpuid.subleaf, req.data.regs.x86.rax, req.data.regs.x86.rbx, req.data.regs.x86.rcx, diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index 7277c12..53ab804 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -136,7 +136,8 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type, return monitor_traps(curr, sync, &req); } -int hvm_monitor_cpuid(unsigned long insn_length) +int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf, + unsigned int subleaf) { struct vcpu *curr = current; struct arch_domain *ad = &curr->domain->arch; @@ -148,6 +149,8 @@ int hvm_monitor_cpuid(unsigned long insn_length) req.reason = VM_EVENT_REASON_CPUID; req.vcpu_id = curr->vcpu_id; req.u.cpuid.insn_length = insn_length; + req.u.cpuid.leaf = leaf; + req.u.cpuid.subleaf = subleaf; return monitor_traps(curr, 1, &req); } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 3d330b6..bb7a329 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2402,12 +2402,16 @@ static void vmx_cpuid_intercept( static int vmx_do_cpuid(struct cpu_user_regs *regs) { unsigned int eax, ebx, ecx, edx; + unsigned int leaf, subleaf; eax = regs->eax; ebx = regs->ebx; ecx = regs->ecx; edx = regs->edx; + leaf = regs->eax; + subleaf = regs->ecx; + vmx_cpuid_intercept(&eax, &ebx, &ecx, &edx); regs->eax = eax; @@ -2415,7 +2419,7 @@ static int vmx_do_cpuid(struct cpu_user_regs *regs) regs->ecx = ecx; regs->edx = edx; - return hvm_monitor_cpuid(get_instruction_length()); + return hvm_monitor_cpuid(get_instruction_length(), leaf, subleaf); } static void vmx_dr_access(unsigned long exit_qualification, diff --git a/xen/include/asm-x86/hvm/monitor.h b/xen/include/asm-x86/hvm/monitor.h index a92f3fc..82b85ec 100644 --- a/xen/include/asm-x86/hvm/monitor.h +++ b/xen/include/asm-x86/hvm/monitor.h @@ -40,7 +40,8 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, void hvm_monitor_msr(unsigned int msr, uint64_t value); int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type, unsigned long trap_type, unsigned long insn_length); -int hvm_monitor_cpuid(unsigned long insn_length); +int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf, + unsigned int subleaf); #endif /* __ASM_X86_HVM_MONITOR_H__ */ diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index 64e6857..99d60ea 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -226,6 +226,8 @@ struct vm_event_mov_to_msr { struct vm_event_cpuid { uint32_t insn_length; + uint32_t leaf; + uint32_t subleaf; uint32_t _pad; };