spapr: Remove obsolete ram_limit field from sPAPRMachineState
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 <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
28e0204254
commit
fb16499418
@ -265,15 +265,18 @@ static size_t create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,
|
|||||||
|
|
||||||
static hwaddr spapr_node0_size(void)
|
static hwaddr spapr_node0_size(void)
|
||||||
{
|
{
|
||||||
|
MachineState *machine = MACHINE(qdev_get_machine());
|
||||||
|
|
||||||
if (nb_numa_nodes) {
|
if (nb_numa_nodes) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < nb_numa_nodes; ++i) {
|
for (i = 0; i < nb_numa_nodes; ++i) {
|
||||||
if (numa_info[i].node_mem) {
|
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) \
|
#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)
|
static int spapr_populate_memory(sPAPRMachineState *spapr, void *fdt)
|
||||||
{
|
{
|
||||||
|
MachineState *machine = MACHINE(spapr);
|
||||||
hwaddr mem_start, node_size;
|
hwaddr mem_start, node_size;
|
||||||
int i, nb_nodes = nb_numa_nodes;
|
int i, nb_nodes = nb_numa_nodes;
|
||||||
NodeInfo *nodes = numa_info;
|
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 */
|
/* No NUMA nodes, assume there is just one node with whole RAM */
|
||||||
if (!nb_numa_nodes) {
|
if (!nb_numa_nodes) {
|
||||||
nb_nodes = 1;
|
nb_nodes = 1;
|
||||||
ramnode.node_mem = ram_size;
|
ramnode.node_mem = machine->ram_size;
|
||||||
nodes = &ramnode;
|
nodes = &ramnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,12 +669,12 @@ static int spapr_populate_memory(sPAPRMachineState *spapr, void *fdt)
|
|||||||
if (!nodes[i].node_mem) {
|
if (!nodes[i].node_mem) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mem_start >= ram_size) {
|
if (mem_start >= machine->ram_size) {
|
||||||
node_size = 0;
|
node_size = 0;
|
||||||
} else {
|
} else {
|
||||||
node_size = nodes[i].node_mem;
|
node_size = nodes[i].node_mem;
|
||||||
if (node_size > ram_size - mem_start) {
|
if (node_size > machine->ram_size - mem_start) {
|
||||||
node_size = ram_size - mem_start;
|
node_size = machine->ram_size - mem_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!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)
|
static void ppc_spapr_init(MachineState *machine)
|
||||||
{
|
{
|
||||||
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
|
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
|
||||||
ram_addr_t ram_size = machine->ram_size;
|
|
||||||
const char *cpu_model = machine->cpu_model;
|
const char *cpu_model = machine->cpu_model;
|
||||||
const char *kernel_filename = machine->kernel_filename;
|
const char *kernel_filename = machine->kernel_filename;
|
||||||
const char *kernel_cmdline = machine->kernel_cmdline;
|
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. */
|
* more than needed for the Linux guests we support. */
|
||||||
spapr->htab_shift = 18; /* Minimum architected size */
|
spapr->htab_shift = 18; /* Minimum architected size */
|
||||||
while (spapr->htab_shift <= 46) {
|
while (spapr->htab_shift <= 46) {
|
||||||
if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {
|
if ((1ULL << (spapr->htab_shift + 7)) >= machine->ram_size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spapr->htab_shift++;
|
spapr->htab_shift++;
|
||||||
@ -1497,9 +1500,8 @@ static void ppc_spapr_init(MachineState *machine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate RAM */
|
/* allocate RAM */
|
||||||
spapr->ram_limit = ram_size;
|
|
||||||
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
|
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
|
||||||
spapr->ram_limit);
|
machine->ram_size);
|
||||||
memory_region_add_subregion(sysmem, 0, ram);
|
memory_region_add_subregion(sysmem, 0, ram);
|
||||||
|
|
||||||
if (rma_alloc_size && rma) {
|
if (rma_alloc_size && rma) {
|
||||||
|
@ -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,
|
static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr,
|
||||||
target_ulong opcode, target_ulong *args)
|
target_ulong opcode, target_ulong *args)
|
||||||
{
|
{
|
||||||
|
MachineState *machine = MACHINE(spapr);
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
target_ulong flags = args[0];
|
target_ulong flags = args[0];
|
||||||
target_ulong pte_index = args[1];
|
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);
|
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 */
|
/* Regular RAM - should have WIMG=0010 */
|
||||||
if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) {
|
if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) {
|
||||||
return H_PARAMETER;
|
return H_PARAMETER;
|
||||||
|
@ -33,7 +33,6 @@ struct sPAPRMachineState {
|
|||||||
XICSState *icp;
|
XICSState *icp;
|
||||||
DeviceState *rtc;
|
DeviceState *rtc;
|
||||||
|
|
||||||
hwaddr ram_limit;
|
|
||||||
void *htab;
|
void *htab;
|
||||||
uint32_t htab_shift;
|
uint32_t htab_shift;
|
||||||
hwaddr rma_size;
|
hwaddr rma_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user