From patchwork Thu Oct 19 15:51:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116405 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp647585qgn; Thu, 19 Oct 2017 08:54:12 -0700 (PDT) X-Received: by 10.55.170.74 with SMTP id t71mr2606471qke.84.1508428452579; Thu, 19 Oct 2017 08:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428452; cv=none; d=google.com; s=arc-20160816; b=jgzfrUgGXQoDBQKU00vTLorWHB4s7rD6NOcBlZuL6gskx/4/4+WM4RpKejdEbB0R+G SEQyVY2OHT+tmQQdFTcijdsbbGFDxhnbJYufr8sscEaDOUczw7LXLy9WFOJ2wDCxFmnQ aeg8vVAazs21vSz9R0WkGKLr7HC/5ZAEg/LSQlh8ZiC2nIPhnCGgDMC9YKbYJJqMnbwO M50uXeelTJqAhgfx8F5AFshyLnbkeLiSgC1wirQTcuepsZ2Tuj6rjH3CMvwCJBXakiQg r24Bkh7Gvk6gkgJbRCxitJ3pKQFhWvMrR/F/Cv6mvLFNRNcp82T+YHcy3IT1Kh7YBbCh uICA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=eqmwbQqhDeW7SUa/Gm1viVaFNSiHNxF40omEz/xnr4cYCdOGdxZZ905ipMcO47kNts nl8mh+7BKTlw49arrsZmLYbCC54ku54RjVFkoDX326UG7RjFIFdGYMDguZmRVJKawumc xZJGE/p3H0zbKMDRsb+GZ44LZ0NLALyWQDd8FbzHkmee93uepLIEVVKn6e4Jmqyb+sY8 gd9G71wj99cj3GG/qqpiXZb1QvvRA+k0ccimZJDyGxY+5usBXRAA5T55nW3ssCd1+eZh SP5c4TKD7ahfbx2q8IN2tWoST3fEQ9FYZl0eSk3Wovr1v3AR9a5hXEfpv5dk3lsdmeN8 uM4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BwK0MqGx; 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 u37si1911235qtk.309.2017.10.19.08.54.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:54:12 -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=BwK0MqGx; 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]:49834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D98-0008Lu-A7 for patch@linaro.org; Thu, 19 Oct 2017 11:54:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D6z-000792-3t for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D6v-0000CU-Fs for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:57 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:46245) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6v-0000BB-8c for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:53 -0400 Received: by mail-pf0-x242.google.com with SMTP id p87so6869430pfj.3 for ; Thu, 19 Oct 2017 08:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=BwK0MqGxYwPwnA4yrwecxeZHvbG19aB5s3zwA5cE4KP5/al2vRnwTyt0O1L4hogpyt AzPrxiwUtTSMNVo7Ypemhp4gSzX7sGP0WeS5gBjaqKE36xHKogFfQPyVJMhLk+0AH6XB D+d8baDpK5lmqurfNavLzZFsOLgt7+aZECe3U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=TlMvkgd1A5eHd06q1RUvisql+LkTwaj2QvQ4YQo4reoRKebe8rGp+c/7maIuPdNbI1 GUfHpbfTT1T2Upx/AQkFreNjAF0Tyn8FPMehnEg3QZg1U2DZSbuqvqde+43BVZuNMKGV O0q1ndHumkhl6l1a3foWBlvHsPZZNAY6yNQtbPLpCpbRHC04HiQtkMh2q3lzIET6aXXR Ojl0qmO7W/RyJOz5/8HMTqJtC7F34CLFZmLv+l80lJ+tCaC7L61QYTlPZITkqziFoqw+ evnlfXN74zLMNlVxTD5kwJZ4cTmfT+PE5ELNl1xGp0i+51IVdTd6qYWqTjywTxX/rMh2 rVDg== X-Gm-Message-State: AMCzsaVKAqoBKYEIwHQ3p8zp8oWJMFKs4tO5InjRzaRxo+VAkyh0RbXk +R//aweEVOMlTnlpazi+J1O9MTCHXpw= X-Google-Smtp-Source: ABhQp+SxwvBtr91WOkce8V5T8CJTTdemeReJGAOUcYdFlKv6o8yc8i3TfMU50sTWwhzoDFhPJyPqqA== X-Received: by 10.84.232.7 with SMTP id h7mr1826271plk.274.1508428310436; Thu, 19 Oct 2017 08:51:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id 76sm27971114pfq.4.2017.10.19.08.51.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:38 -0700 Message-Id: <20171019155146.30434-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019155146.30434-1-richard.henderson@linaro.org> References: <20171019155146.30434-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v6 1/9] 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: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée 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.6 diff --git a/disas.c b/disas.c index 54eea3f9c9..7e22a80da6 100644 --- a/disas.c +++ b/disas.c @@ -204,16 +204,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; } @@ -389,16 +380,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 fe0d1bdbb4..a736ae9a81 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 98732cd65f..13b2f8fbc5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4097,6 +4097,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 */ @@ -4216,6 +4227,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 5f24a2de3c..69a87de83b 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8557,15 +8557,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 = {