From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 2/7] KVM: x86 emulator: Support for declaring single operand fastops Date: Sat, 22 Dec 2012 14:26:52 +0200 Message-ID: <1356179217-5526-3-git-send-email-avi.kivity@gmail.com> References: <1356179217-5526-1-git-send-email-avi.kivity@gmail.com> Cc: kvm@vger.kernel.org To: Marcelo Tosatti , Gleb Natapov Return-path: Received: from mail-wg0-f51.google.com ([74.125.82.51]:38548 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059Ab2LVMce (ORCPT ); Sat, 22 Dec 2012 07:32:34 -0500 Received: by mail-wg0-f51.google.com with SMTP id gg4so2497801wgb.6 for ; Sat, 22 Dec 2012 04:32:33 -0800 (PST) In-Reply-To: <1356179217-5526-1-git-send-email-avi.kivity@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- arch/x86/kvm/emulate.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index cdf7b97..9859df6 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -24,6 +24,7 @@ #include "kvm_cache_regs.h" #include #include +#include #include "x86.h" #include "tss.h" @@ -432,6 +433,30 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt) } \ } while (0) +#define FOP_ALIGN ".align " __stringify(FASTOP_SIZE) " \n\t" +#define FOP_RET "ret \n\t" + +#define FOP_START(op) \ + extern void em_##op(struct fastop *fake); \ + asm(".pushsection .text, \"ax\" \n\t" \ + ".global em_" #op " \n\t" \ + FOP_ALIGN \ + "em_" #op ": \n\t" + +#define FOP_END \ + ".popsection") + +#define FOP1E(op, dst) \ + FOP_ALIGN #op " %" #dst " \n\t" FOP_RET + +#define FASTOP1(op) \ + FOP_START(op) \ + FOP1E(op##b, al) \ + FOP1E(op##w, ax) \ + FOP1E(op##l, eax) \ + ON64(FOP1E(op##q, rax)) \ + FOP_END + #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex) \ do { \ unsigned long _tmp; \ -- 1.7.11.7