From patchwork Tue Feb 7 02:56:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Bobroff X-Patchwork-Id: 9559115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2077E604DC for ; Tue, 7 Feb 2017 02:58:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 138281FE82 for ; Tue, 7 Feb 2017 02:58:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07EC02808F; Tue, 7 Feb 2017 02:58:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 787A91FE82 for ; Tue, 7 Feb 2017 02:58:46 +0000 (UTC) Received: from localhost ([::1]:51707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cavzR-0005Kx-J3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Feb 2017 21:58:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cavyi-00055r-05 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 21:58:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cavye-0002so-TB for qemu-devel@nongnu.org; Mon, 06 Feb 2017 21:58:00 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38019 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cavye-0002sW-N8 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 21:57:56 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v172ruS6139775 for ; Mon, 6 Feb 2017 21:57:56 -0500 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0b-001b2d01.pphosted.com with ESMTP id 28ew5e273q-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 06 Feb 2017 21:57:55 -0500 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 12:57:52 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 12:57:50 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id D6D922CE805A; Tue, 7 Feb 2017 13:57:49 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v172vf8011403296; Tue, 7 Feb 2017 13:57:49 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v172vHYS024657; Tue, 7 Feb 2017 13:57:17 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v172vHEg024106; Tue, 7 Feb 2017 13:57:17 +1100 Received: from tungsten.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id EF561A0256; Tue, 7 Feb 2017 13:56:52 +1100 (AEDT) From: Sam Bobroff To: qemu-devel@nongnu.org Date: Tue, 7 Feb 2017 13:56:46 +1100 X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020702-0040-0000-0000-000002EC93C9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020702-0041-0000-0000-00000C32BA73 Message-Id: <0de3d80bc7658aac7dc5f6b271045463b572c7ff.1486436186.git.sam.bobroff@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702070026 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [RFC PATCH 3/9] spapr: Add ibm, processor-radix-AP-encodings to the device tree 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, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the new ioctl, KVM_PPC_GET_RMMU_INFO, to fetch radix MMU information from KVM and present the page encodings in the device tree under ibm,processor-radix-AP-encodings. This provides page size information to the guest which is necessary for it to use radix mode. Signed-off-by: Sam Bobroff --- hw/ppc/spapr.c | 7 +++++++ target/ppc/cpu.h | 5 +++++ target/ppc/kvm.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a642e663d4..d629e2630c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -496,6 +496,13 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, ppc_get_compat_smt_threads(cpu))); + + if (env->radix_page_info.count) { + _FDT((fdt_setprop(fdt, offset, "ibm,processor-radix-AP-encodings", + env->radix_page_info.entries, + env->radix_page_info.count * + sizeof(env->radix_page_info.entries[0])))); + } } static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index afb7ddbdd0..5a96d98b6f 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -914,6 +914,10 @@ struct ppc_segment_page_sizes { struct ppc_one_seg_page_size sps[PPC_PAGE_SIZES_MAX_SZ]; }; +struct ppc_radix_page_info { + uint32_t count; + uint32_t entries[PPC_PAGE_SIZES_MAX_SZ]; +}; /*****************************************************************************/ /* The whole PowerPC CPU context */ @@ -1053,6 +1057,7 @@ struct CPUPPCState { ppc_slb_t vrma_slb; target_ulong rmls; bool ci_large_pages; + struct ppc_radix_page_info radix_page_info; #endif #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index ec92c64159..390d6342cc 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -328,6 +328,18 @@ static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *info) kvm_get_fallback_smmu_info(cpu, info); } +static bool kvm_get_rmmu_info(PowerPCCPU *cpu, struct kvm_ppc_rmmu_info *info) +{ + CPUState *cs = CPU(cpu); + int ret; + + if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_MMU_RADIX)) { + ret = kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_RMMU_INFO, info); + return (ret == 0); + } + return false; +} + static long gethugepagesize(const char *mem_path) { struct statfs fs; @@ -441,9 +453,11 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu) { static struct kvm_ppc_smmu_info smmu_info; static bool has_smmu_info; + static struct kvm_ppc_rmmu_info rmmu_info; + static bool has_rmmu_info; CPUPPCState *env = &cpu->env; long rampagesize; - int iq, ik, jq, jk; + int iq, ik, jq, jk, i; bool has_64k_pages = false; /* We only handle page sizes for 64-bit server guests for now */ @@ -508,6 +522,22 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu) if (!has_64k_pages) { env->mmu_model &= ~POWERPC_MMU_64K; } + + /* Collect radix page info from kernel if not already */ + if (!has_rmmu_info) { + env->radix_page_info.count = 0; + if (kvm_get_rmmu_info(cpu, &rmmu_info)) { + for (i = 0; i < 8; i++) { + if (rmmu_info.ap_encodings[i]) { + env->radix_page_info.entries[i] = + cpu_to_be32(rmmu_info.ap_encodings[i]); + env->radix_page_info.count++; + } + } + } + has_rmmu_info = true; + } + } #else /* defined (TARGET_PPC64) */