From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J00AO-0006qJ-SW for qemu-devel@nongnu.org; Wed, 05 Dec 2007 14:44:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J00AN-0006q7-E0 for qemu-devel@nongnu.org; Wed, 05 Dec 2007 14:44:20 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J00AN-0006q4-8Q for qemu-devel@nongnu.org; Wed, 05 Dec 2007 14:44:19 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J00AM-0005Ri-QB for qemu-devel@nongnu.org; Wed, 05 Dec 2007 14:44:19 -0500 Received: from erwin.inf.tu-dresden.de ([141.76.48.80] helo=chrom.inf.tu-dresden.de) by os.inf.tu-dresden.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.68) id 1J00AJ-0007SV-GT for qemu-devel@nongnu.org; Wed, 05 Dec 2007 20:44:15 +0100 Received: from kauer by chrom.inf.tu-dresden.de with local (Exim 4.68) (envelope-from ) id 1J00AN-00057S-KK for qemu-devel@nongnu.org; Wed, 05 Dec 2007 20:44:19 +0100 Date: Wed, 5 Dec 2007 20:44:19 +0100 From: Bernhard Kauer Message-ID: <20071205194419.GA18291@chrom.inf.tu-dresden.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZfOjI3PrQbgiZnxM" Content-Disposition: inline Subject: [Qemu-devel] [PATCH] add rdpmc intercept for SVM Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --ZfOjI3PrQbgiZnxM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The attached patch adds an SVM intercept for rdpmc to qemu, thus allowing a VMM to virtualize them. Please note that performance counters are currently unimplemented in qemu. Bernhard Kauer --ZfOjI3PrQbgiZnxM Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="qemu_rdpmc.diff" Index: target-i386/helper.c --- target-i386/helper.c 18 Nov 2007 01:44:38 -0000 1.95 +++ target-i386/helper.c 5 Dec 2007 19:31:31 -0000 @@ -2743,6 +2816,19 @@ EDX = (uint32_t)(val >> 32); } +void helper_rdpmc() +{ + if ((env->cr[4] & CR4_PCE_MASK) && ((env->hflags & HF_CPL_MASK) != 0)) { + raise_exception(EXCP0D_GPF); + } + + if (!svm_check_intercept_param(SVM_EXIT_RDPMC, 0)) + { + // currently unimplemented + raise_exception_err(EXCP06_ILLOP, 0); + } +} + #if defined(CONFIG_USER_ONLY) void helper_wrmsr(void) { Index: target-i386/op.c --- target-i386/op.c 23 Sep 2007 15:28:04 -0000 1.51 +++ target-i386/op.c 5 Dec 2007 19:31:32 -0000 @@ -953,6 +953,11 @@ helper_rdtsc(); } +void OPPROTO op_rdpmc(void) +{ + helper_rdpmc(); +} + void OPPROTO op_cpuid(void) { helper_cpuid(); Index: target-i386/translate.c --- target-i386/translate.c 8 Nov 2007 14:25:03 -0000 1.74 +++ target-i386/translate.c 5 Dec 2007 19:31:38 -0000 @@ -5653,5 +5653,9 @@ gen_op_rdtsc(); break; + case 0x133: /* rdpmc */ + gen_jmp_im(pc_start - s->cs_base); + gen_op_rdpmc(); + break; case 0x134: /* sysenter */ if (CODE64(s)) goto illegal_op; --ZfOjI3PrQbgiZnxM--