[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 07/30] spapr: Remove obsolete ram_limit field from sPAP
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PULL 07/30] spapr: Remove obsolete ram_limit field from sPAPRMachineState |
Date: |
Tue, 7 Jul 2015 17:49:19 +0200 |
From: David Gibson <address@hidden>
The ram_limit field was imported from sPAPREnvironment where it predates
the machine's ram size being available generically from machine->ram_size.
Worse, the existing code was inconsistent about where it got the ram size
from. Sometimes it used spapr->ram_limit, sometimes the global 'ram_size'
and sometimes a local 'ram_size' masking the global.
This cleans up the code to consistently use machine->ram_size, eliminating
spapr->ram_limit in the process.
Signed-off-by: David Gibson <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/spapr.c | 22 ++++++++++++----------
hw/ppc/spapr_hcall.c | 3 ++-
include/hw/ppc/spapr.h | 1 -
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f820534..6adfb68 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -265,15 +265,18 @@ static size_t create_page_sizes_prop(CPUPPCState *env,
uint32_t *prop,
static hwaddr spapr_node0_size(void)
{
+ MachineState *machine = MACHINE(qdev_get_machine());
+
if (nb_numa_nodes) {
int i;
for (i = 0; i < nb_numa_nodes; ++i) {
if (numa_info[i].node_mem) {
- return MIN(pow2floor(numa_info[i].node_mem), ram_size);
+ return MIN(pow2floor(numa_info[i].node_mem),
+ machine->ram_size);
}
}
}
- return ram_size;
+ return machine->ram_size;
}
#define _FDT(exp) \
@@ -649,6 +652,7 @@ static void spapr_populate_memory_node(void *fdt, int
nodeid, hwaddr start,
static int spapr_populate_memory(sPAPRMachineState *spapr, void *fdt)
{
+ MachineState *machine = MACHINE(spapr);
hwaddr mem_start, node_size;
int i, nb_nodes = nb_numa_nodes;
NodeInfo *nodes = numa_info;
@@ -657,7 +661,7 @@ static int spapr_populate_memory(sPAPRMachineState *spapr,
void *fdt)
/* No NUMA nodes, assume there is just one node with whole RAM */
if (!nb_numa_nodes) {
nb_nodes = 1;
- ramnode.node_mem = ram_size;
+ ramnode.node_mem = machine->ram_size;
nodes = &ramnode;
}
@@ -665,12 +669,12 @@ static int spapr_populate_memory(sPAPRMachineState
*spapr, void *fdt)
if (!nodes[i].node_mem) {
continue;
}
- if (mem_start >= ram_size) {
+ if (mem_start >= machine->ram_size) {
node_size = 0;
} else {
node_size = nodes[i].node_mem;
- if (node_size > ram_size - mem_start) {
- node_size = ram_size - mem_start;
+ if (node_size > machine->ram_size - mem_start) {
+ node_size = machine->ram_size - mem_start;
}
}
if (!mem_start) {
@@ -1374,7 +1378,6 @@ static void spapr_boot_set(void *opaque, const char
*boot_device,
static void ppc_spapr_init(MachineState *machine)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
- ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
@@ -1443,7 +1446,7 @@ static void ppc_spapr_init(MachineState *machine)
* more than needed for the Linux guests we support. */
spapr->htab_shift = 18; /* Minimum architected size */
while (spapr->htab_shift <= 46) {
- if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {
+ if ((1ULL << (spapr->htab_shift + 7)) >= machine->ram_size) {
break;
}
spapr->htab_shift++;
@@ -1497,9 +1500,8 @@ static void ppc_spapr_init(MachineState *machine)
}
/* allocate RAM */
- spapr->ram_limit = ram_size;
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
- spapr->ram_limit);
+ machine->ram_size);
memory_region_add_subregion(sysmem, 0, ram);
if (rma_alloc_size && rma) {
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 1a20884..652ddf6 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -87,6 +87,7 @@ static inline bool valid_pte_index(CPUPPCState *env,
target_ulong pte_index)
static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
+ MachineState *machine = MACHINE(spapr);
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
@@ -118,7 +119,7 @@ static target_ulong h_enter(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
raddr = (ptel & HPTE64_R_RPN) & ~((1ULL << page_shift) - 1);
- if (raddr < spapr->ram_limit) {
+ if (raddr < machine->ram_size) {
/* Regular RAM - should have WIMG=0010 */
if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) {
return H_PARAMETER;
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index c3652aa..9e7cf0f 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -33,7 +33,6 @@ struct sPAPRMachineState {
XICSState *icp;
DeviceState *rtc;
- hwaddr ram_limit;
void *htab;
uint32_t htab_shift;
hwaddr rma_size;
--
1.8.1.4
- [Qemu-ppc] [PULL 04/30] spapr: ensure we have at least one XICS server, (continued)
- [Qemu-ppc] [PULL 04/30] spapr: ensure we have at least one XICS server, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 20/30] spapr: Consolidate cpu init code into a routine, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 28/30] sPAPR: Don't enable EEH on emulated PCI devices, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 29/30] sPAPR: Reenable EEH functionality on reboot, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 13/30] spapr_iommu: drop erroneous check in h_put_tce_indirect(), Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 11/30] spapr_pci: encode class code including Prog IF register, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 22/30] xics_kvm: Don't enable KVM_CAP_IRQ_XICS if already enabled, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 30/30] sPAPR: Clear stale MSIx table during EEH reset, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 08/30] spapr: Remove obsolete entry_point field from sPAPRMachineState, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 26/30] spapr_vty: lookup should only return valid VTY objects, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 07/30] spapr: Remove obsolete ram_limit field from sPAPRMachineState,
Alexander Graf <=
- [Qemu-ppc] [PULL 17/30] spapr: Support ibm, lrdr-capacity device tree property, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 21/30] ppc: Update cpu_model in MachineState, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 23/30] spapr_pci: enumerate and add PCI device tree, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 15/30] Revert "hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)", Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 27/30] spapr-vty: Use TYPE_ definition instead of hardcoding, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 25/30] spapr_pci: drop redundant args in spapr_[populate, create]_pci_child_dt, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 19/30] spapr: Reorganize CPU dt generation code, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 24/30] spapr_pci: populate ibm,loc-code, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 06/30] spapr: Merge sPAPREnvironment into sPAPRMachineState, Alexander Graf, 2015/07/07
- [Qemu-ppc] [PULL 05/30] pseries: Update SLOF firmware image to qemu-slof-20150429, Alexander Graf, 2015/07/07