From patchwork Fri Nov 11 11:28:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Palatin X-Patchwork-Id: 693638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tFd6t2p2fz9t1b for ; Fri, 11 Nov 2016 22:32:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="Cb287nXt"; dkim-atps=neutral Received: from localhost ([::1]:52120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5A3v-0002dt-Is for incoming@patchwork.ozlabs.org; Fri, 11 Nov 2016 06:32:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5A1D-0000La-AF for qemu-devel@nongnu.org; Fri, 11 Nov 2016 06:29:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5A1C-0001rT-1p for qemu-devel@nongnu.org; Fri, 11 Nov 2016 06:29:15 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:38590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c5A1B-0001q7-Nc for qemu-devel@nongnu.org; Fri, 11 Nov 2016 06:29:13 -0500 Received: by mail-wm0-x232.google.com with SMTP id f82so86529066wmf.1 for ; Fri, 11 Nov 2016 03:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=o5HIQ8C1/JWq5RXu/GttT/MIFOmqz5PggfepOrPw3JM=; b=Cb287nXtZm6hw/nxG4qPVfdzgy2gr2EqSOYgGw0BX/XSPUrUbpv7KtR/zYCIhwlF7E 9ofdemK7YXxpuXtZt3QUwKZI5dAYuoP6tUbL5ogYG2B1nMKyvuTrOwZskyrw4077QoQc wyCBkk7eVb8C+bgTzsUzTg6vKMYmT81nFZ483RZ1npbmddK4FtDMge0EYsHO5iDVr7RU MqRDXb+CYevF7sb0dBwJ7MxdxT3MMwmAwGdaag1y2ioHVUFAtKWHOI8lvkGM4cuQhZ8a fA/SBIQgE8GFnayRRNv2qSk2Fiut11Ba6pdgi5Ib9G3DKTw0+PB1C/RwvOX55jeOtPCc 0iDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=o5HIQ8C1/JWq5RXu/GttT/MIFOmqz5PggfepOrPw3JM=; b=l/UvX632R1MJSEzcaNMK5npxMkHYtuk0VU2qsEhHQVUeTNIBV5plcEZ5tDA/VteTm0 PJT4eMK6gdQbxhdBt9cWEELrgoorXIBWlTt+XV5AzkX0gvgh8ac1N9fXaUOskNNy6oYT bZZytpicmfjhTdqNgwJLvEyc/eoJzUAQ6y/6Pk/2u+xxVS1RIw+hURv1mu+kzZFCg+DC 3VPmCfl+iAGieWxekjmWvzSSl1Zr/vPSAnw4Z4Ihv1uFKJ6eUUR0UBBhV7/2Xcrf0B/W WOdHUDRGnPdOLxPNlYcjCsD2SA975/5AxB4+uPkNBcYFiLMhqMjs1fSjX1A6EP5jOTXs 6RGw== X-Gm-Message-State: ABUngvfI8y5Y5//qN4SiUl0CtwlkbKqchvORaNu9CCxPhQnaFtG2LJyAxpaHMiU8HaLtJOYI X-Received: by 10.28.214.84 with SMTP id n81mr10560792wmg.120.1478863751402; Fri, 11 Nov 2016 03:29:11 -0800 (PST) Received: from vpalatin.zrh.corp.google.com ([172.16.114.40]) by smtp.gmail.com with ESMTPSA id i10sm10961389wjd.15.2016.11.11.03.29.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Nov 2016 03:29:10 -0800 (PST) From: Vincent Palatin To: qemu-devel Date: Fri, 11 Nov 2016 12:28:34 +0100 Message-Id: <4a30f0d403ec76ab5e349980d5623b2b9200a917.1478863621.git.vpalatin@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 Subject: [Qemu-devel] [PATCH v2 4/5] hax: simplify init 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: Vincent Palatin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" remove the leftovers from the Android specific code, and use the AccelClass allowed field as expected. then we can simplify the remaining logic and remove the hax_pre_init callback. Signed-off-by: Vincent Palatin --- hax-stub.c | 15 --------------- include/sysemu/hax.h | 4 ---- target-i386/hax-all.c | 49 ++++++++++++----------------------------------- target-i386/hax-windows.c | 20 ------------------- 4 files changed, 12 insertions(+), 76 deletions(-) diff --git a/hax-stub.c b/hax-stub.c index 0e756a3..a532dba 100644 --- a/hax-stub.c +++ b/hax-stub.c @@ -23,21 +23,6 @@ int hax_sync_vcpus(void) return 0; } -void hax_disable(int disable) -{ - return; -} - -int hax_pre_init(uint64_t ram_size) -{ - return 0; -} - -int hax_get_max_ram(uint64_t *max_ram) -{ - return 0; -} - int hax_populate_ram(uint64_t va, uint32_t size) { return -ENOSYS; diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h index 50b3fc4..51c8fd5 100644 --- a/include/sysemu/hax.h +++ b/include/sysemu/hax.h @@ -25,13 +25,9 @@ #include "config-host.h" #include "qemu-common.h" -int hax_pre_init(uint64_t ram_size); int hax_sync_vcpus(void); -void hax_disable(int disable); int hax_init_vcpu(CPUState *cpu); int hax_smp_cpu_exec(CPUState *cpu); -/* get the max haxm ram even before haxm library is initialized */ -int hax_get_max_ram(uint64_t *max_ram); int hax_populate_ram(uint64_t va, uint32_t size); void hax_cpu_synchronize_state(CPUState *cpu); diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index ad5414c..007178d 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -36,6 +36,7 @@ #include "exec/address-spaces.h" #include "qemu/main-loop.h" #include "hax-slot.h" +#include "hw/boards.h" static const char kHaxVcpuSyncFailed[] = "Failed to sync HAX vcpu context"; #define derror(msg) do { fprintf(stderr, (msg)); } while (0) @@ -66,7 +67,7 @@ const uint32_t hax_min_version = 0x3; #define HAX_EMULATE_STATE_NONE 0x3 #define HAX_EMULATE_STATE_INITIAL 0x4 -bool hax_allowed; +static bool hax_allowed; static void hax_vcpu_sync_state(CPUArchState *env, int modified); static int hax_arch_get_registers(CPUArchState *env); @@ -75,20 +76,11 @@ static int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port, static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft); struct hax_state hax_global; -int ret_hax_init; -static int hax_disabled = 1; - -int hax_support = -1; /* Called after hax_init */ int hax_enabled(void) { - return !hax_disabled && hax_support; -} - -void hax_disable(int disable) -{ - hax_disabled = disable; + return hax_allowed; } static int hax_prepare_emulation(CPUArchState *env) @@ -456,32 +448,17 @@ static void hax_handle_interrupt(CPUState *cpu, int mask) } } -int hax_pre_init(uint64_t ram_size) -{ - struct hax_state *hax = NULL; - - fprintf(stdout, "Hax is %s\n", hax_disabled ? "disabled" : "enabled"); - if (hax_disabled) { - return 0; - } - hax = &hax_global; - memset(hax, 0, sizeof(struct hax_state)); - hax->mem_quota = ram_size; - fprintf(stdout, "Hax ram_size 0x%llx\n", ram_size); - - return 0; -} - -static int hax_init(void) +static int hax_init(ram_addr_t ram_size) { struct hax_state *hax = NULL; struct hax_qemu_version qversion; int ret; - hax_support = 0; - hax = &hax_global; + memset(hax, 0, sizeof(struct hax_state)); + hax->mem_quota = ram_size; + hax->fd = hax_mod_open(); if (hax_invalid_fd(hax->fd)) { hax->fd = 0; @@ -519,7 +496,6 @@ static int hax_init(void) qversion.min_version = hax_min_version; hax_notify_qemu_version(hax->vm->fd, &qversion); cpu_interrupt_handler = hax_handle_interrupt; - hax_support = 1; return ret; error: @@ -535,17 +511,16 @@ static int hax_init(void) static int hax_accel_init(MachineState *ms) { - ret_hax_init = hax_init(); + int ret = hax_init(ms->ram_size); - if (ret_hax_init && (ret_hax_init != -ENOSPC)) { + if (ret && (ret != -ENOSPC)) { fprintf(stderr, "No accelerator found.\n"); - return ret_hax_init; } else { fprintf(stdout, "HAX is %s and emulator runs in %s mode.\n", - !ret_hax_init ? "working" : "not working", - !ret_hax_init ? "fast virt" : "emulation"); - return 0; + !ret ? "working" : "not working", + !ret ? "fast virt" : "emulation"); } + return ret; } static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft) diff --git a/target-i386/hax-windows.c b/target-i386/hax-windows.c index 194ac1c..71c230d 100644 --- a/target-i386/hax-windows.c +++ b/target-i386/hax-windows.c @@ -54,26 +54,6 @@ static int hax_open_device(hax_fd *fd) return 0; } -int hax_get_max_ram(uint64_t *max_ram) -{ - DWORD dSize = 0; - struct hax_capabilityinfo cap; - hax_fd fd = hax_mod_open(); - if (fd == NULL) { - return -1; - } - int result = DeviceIoControl(fd, HAX_IOCTL_CAPABILITY, NULL, 0, &cap, - sizeof(cap), &dSize, (LPOVERLAPPED) NULL); - CloseHandle(fd); - - if (!result) { - return -2; - } - *max_ram = cap.mem_quota; - - return 0; -} - /* hax_fd hax_mod_open */ hax_fd hax_mod_open(void) {