From nobody Mon Feb 9 05:43:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487830110892183.25016944218214; Wed, 22 Feb 2017 22:08:30 -0800 (PST) Received: from localhost ([::1]:56807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgmZo-00060c-H2 for importer@patchew.org; Thu, 23 Feb 2017 01:08:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgmTB-00008x-KU for qemu-devel@nongnu.org; Thu, 23 Feb 2017 01:01:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgmT8-0001iU-G7 for qemu-devel@nongnu.org; Thu, 23 Feb 2017 01:01:37 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42587 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 1cgmT8-0001hq-AZ for qemu-devel@nongnu.org; Thu, 23 Feb 2017 01:01:34 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1N5reUO013186 for ; Thu, 23 Feb 2017 01:01:33 -0500 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0b-001b2d01.pphosted.com with ESMTP id 28sqms4v53-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 23 Feb 2017 01:01:33 -0500 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Feb 2017 16:01:30 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 23 Feb 2017 16:01:28 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 5879D357805C; Thu, 23 Feb 2017 17:01:27 +1100 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1N61JA826673312; Thu, 23 Feb 2017 17:01:27 +1100 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1N60sJ8027927; Thu, 23 Feb 2017 17:00:55 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1N60sco026830; Thu, 23 Feb 2017 17:00:54 +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 125F4A03B4; Thu, 23 Feb 2017 17:00:06 +1100 (AEDT) From: Sam Bobroff To: qemu-ppc@nongnu.org Date: Thu, 23 Feb 2017 17:00:01 +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: 17022306-0048-0000-0000-00000208FDC9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022306-0049-0000-0000-00004795E1D2 Message-Id: <034945c1bbc8d4a97e5f568d4d463af2c9a24080.1487829585.git.sam.bobroff@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-23_04:, , 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-1702230057 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 v2 08/12] spapr: Only setup HTP if necessary. 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-devel@nongnu.org, sjitindarsingh@gmail.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If QEMU is using KVM, and KVM is capable of running in radix mode, guests can be run in real-mode without allocating a HPT (because KVM will use a minimal RPT). So in this case, we avoid creating the HPT at reset time and later (during CAS) create it if it is necessary. Signed-off-by: Sam Bobroff --- v2: * This patch has been mostly rewritten to move the late HPT allocation to C= AS. This allows a guest to start in radix mode (when it's in real mode) and then change to hash, even if it is a legacy guest and will not call h_register_process_table(). * Added an exported function to spapr.c to perform HPT allocation and adjust the vrma if necessary. This makes it possible to allocate the HPT from h_client_architecture_support() in spapr_hcall.c. hw/ppc/spapr.c | 24 +++++++++++++++--------- hw/ppc/spapr_hcall.c | 10 ++++++++++ include/hw/ppc/spapr.h | 1 + 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ca3812555f..dfee0f685f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1123,6 +1123,17 @@ static void spapr_reallocate_hpt(sPAPRMachineState *= spapr, int shift, } } =20 +void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr) +{ + spapr_reallocate_hpt(spapr, + spapr_hpt_shift_for_ramsize(MACHINE(qdev_get_machine(= ))->maxram_size), + &error_fatal); + if (spapr->vrma_adjust) { + spapr->rma_size =3D kvmppc_rma_size(spapr_node0_size(), + spapr->htab_shift); + } +} + static void find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque) { bool matched =3D false; @@ -1151,15 +1162,10 @@ static void ppc_spapr_reset(void) /* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); =20 - /* Allocate and/or reset the hash page table */ - spapr_reallocate_hpt(spapr, - spapr_hpt_shift_for_ramsize(machine->maxram_size), - &error_fatal); - - /* Update the RMA size if necessary */ - if (spapr->vrma_adjust) { - spapr->rma_size =3D kvmppc_rma_size(spapr_node0_size(), - spapr->htab_shift); + /* If using KVM with radix mode available, VCPUs can be started + * without a HPT because KVM will start them in radix mode. */ + if (!(kvm_enabled() && kvmppc_has_cap_mmu_radix())) { + spapr_setup_hpt_and_vrma(spapr); } =20 qemu_devices_reset(); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 42d20e0b92..cea34073aa 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1002,6 +1002,16 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, ov5_updates =3D spapr_ovec_new(); spapr->cas_reboot =3D spapr_ovec_diff(ov5_updates, ov5_cas_old, spapr->ov5_cas); + if (kvm_enabled()) { + if (kvmppc_has_cap_mmu_radix()) { + /* If the HPT hasn't yet been set up (see + * ppc_spapr_reset()), and it's needed, do it now: */ + if (!spapr_ovec_test(ov5_updates, OV5_MMU_RADIX)) { + /* legacy hash or new hash: */ + spapr_setup_hpt_and_vrma(spapr); + } + } + } =20 if (!spapr->cas_reboot) { spapr->cas_reboot =3D diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index f9b17d860a..a30cbc485c 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -590,6 +590,7 @@ void spapr_dt_events(sPAPRMachineState *sm, void *fdt); int spapr_h_cas_compose_response(sPAPRMachineState *sm, target_ulong addr, target_ulong size, sPAPROptionVector *ov5_updates); +void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr); sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn); void spapr_tce_table_enable(sPAPRTCETable *tcet, uint32_t page_shift, uint64_t bus_offset, --=20 2.11.0