From patchwork Wed Jan 21 18:49:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 43480 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5227F240F1 for ; Wed, 21 Jan 2015 18:51:40 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id c13sf11017542eek.1 for ; Wed, 21 Jan 2015 10:51:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Plj/pSuJ5229svzVQudQA5LLZK02Jfo248IraXi1lCA=; b=UJdMcpjV+nfgs/xW4NgJMjXUDAYXxooQYVD56NFCivoE3g6KOJzNTPzkteOOQsyyRA rhB2C3ZdToPkTsk18R5DvPNhpBBgcF+rltlj0tI/ALB3QegwkZAeJrh3EYk4ZT/DdBYk diBJF8toM40qeTKa3Wl+nuEbxdLSisohLJ/QC7xPNjqweWNB8NvTAGonEsz6HUMVjQXv eTteHRZ+bmaLKqQ3EkPsc9XsNhqIfqv976Lh6LKGjijanSkaBZgdPmVXrT9eY6SUUdUP 5+ds6/U3wmC1Rshu/Yw6kw9pJyzomUslIqFrTaKCtGUZaJcBgG9d/ydV+ctOPpN0/mcE tTGg== X-Gm-Message-State: ALoCoQnTR1x/ipO/AMjawP22PtTR8YEPcuBBoD4Jgj/SidJ7LHjcVdLnWJGIF+IJP8AZG6X6gKha X-Received: by 10.180.105.97 with SMTP id gl1mr3786040wib.7.1421866299530; Wed, 21 Jan 2015 10:51:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls72262lad.37.gmail; Wed, 21 Jan 2015 10:51:39 -0800 (PST) X-Received: by 10.152.6.67 with SMTP id y3mr45934755lay.90.1421866299371; Wed, 21 Jan 2015 10:51:39 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id b5si2125654lah.17.2015.01.21.10.51.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 10:51:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so20858514lab.10 for ; Wed, 21 Jan 2015 10:51:39 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr45879712lac.6.1421866299270; Wed, 21 Jan 2015 10:51:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp8339lbb; Wed, 21 Jan 2015 10:51:38 -0800 (PST) X-Received: by 10.236.14.135 with SMTP id d7mr20678823yhd.3.1421866297801; Wed, 21 Jan 2015 10:51:37 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id mn9si5682691qcb.19.2015.01.21.10.51.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 21 Jan 2015 10:51:37 -0800 (PST) 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; Received: from localhost ([::1]:49752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE0NM-0007h5-Us for patch@linaro.org; Wed, 21 Jan 2015 13:51:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE0M2-0006E8-Eb for qemu-devel@nongnu.org; Wed, 21 Jan 2015 13:50:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YE0Lz-0001MP-8J for qemu-devel@nongnu.org; Wed, 21 Jan 2015 13:50:14 -0500 Received: from mail-pd0-f175.google.com ([209.85.192.175]:64913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE0Lz-0001MF-3I for qemu-devel@nongnu.org; Wed, 21 Jan 2015 13:50:11 -0500 Received: by mail-pd0-f175.google.com with SMTP id fl12so18444370pdb.6 for ; Wed, 21 Jan 2015 10:50:10 -0800 (PST) X-Received: by 10.68.69.5 with SMTP id a5mr22057940pbu.57.1421866210495; Wed, 21 Jan 2015 10:50:10 -0800 (PST) Received: from gbellows-linaro.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id zk9sm7047429pac.1.2015.01.21.10.50.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 10:50:09 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org Date: Wed, 21 Jan 2015 12:49:53 -0600 Message-Id: <1421866193-24941-5-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1421866193-24941-1-git-send-email-greg.bellows@linaro.org> References: <1421866193-24941-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.175 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v2 4/4] target-arm: Add AArch32 guest support to KVM64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add 32-bit to/from 64-bit register synchronization on register gets and puts. Set EL1_32BIT feature flag passed to KVM Signed-off-by: Greg Bellows --- target-arm/kvm64.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c index ba16821..0061099 100644 --- a/target-arm/kvm64.c +++ b/target-arm/kvm64.c @@ -81,8 +81,7 @@ int kvm_arch_init_vcpu(CPUState *cs) int ret; ARMCPU *cpu = ARM_CPU(cs); - if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE || - !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) { fprintf(stderr, "KVM is not supported for this guest CPU type\n"); return -EINVAL; } @@ -96,6 +95,9 @@ int kvm_arch_init_vcpu(CPUState *cs) cpu->psci_version = 2; cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; } + if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; + } /* Do KVM_ARM_VCPU_INIT ioctl */ ret = kvm_arm_vcpu_init(cs); @@ -133,6 +135,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + aarch64_sync_32_to_64(env); for (i = 0; i < 31; i++) { reg.id = AARCH64_CORE_REG(regs.regs[i]); reg.addr = (uintptr_t) &env->xregs[i]; @@ -162,7 +165,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) } /* Note that KVM thinks pstate is 64 bit but we use a uint32_t */ - val = pstate_read(env); + if (is_a64(env)) { + val = pstate_read(env); + } else { + val = cpsr_read(env); + } reg.id = AARCH64_CORE_REG(regs.pstate); reg.addr = (uintptr_t) &val; ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); @@ -218,6 +225,7 @@ int kvm_arch_get_registers(CPUState *cs) return ret; } } + aarch64_sync_64_to_32(env); reg.id = AARCH64_CORE_REG(regs.sp); reg.addr = (uintptr_t) &env->sp_el[0]; @@ -239,7 +247,12 @@ int kvm_arch_get_registers(CPUState *cs) if (ret) { return ret; } - pstate_write(env, val); + if (is_a64(env)) { + pstate_write(env, val); + } else { + env->uncached_cpsr = val & CPSR_M; + cpsr_write(env, val, 0xffffffff); + } /* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the * QEMU side we keep the current SP in xregs[31] as well.