From patchwork Thu Feb 5 09:59:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PranavkumarSawargaonkar X-Patchwork-Id: 44418 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9923321521 for ; Thu, 5 Feb 2015 10:02:02 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id fb4sf5631117wid.3 for ; Thu, 05 Feb 2015 02:02:01 -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=MoDvO99Fy0CDodOMxSbPm9bVDWCBnJqolbtWSRqy/lk=; b=BeO391xsxR7UtOJSbF/BfKR+xcZU6hgTs7UeXHqs1a58i3MJy3tU1tYqFDFYsjonxm 8AZGSfvVO3d2KHEzqyKmR9nkcGYI7NPtwcVtVVg6d1spKivJjIcG79Mxw3PJmPjEWMeS VRBhyZ98O16qROwQ6SmcZkhQP6IWq77YyWCsfzHKYc1SQCfzpPqYM0LdeTT0cMkpBYEu CMJ7/LuR6atU5o8GKPscgT/GYN9bUotgUzjAhL8ZqvVG7XSABLuTKq4Y9k9wwAh4qKnd U3gBEhDCe1dLBDFwpGaAo9KdhO3/S3rCRg0/6r0SvMRrIPDel3enqUQDbhHVpWLxl8oN 7h2Q== X-Gm-Message-State: ALoCoQnh5Ot3s2YvdXNjx6BSQcPOHU45wu1PZ5igcmhUmE+Z+sYbWspU270JN5UDnssCPSLfi4Ja X-Received: by 10.180.98.131 with SMTP id ei3mr909391wib.5.1423130521438; Thu, 05 Feb 2015 02:02:01 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.164 with SMTP id wr4ls149813lac.79.gmail; Thu, 05 Feb 2015 02:02:01 -0800 (PST) X-Received: by 10.112.184.198 with SMTP id ew6mr2415891lbc.71.1423130521135; Thu, 05 Feb 2015 02:02:01 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ww5si3565225lbb.22.2015.02.05.02.02.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 02:02:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so6087690lbv.8 for ; Thu, 05 Feb 2015 02:02:01 -0800 (PST) X-Received: by 10.112.63.134 with SMTP id g6mr2525752lbs.52.1423130521052; Thu, 05 Feb 2015 02:02:01 -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.35.133 with SMTP id h5csp1036600lbj; Thu, 5 Feb 2015 02:02:00 -0800 (PST) X-Received: by 10.229.190.6 with SMTP id dg6mr6641877qcb.16.1423130519685; Thu, 05 Feb 2015 02:01:59 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i8si5506197qas.93.2015.02.05.02.01.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:01:59 -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]:40965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJJG2-00080j-UZ for patch@linaro.org; Thu, 05 Feb 2015 05:01:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJJEV-0006Ah-LZ for qemu-devel@nongnu.org; Thu, 05 Feb 2015 05:00:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJJER-0003SK-3F for qemu-devel@nongnu.org; Thu, 05 Feb 2015 05:00:23 -0500 Received: from mail-pd0-f175.google.com ([209.85.192.175]:42880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJJEQ-0003SA-Us for qemu-devel@nongnu.org; Thu, 05 Feb 2015 05:00:19 -0500 Received: by pdjy10 with SMTP id y10so6838803pdj.9 for ; Thu, 05 Feb 2015 02:00:18 -0800 (PST) X-Received: by 10.68.240.233 with SMTP id wd9mr4320068pbc.69.1423130416918; Thu, 05 Feb 2015 02:00:16 -0800 (PST) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id bi11sm4577429pdb.8.2015.02.05.02.00.13 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Feb 2015 02:00:16 -0800 (PST) From: Pranavkumar Sawargaonkar To: qemu-devel@nongnu.org Date: Thu, 5 Feb 2015 15:29:42 +0530 Message-Id: <1423130382-18640-3-git-send-email-pranavkumar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1423130382-18640-1-git-send-email-pranavkumar@linaro.org> References: <1423130382-18640-1-git-send-email-pranavkumar@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: peter.maydell@linaro.org, patches@apm.com, alex.bennee@linaro.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, Pranavkumar Sawargaonkar Subject: [Qemu-devel] [PATCH V3 2/2] target-arm: Guest cpu endianness determination for virtio KVM ARM/ARM64 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: pranavkumar@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.217.177 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 This patch implements a fucntion pointer "virtio_is_big_endian" from "CPUClass" structure for arm/arm64. Function arm_cpu_is_big_endian() is added to determine and return the guest cpu endianness to virtio. This is required for running cross endian guests with virtio on ARM/ARM64. Signed-off-by: Pranavkumar Sawargaonkar --- target-arm/cpu.c | 24 ++++++++++++++++++++++++ target-arm/cpu.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 285947f..4d9cded 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -320,6 +320,29 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0); #endif } + +static bool arm_cpu_is_big_endian(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + int cur_el; + + cpu_synchronize_state(cs); + + /* In 32bit guest endianess is determined by looking at CPSR's E bit */ + if (!is_a64(env)) { + return (env->pstate & CPSR_E) ? 1 : 0; + } + + cur_el = arm_current_el(env); + + if (cur_el == 0) { + return (env->cp15.sctlr_el[1] & SCTLR_E0E) != 0; + } + + return (env->cp15.sctlr_el[cur_el] & SCTLR_EE) != 0; +} + #endif static inline void set_feature(CPUARMState *env, int feature) @@ -1189,6 +1212,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = arm_cpu_do_interrupt; cc->get_phys_page_debug = arm_cpu_get_phys_page_debug; cc->vmsd = &vmstate_arm_cpu; + cc->virtio_is_big_endian = arm_cpu_is_big_endian; #endif cc->gdb_num_core_regs = 26; cc->gdb_core_xml_file = "arm-core.xml"; diff --git a/target-arm/cpu.h b/target-arm/cpu.h index cd7a9e8..317e801 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -32,6 +32,8 @@ # define ELF_MACHINE EM_ARM #endif +#define TARGET_IS_BIENDIAN 1 + #define CPUArchState struct CPUARMState #include "qemu-common.h"