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 = { From patchwork Thu Oct 19 15:51:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116409 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp649807qgn; Thu, 19 Oct 2017 08:56:39 -0700 (PDT) X-Received: by 10.200.2.158 with SMTP id p30mr2968269qtg.255.1508428599535; Thu, 19 Oct 2017 08:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428599; cv=none; d=google.com; s=arc-20160816; b=Pqb6xcGv/a/1HH2JqzcpFRA7tCGk+ud+80K2zOiMnJAVHWIK2V7Zj5/TOJvdOlrn3M YmG/04nc2Yer2rQU21kADLvKILdn1JQJ2xxs+mOjFL0n0LtTWN7YxrjbHK20c3q24+Po L2VOHPt6JuIf1kxkIxxxUMTTKUTOF+GijH0iGKbuosdxs8ys81TTAR6JcHQOXoJrVV/u d5KOwyXJh4kNfRfIdnsOlFycAS7nR0Dj1oEnkAvlACVysL+sLjXNjyyGzrToUshslbBS JPVNU5yGgwP00r6NkqzhAAy7qy4lwpCdL3SZaZFNy97Emv3h3nkxx47V5GeVhe/l50K/ G8hA== 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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=dlDugfezSuwtwOm5io0AheHNwAqAkeRVA5S1k9AELUjO4xXGioZx/eW45vu/PsBR49 BSzHUmDLntQ0r3VfXw/jx+RBNFRVHdsDksDOtpOn3ivifzIakFmcH+dRvCYIR1UX9Z+A WNngpXElQNxjaUdQWPW3Vzru8NqVV/Kbssk3IssnzzynBtWM+FHWnILWq7/1f3ChieNV 0QvaRs9UGy62w88v/hq9+LrFdIvzxeEqZgu2uIyWXnJ8qkqOhi1JgLmniv4zRy1m2AFa lkgmmeMDut8G8b0AOPiR8x/zz/QRU7DDTj3K4OHb5iciEJcIFf+fl8g2wUmCsGqWlt3R 4hAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YEkSIPCM; 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 b74si1902078qkg.64.2017.10.19.08.56.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:56:39 -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=YEkSIPCM; 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]:49847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DBV-0001zR-AE for patch@linaro.org; Thu, 19 Oct 2017 11:56:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D6z-000790-3Y 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-0000Cd-Iw for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:57 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:51592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6v-0000C3-BM for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:53 -0400 Received: by mail-pf0-x244.google.com with SMTP id n14so6858616pfh.8 for ; Thu, 19 Oct 2017 08:51:53 -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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=YEkSIPCMX8o3whyQO1ww7FPS7HadKT/L5VX6pzfLgdgAzLbFPj1bDUGM0LgJQApamk LzN2439vs+mB2lf7lzfuhlmWX2cT9gYZFAXY59Qpw4JVSkfPFlv4dXhPPnBzP3hx1V/s m8gZwFGXriQd8FAFphK8HlRVyJXxFGFAz2Svs= 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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=UG8pUK9OUkExJHlDGBfRiLkC0hWXI6YtwHl16Q734CSkfNTOUCTKkVd94vy05Je4u0 1IiM/caeXkUZacWtF35mFwdPHSFcKI1PHdrUgAJI3OZl6OvV0hPHmrHRCfImXYWVCQsf 5NdsM4gdXwGVR/lpfYjlqDMJAZUz9gf+tGz10XN6jM8W9GbRZs9ZmOiujOSLIDSsmOWW k2ZbjshwwWRJwLeM+GoaOOwLogoTME9EZQeyFLS8ZLeorS9kXZ58b1vhdC40vl5SGGlt /c7YWZtXNZUoq6TsZRaKbge1vajCyhOdGcf7rGsnFrdGCAhU0Bi0YMyPayHjyOjJWkUU 5HuQ== X-Gm-Message-State: AMCzsaUzPh13SD0JvPx7eEhJPJ2cJ4UvW+Du1D1s2d1uxPUcwOgaZV4k 1OtTUfxYevfpw72/UJ1MiBG1xAMWBak= X-Google-Smtp-Source: ABhQp+R385Nr/iuWvJG1qLHlte7Pi3No3kKBtJ7P6SZi40QAGaBTDL5hnbDF9/iyFTSdXq7EtYNEbg== X-Received: by 10.98.55.133 with SMTP id e127mr1972585pfa.130.1508428311887; Thu, 19 Oct 2017 08:51:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:39 -0700 Message-Id: <20171019155146.30434-3-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::244 Subject: [Qemu-devel] [PATCH v6 2/9] target/ppc: 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 | 33 --------------------------------- monitor.c | 5 ----- target/ppc/translate.c | 5 +---- target/ppc/translate_init.c | 21 +++++++++++++++++++++ 4 files changed, 22 insertions(+), 42 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 7e22a80da6..88d16fbd57 100644 --- a/disas.c +++ b/disas.c @@ -204,23 +204,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - s.info.disassembler_options = (char *)"any"; - s.info.print_insn = print_insn_ppc; -#endif if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -380,22 +363,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - s.info.print_insn = print_insn_ppc; -#endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/monitor.c b/monitor.c index a736ae9a81..2164dfcc3b 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,11 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_PPC - CPUArchState *env = mon_get_cpu_env(); - flags = msr_le << 16; - flags |= env->bfd_mach; -#endif monitor_disas(mon, cs, addr, count, is_physical, flags); return; } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index a81ff69d75..cddbf92564 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7407,12 +7407,9 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - int flags; - flags = env->bfd_mach; - flags |= ctx.le_mode << 16; qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, flags); + log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 7b9bf6a773..9b4353437a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10519,6 +10519,26 @@ static gchar *ppc_gdb_arch_name(CPUState *cs) #endif } +static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) +{ + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + if ((env->hflags >> MSR_LE) & 1) { + info->endian = BFD_ENDIAN_LITTLE; + } + info->mach = env->bfd_mach; + if (!env->bfd_mach) { +#ifdef TARGET_PPC64 + info->mach = bfd_mach_ppc64; +#else + info->mach = bfd_mach_ppc; +#endif + } + info->disassembler_options = (char *)"any"; + info->print_insn = print_insn_ppc; +} + static Property ppc_cpu_properties[] = { DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, false), DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, @@ -10582,6 +10602,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian = ppc_cpu_is_big_endian; #endif + cc->disas_set_info = ppc_disas_set_info; dc->fw_name = "PowerPC,UNKNOWN"; } From patchwork Thu Oct 19 15:51:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116407 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp647802qgn; Thu, 19 Oct 2017 08:54:31 -0700 (PDT) X-Received: by 10.200.17.1 with SMTP id c1mr2537563qtj.252.1508428471311; Thu, 19 Oct 2017 08:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428471; cv=none; d=google.com; s=arc-20160816; b=Kk4v/gmGIK8hJixGVTB9ce87Yma4TRr77qo24IwR5VBfmCyCf9jFBx54LRP3iJ1e+9 aKYE2URA5EFDdHp1tg7jTawF6cSkg/uRMDoq1Gebsl7TQwQKvRc+fGq6zfahWVg6UyoH Ok3nzN+k7dPsyn8SbmkRe2SQkbWScZtu9ZiBlcaZbFSB8Xg/sWJQSm3VzMdPdq4yetGw TvYhyPtmT6m869uS34pE1FNPxdh4YcTWuZ1MeH/C0aQfsiyMmR+XBurhX+8BXErBojVC 2M1uFMuEdB9t06L1J6tMr28uIs0RXg2PW+um/YbMMGzz7pwHiEUquKk/dEzowfgZuwXB T4Vw== 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=OE0WMuyz6FXkLUS7if7XpUhIBpdcWaJyEUZ5vJ49EKc=; b=HVZKJOy3ov3RO03GD2pLL5UI3Jo7ZQUYlwMAAwKyQ3kaqJnZ6eTWKsyCzWGWfQMHtN BlOtQaMwmB4GWqPvCsRcf5VMFXQmFBKni4Zub7oGV84+9WpnT8PQBGG0or83XjU0WVx4 mR3y2+q3jd/0hzcRS+Hs8CVtJrhhyMZnOu0tyRet8y7hXCG3yjs3lrHtllcLBFoS5sUG kL8poJ55rD9Fug9EVYer6yNO8edBd0ioBuT5B7SsRDzXZ1xjTdfIOOEfg1MI1wJ9qS27 vIYqhP9e6pjfwdEg0Hls9Y6NVGSAhyV8Tu1Wwhxow0AFWbPRHrJgrOddpY3Hunue6N18 PgTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FbZiaaol; 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 i7si979771qkf.144.2017.10.19.08.54.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:54:31 -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=FbZiaaol; 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]:49836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D9Q-0000Aa-U5 for patch@linaro.org; Thu, 19 Oct 2017 11:54:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D6z-000791-3f for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D6x-0000DR-1Z for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:57 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:54106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6w-0000Ct-O9 for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:54 -0400 Received: by mail-pg0-x243.google.com with SMTP id s2so7522350pge.10 for ; Thu, 19 Oct 2017 08:51:54 -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=OE0WMuyz6FXkLUS7if7XpUhIBpdcWaJyEUZ5vJ49EKc=; b=FbZiaaolE3CNxvBnzrxcz8HWLMVewuTDpN3J9UgEVF9jDq2FwTU3kJaizcZBIHzUtb rbovZsiAqbXMVOzCI7oJBE/yVUmcIrp8OwUmmOkoY88sMguxET8uwF0hNyFyJcS+vzpX UgG5mqBZLBQE/5P/vo5R8IMC4C9eRE1WAcHPs= 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=OE0WMuyz6FXkLUS7if7XpUhIBpdcWaJyEUZ5vJ49EKc=; b=k7xRKCaqQjlUiXB8ezANJwPktHtikF7wkmZh9mXtoEuDWLaHBaffIMzBBUjhlp7cik r8X9jMnXCvrUdU/Pn8/tvQdW2+ngERdwYB3b/74oz+pqSsq5bO29mwr9Xkjga0QM+aPk ZISNHqorSBwFVYA2IAPyiJloCjomGE75jB9C4fPmkQdt6MZVqbJxk8wK0cr/o+ksO75r P424r7jsJBGibi+PdZTlgsKdsvk9gKGofJbNxlQJliGqe+nYTf3z2WgrmTty59JymBIU nIXOgjhyZ8+nmyhigpwtGH023wyV2EpgKXYn54Cq14Qrm/DAkXCjqe9NQ8Jd9rQgRYhv MyoA== X-Gm-Message-State: AMCzsaVeUX5ohDpbij5cFt//uuVfXgJMQWmK6w63h/TU7dt9Fnn6BA1b U46QgK+4ah+LZ1DqjVFmn8tuwj15CZg= X-Google-Smtp-Source: ABhQp+RRQensv6aOfKZLKUcVMPYu1zXHC2bx6Xg6PK1s0caDz+79B5XT3+p76g8Mdl5SBKKWv7n0Ug== X-Received: by 10.98.87.207 with SMTP id i76mr1979308pfj.134.1508428313148; Thu, 19 Oct 2017 08:51:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:40 -0700 Message-Id: <20171019155146.30434-4-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:c05::243 Subject: [Qemu-devel] [PATCH v6 3/9] disas: Remove unused flags arguments 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" Now that every target is using the disas_set_info hook, the flags argument is unused. Remove it. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/disas/disas.h | 4 ++-- include/exec/log.h | 4 ++-- disas.c | 15 ++++----------- monitor.c | 3 +-- target/alpha/translate.c | 2 +- target/arm/translate-a64.c | 3 +-- target/arm/translate.c | 3 +-- target/cris/translate.c | 3 +-- target/hppa/translate.c | 2 +- target/i386/translate.c | 2 +- target/lm32/translate.c | 2 +- target/m68k/translate.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/translate.c | 2 +- target/nios2/translate.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/translate.c | 2 +- target/s390x/translate.c | 2 +- target/sh4/translate.c | 2 +- target/sparc/translate.c | 2 +- target/tricore/translate.c | 2 +- target/unicore32/translate.c | 2 +- target/xtensa/translate.c | 2 +- 23 files changed, 28 insertions(+), 39 deletions(-) -- 2.13.6 diff --git a/include/disas/disas.h b/include/disas/disas.h index e549ca24a1..4d48c13c65 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -9,10 +9,10 @@ /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags); + target_ulong size); void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags); + target_ulong pc, int nb_insn, int is_physical); /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(target_ulong orig_addr); diff --git a/include/exec/log.h b/include/exec/log.h index ba1c9b5682..c249307911 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -38,9 +38,9 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) #ifdef NEED_CPU_H /* disas() and target_disas() to qemu_logfile: */ static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len, int flags) + target_ulong len) { - target_disas(qemu_logfile, cpu, start, len, flags); + target_disas(qemu_logfile, cpu, start, len); } static inline void log_disas(void *code, unsigned long size) diff --git a/disas.c b/disas.c index 88d16fbd57..2b26466b61 100644 --- a/disas.c +++ b/disas.c @@ -171,15 +171,9 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } -/* Disassemble this for me please... (debugging). 'flags' has the following - values: - i386 - 1 means 16 bit code, 2 means 64 bit code - ppc - bits 0:15 specify (optionally) the machine instruction set; - bit 16 indicates little endian. - other targets - unused - */ +/* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags) + target_ulong size) { CPUClass *cc = CPU_GET_CLASS(cpu); target_ulong pc; @@ -335,10 +329,9 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, return 0; } -/* Disassembler for the monitor. - See target_disas for a description of flags. */ +/* Disassembler for the monitor. */ void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags) + target_ulong pc, int nb_insn, int is_physical) { CPUClass *cc = CPU_GET_CLASS(cpu); int count, i; diff --git a/monitor.c b/monitor.c index 2164dfcc3b..7a802a345e 100644 --- a/monitor.c +++ b/monitor.c @@ -1309,8 +1309,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, } if (format == 'i') { - int flags = 0; - monitor_disas(mon, cs, addr, count, is_physical, flags); + monitor_disas(mon, cs, addr, count, is_physical); return; } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index f32c95b9a1..3de369b17e 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -3048,7 +3048,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) static void alpha_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size, 1); + log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps alpha_tr_ops = { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a39b9d3633..fc5419df7f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11403,8 +11403,7 @@ static void aarch64_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - 4 | (bswap_code(dc->sctlr_b) ? 2 : 0)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } const TranslatorOps aarch64_translator_ops = { diff --git a/target/arm/translate.c b/target/arm/translate.c index 4da1a4cbc6..9d31769c8d 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12371,8 +12371,7 @@ static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - dc->thumb | (dc->sctlr_b << 1)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps arm_translator_ops = { diff --git a/target/cris/translate.c b/target/cris/translate.c index 38a999e6f1..b1fda57c74 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3297,8 +3297,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, - env->pregs[PR_VR]); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 26242f4b3c..ca6a6d3372 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3904,7 +3904,7 @@ static void hppa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) break; default: qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, tb->size, 1); + log_target_disas(cs, tb->pc, tb->size); break; } } diff --git a/target/i386/translate.c b/target/i386/translate.c index 69a87de83b..e81479a50c 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8559,7 +8559,7 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps i386_tr_ops = { diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 65bc9c0bf6..a83cbdf729 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -1156,7 +1156,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("\n"); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d738f32f9c..e1e31f622c 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5620,7 +5620,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 067b0878d6..fecc61a1ec 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1810,7 +1810,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); #if DISAS_GNU - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); #endif qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); diff --git a/target/mips/translate.c b/target/mips/translate.c index ac05f3aa09..7c96aff1a0 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20370,7 +20370,7 @@ done_generating: && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 54fbe898df..0d2d03d2d0 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -907,7 +907,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, dc->pc - tb->pc, 0); + log_target_disas(cs, tb->pc, dc->pc - tb->pc); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 112db1ad0f..99f2b463ce 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1653,7 +1653,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - log_target_disas(cs, pc_start, tb->size, 0); + log_target_disas(cs, pc_start, tb->size); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index cddbf92564..469ebeb446 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7409,7 +7409,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); + log_target_disas(cs, pc_start, ctx.nip - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 165d2cac3e..4fa7609c64 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -5970,7 +5970,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log("IN: EXECUTE %016" PRIx64 "\n", dc.ex_value); } else { qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 1); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); } qemu_log_unlock(); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 8db9fba26e..27067cbd30 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2347,7 +2347,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */ - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6290705b11..e89b6227f2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5855,7 +5855,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0); + log_target_disas(cs, pc_start, last_pc + 4 - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 4e4198e887..e807500e26 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8839,7 +8839,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 6c094d59d7..f9aa248a80 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -2031,7 +2031,7 @@ done_generating: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index d7bf07e8e6..03719ce12b 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -3250,7 +3250,7 @@ done: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 0); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } From patchwork Thu Oct 19 15:51:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116408 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp648436qgn; Thu, 19 Oct 2017 08:55:17 -0700 (PDT) X-Received: by 10.237.59.7 with SMTP id p7mr2559648qte.3.1508428517397; Thu, 19 Oct 2017 08:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428517; cv=none; d=google.com; s=arc-20160816; b=fAcOsd6kqaW9YjmQWOmzw8Eq2kBte6QyFsNjPhhfPkKMke47GRGagkXrsM+SpXzn+Z xTowXG+w4RKRVmUlHHXcro/BhiUogpDVQhEFt7pNj4uUJvrARHYH+Sdd1DGUJoVbihzW ntYue83GZCe1NiALpDnJv8Eklrwhxt4xDDqc3W0NvDXkRfkUxrlkSx3HMJfax2+DCTk9 0C553OcbyDmnHgch6zaDnFtTDNzui00bzJshRLKLjYTOIoxoJhTZ7CZsRKm6pSw8RdZY jbpJu7kuLfJ8fL0xoMzzvfwWSLBVWoZDlsCyoFea1zVcvXEU7Hds9NuW2r9stpPHJk1P hoOA== 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=zbxxfo2QG6dSSgV3wwDFvCcftwl8jDp3BYwJJYqSvmU=; b=jsuvIK5t2bdEcS5INLNVY+u3zSFLubKzJQXNAesQ5S3+2aaE6oiA1RyZ/VfFh+MwLZ EsPU0OEYZ8HJc+0Y9IOBixWntj5SWD2b4Oy+BCWCleEluz3aVcFl1Gw+YeNCk7RO4Oye BBceG1TTk6l1Z1Oxo0zwdvZCH+N93cFMp4sRbzCJRozj3CLGzmrtF7VPNzLdtupKXaZm bjomjsehgl/nw3QTBvvpIa+yvWfyJFntcvHWhpmtVlEBMjtP9MwsdkrHDH6AWB+rbU9Q y6iMOM2NthsMOG040U/Y66U/fYIxwqTLoBOD68RsiY4oVO1A6GWlgQIPHUYx8NPTR859 Z7Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=krJtul3G; 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 43si1047895qtp.62.2017.10.19.08.55.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:55:17 -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=krJtul3G; 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]:49837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DAB-0000yV-8l for patch@linaro.org; Thu, 19 Oct 2017 11:55:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D70-0007BO-VZ for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D6y-0000EP-SL for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:59 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:52054) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6y-0000E4-Jm for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:56 -0400 Received: by mail-pg0-x241.google.com with SMTP id p9so7525029pgc.8 for ; Thu, 19 Oct 2017 08:51:56 -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=zbxxfo2QG6dSSgV3wwDFvCcftwl8jDp3BYwJJYqSvmU=; b=krJtul3GmwONN8eqTxmcURuPwVZ8BWu4nYAUFdua3Ubj8oTeRrx3WTE+Ui6ynd6cY0 4ViSED5ZGoSVipFx+BPKDv4qWW/C00to5jLyuXCCJx7dYWUu3i9x78DfssWMEXuo4m8z lbMsq46qR2FwXXSrNoOHD0pQCsHFBbPA3uTpE= 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=zbxxfo2QG6dSSgV3wwDFvCcftwl8jDp3BYwJJYqSvmU=; b=DYlCNpV8z2iljFFZdYySwUAdx8LVJXdAvSlmXEdMwqaNO8bawMgKeEPibG/+ayFAAB YYD4fC2FjyZcGZyHI242Tt65/jkG58DOE+UCPyqfDBIJhYH18mBVZViqJ3I9UWGi9tXY tJWVXEievpGwN9EAIjAdbHbFe1iIoLFQsamJ7UAButGAYlOH5zSqzzDRM15mTcbEWj20 lqu6/g+N4E1L9pGAUuSm/qbxcYi8pasvDcJfYfKi2PLOKV9bkBAt/rLeAX+pkriQbQD+ wNzS7ut597J5S7gyjuhn3TYPVGflWSq1T5HPt8jRsRxtWijWpzwGLvW0LW5qGbTnMQcZ JjBQ== X-Gm-Message-State: AMCzsaXspvlmdb57ky7nRk6OgxBa1DYW1JxbMPdMsVgs0WKTyeAN2q5P B20jOnEvxtN8CWLs9V5MPtKgkvpraiw= X-Google-Smtp-Source: ABhQp+Qw0u9yp0HVBESYPVEDPKbIFgfSpSHnZnvuRLZTvBtseWPHzkUU9EVDzED7TwFCfQBR84SisQ== X-Received: by 10.98.71.132 with SMTP id p4mr1995358pfi.274.1508428314950; Thu, 19 Oct 2017 08:51:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:41 -0700 Message-Id: <20171019155146.30434-5-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:c05::241 Subject: [Qemu-devel] [PATCH v6 4/9] disas: Support the Capstone disassembler library 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" If configured, prefer this over our rather dated copy of the GPLv2-only binutils. This will be especially apparent with the proposed vector extensions to TCG, as disas/i386.c does not handle AVX. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/disas/bfd.h | 4 + include/disas/capstone.h | 38 ++++++++ disas.c | 219 ++++++++++++++++++++++++++++++++++++++++++++--- configure | 26 ++++++ 4 files changed, 274 insertions(+), 13 deletions(-) create mode 100644 include/disas/capstone.h -- 2.13.6 diff --git a/include/disas/bfd.h b/include/disas/bfd.h index d99da68267..9b0657cfa9 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -377,6 +377,10 @@ typedef struct disassemble_info { /* Command line options specific to the target disassembler. */ char * disassembler_options; + /* Options for Capstone disassembly. */ + int cap_arch; + int cap_mode; + } disassemble_info; diff --git a/include/disas/capstone.h b/include/disas/capstone.h new file mode 100644 index 0000000000..84e214956d --- /dev/null +++ b/include/disas/capstone.h @@ -0,0 +1,38 @@ +#ifndef QEMU_CAPSTONE_H +#define QEMU_CAPSTONE_H 1 + +#ifdef CONFIG_CAPSTONE + +#include + +#else + +/* Just enough to allow backends to init without ifdefs. */ + +#define CS_ARCH_ARM -1 +#define CS_ARCH_ARM64 -1 +#define CS_ARCH_MIPS -1 +#define CS_ARCH_X86 -1 +#define CS_ARCH_PPC -1 +#define CS_ARCH_SPARC -1 +#define CS_ARCH_SYSZ -1 + +#define CS_MODE_LITTLE_ENDIAN 0 +#define CS_MODE_BIG_ENDIAN 0 +#define CS_MODE_ARM 0 +#define CS_MODE_16 0 +#define CS_MODE_32 0 +#define CS_MODE_64 0 +#define CS_MODE_THUMB 0 +#define CS_MODE_MCLASS 0 +#define CS_MODE_V8 0 +#define CS_MODE_MICRO 0 +#define CS_MODE_MIPS3 0 +#define CS_MODE_MIPS32R6 0 +#define CS_MODE_MIPSGP64 0 +#define CS_MODE_V9 0 +#define CS_MODE_MIPS32 0 +#define CS_MODE_MIPS64 0 + +#endif /* CONFIG_CAPSTONE */ +#endif /* QEMU_CAPSTONE_H */ diff --git a/disas.c b/disas.c index 2b26466b61..e392a2926e 100644 --- a/disas.c +++ b/disas.c @@ -6,6 +6,7 @@ #include "cpu.h" #include "disas/disas.h" +#include "disas/capstone.h" typedef struct CPUDebug { struct disassemble_info info; @@ -171,6 +172,192 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } +#ifdef CONFIG_CAPSTONE +/* Temporary storage for the capstone library. This will be alloced via + malloc with a size private to the library; thus there's no reason not + to share this across calls and across host vs target disassembly. */ +static __thread cs_insn *cap_insn; + +/* Initialize the Capstone library. */ +/* ??? It would be nice to cache this. We would need one handle for the + host and one for the target. For most targets we can reset specific + parameters via cs_option(CS_OPT_MODE, new_mode), but we cannot change + CS_ARCH_* in this way. Thus we would need to be able to close and + re-open the target handle with a different arch for the target in order + to handle AArch64 vs AArch32 mode switching. */ +static cs_err cap_disas_start(disassemble_info *info, csh *handle) +{ + cs_mode cap_mode = info->cap_mode; + cs_err err; + + cap_mode += (info->endian == BFD_ENDIAN_BIG ? CS_MODE_BIG_ENDIAN + : CS_MODE_LITTLE_ENDIAN); + + err = cs_open(info->cap_arch, cap_mode, handle); + if (err != CS_ERR_OK) { + return err; + } + + /* ??? There probably ought to be a better place to put this. */ + if (info->cap_arch == CS_ARCH_X86) { + /* We don't care about errors (if for some reason the library + is compiled without AT&T syntax); the user will just have + to deal with the Intel syntax. */ + cs_option(*handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); + } + + /* "Disassemble" unknown insns as ".byte W,X,Y,Z". */ + cs_option(*handle, CS_OPT_SKIPDATA, CS_OPT_ON); + + /* Allocate temp space for cs_disasm_iter. */ + if (cap_insn == NULL) { + cap_insn = cs_malloc(*handle); + if (cap_insn == NULL) { + cs_close(handle); + return CS_ERR_MEM; + } + } + return CS_ERR_OK; +} + +/* Disassemble SIZE bytes at PC for the target. */ +static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + size_t tsize = MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf = cap_buf; + + target_read_memory(pc + csize, cap_buf + csize, tsize, info); + csize += tsize; + size -= tsize; + + while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + + /* If the target memory is not consumed, go back for more... */ + if (size != 0) { + /* ... taking care to move any remaining fractional insn + to the beginning of the buffer. */ + if (csize != 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } + + /* Since the target memory is consumed, we should not have + a remaining fractional insn. */ + if (csize != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with translator " + "over instruction decoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + break; + } + + cs_close(&handle); + return true; +} + +/* Disassemble SIZE bytes at CODE for the host. */ +static bool cap_disas_host(disassemble_info *info, void *code, size_t size) +{ + csh handle; + const uint8_t *cbuf; + cs_insn *insn; + uint64_t pc; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + cbuf = code; + pc = (uintptr_t)code; + + while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + if (size != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with TCG over instruction encoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + + cs_close(&handle); + return true; +} + +#if !defined(CONFIG_USER_ONLY) +/* Disassemble COUNT insns at PC for the target. */ +static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) +{ + uint8_t cap_buf[32]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + /* We want to read memory for one insn, but generically we do not + know how much memory that is. We have a small buffer which is + known to be sufficient for all supported targets. Try to not + read beyond the page, Just In Case. For even more simplicity, + ignore the actual target page size and use a 1k boundary. If + that turns out to be insufficient, we'll come back around the + loop and read more. */ + uint64_t epc = QEMU_ALIGN_UP(pc + csize + 1, 1024); + size_t tsize = MIN(sizeof(cap_buf) - csize, epc - pc); + const uint8_t *cbuf = cap_buf; + + /* Make certain that we can make progress. */ + assert(tsize != 0); + info->read_memory_func(pc, cap_buf + csize, tsize, info); + csize += tsize; + + if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + if (--count <= 0) { + break; + } + } + memmove(cap_buf, cbuf, csize); + } + + cs_close(&handle); + return true; +} +#endif /* !CONFIG_USER_ONLY */ +#else +# define cap_disas_target(i, p, s) false +# define cap_disas_host(i, p, s) false +# define cap_disas_monitor(i, p, c) false +#endif /* CONFIG_CAPSTONE */ + /* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size) @@ -187,6 +374,8 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, s.info.buffer_vma = code; s.info.buffer_length = size; s.info.print_address_func = generic_print_address; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -198,6 +387,10 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_target(&s.info, code, size)) { + return; + } + if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -205,18 +398,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, for (pc = code; size > 0; pc += count, size -= count) { fprintf(out, "0x" TARGET_FMT_lx ": ", pc); count = s.info.print_insn(pc, &s.info); -#if 0 - { - int i; - uint8_t b; - fprintf(out, " {"); - for(i = 0; i < count; i++) { - target_read_memory(pc + i, &b, 1, &s.info); - fprintf(out, " %02x", b); - } - fprintf(out, " }"); - } -#endif fprintf(out, "\n"); if (count < 0) break; @@ -244,6 +425,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t)code; s.info.buffer_length = size; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef HOST_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -281,6 +464,11 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__hppa__) print_insn = print_insn_hppa; #endif + + if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) { + return; + } + if (print_insn == NULL) { print_insn = print_insn_od_host; } @@ -343,8 +531,9 @@ void monitor_disas(Monitor *mon, CPUState *cpu, monitor_disas_is_physical = is_physical; s.info.read_memory_func = monitor_read_memory; s.info.print_address_func = generic_print_address; - s.info.buffer_vma = pc; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -356,6 +545,10 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) { + return; + } + if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/configure b/configure index 6f21aaf989..26e5ce7787 100755 --- a/configure +++ b/configure @@ -375,6 +375,7 @@ opengl_dmabuf="no" cpuid_h="no" avx2_opt="no" zlib="yes" +capstone="" lzo="" snappy="" bzip2="" @@ -1294,6 +1295,10 @@ for opt do error_exit "vhost-user isn't available on win32" fi ;; + --disable-capstone) capstone="no" + ;; + --enable-capstone) capstone="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1541,6 +1546,7 @@ disabled with --disable-FEATURE, default is enabled if available: vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver vhost-user vhost-user support + capstone capstone disassembler support NOTE: The object files are built at the place where configure is launched EOF @@ -4411,6 +4417,22 @@ EOF fi ########################################## +# capstone + +if test "$capstone" != no; then + if $pkg_config capstone; then + capstone=yes + QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" + LIBS="$($pkg_config --libs capstone) $LIBS" + else + if test "$capstone" = yes; then + feature_not_found capstone + fi + capstone=no + fi +fi + +########################################## # check if we have fdatasync fdatasync=no @@ -5468,6 +5490,7 @@ echo "jemalloc support $jemalloc" echo "avx2 optimization $avx2_opt" echo "replication support $replication" echo "VxHS block device $vxhs" +echo "capstone $capstone" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6142,6 +6165,9 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi +if test "$capstone" = "yes" ; then + echo "CONFIG_CAPSTONE=y" >> $config_host_mak +fi # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on From patchwork Thu Oct 19 15:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116406 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp647618qgn; Thu, 19 Oct 2017 08:54:15 -0700 (PDT) X-Received: by 10.55.109.195 with SMTP id i186mr2612468qkc.147.1508428454861; Thu, 19 Oct 2017 08:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428454; cv=none; d=google.com; s=arc-20160816; b=dlfjd42PPWODCr9O+ksa+0fw6RuglbsX9FB9K0wBqB7iGXG9APPb1x5Qq8wTTxGvnb 8rvmolY+NjJj7U9+XRMmC6w9LEW50b5tmdNLwejV3Sik/L8VlTUJnU62ZLyUbfkT6fB+ bxJpjqa0wWlWcseJMe0R/ELUdv0PL4cGluklIUIllBv1xBeJ5uIEHkK+hKY+CiZpNdhT +yc/zm6VsAgJIKpkzL5R1/jvArXuzXx34PumdtCr8mMdWp/FPPTnkTp30QKyJlJ4p1Qo xH/NKDTfpCPSdRxoBR3HO9JLPrpdK6d9Z6Bc75Jsl6WZMllgQg5uGbJ9z9khP7t8c9Pw gl8w== 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=v2cfPsTL4FP75FaKJwqc72lqYTxbji6GG2AudOwx3UZTd7rDa2Fg1gaEJCObey0ZJQ ZfHLZS0ipIk/f8Y6og5Z4JwXCCB8Q3NJr/mISb/fVHR1sPirBM+bAjj7bwi2N2gGu/b/ iHuJuisZhuaQ0PugMYROgN0Ny7odWY1xU2kgSeI0FbAjYMzUaa8Z3kYLamV7U6xPBh0a gyWBpFCDP8E9n/hga+wUmCYYUBgRXXvu/y+BoIXVPGBk+Al+3eNlrUx+UiRc8nSO176m UP6yNRim8z00Qv78bMghlhhfCrUB0t2hUWjyCSkb6Ba1fG9ckJV+KUYezKvkkx3QLDiX WYqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iiTYv/Og; 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 202si4948612qkm.81.2017.10.19.08.54.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:54:14 -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=iiTYv/Og; 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]:49835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D9A-0008Na-Qv for patch@linaro.org; Thu, 19 Oct 2017 11:54:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D70-0007BC-LN for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D6z-0000FE-Ia for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:58 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:50831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6z-0000ET-Dt for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:57 -0400 Received: by mail-pf0-x243.google.com with SMTP id b6so6866228pfh.7 for ; Thu, 19 Oct 2017 08:51:57 -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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=iiTYv/Og4vUV1DuE7+hEsKOnBybeu6p1Ue5Ll5WgHBUQul5XYUop6z0gRCkvy5hBrA 2ZVNBezsUF7StW8/IK3LAvqfQAkjlFuB/XTXafX0lU3ITTkSK0DTQBmqeXF4hNwaeTIq QZ2LKDvoQFsc4jCIqC7lGfXrEdIAG5KQ/+Cdw= 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=WtwmPAQWVUHMwjrkJYeEx5T3XPaj+qiQd6X/NwplkD4KOwulIg1pJg3SdLs7I0YfU3 PjW4Zp2Xq2CW6vhQufLkwtujlmQHK7m1ssCGqNuMQByyUMWKIO8RWJ0LgsQKeWbihlu3 6tZ3p+AAewMKD1Jg9BPXC47JlHUpzo4cP2P2ssIH1uZqINWYRE7JXIMOnlh0il2Lwo3s ifua4qg3nnWo+gZEyXJ2t+yAS91cNVvl2G36/F30s7bjnPsMEx3Jw8T5pfRkyK5IKKDj D3/q3t1t+CcSbu+WsB5b3izOxIuUl72SYuT61PyEhYxYQ9IsHT+uUSdW1TSFneztTr9o /I5A== X-Gm-Message-State: AMCzsaXHuGINtodDpldk1CmgoDeDGvi6GTrSgnkFUQjpBhP8yugZL1qX C1Lzyqbyv6PopJCobH94lFvCezQ9HfY= X-Google-Smtp-Source: ABhQp+QwcRktxjzBc7p53096ZTOQqBM+w7lco8L1TXuApiqRk/QkLz76RMBlHLNiDeGAKacDD488yg== X-Received: by 10.99.95.216 with SMTP id t207mr1743996pgb.185.1508428316009; Thu, 19 Oct 2017 08:51:56 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:42 -0700 Message-Id: <20171019155146.30434-6-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::243 Subject: [Qemu-devel] [PATCH v6 5/9] i386: Support Capstone in disas_set_info 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 | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index e392a2926e..63dc573e9f 100644 --- a/disas.c +++ b/disas.c @@ -438,9 +438,13 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__i386__) s.info.mach = bfd_mach_i386_i386; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_32; #elif defined(__x86_64__) s.info.mach = bfd_mach_x86_64; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_64; #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13b2f8fbc5..cf890b763b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -51,6 +51,8 @@ #include "hw/i386/apic_internal.h" #endif +#include "disas/capstone.h" + /* Cache topology CPUID constants: */ @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info) : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 : bfd_mach_i386_i8086); info->print_insn = print_insn_i386; + + info->cap_arch = CS_ARCH_X86; + info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64 + : env->hflags & HF_CS32_MASK ? CS_MODE_32 + : CS_MODE_16); } static Property x86_cpu_properties[] = { From patchwork Thu Oct 19 15:51:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116412 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp651719qgn; Thu, 19 Oct 2017 08:58:50 -0700 (PDT) X-Received: by 10.55.152.132 with SMTP id a126mr2717839qke.12.1508428730898; Thu, 19 Oct 2017 08:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428730; cv=none; d=google.com; s=arc-20160816; b=UiOAsXiAbj06XBp1cfLJkV2oeF0gOGWGTR3PgZwwoQFfo17EGaJgHWSLbufZ00dbiu Eq9OkEHnPKN8B7WSzYAx1HvKEeJERnGjSRdILrW6fqaLDG5j5P92eCj307dndSmZAktJ y84Wn2TK7iDyXYRN1mMC5s1ufxtlP+vOtB2lEFL0+ElR2s6OPAILveyyZbMySWMssIhc sQFV1p4snepPOFhSLfB9AkWRMWU5GQqJQPwIwj9rSbnAhja8vqXTXRCWUN0tFMjJThlH 0lnuSXHw1U+RHS0oL8wL69rrdxp1gmNtQ4cXQDbaoihkE4ysrPGFJmCFUWklSNQbe4mv aCHg== 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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=YelbbLcplQTcUOBS4yekqRv1zw2a0mNM+hSlXAn3vfAbe3E1gR+pr6pAoPdoNsorzL nUFUBIl9vnCpqYrs9bSMcODRTQErylu9P3S3u3GO1yMvG3aF0XAtNZdf+xdSlfmyIaZT OcCr8zcVhQJb/g3qxcg/L0mDZp/tVHuHtoJexCcpymi7rl/0KT0CZBaBgxyfNIveD5p7 Gn7pK7hl4Oj1cAxkvL1SXyeKlUTslSHeV9QbHKSDni7qUZ6xy177/wPJGhJYVCzHVoN5 +MhyDIZoZ1Alau28S4/tW4KRrqX3x5xaL02RkL1hT3dcoK3d5TGwQPV/HEKA0hKl2C9l HBTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G76cTymy; 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 k7si161634qtk.147.2017.10.19.08.58.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:58:50 -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=G76cTymy; 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]:49855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DDc-0003n0-T7 for patch@linaro.org; Thu, 19 Oct 2017 11:58:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D71-0007Bp-Pv for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D70-0000G8-VM for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:59 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:54331) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D70-0000FZ-PR for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:58 -0400 Received: by mail-pf0-x241.google.com with SMTP id n89so6854418pfk.11 for ; Thu, 19 Oct 2017 08:51:58 -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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=G76cTymyupc4s7VFY9TUpXV2FEa6XyhO5ZIzmObOUni3MWefRlkME0qbL2rCvAGv+O JKd9JEY0vhMV7Tf5PYT2v6v8cGRVWIO/2hyjGBgmtn5mRVhk4oaeycItQrOHE+wPnyg7 HVDRgPesCc0AG1ayBnUTxvHL9c5F7jNu9ENDI= 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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=k+iFgvILiqdPm/bfRQP0xXXiXLwvmIIkiRnGayLIMyJB/IwZ7sJqt4TH1/QZXjFkzm w3UpZtHxQ7Q9DFlP47lL3MPREs9VlVaZY+4Km0Ij8vavb4Ys5yPfvQFM+/JEeIe2Fm9d 1JPKuowmJHu3jvZtcHmybEQLAbByNpblZLNds04YIb+c+Ena/QB+uC/PjkDd75bqzgEm Z4fbLnFlks3ruBYKljs0rSkV0DbMMNkL/RPudxyg8OZk/hkePSuZiYHHlEljllpSaGMz HzTyfqOYWLdShsTU5qAlZzIbRvKprEggXv1pQZyxjyvvk/O1mgyBZoCrt1kfeVEA5PHI YkCA== X-Gm-Message-State: AMCzsaVfl8a2aS2VD3UWQNMRcTHr/O3RwwWkkkrjpInj/cPbaqpPWdjy vgF6I7TOxZAWMFLubBeQEem3DLmazc8= X-Google-Smtp-Source: ABhQp+Slle6XckJ1ZiDB9j6NQGXbBND0YjcHTr5B63XAx9JT1Fn3iAM065rrin0z69M9/pc/6kuKng== X-Received: by 10.99.133.200 with SMTP id u191mr1766522pgd.426.1508428317451; Thu, 19 Oct 2017 08:51:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:43 -0700 Message-Id: <20171019155146.30434-7-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::241 Subject: [Qemu-devel] [PATCH v6 6/9] arm: Support Capstone in disas_set_info 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: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 63dc573e9f..8d9bd4901c 100644 --- a/disas.c +++ b/disas.c @@ -450,6 +450,7 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_ppc; #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; + s.info.cap_arch = CS_ARCH_ARM64; #elif defined(__alpha__) print_insn = print_insn_alpha; #elif defined(__sparc__) @@ -457,6 +458,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.mach = bfd_mach_sparc_v9b; #elif defined(__arm__) print_insn = print_insn_arm; + s.info.cap_arch = CS_ARCH_ARM; + /* TCG only generates code for arm mode. */ #elif defined(__MIPSEB__) print_insn = print_insn_big_mips; #elif defined(__MIPSEL__) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..1576a6d372 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -33,6 +33,7 @@ #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" +#include "disas/capstone.h" static void arm_cpu_set_pc(CPUState *cs, vaddr value) { @@ -501,10 +502,24 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #if defined(CONFIG_ARM_A64_DIS) info->print_insn = print_insn_arm_a64; #endif - } else if (env->thumb) { - info->print_insn = print_insn_thumb1; + info->cap_arch = CS_ARCH_ARM64; } else { - info->print_insn = print_insn_arm; + int cap_mode; + if (env->thumb) { + info->print_insn = print_insn_thumb1; + cap_mode = CS_MODE_THUMB; + } else { + info->print_insn = print_insn_arm; + cap_mode = CS_MODE_ARM; + } + if (arm_feature(env, ARM_FEATURE_V8)) { + cap_mode |= CS_MODE_V8; + } + if (arm_feature(env, ARM_FEATURE_M)) { + cap_mode |= CS_MODE_MCLASS; + } + info->cap_arch = CS_ARCH_ARM; + info->cap_mode = cap_mode; } if (bswap_code(arm_sctlr_b(env))) { #ifdef TARGET_WORDS_BIGENDIAN From patchwork Thu Oct 19 15:51:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116411 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp650753qgn; Thu, 19 Oct 2017 08:57:46 -0700 (PDT) X-Received: by 10.200.53.12 with SMTP id y12mr2945278qtb.84.1508428666530; Thu, 19 Oct 2017 08:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428666; cv=none; d=google.com; s=arc-20160816; b=VXZScLnA12U9GTMZ/YcorhYYZdKzohvUBIXZmCwCvi8KYaoahZzOErJjQKW4dMS/z1 3zWvRvJ36Lc0Gj1rGtjcOB5PndZX08EZSf8uy5W9UXepN0y6dawljiLx8k5hshV38YAc XgLs2NcnQPJFPSBZl0HF1twAau5+MO40q5Tgy4htuI+zW1sHwTwEDaboS+5+P8cRsgTY IIrLnW4oxLiGy/g2n9hyNkHJ6W0xgwGZ1CTAoBGedBs8CO2NdzabMiVpjhWUhTOZhjUP r6yYfkMkOt65jd7TJ8YhxIeUzLK+1DdpDU8+B0rXG+dLioAELPlZAt0tU4O8y6qS+uDo vn2g== 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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=Cr3X9rpwfshfBHQIdaWHzBRIQbD8oDc8jCp7PvTszgD1w2kc9mvKj60KvlSbPpy3SH GkRjAJrATAHC9cKFV4PSmUJtMudlllNG3XupLZwn9+eZzZ4H33Ggrrc46kgny+5jh1i1 vKwWhl7U2DOfM1N9JfCVMr2IU6K+N1+5rF8zGy0GzwBEfk6rtFq/VGEDvIUkcvdAnRmH u6cf31xPqnZRCqAWklEX7aMwKxwZfBNpYpztWswcBShqHAOV5CaIxn2JDqUcSkosVpd+ AzJq9nCycwblVay7sD7vMP0teIAeSoNuVjHGePxxWayBgaie5eybLyZLDxrTeCgpRAfA 6QEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Eg/qrf51; 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 54si4717023qts.209.2017.10.19.08.57.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:57:46 -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=Eg/qrf51; 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]:49852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DCa-00035s-G8 for patch@linaro.org; Thu, 19 Oct 2017 11:57:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D73-0007DP-3E for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D72-0000HH-9e for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:01 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:54107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D72-0000Ge-4p for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:00 -0400 Received: by mail-pg0-x241.google.com with SMTP id s2so7522578pge.10 for ; Thu, 19 Oct 2017 08:51:59 -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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=Eg/qrf51wMOftowIBt875SYqHJXLKYMxfh/uBg7LBiTNa0O24LnU65c+djeK8QDYbh Y3Q1znhPL76W79ceEgoob9/OuOf25dN5c5JEGpExeqixaj9f1/lntCchsRQL5ZSOu5Kn x920g/HHo0sc6M+TvLQ5gE5GVFUIYL0QAhDO8= 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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=PcBu7peyWOu2888CTFW6K712UGcFdoHmGgqkMnA8eOLLd4B/1qxL1+75UxR5odHch/ 9rh0kVFJHgz/zCwppcCP8FLFWQyANHhDJ15kOGr9W5L24P+izGhcPA9KVpSiavu7diaw lz+TsQ4lEFPyEK0KZ+JYv+SDuDESLx/IozH1fF8lh/3aznFkhbFNmiTNV6G0p19rKCvW KWmpANGDIZmAqkjMk6OWcagFisq4rXEZYhWecOKD8O0vz8QyktySkVgmBX+E6kdrm+hg LtLIPpN8RYaj6FgB/IEB3EjZme7fy/rqTe/AgRW0AIFLxux0Bevbdv6yVx0tM+yvqkme uHeA== X-Gm-Message-State: AMCzsaWI/8LdW8D+KH27T81Ny1LKk3mClx2Vok7kkmR13gCQycBRAxA/ QIKZXy9lZe1NnVdL4SUlkkpsbpk81TM= X-Google-Smtp-Source: ABhQp+TLcAhXlkIQ6+fZgj2bRPadyTpqK8W9ZagL0exnGaOV0tFuZAWiS6iQGDZRxWFauMHBlqML1Q== X-Received: by 10.99.97.149 with SMTP id v143mr1772567pgb.413.1508428318906; Thu, 19 Oct 2017 08:51:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:44 -0700 Message-Id: <20171019155146.30434-8-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:c05::241 Subject: [Qemu-devel] [PATCH v6 7/9] ppc: Support Capstone in disas_set_info 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: qemu-ppc@nongnu.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/ppc/translate_init.c | 6 ++++++ 2 files changed, 10 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index 8d9bd4901c..e52e776a60 100644 --- a/disas.c +++ b/disas.c @@ -448,6 +448,10 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; + s.info.cap_arch = CS_ARCH_PPC; +# ifdef _ARCH_PPC64 + s.info.cap_mode = CS_MODE_64; +# endif #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; s.info.cap_arch = CS_ARCH_ARM64; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 9b4353437a..41f46193a1 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -35,6 +35,7 @@ #include "mmu-book3s-v3.h" #include "sysemu/qtest.h" #include "qemu/cutils.h" +#include "disas/capstone.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10537,6 +10538,11 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) } info->disassembler_options = (char *)"any"; info->print_insn = print_insn_ppc; + + info->cap_arch = CS_ARCH_PPC; +#ifdef TARGET_PPC64 + info->cap_mode = CS_MODE_64; +#endif } static Property ppc_cpu_properties[] = { From patchwork Thu Oct 19 15:51:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116413 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp654949qgn; Thu, 19 Oct 2017 09:01:40 -0700 (PDT) X-Received: by 10.55.134.70 with SMTP id i67mr2738049qkd.22.1508428900048; Thu, 19 Oct 2017 09:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428900; cv=none; d=google.com; s=arc-20160816; b=wLuSvSeZbPLxu15i/OOz6W0dw8KwymXONUxB9ms25SGYf6tpSn+ikNgCMPHoPURT8x 9JvC/eCvnWPLIS09MKaWJ4GCtvNXbBk9hjskRmdsewFStnmbhr8LBZXk0YayY+OJG5se UZ+cT4bPb4OFZ6TRAms0v45MS4ZnN0ZNRrKLYjNST8iWML7yrJ7VYT8lj20qugsYoi+P GOyPjvV+vclgJwWla5p8fbchJ0HcMDmEkzHVum61il3OK9Ddu5hiCzIXRLYesItaORAm CUdbnyseGjlv8yW16kkSXM0bUqrpWwtZDuaYMsQVHi+hIPcaC12ZAbOhvB4GqCEjBeC4 SjTw== 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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=QVSaVtLhmv8yXIC/zZKj+ev9z+OymdmTPhYvLtMSi/2NN7C5WrgtMBFXMf01UoIhBE 1/yVCRdrukpUPIkuFp+ptvsPKWerQrVBEeKvu743aLgpoG9fJ+iNj/J7/ySyjak2iGfH p/DQvK4yehVUiZGzb9aYjgbHW0jrdVoU486EniS23EnQ5AJvkiaQY94Sw9Nc37sz2YTM 5aLvLYdeFFfCbvf6LsZ25KiP8wdOjtaUV9xq5eBPqRmAiZZmSuhlJm9uzQZP/FR23aKe OLiqvBk/g0mJvkhl4Qr7zQVtp1DgAq9lMs7bb6lP5kOfw9BYsGPOs7hB4ZtPDXa/7cDn Hv0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wp1iwzPK; 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 o37si4713574qkh.186.2017.10.19.09.01.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 09:01:40 -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=Wp1iwzPK; 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]:49895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DGL-0005vx-Vv for patch@linaro.org; Thu, 19 Oct 2017 12:01:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D74-0007FV-OD for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D73-0000Iw-S7 for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:02 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:47746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D73-0000I5-Ld for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:01 -0400 Received: by mail-pg0-x242.google.com with SMTP id r25so7532975pgn.4 for ; Thu, 19 Oct 2017 08:52:01 -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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=Wp1iwzPK4Qz12LTcA1cq6LoR96X4IxFW9PqEtQGGoMEyR3+yHhG9qXckxgQq7EBj+p 0GLhXGzNREBsOaL1lA2o0rzHL8o/252kxm64SWowStytI/wyAix0VId+DlCM4EWI6KwQ fJiwBzA07+r8KJiJQG0X8jYxLvM+mAX8JvZSA= 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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=hqTDKTIhi+/OP7NWv4n3CFtqhkm5mKXmaOsHp8LatwDAkX2b0//f3eRhRaQaryTbJ+ 0Xe9rGK2ElgoYR4eN4Yqkx/kXKwl6VXM+D6fbqgAZwnZRu+sDeNGLcFzWQ911zEY1A6S D5s1rf+Zht8jAoUbU1YE1S7wuUinBIRsNlLtZppE29ny4zsr/umcGErZIYMXsQdT9xVX YzF4eQmn1Sae72kxgFCQpVLCZ9yuGSO89FH6YLVrvuccCxz/1vrqfTJhn+/laDeWsTt0 2yxIcy2AUmAGS5k0c+AOQwNKgABlkUHYCXComKPfJ80k2cEIyfOuGLj70lhSI33iPNCA L01A== X-Gm-Message-State: AMCzsaUKwxNISO3A/R+WfuPELo706iTo/rhKH0HhQhl5P6DXAS7IQ0WV 6b0oH7Z6x/KdF2aLWh0rMLV1fcfzjS0= X-Google-Smtp-Source: ABhQp+SFVXHIOzXILcVtJGGEhlMvpygdoiuXuPDAKhsV/rpc8Ku7L+asKDvd8fFLVU6H9Y45ev8qYw== X-Received: by 10.99.190.12 with SMTP id l12mr1784516pgf.340.1508428320342; Thu, 19 Oct 2017 08:52:00 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:45 -0700 Message-Id: <20171019155146.30434-9-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:c05::242 Subject: [Qemu-devel] [PATCH v6 8/9] disas: Remove monitor_disas_is_physical 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" Even though there is only one monitor, and thus no race on this global data object, there is also no point in having it. We can just as well record the decision in the read_memory_function that we select. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index e52e776a60..92b389d25f 100644 --- a/disas.c +++ b/disas.c @@ -512,19 +512,11 @@ const char *lookup_symbol(target_ulong orig_addr) #include "monitor/monitor.h" -static int monitor_disas_is_physical; - static int -monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, +physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) { - CPUDebug *s = container_of(info, CPUDebug, info); - - if (monitor_disas_is_physical) { - cpu_physical_memory_read(memaddr, myaddr, length); - } else { - cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0); - } + cpu_physical_memory_read(memaddr, myaddr, length); return 0; } @@ -539,8 +531,8 @@ void monitor_disas(Monitor *mon, CPUState *cpu, INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); s.cpu = cpu; - monitor_disas_is_physical = is_physical; - s.info.read_memory_func = monitor_read_memory; + s.info.read_memory_func + = (is_physical ? physical_read_memory : target_read_memory); s.info.print_address_func = generic_print_address; s.info.buffer_vma = pc; s.info.cap_arch = -1; From patchwork Thu Oct 19 15:51:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116410 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp650536qgn; Thu, 19 Oct 2017 08:57:31 -0700 (PDT) X-Received: by 10.237.62.71 with SMTP id m7mr2738622qtf.269.1508428651647; Thu, 19 Oct 2017 08:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428651; cv=none; d=google.com; s=arc-20160816; b=kr+n6PiyDpHYUs/B6hWAwNDv6IVfTy/QWd1ThmCWXcvg72KYcR7yGBZgnqSUOxuZ5s GN/499mEGewV0Qw/LQ4SSgjjZbApIE5gFkno3ENFJMRMoxushaIJmfNMXtaaa2CMDqyK wzEMwj2qLfAe2+lBXmHoA4DBT0LYNrQFAflyZjotWKph8EsxjMqqD2NOL+ENdpVCtV0Z z4KKdnrN25fawpI0CkOaDnT3B/sKwIndixiZ+hP1Z2Cl0GXBRZ25XGa4bdRfKmV0dc3V aWsSA/NW193Y1TDSeDfoeglsAiEitt5KUuxUHXZpVsZwpQaxArJJLPFLZL8SaPY1BrSY rA/Q== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=lGfLaIPn07o8ncf9Uq2MInJGef5finVHQiTn4GOYg+rQsRcNAEqHXXsO9NevWKuIIs gl4T1Q8dVYFoV7P5cDY1ijacrbg2dDvpPwequhIyNP9JezTnbDqVZwA/tSVs5YQ4O25x /2jYR7OclgpB1yVxwYaQPCCicNAACzcHhuTPOJWH1euM+BeYmsAtYsFHHZBvoXEEkSZA wpyUvoZzVQm0SCZrWAmHt2NZfQhRaFekyIRh/8WBQNtyoX47TtjvDjYj2BJxuRJw9oop n008Zj6rWz7CfJQKgbazg/F9LIHDiZQDkhJ/Rw9y3mwsc6mDerVb+1d/Um2rxI53yPjV kObw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BCCX32b/; 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 l25si3255774qki.290.2017.10.19.08.57.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:57:31 -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=BCCX32b/; 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]:49849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DCL-0002fn-GO for patch@linaro.org; Thu, 19 Oct 2017 11:57:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D7A-0007Kf-BD for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D75-0000KJ-Od for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:08 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:47240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D75-0000Jt-Iv for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:03 -0400 Received: by mail-pf0-x244.google.com with SMTP id z11so6865707pfk.4 for ; Thu, 19 Oct 2017 08:52:03 -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; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=BCCX32b/2Okfp09A1hVGBV6/XAQT4z0iDeTq0/nANCQTgC3iOtUme1jISpn+7snHrj tLFy+aymv/YZNldsVnFNgimBghc40ScpXQVyJc881Mxc5X2BG5cstz6Onkz/Fk7d1hS+ 0M+47Y3LtyRPw8PJiWeNPlhhIbBtRSYb0QuV4= 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; bh=SgAc7iOmz6YqrtoDtWcnmz7PTxG614/3TlJEs5rkdnI=; b=frjnTwl1Iv14xzavxmo0tfSpP/LZouYs99Zt6XRk1cmVvR59lMHz2InOXHdru9BRvx jTEui/oy50fXft7hLGlAxuRXGA8LkS431W75XbhuHTizwX77Y+ePNl4kNOtdcyE4E35P xZgB6wfL5EPqnU2J/F7kn+kTn6xN+lLkMnRIdTJhbtzAVMLQ9mkjf+tTQjQc95VZdflS qtbkQ92chTXPCfraG1ahQNf4WKqjuKKAgEEVMqNo23zZ2mIBk7wn7b9aJ1LdJgVB8qED QNib/RM4jLognR1jrHlS/qwJ5tC8zat7ZIJoeqROejl7ffiiS74ICyZuhfusTmwMJtYc jCbg== X-Gm-Message-State: AMCzsaUldeOrPPiQcYtaqPuhtcePY0xt9LcMion8q4cGTk99ZRVyIZHd 35iYuj+uh2mdJWNHW7b9lfPx5Mf5T8s= X-Google-Smtp-Source: ABhQp+QyKp8rBmeW9yiqC9genjU08EefpbBuVAudOqdudzbmOcp0AqnQG+UqmwraZwx+2xdWo+Kf/w== X-Received: by 10.99.146.76 with SMTP id s12mr1779827pgn.354.1508428322275; Thu, 19 Oct 2017 08:52:02 -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.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:52:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:46 -0700 Message-Id: <20171019155146.30434-10-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v6 9/9] disas: Add capstone as submodule 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" Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way. Signed-off-by: Richard Henderson --- Makefile | 13 +++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 59 +++++++++++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 64 insertions(+), 12 deletions(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 062745f3ba..c6436e2442 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,19 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: mkdir -p $@ +# Overriding CFLAGS causes us to lose defines added in the sub-makefile. +# Not overriding CFLAGS leads to mis-matches between compilation modes. +# Therefore we replicate some of the logic in the sub-makefile. +CAP_CFLAGS = $(subst -Werror,,$(CFLAGS) $(QEMU_CFLAGS)) +CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM64 +CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC +CAP_CFLAGS += -DCAPSTONE_HAS_X86 + +subdir-capstone: .git-submodule-status + $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/libcapstone.a) + $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) diff --git a/.gitmodules b/.gitmodules index 7c981a42b6..1500579638 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "ui/keycodemapdb"] path = ui/keycodemapdb url = git://git.qemu.org/keycodemapdb.git +[submodule "capstone"] + path = capstone + url = git://git.qemu.org/capstone.git diff --git a/capstone b/capstone new file mode 160000 index 0000000000..a279481dbf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit a279481dbfd54bb1e2336d771e89978cc6d43176 diff --git a/configure b/configure index 26e5ce7787..892bfba2d2 100755 --- a/configure +++ b/configure @@ -375,7 +375,7 @@ opengl_dmabuf="no" cpuid_h="no" avx2_opt="no" zlib="yes" -capstone="" +capstone="yes" lzo="" snappy="" bzip2="" @@ -1299,6 +1299,10 @@ for opt do ;; --enable-capstone) capstone="yes" ;; + --enable-capstone=git) capstone="git" + ;; + --enable-capstone=system) capstone="system" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -4419,18 +4423,46 @@ fi ########################################## # capstone -if test "$capstone" != no; then - if $pkg_config capstone; then - capstone=yes +case "$capstone" in + yes) + if $pkg_config capstone; then + capstone=system + elif test -e "${source_path}/.git" ; then + capstone=git + elif test -e "${source_path}/capstone/Makefile" ; then + capstone=internal + fi + ;; + + system) + if ! $pkg_config capstone; then + feature_not_found "capstone" "Install capstone devel" + fi + ;; +esac + +case "$capstone" in + git | internal) + if test "$capstone" = git; then + git_submodules="${git_submodules} capstone" + fi + capstone_internal=yes + mkdir -p capstone + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS="\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + ;; + + system) QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" LIBS="$($pkg_config --libs capstone) $LIBS" - else - if test "$capstone" = yes; then - feature_not_found capstone - fi - capstone=no - fi -fi + ;; + + no) + ;; + *) + error_exit "Unknown state for capstone: $capstone" + ;; +esac ########################################## # check if we have fdatasync @@ -6165,7 +6197,7 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi -if test "$capstone" = "yes" ; then +if test "$capstone" != "no" ; then echo "CONFIG_CAPSTONE=y" >> $config_host_mak fi @@ -6650,6 +6682,9 @@ done # for target in $targets if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak