[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v4 3/8] spapr: Only setup HPT if necessary
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v4 3/8] spapr: Only setup HPT if necessary |
Date: |
Fri, 17 Mar 2017 13:57:44 +1100 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Thu, Mar 16, 2017 at 05:08:15PM +1100, Sam Bobroff wrote:
> 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 <address@hidden>
Reviewed-by: David Gibson <address@hidden>
> ---
> Changes in v4:
> * Fixed typo in title.
> * Reworked to track that no HPT has been allocated using the GR bit of PATB.
>
> hw/ppc/spapr.c | 30 +++++++++++++++++++-----------
> hw/ppc/spapr_hcall.c | 7 +++++++
> include/hw/ppc/spapr.h | 1 +
> 3 files changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index d96e5f60fe..f264773e11 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1239,6 +1239,17 @@ static void spapr_reallocate_hpt(sPAPRMachineState
> *spapr, int shift,
> }
> }
>
> +void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr)
> +{
> + spapr_reallocate_hpt(spapr,
> +
> spapr_hpt_shift_for_ramsize(MACHINE(spapr)->maxram_size),
> + &error_fatal);
> + if (spapr->vrma_adjust) {
> + spapr->rma_size = kvmppc_rma_size(spapr_node0_size(),
> + spapr->htab_shift);
> + }
> +}
> +
> static void find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque)
> {
> bool matched = false;
> @@ -1267,17 +1278,14 @@ static void ppc_spapr_reset(void)
> /* Check for unknown sysbus devices */
> foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
>
> - spapr->patb_entry = 0;
> -
> - /* 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 = kvmppc_rma_size(spapr_node0_size(),
> - spapr->htab_shift);
> + if (kvm_enabled() && kvmppc_has_cap_mmu_radix()) {
> + /* If using KVM with radix mode available, VCPUs can be started
> + * without a HPT because KVM will start them in radix mode.
> + * Set the GR bit in PATB so that we know there is no HPT. */
> + spapr->patb_entry = PATBE1_GR;
> + } else {
> + spapr->patb_entry = 0;
> + spapr_setup_hpt_and_vrma(spapr);
> }
>
> qemu_devices_reset();
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index f05a90ed2c..1ce21af9f4 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -999,6 +999,13 @@ static target_ulong
> h_client_architecture_support(PowerPCCPU *cpu,
> ov5_updates = spapr_ovec_new();
> spapr->cas_reboot = spapr_ovec_diff(ov5_updates,
> ov5_cas_old, spapr->ov5_cas);
> + /* If the HPT hasn't yet been set up (see
> + * ppc_spapr_reset()), but it's now needed, do it now: */
> + if ((spapr->patb_entry & PATBE1_GR) &&
> + !spapr_ovec_test(ov5_updates, OV5_MMU_RADIX)) {
> + /* legacy hash or new hash: */
> + spapr_setup_hpt_and_vrma(spapr);
> + }
>
> if (!spapr->cas_reboot) {
> spapr->cas_reboot =
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index ba9e689ee2..8aeb7f5758 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -605,6 +605,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,
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
- [Qemu-ppc] [PATCH v4 0/8] ISA 3.00 KVM guest support, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 2/8] target-ppc: support KVM_CAP_PPC_MMU_RADIX, KVM_CAP_PPC_MMU_HASH_V3, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 4/8] target/ppc: Add new H-CALL shells for in memory table translation, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 3/8] spapr: Only setup HPT if necessary, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 1/8] spapr: Add ibm, processor-radix-AP-encodings to the device tree, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 8/8] spapr: Workaround for broken radix guests, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 6/8] spapr: move spapr_populate_pa_features(), Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 7/8] spapr: Enable ISA 3.0 MMU mode selection via CAS, Sam Bobroff, 2017/03/16
- [Qemu-ppc] [PATCH v4 5/8] target/ppc: Implement H_REGISTER_PROCESS_TABLE H_CALL, Sam Bobroff, 2017/03/16