From patchwork Thu Sep 14 18:35:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 112612 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1095902qgf; Thu, 14 Sep 2017 11:38:45 -0700 (PDT) X-Received: by 10.55.52.207 with SMTP id b198mr4249749qka.60.1505414325934; Thu, 14 Sep 2017 11:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505414325; cv=none; d=google.com; s=arc-20160816; b=wHhEOqcF+RwYJ8oi+BiaAOX9ShzJ56ASfhBNfK6m9j87aKMjLmOaynh0aZXwh1iKKk oC7OupJjYk7241CAfOQbYW66jEm6brsEd5pyIXRkXEexO8dy7s8ZCrAN87ZkBg+PJ54R lyQFEcE7Wl+s7Ca5jIqvuSv/gYnyyLqGnxGeiA5zNrPFFcDiNfj00vXbvJ+6zLdM4a9a OyO61pU1PjKcm4K8XRnpSI94ejDDfKw+fxWNNWK+aMfxBh6NnQBDFWwD5rCuJck1oyLv PXcUMHx/+cQD0N6zq5fDyyiuTy0yYJYxKypttXCOWeFcq1giZcao7c+Ug2wIpffO8hJQ v8yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=j/AYa9vvFOw0tDoZDdHloxfWiPh/pwMp37woJ/r2Ay0=; b=be91SOVx7sCAC3QqZPsDVrGNPMm9qHHHjknlPcvlG7WVl8vLjYILD5tiOhyRV4gH6I zln9qLpO2ZlFR0LzxCtz0CuMMAMARS+lPdlDFDKio8wKvYot7u2bq71XbwMHdUeFkA7j /YwozjoAsJ9ece2/iThp/EuGZkOFT2Rfrbqh9JcpEp/NVCMHDDkl3jDQ4CAvjBRBmBa1 xfHBXoFuk8MdOgWCBDSfpEK3gu6SWUNV9gbElZJdmXGTTqDRyv2lbIBuun6KGK1mPm5Z qWBCRg+t1bN1/zLxje9JmBah9QFWdH68DGcCiUtWQStzpp5xhD7ln6spIqgZSoZX/c98 2e7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dKEKIQZq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n2si16999501qkc.368.2017.09.14.11.38.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Sep 2017 11:38:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dKEKIQZq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsZ2B-000365-Km for patch@linaro.org; Thu, 14 Sep 2017 14:38:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsYz0-0000P2-K0 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 14:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsYyw-0000OW-PV for qemu-devel@nongnu.org; Thu, 14 Sep 2017 14:35:26 -0400 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:51036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsYyw-0000MS-Jj for qemu-devel@nongnu.org; Thu, 14 Sep 2017 14:35:22 -0400 Received: by mail-pg0-x22e.google.com with SMTP id p5so117627pgn.7 for ; Thu, 14 Sep 2017 11:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=j/AYa9vvFOw0tDoZDdHloxfWiPh/pwMp37woJ/r2Ay0=; b=dKEKIQZqZNvdVMg/oCB5Y/qy23I+oOeW1RJVkRqSMigNkffViAtei4XvgZ3WpVy7T6 T9MnpYERp1nwo3OFyBYeWykxh2aqyU3O1Aeg82Twi5U3ohB0DRuJqnhP1KbH0YvO+HP5 gZJ3QSqF/3Mb3dcTFVcQWvWHMjuJEvQ24d5q4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=j/AYa9vvFOw0tDoZDdHloxfWiPh/pwMp37woJ/r2Ay0=; b=osUfIa/welVMTdD4O0hzyftj9dAEuVI1QlBVeXEdvwIgXFL+KxK6QNG8BSjFZ0i8uz vrhfXbR+45Y6W9QQMMUkSNqJLWuXcO/78rFKWX1s5yXeSYZddkfNWNABpLeZ8HbWMRMq nPEbmlW+QhD/nP9thE7IF7MlfxlWMyevrfsB3bctgtVQuN/e6KzjfPsG3l8lhCAY8Ef6 +bm478EpBB0gDjF0u1yo3Q2GXzT0pFf2AMjwIlbF8F70hZJjZAylXre4N2EmIvDVF/7p F5p5uWXbEvVnSQl5pcL4NvpqM7DrXJU+3CrFgvCHTL91XC1G4P7pL5uATxepyIxgPsOZ qkSw== X-Gm-Message-State: AHPjjUifYFsuqHupoQhpZebFkLuKx1kZAXsXmEwxNQool0pidWRbQJ7X HrgS2pZ5oqnVR6aBjIvbdA== X-Google-Smtp-Source: ADKCNb40H3GqYdZ1lwcSTrFV4lG3gz/A9XMXo3cE+M32v/E8MNISzQp1sQ4a1EJPZxbgtAI1MWL88A== X-Received: by 10.98.163.153 with SMTP id q25mr21833367pfl.183.1505414120043; Thu, 14 Sep 2017 11:35:20 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-103-167.tukw.qwest.net. [97.126.103.167]) by smtp.gmail.com with ESMTPSA id l85sm32473848pfb.176.2017.09.14.11.35.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2017 11:35:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 11:35:07 -0700 Message-Id: <20170914183516.19537-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170914183516.19537-1-richard.henderson@linaro.org> References: <20170914183516.19537-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22e Subject: [Qemu-devel] [PATCH 01/10] target/i386: Convert to disas_set_info hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- disas.c | 22 ++-------------------- monitor.c | 21 --------------------- target/i386/cpu.c | 12 ++++++++++++ target/i386/translate.c | 8 +------- 4 files changed, 15 insertions(+), 48 deletions(-) -- 2.13.5 Reviewed-by: Alex Bennée diff --git a/disas.c b/disas.c index d6a1eb9c8e..2be716fdb2 100644 --- a/disas.c +++ b/disas.c @@ -205,16 +205,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if ((flags >> 16) & 1) { s.info.endian = BFD_ENDIAN_LITTLE; } @@ -390,16 +381,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if (flags & 0xFFFF) { /* If we have a precise definition of the instruction set, use it. */ s.info.mach = flags & 0xFFFF; diff --git a/monitor.c b/monitor.c index 9239f7adde..3f3ebc31ef 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,27 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_I386 - CPUArchState *env = mon_get_cpu_env(); - if (wsize == 2) { - flags = 1; - } else if (wsize == 4) { - flags = 0; - } else { - /* as default we use the current CS size */ - flags = 0; - if (env) { -#ifdef TARGET_X86_64 - if ((env->efer & MSR_EFER_LMA) && - (env->segs[R_CS].flags & DESC_L_MASK)) - flags = 2; - else -#endif - if (!(env->segs[R_CS].flags & DESC_B_MASK)) - flags = 1; - } - } -#endif #ifdef TARGET_PPC CPUArchState *env = mon_get_cpu_env(); flags = msr_le << 16; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 69676e13e1..b869a69c53 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4099,6 +4099,17 @@ static bool x86_cpu_has_work(CPUState *cs) !(env->hflags & HF_SMM_MASK)); } +static void x86_disas_set_info(CPUState *cs, disassemble_info *info) +{ + X86CPU *cpu = X86_CPU(cs); + CPUX86State *env = &cpu->env; + + info->mach = (env->hflags & HF_CS64_MASK ? bfd_mach_x86_64 + : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 + : bfd_mach_i386_i8086); + info->print_insn = print_insn_i386; +} + static Property x86_cpu_properties[] = { #ifdef CONFIG_USER_ONLY /* apic_id = 0 by default for *-user, see commit 9886e834 */ @@ -4204,6 +4215,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) #endif cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->disas_set_info = x86_disas_set_info; dc->user_creatable = true; } diff --git a/target/i386/translate.c b/target/i386/translate.c index de0c989763..06c2cb9e64 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8526,15 +8526,9 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - int disas_flags = !dc->code32; qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); -#ifdef TARGET_X86_64 - if (dc->code64) { - disas_flags = 2; - } -#endif - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, disas_flags); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); } static const TranslatorOps i386_tr_ops = {