From patchwork Sun Apr 3 10:37:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Education Directorate X-Patchwork-Id: 8733981 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C975F9F36E for ; Sun, 3 Apr 2016 10:38:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF3ED200E8 for ; Sun, 3 Apr 2016 10:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FFFD2021B for ; Sun, 3 Apr 2016 10:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbcDCKiN (ORCPT ); Sun, 3 Apr 2016 06:38:13 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:36832 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752565AbcDCKiL (ORCPT ); Sun, 3 Apr 2016 06:38:11 -0400 Received: by mail-pa0-f45.google.com with SMTP id tt10so123465674pab.3 for ; Sun, 03 Apr 2016 03:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cL1Z9sD4bkNKSVxOzIWKTCm30T9+QWQ4CS3kBM5vu3c=; b=KLJfhvF10iFP/tMCsyJpG3kzb86Zm85vMbJ8OSw6XEqUtfYOP3Zlu4F8AF4xDD8lL7 TJRdGUG0L/XO85AHDEfPcELwAk/MjXGRjHN1HKnDm1I/CucqfUSfKdVMGAVMrAK8115y 6xqr3Gdc73J5GzWBxJ2uHmFzPVyiGV8UxHQtYEj54WRhZpJN4Atdz3MixHe+2WUG/fG1 e665rqM9EjKk1AG9sG00Hli65WHhMOIv0x9dxCpTgm8x6Xjt8V3A0adhsYmgGtmX5ugw TZtTUVn+pZ+1kP1fPX5yxXJbVKzxnoyt99wYIWyMolfNy5Sdz4Yc8gLwVWDxqwbGc5XY 7Ysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cL1Z9sD4bkNKSVxOzIWKTCm30T9+QWQ4CS3kBM5vu3c=; b=BZeXCURErXIrUb/bwMw+yFKEGyVvPcd+0s09Qku7sKJmQ24da6jwaD+E1yglL7KjBE RgebzChLDIFSASMbC6PPINgPgRVkToDKplAYlBvdStcjW68M1/cLRlQcfLAmVrG3HYSc MAGZ/JGtTeucOcE+0Nhltqa8Fic7EnmbxjnSkqKsmQOVb/eNE/GLTaWRB1V8Rt6jEbyr TY4XrddzOMR940/xowEoC6EZQuC4HrFh1e7SLdBw0DN1UZhpYS5mlahATowR4beMEgbl IS75PwkZ2zcHk0y+IG+VuwhWkebNNlrbsDxwoHF4iSCJYdo0yhk/j7ghwWJwNWKBCxRf kwig== X-Gm-Message-State: AD7BkJLElyfPaiiFqJpYiLhmmsvYf8yOLWLKoqA9JO6F5YoRnHWpugQudxzzlP/FKv/7YA== X-Received: by 10.66.63.104 with SMTP id f8mr44545269pas.109.1459679890632; Sun, 03 Apr 2016 03:38:10 -0700 (PDT) Received: from cotter.ozlabs.ibm.com (14-202-194-140.static.tpgi.com.au. [14.202.194.140]) by smtp.gmail.com with ESMTPSA id l4sm31888610pfi.73.2016.04.03.03.38.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Apr 2016 03:38:10 -0700 (PDT) Received: by cotter.ozlabs.ibm.com (Postfix, from userid 1000) id D97ECC006C; Sun, 3 Apr 2016 20:38:03 +1000 (AEST) From: Balbir Singh To: will.deacon@arm.com, kvm@vger.kernel.org Cc: mpe@ellerman.id.au, mikey@neuling.org, aik@ozlabs.ru, Balbir Singh Subject: [KVMTOOL][PATCH 1/5] Add basic little endian support for ppc64le. Date: Sun, 3 Apr 2016 20:37:58 +1000 Message-Id: <1459679882-30382-2-git-send-email-bsingharora@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459679882-30382-1-git-send-email-bsingharora@gmail.com> References: <1459679882-30382-1-git-send-email-bsingharora@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently kvmtool works well/was designed for big endian ppc64 systems. This patch adds support for little endian systems The system does not yet boot as support for h_set_mode is required to help with exceptions in big endian mode -- first page fault. The support comes in the next patch of the series Signed-off-by: Balbir Singh Acked-by: Michael Ellerman --- powerpc/kvm.c | 24 ++++++++++++------------ powerpc/spapr.h | 5 +++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/powerpc/kvm.c b/powerpc/kvm.c index b4c3310..d147e0c 100644 --- a/powerpc/kvm.c +++ b/powerpc/kvm.c @@ -253,21 +253,21 @@ static void generate_segment_page_sizes(struct kvm_ppc_smmu_info *info, struct f if (sps->page_shift == 0) break; - *p++ = sps->page_shift; - *p++ = sps->slb_enc; + *p++ = cpu_to_be32(sps->page_shift); + *p++ = cpu_to_be32(sps->slb_enc); for (j = 0; j < KVM_PPC_PAGE_SIZES_MAX_SZ; j++) if (!info->sps[i].enc[j].page_shift) break; - *p++ = j; /* count of enc */ + *p++ = cpu_to_be32(j); /* count of enc */ for (j = 0; j < KVM_PPC_PAGE_SIZES_MAX_SZ; j++) { if (!info->sps[i].enc[j].page_shift) break; - *p++ = info->sps[i].enc[j].page_shift; - *p++ = info->sps[i].enc[j].pte_enc; + *p++ = cpu_to_be32(info->sps[i].enc[j].page_shift); + *p++ = cpu_to_be32(info->sps[i].enc[j].pte_enc); } } } @@ -292,7 +292,7 @@ static int setup_fdt(struct kvm *kvm) u8 staging_fdt[FDT_MAX_SIZE]; struct cpu_info *cpu_info = find_cpu_info(kvm); struct fdt_prop segment_page_sizes; - u32 segment_sizes_1T[] = {0x1c, 0x28, 0xffffffff, 0xffffffff}; + u32 segment_sizes_1T[] = {cpu_to_be32(0x1c), cpu_to_be32(0x28), 0xffffffff, 0xffffffff}; /* Generate an appropriate DT at kvm->arch.fdt_gra */ void *fdt_dest = guest_flat_to_host(kvm, kvm->arch.fdt_gra); @@ -364,7 +364,7 @@ static int setup_fdt(struct kvm *kvm) _FDT(fdt_property_cell(fdt, "#size-cells", 0x0)); for (i = 0; i < smp_cpus; i += SMT_THREADS) { - int32_t pft_size_prop[] = { 0, HPT_ORDER }; + int32_t pft_size_prop[] = { 0, cpu_to_be32(HPT_ORDER) }; uint32_t servers_prop[SMT_THREADS]; uint32_t gservers_prop[SMT_THREADS * 2]; int threads = (smp_cpus - i) >= SMT_THREADS ? SMT_THREADS : @@ -503,11 +503,11 @@ int kvm__arch_setup_firmware(struct kvm *kvm) */ uint32_t *rtas = guest_flat_to_host(kvm, kvm->arch.rtas_gra); - rtas[0] = 0x7c641b78; - rtas[1] = 0x3c600000; - rtas[2] = 0x6063f000; - rtas[3] = 0x44000022; - rtas[4] = 0x4e800020; + rtas[0] = cpu_to_be32(0x7c641b78); + rtas[1] = cpu_to_be32(0x3c600000); + rtas[2] = cpu_to_be32(0x6063f000); + rtas[3] = cpu_to_be32(0x44000022); + rtas[4] = cpu_to_be32(0x4e800020); kvm->arch.rtas_size = 20; pr_info("Set up %ld bytes of RTAS at 0x%lx\n", diff --git a/powerpc/spapr.h b/powerpc/spapr.h index 7a377d0..8b294d1 100644 --- a/powerpc/spapr.h +++ b/powerpc/spapr.h @@ -15,6 +15,7 @@ #define __HW_SPAPR_H__ #include +#include #include "kvm/kvm.h" #include "kvm/kvm-cpu.h" @@ -80,12 +81,12 @@ int spapr_rtas_fdt_setup(struct kvm *kvm, void *fdt); static inline uint32_t rtas_ld(struct kvm *kvm, target_ulong phys, int n) { - return *((uint32_t *)guest_flat_to_host(kvm, phys + 4*n)); + return cpu_to_be32(*((uint32_t *)guest_flat_to_host(kvm, phys + 4*n))); } static inline void rtas_st(struct kvm *kvm, target_ulong phys, int n, uint32_t val) { - *((uint32_t *)guest_flat_to_host(kvm, phys + 4*n)) = val; + *((uint32_t *)guest_flat_to_host(kvm, phys + 4*n)) = cpu_to_be32(val); } typedef void (*spapr_rtas_fn)(struct kvm_cpu *vcpu, uint32_t token,