mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
ppc patch queue 2021-07-09
Here's a (probably) final pull request before the qemu-6.1 soft freeze. Includes: * Implementation of the new H_RPT_INVALIDATE hypercall * Virtual Open Firmware for pSeries and pegasos2 machine types. This is an experimental minimal Open Firmware implementation which works by delegating nearly everything to qemu itself via a special hypercall. * A number of cleanups to the ppc soft MMU code * Fix to handling of two-level radix mode translations for the powernv machine type * Update the H_GET_CPU_CHARACTERISTICS call with newly defined bits. This will allow more flexible handling of possible future CPU Spectre-like flaws * Correctly treat mtmsrd as an illegal instruction on BookE cpus * Firmware update for the ppce500 machine type -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmDn27oACgkQbDjKyiDZ s5I3eRAA2q76JMP1wH/orAS4gwgJVKxpdQ8F29xgtUnmL1w5RlVs2E0gXSEHYdt2 8rwmxtaz2iCzvc3hv6jZMjFz6A+otrEPFUqlE030mruxQDj2JXFnNLQP2dir3ZPg Nn0K2U+ChSr2MXjSyUzbB0vQJSVyLxFmR43MsyCbeHSxq2kfSuZ2dNfclzUJ0IXD 8QtCnjZrnOLHtaJ2Vkr/11Yb7rFmbDVZkA1c/ljE3NHGiYjWyZBgSG/Mk/SLeEZe 7wVblUFKZtuiqGCyg2BBAnoWJXPDzDO/ZHFsn5NeUf2d5KTgoeKO3MYfVKQLv3d2 W8JdI09S1OL6g1XEMWvm80S8NPCi0YxUGBXCJaKnuofiU+qwzBMUoj7Xk/2gheT3 uWZCSATUWiKLmOzksR4PbKmHCG9J1EiEMLma7IoNuVw6+pLwMgurM3hlYZtrXGSh 35oBsUT5fMkAM3BtkKh/ZKOfvKfgb1M5FmickI9O0L9BXbzPrmXre5fENhI0ROVs JeKNPjk/QUG1ftEMqpoYms+JR1rUiUN+jQBh+sFfJTi3CJFAbomoPitV6iGGPWZR sbDCRqkOyqZ9fR3hEXHzO+ThhwoI2xJPIs6+3/8XbVnFd74siqxOornWJZPpKjcf CSuOL2n81KJab8h/ERnb9QmJJWb9IJGv6YgZ5E4EFARDWvdSE3c= =9cX3 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210709' into staging ppc patch queue 2021-07-09 Here's a (probably) final pull request before the qemu-6.1 soft freeze. Includes: * Implementation of the new H_RPT_INVALIDATE hypercall * Virtual Open Firmware for pSeries and pegasos2 machine types. This is an experimental minimal Open Firmware implementation which works by delegating nearly everything to qemu itself via a special hypercall. * A number of cleanups to the ppc soft MMU code * Fix to handling of two-level radix mode translations for the powernv machine type * Update the H_GET_CPU_CHARACTERISTICS call with newly defined bits. This will allow more flexible handling of possible future CPU Spectre-like flaws * Correctly treat mtmsrd as an illegal instruction on BookE cpus * Firmware update for the ppce500 machine type # gpg: Signature made Fri 09 Jul 2021 06:16:42 BST # gpg: using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392 # gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" [full] # gpg: aka "David Gibson (Red Hat) <dgibson@redhat.com>" [full] # gpg: aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" [full] # gpg: aka "David Gibson (kernel.org) <dwg@kernel.org>" [unknown] # Primary key fingerprint: 75F4 6586 AE61 A66C C44E 87DC 6C38 CACA 20D9 B392 * remotes/dg-gitlab/tags/ppc-for-6.1-20210709: (33 commits) target/ppc: Support for H_RPT_INVALIDATE hcall linux-headers: Update spapr: Fix implementation of Open Firmware client interface target/ppc: Don't compile ppc_tlb_invalid_all without TCG ppc/pegasos2: Implement some RTAS functions with VOF ppc/pegasos2: Fix use of && instead of & ppc/pegasos2: Use Virtual Open Firmware as firmware replacement target/ppc/spapr: Update H_GET_CPU_CHARACTERISTICS L1D cache flush bits target/ppc: Allow virtual hypervisor on CPU without HV ppc/pegasos2: Introduce Pegasos2MachineState structure target/ppc: mtmsrd is an illegal instruction on BookE spapr: Implement Open Firmware client interface docs/system: ppc: Update ppce500 documentation with eTSEC support roms/u-boot: Bump ppce500 u-boot to v2021.07 to add eTSEC support target/ppc: change ppc_hash32_xlate to use mmu_idx target/ppc: introduce mmu-books.h target/ppc: changed ppc_hash64_xlate to use mmu_idx target/ppc: fix address translation bug for radix mmus target/ppc: Fix compilation with DEBUG_BATS debug option target/ppc: Fix compilation with FLUSH_ALL_TLBS debug option ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
fc32b91a88
70 changed files with 3257 additions and 604 deletions
|
@ -13,6 +13,7 @@ config PSERIES
|
|||
select MSI_NONBROKEN
|
||||
select FDT_PPC
|
||||
select CHRP_NVRAM
|
||||
select VOF
|
||||
|
||||
config SPAPR_RNG
|
||||
bool
|
||||
|
@ -75,6 +76,7 @@ config PEGASOS2
|
|||
select VT82C686
|
||||
select IDE_VIA
|
||||
select SMBUS_EEPROM
|
||||
select VOF
|
||||
# This should come with VT82C686
|
||||
select ACPI_X86
|
||||
|
||||
|
@ -144,3 +146,6 @@ config FW_CFG_PPC
|
|||
|
||||
config FDT_PPC
|
||||
bool
|
||||
|
||||
config VOF
|
||||
bool
|
||||
|
|
|
@ -84,4 +84,7 @@ ppc_ss.add(when: 'CONFIG_VIRTEX', if_true: files('virtex_ml507.c'))
|
|||
# Pegasos2
|
||||
ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c'))
|
||||
|
||||
ppc_ss.add(when: 'CONFIG_VOF', if_true: files('vof.c'))
|
||||
ppc_ss.add(when: ['CONFIG_VOF', 'CONFIG_PSERIES'], if_true: files('spapr_vof.c'))
|
||||
|
||||
hw_arch += {'ppc': ppc_ss}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* QEMU PowerPC CHRP (Genesi/bPlan Pegasos II) hardware System Emulator
|
||||
*
|
||||
* Copyright (c) 2018-2020 BALATON Zoltan
|
||||
* Copyright (c) 2018-2021 BALATON Zoltan
|
||||
*
|
||||
* This work is licensed under the GNU GPL license version 2 or later.
|
||||
*
|
||||
|
@ -34,26 +34,68 @@
|
|||
#include "trace.h"
|
||||
#include "qemu/datadir.h"
|
||||
#include "sysemu/device_tree.h"
|
||||
#include "hw/ppc/vof.h"
|
||||
|
||||
#define PROM_FILENAME "pegasos2.rom"
|
||||
#include <libfdt.h>
|
||||
|
||||
#define PROM_FILENAME "vof.bin"
|
||||
#define PROM_ADDR 0xfff00000
|
||||
#define PROM_SIZE 0x80000
|
||||
|
||||
#define KVMPPC_HCALL_BASE 0xf000
|
||||
#define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
|
||||
#define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5)
|
||||
|
||||
#define H_SUCCESS 0
|
||||
#define H_PRIVILEGE -3 /* Caller not privileged */
|
||||
#define H_PARAMETER -4 /* Parameter invalid, out-of-range or conflicting */
|
||||
|
||||
#define BUS_FREQ_HZ 133333333
|
||||
|
||||
#define PCI0_MEM_BASE 0xc0000000
|
||||
#define PCI0_MEM_SIZE 0x20000000
|
||||
#define PCI0_IO_BASE 0xf8000000
|
||||
#define PCI0_IO_SIZE 0x10000
|
||||
|
||||
#define PCI1_MEM_BASE 0x80000000
|
||||
#define PCI1_MEM_SIZE 0x40000000
|
||||
#define PCI1_IO_BASE 0xfe000000
|
||||
#define PCI1_IO_SIZE 0x10000
|
||||
|
||||
#define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2")
|
||||
OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)
|
||||
|
||||
struct Pegasos2MachineState {
|
||||
MachineState parent_obj;
|
||||
PowerPCCPU *cpu;
|
||||
DeviceState *mv;
|
||||
Vof *vof;
|
||||
void *fdt_blob;
|
||||
uint64_t kernel_addr;
|
||||
uint64_t kernel_entry;
|
||||
uint64_t kernel_size;
|
||||
};
|
||||
|
||||
static void *build_fdt(MachineState *machine, int *fdt_size);
|
||||
|
||||
static void pegasos2_cpu_reset(void *opaque)
|
||||
{
|
||||
PowerPCCPU *cpu = opaque;
|
||||
Pegasos2MachineState *pm = PEGASOS2_MACHINE(current_machine);
|
||||
|
||||
cpu_reset(CPU(cpu));
|
||||
cpu->env.spr[SPR_HID1] = 7ULL << 28;
|
||||
if (pm->vof) {
|
||||
cpu->env.gpr[1] = 2 * VOF_STACK_SIZE - 0x20;
|
||||
cpu->env.nip = 0x100;
|
||||
}
|
||||
}
|
||||
|
||||
static void pegasos2_init(MachineState *machine)
|
||||
{
|
||||
PowerPCCPU *cpu = NULL;
|
||||
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
|
||||
CPUPPCState *env;
|
||||
MemoryRegion *rom = g_new(MemoryRegion, 1);
|
||||
DeviceState *mv;
|
||||
PCIBus *pci_bus;
|
||||
PCIDevice *dev;
|
||||
I2CBus *i2c_bus;
|
||||
|
@ -63,15 +105,16 @@ static void pegasos2_init(MachineState *machine)
|
|||
uint8_t *spd_data;
|
||||
|
||||
/* init CPU */
|
||||
cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
|
||||
if (PPC_INPUT(&cpu->env) != PPC_FLAGS_INPUT_6xx) {
|
||||
pm->cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
|
||||
env = &pm->cpu->env;
|
||||
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
||||
error_report("Incompatible CPU, only 6xx bus supported");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Set time-base frequency */
|
||||
cpu_ppc_tb_init(&cpu->env, BUS_FREQ_HZ / 4);
|
||||
qemu_register_reset(pegasos2_cpu_reset, cpu);
|
||||
cpu_ppc_tb_init(env, BUS_FREQ_HZ / 4);
|
||||
qemu_register_reset(pegasos2_cpu_reset, pm->cpu);
|
||||
|
||||
/* RAM */
|
||||
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
|
||||
|
@ -82,30 +125,36 @@ static void pegasos2_init(MachineState *machine)
|
|||
error_report("Could not find firmware '%s'", fwname);
|
||||
exit(1);
|
||||
}
|
||||
if (!machine->firmware && !pm->vof) {
|
||||
pm->vof = g_malloc0(sizeof(*pm->vof));
|
||||
}
|
||||
memory_region_init_rom(rom, NULL, "pegasos2.rom", PROM_SIZE, &error_fatal);
|
||||
memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom);
|
||||
sz = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1,
|
||||
PPC_ELF_MACHINE, 0, 0);
|
||||
if (sz <= 0) {
|
||||
sz = load_image_targphys(filename, PROM_ADDR, PROM_SIZE);
|
||||
sz = load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM_SIZE);
|
||||
}
|
||||
if (sz <= 0 || sz > PROM_SIZE) {
|
||||
error_report("Could not load firmware '%s'", filename);
|
||||
exit(1);
|
||||
}
|
||||
g_free(filename);
|
||||
if (pm->vof) {
|
||||
pm->vof->fw_size = sz;
|
||||
}
|
||||
|
||||
/* Marvell Discovery II system controller */
|
||||
mv = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
|
||||
((qemu_irq *)cpu->env.irq_inputs)[PPC6xx_INPUT_INT]));
|
||||
pci_bus = mv64361_get_pci_bus(mv, 1);
|
||||
pm->mv = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
|
||||
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]));
|
||||
pci_bus = mv64361_get_pci_bus(pm->mv, 1);
|
||||
|
||||
/* VIA VT8231 South Bridge (multifunction PCI device) */
|
||||
/* VT8231 function 0: PCI-to-ISA Bridge */
|
||||
dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true,
|
||||
TYPE_VT8231_ISA);
|
||||
qdev_connect_gpio_out(DEVICE(dev), 0,
|
||||
qdev_get_gpio_in_named(mv, "gpp", 31));
|
||||
qdev_get_gpio_in_named(pm->mv, "gpp", 31));
|
||||
|
||||
/* VT8231 function 1: IDE Controller */
|
||||
dev = pci_create_simple(pci_bus, PCI_DEVFN(12, 1), "via-ide");
|
||||
|
@ -127,18 +176,728 @@ static void pegasos2_init(MachineState *machine)
|
|||
|
||||
/* other PC hardware */
|
||||
pci_vga_init(pci_bus);
|
||||
|
||||
if (machine->kernel_filename) {
|
||||
sz = load_elf(machine->kernel_filename, NULL, NULL, NULL,
|
||||
&pm->kernel_entry, &pm->kernel_addr, NULL, NULL, 1,
|
||||
PPC_ELF_MACHINE, 0, 0);
|
||||
if (sz <= 0) {
|
||||
error_report("Could not load kernel '%s'",
|
||||
machine->kernel_filename);
|
||||
exit(1);
|
||||
}
|
||||
pm->kernel_size = sz;
|
||||
if (!pm->vof) {
|
||||
warn_report("Option -kernel may be ineffective with -bios.");
|
||||
}
|
||||
}
|
||||
if (machine->kernel_cmdline && !pm->vof) {
|
||||
warn_report("Option -append may be ineffective with -bios.");
|
||||
}
|
||||
}
|
||||
|
||||
static void pegasos2_machine(MachineClass *mc)
|
||||
static uint32_t pegasos2_pci_config_read(AddressSpace *as, int bus,
|
||||
uint32_t addr, uint32_t len)
|
||||
{
|
||||
hwaddr pcicfg = (bus ? 0xf1000c78 : 0xf1000cf8);
|
||||
uint32_t val = 0xffffffff;
|
||||
|
||||
stl_le_phys(as, pcicfg, addr | BIT(31));
|
||||
switch (len) {
|
||||
case 4:
|
||||
val = ldl_le_phys(as, pcicfg + 4);
|
||||
break;
|
||||
case 2:
|
||||
val = lduw_le_phys(as, pcicfg + 4);
|
||||
break;
|
||||
case 1:
|
||||
val = ldub_phys(as, pcicfg + 4);
|
||||
break;
|
||||
default:
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid length\n", __func__);
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static void pegasos2_pci_config_write(AddressSpace *as, int bus, uint32_t addr,
|
||||
uint32_t len, uint32_t val)
|
||||
{
|
||||
hwaddr pcicfg = (bus ? 0xf1000c78 : 0xf1000cf8);
|
||||
|
||||
stl_le_phys(as, pcicfg, addr | BIT(31));
|
||||
switch (len) {
|
||||
case 4:
|
||||
stl_le_phys(as, pcicfg + 4, val);
|
||||
break;
|
||||
case 2:
|
||||
stw_le_phys(as, pcicfg + 4, val);
|
||||
break;
|
||||
case 1:
|
||||
stb_phys(as, pcicfg + 4, val);
|
||||
break;
|
||||
default:
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid length\n", __func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pegasos2_machine_reset(MachineState *machine)
|
||||
{
|
||||
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
|
||||
AddressSpace *as = CPU(pm->cpu)->as;
|
||||
void *fdt;
|
||||
uint64_t d[2];
|
||||
int sz;
|
||||
|
||||
qemu_devices_reset();
|
||||
if (!pm->vof) {
|
||||
return; /* Firmware should set up machine so nothing to do */
|
||||
}
|
||||
|
||||
/* Otherwise, set up devices that board firmware would normally do */
|
||||
stl_le_phys(as, 0xf1000000, 0x28020ff);
|
||||
stl_le_phys(as, 0xf1000278, 0xa31fc);
|
||||
stl_le_phys(as, 0xf100f300, 0x11ff0400);
|
||||
stl_le_phys(as, 0xf100f10c, 0x80000000);
|
||||
stl_le_phys(as, 0xf100001c, 0x8000000);
|
||||
pegasos2_pci_config_write(as, 0, PCI_COMMAND, 2, PCI_COMMAND_IO |
|
||||
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
|
||||
pegasos2_pci_config_write(as, 1, PCI_COMMAND, 2, PCI_COMMAND_IO |
|
||||
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 0) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x9);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 0) << 8) |
|
||||
0x50, 1, 0x2);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 1) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x109);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 1) << 8) |
|
||||
PCI_CLASS_PROG, 1, 0xf);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 1) << 8) |
|
||||
0x40, 1, 0xb);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 1) << 8) |
|
||||
0x50, 4, 0x17171717);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 1) << 8) |
|
||||
PCI_COMMAND, 2, 0x87);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 2) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x409);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 3) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x409);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 4) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x9);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 4) << 8) |
|
||||
0x48, 4, 0xf00);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 4) << 8) |
|
||||
0x40, 4, 0x558020);
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 4) << 8) |
|
||||
0x90, 4, 0xd00);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 5) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x309);
|
||||
|
||||
pegasos2_pci_config_write(as, 1, (PCI_DEVFN(12, 6) << 8) |
|
||||
PCI_INTERRUPT_LINE, 2, 0x309);
|
||||
|
||||
/* Device tree and VOF set up */
|
||||
vof_init(pm->vof, machine->ram_size, &error_fatal);
|
||||
if (vof_claim(pm->vof, 0, VOF_STACK_SIZE, VOF_STACK_SIZE) == -1) {
|
||||
error_report("Memory allocation for stack failed");
|
||||
exit(1);
|
||||
}
|
||||
if (pm->kernel_size &&
|
||||
vof_claim(pm->vof, pm->kernel_addr, pm->kernel_size, 0) == -1) {
|
||||
error_report("Memory for kernel is in use");
|
||||
exit(1);
|
||||
}
|
||||
fdt = build_fdt(machine, &sz);
|
||||
/* FIXME: VOF assumes entry is same as load address */
|
||||
d[0] = cpu_to_be64(pm->kernel_entry);
|
||||
d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr));
|
||||
qemu_fdt_setprop(fdt, "/chosen", "qemu,boot-kernel", d, sizeof(d));
|
||||
|
||||
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
|
||||
g_free(pm->fdt_blob);
|
||||
pm->fdt_blob = fdt;
|
||||
|
||||
vof_build_dt(fdt, pm->vof);
|
||||
vof_client_open_store(fdt, pm->vof, "/chosen", "stdout", "/failsafe");
|
||||
pm->cpu->vhyp = PPC_VIRTUAL_HYPERVISOR(machine);
|
||||
}
|
||||
|
||||
enum pegasos2_rtas_tokens {
|
||||
RTAS_RESTART_RTAS = 0,
|
||||
RTAS_NVRAM_FETCH = 1,
|
||||
RTAS_NVRAM_STORE = 2,
|
||||
RTAS_GET_TIME_OF_DAY = 3,
|
||||
RTAS_SET_TIME_OF_DAY = 4,
|
||||
RTAS_EVENT_SCAN = 6,
|
||||
RTAS_CHECK_EXCEPTION = 7,
|
||||
RTAS_READ_PCI_CONFIG = 8,
|
||||
RTAS_WRITE_PCI_CONFIG = 9,
|
||||
RTAS_DISPLAY_CHARACTER = 10,
|
||||
RTAS_SET_INDICATOR = 11,
|
||||
RTAS_POWER_OFF = 17,
|
||||
RTAS_SUSPEND = 18,
|
||||
RTAS_HIBERNATE = 19,
|
||||
RTAS_SYSTEM_REBOOT = 20,
|
||||
};
|
||||
|
||||
static target_ulong pegasos2_rtas(PowerPCCPU *cpu, Pegasos2MachineState *pm,
|
||||
target_ulong args_real)
|
||||
{
|
||||
AddressSpace *as = CPU(cpu)->as;
|
||||
uint32_t token = ldl_be_phys(as, args_real);
|
||||
uint32_t nargs = ldl_be_phys(as, args_real + 4);
|
||||
uint32_t nrets = ldl_be_phys(as, args_real + 8);
|
||||
uint32_t args = args_real + 12;
|
||||
uint32_t rets = args_real + 12 + nargs * 4;
|
||||
|
||||
if (nrets < 1) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "Too few return values in RTAS call\n");
|
||||
return H_PARAMETER;
|
||||
}
|
||||
switch (token) {
|
||||
case RTAS_READ_PCI_CONFIG:
|
||||
{
|
||||
uint32_t addr, len, val;
|
||||
|
||||
if (nargs != 2 || nrets != 2) {
|
||||
stl_be_phys(as, rets, -1);
|
||||
return H_PARAMETER;
|
||||
}
|
||||
addr = ldl_be_phys(as, args);
|
||||
len = ldl_be_phys(as, args + 4);
|
||||
val = pegasos2_pci_config_read(as, !(addr >> 24),
|
||||
addr & 0x0fffffff, len);
|
||||
stl_be_phys(as, rets, 0);
|
||||
stl_be_phys(as, rets + 4, val);
|
||||
return H_SUCCESS;
|
||||
}
|
||||
case RTAS_WRITE_PCI_CONFIG:
|
||||
{
|
||||
uint32_t addr, len, val;
|
||||
|
||||
if (nargs != 3 || nrets != 1) {
|
||||
stl_be_phys(as, rets, -1);
|
||||
return H_PARAMETER;
|
||||
}
|
||||
addr = ldl_be_phys(as, args);
|
||||
len = ldl_be_phys(as, args + 4);
|
||||
val = ldl_be_phys(as, args + 8);
|
||||
pegasos2_pci_config_write(as, !(addr >> 24),
|
||||
addr & 0x0fffffff, len, val);
|
||||
stl_be_phys(as, rets, 0);
|
||||
return H_SUCCESS;
|
||||
}
|
||||
case RTAS_DISPLAY_CHARACTER:
|
||||
if (nargs != 1 || nrets != 1) {
|
||||
stl_be_phys(as, rets, -1);
|
||||
return H_PARAMETER;
|
||||
}
|
||||
qemu_log_mask(LOG_UNIMP, "%c", ldl_be_phys(as, args));
|
||||
stl_be_phys(as, rets, 0);
|
||||
return H_SUCCESS;
|
||||
default:
|
||||
qemu_log_mask(LOG_UNIMP, "Unknown RTAS token %u (args=%u, rets=%u)\n",
|
||||
token, nargs, nrets);
|
||||
stl_be_phys(as, rets, 0);
|
||||
return H_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
|
||||
{
|
||||
Pegasos2MachineState *pm = PEGASOS2_MACHINE(vhyp);
|
||||
CPUPPCState *env = &cpu->env;
|
||||
|
||||
/* The TCG path should also be holding the BQL at this point */
|
||||
g_assert(qemu_mutex_iothread_locked());
|
||||
|
||||
if (msr_pr) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=1\n");
|
||||
env->gpr[3] = H_PRIVILEGE;
|
||||
} else if (env->gpr[3] == KVMPPC_H_RTAS) {
|
||||
env->gpr[3] = pegasos2_rtas(cpu, pm, env->gpr[4]);
|
||||
} else if (env->gpr[3] == KVMPPC_H_VOF_CLIENT) {
|
||||
int ret = vof_client_call(MACHINE(pm), pm->vof, pm->fdt_blob,
|
||||
env->gpr[4]);
|
||||
env->gpr[3] = (ret ? H_PARAMETER : H_SUCCESS);
|
||||
} else {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "Unsupported hypercall " TARGET_FMT_lx
|
||||
"\n", env->gpr[3]);
|
||||
env->gpr[3] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void vhyp_nop(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
static target_ulong vhyp_encode_hpt_for_kvm_pr(PPCVirtualHypervisor *vhyp)
|
||||
{
|
||||
return POWERPC_CPU(current_cpu)->env.spr[SPR_SDR1];
|
||||
}
|
||||
|
||||
static void pegasos2_machine_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
MachineClass *mc = MACHINE_CLASS(oc);
|
||||
PPCVirtualHypervisorClass *vhc = PPC_VIRTUAL_HYPERVISOR_CLASS(oc);
|
||||
|
||||
mc->desc = "Genesi/bPlan Pegasos II";
|
||||
mc->init = pegasos2_init;
|
||||
mc->reset = pegasos2_machine_reset;
|
||||
mc->block_default_type = IF_IDE;
|
||||
mc->default_boot_order = "cd";
|
||||
mc->default_display = "std";
|
||||
mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7400_v2.9");
|
||||
mc->default_ram_id = "pegasos2.ram";
|
||||
mc->default_ram_size = 512 * MiB;
|
||||
|
||||
vhc->hypercall = pegasos2_hypercall;
|
||||
vhc->cpu_exec_enter = vhyp_nop;
|
||||
vhc->cpu_exec_exit = vhyp_nop;
|
||||
vhc->encode_hpt_for_kvm_pr = vhyp_encode_hpt_for_kvm_pr;
|
||||
}
|
||||
|
||||
DEFINE_MACHINE("pegasos2", pegasos2_machine)
|
||||
static const TypeInfo pegasos2_machine_info = {
|
||||
.name = TYPE_PEGASOS2_MACHINE,
|
||||
.parent = TYPE_MACHINE,
|
||||
.class_init = pegasos2_machine_class_init,
|
||||
.instance_size = sizeof(Pegasos2MachineState),
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ TYPE_PPC_VIRTUAL_HYPERVISOR },
|
||||
{ }
|
||||
},
|
||||
};
|
||||
|
||||
static void pegasos2_machine_register_types(void)
|
||||
{
|
||||
type_register_static(&pegasos2_machine_info);
|
||||
}
|
||||
|
||||
type_init(pegasos2_machine_register_types)
|
||||
|
||||
/* FDT creation for passing to firmware */
|
||||
|
||||
typedef struct {
|
||||
void *fdt;
|
||||
const char *path;
|
||||
} FDTInfo;
|
||||
|
||||
/* We do everything in reverse order so it comes out right in the tree */
|
||||
|
||||
static void dt_ide(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
|
||||
{
|
||||
qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "spi");
|
||||
}
|
||||
|
||||
static void dt_usb(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
|
||||
{
|
||||
qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 0);
|
||||
qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 1);
|
||||
qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "usb");
|
||||
}
|
||||
|
||||
static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
|
||||
{
|
||||
GString *name = g_string_sized_new(64);
|
||||
uint32_t cells[3];
|
||||
|
||||
qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 1);
|
||||
qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 2);
|
||||
qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "isa");
|
||||
qemu_fdt_setprop_string(fi->fdt, fi->path, "name", "isa");
|
||||
|
||||
/* addional devices */
|
||||
g_string_printf(name, "%s/lpt@i3bc", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(7);
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x3bc);
|
||||
cells[2] = cpu_to_be32(8);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "lpt");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "lpt");
|
||||
|
||||
g_string_printf(name, "%s/fdc@i3f0", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(6);
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x3f0);
|
||||
cells[2] = cpu_to_be32(8);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "fdc");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "fdc");
|
||||
|
||||
g_string_printf(name, "%s/timer@i40", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x40);
|
||||
cells[2] = cpu_to_be32(8);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "timer");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "timer");
|
||||
|
||||
g_string_printf(name, "%s/rtc@i70", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "compatible", "ds1385-rtc");
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(8);
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x70);
|
||||
cells[2] = cpu_to_be32(2);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "rtc");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "rtc");
|
||||
|
||||
g_string_printf(name, "%s/keyboard@i60", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x60);
|
||||
cells[2] = cpu_to_be32(5);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "keyboard");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "keyboard");
|
||||
|
||||
g_string_printf(name, "%s/8042@i60", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "#interrupt-cells", 2);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "#size-cells", 0);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "#address-cells", 1);
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "interrupt-controller", "");
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x60);
|
||||
cells[2] = cpu_to_be32(5);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "8042");
|
||||
|
||||
g_string_printf(name, "%s/serial@i2f8", fi->path);
|
||||
qemu_fdt_add_subnode(fi->fdt, name->str);
|
||||
qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
|
||||
cells[0] = cpu_to_be32(3);
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(1);
|
||||
cells[1] = cpu_to_be32(0x2f8);
|
||||
cells[2] = cpu_to_be32(8);
|
||||
qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "serial");
|
||||
qemu_fdt_setprop_string(fi->fdt, name->str, "name", "serial");
|
||||
|
||||
g_string_free(name, TRUE);
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *id;
|
||||
const char *name;
|
||||
void (*dtf)(PCIBus *bus, PCIDevice *d, FDTInfo *fi);
|
||||
} device_map[] = {
|
||||
{ "pci11ab,6460", "host", NULL },
|
||||
{ "pci1106,8231", "isa", dt_isa },
|
||||
{ "pci1106,571", "ide", dt_ide },
|
||||
{ "pci1106,3044", "firewire", NULL },
|
||||
{ "pci1106,3038", "usb", dt_usb },
|
||||
{ "pci1106,8235", "other", NULL },
|
||||
{ "pci1106,3058", "sound", NULL },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
|
||||
{
|
||||
FDTInfo *fi = opaque;
|
||||
GString *node = g_string_new(NULL);
|
||||
uint32_t cells[(PCI_NUM_REGIONS + 1) * 5];
|
||||
int i, j;
|
||||
const char *name = NULL;
|
||||
g_autofree const gchar *pn = g_strdup_printf("pci%x,%x",
|
||||
pci_get_word(&d->config[PCI_VENDOR_ID]),
|
||||
pci_get_word(&d->config[PCI_DEVICE_ID]));
|
||||
|
||||
for (i = 0; device_map[i].id; i++) {
|
||||
if (!strcmp(pn, device_map[i].id)) {
|
||||
name = device_map[i].name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_string_printf(node, "%s/%s@%x", fi->path, (name ?: pn),
|
||||
PCI_SLOT(d->devfn));
|
||||
if (PCI_FUNC(d->devfn)) {
|
||||
g_string_append_printf(node, ",%x", PCI_FUNC(d->devfn));
|
||||
}
|
||||
|
||||
qemu_fdt_add_subnode(fi->fdt, node->str);
|
||||
if (device_map[i].dtf) {
|
||||
FDTInfo cfi = { fi->fdt, node->str };
|
||||
device_map[i].dtf(bus, d, &cfi);
|
||||
}
|
||||
cells[0] = cpu_to_be32(d->devfn << 8);
|
||||
cells[1] = 0;
|
||||
cells[2] = 0;
|
||||
cells[3] = 0;
|
||||
cells[4] = 0;
|
||||
j = 5;
|
||||
for (i = 0; i < PCI_NUM_REGIONS; i++) {
|
||||
if (!d->io_regions[i].size) {
|
||||
continue;
|
||||
}
|
||||
cells[j] = cpu_to_be32(d->devfn << 8 | (PCI_BASE_ADDRESS_0 + i * 4));
|
||||
if (d->io_regions[i].type & PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
cells[j] |= cpu_to_be32(1 << 24);
|
||||
} else {
|
||||
cells[j] |= cpu_to_be32(2 << 24);
|
||||
if (d->io_regions[i].type & PCI_BASE_ADDRESS_MEM_PREFETCH) {
|
||||
cells[j] |= cpu_to_be32(4 << 28);
|
||||
}
|
||||
}
|
||||
cells[j + 1] = 0;
|
||||
cells[j + 2] = 0;
|
||||
cells[j + 3] = cpu_to_be32(d->io_regions[i].size >> 32);
|
||||
cells[j + 4] = cpu_to_be32(d->io_regions[i].size);
|
||||
j += 5;
|
||||
}
|
||||
qemu_fdt_setprop(fi->fdt, node->str, "reg", cells, j * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fi->fdt, node->str, "name", name ?: pn);
|
||||
if (pci_get_byte(&d->config[PCI_INTERRUPT_PIN])) {
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "interrupts",
|
||||
pci_get_byte(&d->config[PCI_INTERRUPT_PIN]));
|
||||
}
|
||||
/* Pegasos2 firmware has subsystem-id amd subsystem-vendor-id swapped */
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "subsystem-vendor-id",
|
||||
pci_get_word(&d->config[PCI_SUBSYSTEM_ID]));
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "subsystem-id",
|
||||
pci_get_word(&d->config[PCI_SUBSYSTEM_VENDOR_ID]));
|
||||
cells[0] = pci_get_long(&d->config[PCI_CLASS_REVISION]);
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "class-code", cells[0] >> 8);
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "revision-id", cells[0] & 0xff);
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "device-id",
|
||||
pci_get_word(&d->config[PCI_DEVICE_ID]));
|
||||
qemu_fdt_setprop_cell(fi->fdt, node->str, "vendor-id",
|
||||
pci_get_word(&d->config[PCI_VENDOR_ID]));
|
||||
|
||||
g_string_free(node, TRUE);
|
||||
}
|
||||
|
||||
static void *build_fdt(MachineState *machine, int *fdt_size)
|
||||
{
|
||||
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
|
||||
PowerPCCPU *cpu = pm->cpu;
|
||||
PCIBus *pci_bus;
|
||||
FDTInfo fi;
|
||||
uint32_t cells[16];
|
||||
void *fdt = create_device_tree(fdt_size);
|
||||
|
||||
fi.fdt = fdt;
|
||||
|
||||
/* root node */
|
||||
qemu_fdt_setprop_string(fdt, "/", "CODEGEN,description",
|
||||
"Pegasos CHRP PowerPC System");
|
||||
qemu_fdt_setprop_string(fdt, "/", "CODEGEN,board", "Pegasos2");
|
||||
qemu_fdt_setprop_string(fdt, "/", "CODEGEN,vendor", "bplan GmbH");
|
||||
qemu_fdt_setprop_string(fdt, "/", "revision", "2B");
|
||||
qemu_fdt_setprop_string(fdt, "/", "model", "Pegasos2");
|
||||
qemu_fdt_setprop_string(fdt, "/", "device_type", "chrp");
|
||||
qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 1);
|
||||
qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2");
|
||||
|
||||
/* pci@c0000000 */
|
||||
qemu_fdt_add_subnode(fdt, "/pci@c0000000");
|
||||
cells[0] = 0;
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fdt, "/pci@c0000000", "bus-range",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "pci-bridge-number", 1);
|
||||
cells[0] = cpu_to_be32(PCI0_MEM_BASE);
|
||||
cells[1] = cpu_to_be32(PCI0_MEM_SIZE);
|
||||
qemu_fdt_setprop(fdt, "/pci@c0000000", "reg", cells, 2 * sizeof(cells[0]));
|
||||
cells[0] = cpu_to_be32(0x01000000);
|
||||
cells[1] = 0;
|
||||
cells[2] = 0;
|
||||
cells[3] = cpu_to_be32(PCI0_IO_BASE);
|
||||
cells[4] = 0;
|
||||
cells[5] = cpu_to_be32(PCI0_IO_SIZE);
|
||||
cells[6] = cpu_to_be32(0x02000000);
|
||||
cells[7] = 0;
|
||||
cells[8] = cpu_to_be32(PCI0_MEM_BASE);
|
||||
cells[9] = cpu_to_be32(PCI0_MEM_BASE);
|
||||
cells[10] = 0;
|
||||
cells[11] = cpu_to_be32(PCI0_MEM_SIZE);
|
||||
qemu_fdt_setprop(fdt, "/pci@c0000000", "ranges",
|
||||
cells, 12 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#size-cells", 2);
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#address-cells", 3);
|
||||
qemu_fdt_setprop_string(fdt, "/pci@c0000000", "device_type", "pci");
|
||||
qemu_fdt_setprop_string(fdt, "/pci@c0000000", "name", "pci");
|
||||
|
||||
fi.path = "/pci@c0000000";
|
||||
pci_bus = mv64361_get_pci_bus(pm->mv, 0);
|
||||
pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
|
||||
|
||||
/* pci@80000000 */
|
||||
qemu_fdt_add_subnode(fdt, "/pci@80000000");
|
||||
cells[0] = 0;
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fdt, "/pci@80000000", "bus-range",
|
||||
cells, 2 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@80000000", "pci-bridge-number", 0);
|
||||
cells[0] = cpu_to_be32(PCI1_MEM_BASE);
|
||||
cells[1] = cpu_to_be32(PCI1_MEM_SIZE);
|
||||
qemu_fdt_setprop(fdt, "/pci@80000000", "reg", cells, 2 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@80000000", "8259-interrupt-acknowledge",
|
||||
0xf1000cb4);
|
||||
cells[0] = cpu_to_be32(0x01000000);
|
||||
cells[1] = 0;
|
||||
cells[2] = 0;
|
||||
cells[3] = cpu_to_be32(PCI1_IO_BASE);
|
||||
cells[4] = 0;
|
||||
cells[5] = cpu_to_be32(PCI1_IO_SIZE);
|
||||
cells[6] = cpu_to_be32(0x02000000);
|
||||
cells[7] = 0;
|
||||
cells[8] = cpu_to_be32(PCI1_MEM_BASE);
|
||||
cells[9] = cpu_to_be32(PCI1_MEM_BASE);
|
||||
cells[10] = 0;
|
||||
cells[11] = cpu_to_be32(PCI1_MEM_SIZE);
|
||||
qemu_fdt_setprop(fdt, "/pci@80000000", "ranges",
|
||||
cells, 12 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#size-cells", 2);
|
||||
qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#address-cells", 3);
|
||||
qemu_fdt_setprop_string(fdt, "/pci@80000000", "device_type", "pci");
|
||||
qemu_fdt_setprop_string(fdt, "/pci@80000000", "name", "pci");
|
||||
|
||||
fi.path = "/pci@80000000";
|
||||
pci_bus = mv64361_get_pci_bus(pm->mv, 1);
|
||||
pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
|
||||
|
||||
qemu_fdt_add_subnode(fdt, "/failsafe");
|
||||
qemu_fdt_setprop_string(fdt, "/failsafe", "device_type", "serial");
|
||||
qemu_fdt_setprop_string(fdt, "/failsafe", "name", "failsafe");
|
||||
|
||||
qemu_fdt_add_subnode(fdt, "/rtas");
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "system-reboot", RTAS_SYSTEM_REBOOT);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "hibernate", RTAS_HIBERNATE);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "suspend", RTAS_SUSPEND);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "power-off", RTAS_POWER_OFF);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "set-indicator", RTAS_SET_INDICATOR);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "display-character",
|
||||
RTAS_DISPLAY_CHARACTER);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "write-pci-config",
|
||||
RTAS_WRITE_PCI_CONFIG);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "read-pci-config",
|
||||
RTAS_READ_PCI_CONFIG);
|
||||
/* Pegasos2 firmware misspells check-exception and guests use that */
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "check-execption",
|
||||
RTAS_CHECK_EXCEPTION);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "event-scan", RTAS_EVENT_SCAN);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "set-time-of-day",
|
||||
RTAS_SET_TIME_OF_DAY);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "get-time-of-day",
|
||||
RTAS_GET_TIME_OF_DAY);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-store", RTAS_NVRAM_STORE);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-fetch", RTAS_NVRAM_FETCH);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "restart-rtas", RTAS_RESTART_RTAS);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-error-log-max", 0);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-event-scan-rate", 0);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-display-device", 0);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", 20);
|
||||
qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-version", 1);
|
||||
|
||||
/* cpus */
|
||||
qemu_fdt_add_subnode(fdt, "/cpus");
|
||||
qemu_fdt_setprop_cell(fdt, "/cpus", "#cpus", 1);
|
||||
qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1);
|
||||
qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0);
|
||||
qemu_fdt_setprop_string(fdt, "/cpus", "name", "cpus");
|
||||
|
||||
/* FIXME Get CPU name from CPU object */
|
||||
const char *cp = "/cpus/PowerPC,G4";
|
||||
qemu_fdt_add_subnode(fdt, cp);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "l2cr", 0);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "d-cache-size", 0x8000);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "d-cache-block-size",
|
||||
cpu->env.dcache_line_size);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "d-cache-line-size",
|
||||
cpu->env.dcache_line_size);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "i-cache-size", 0x8000);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "i-cache-block-size",
|
||||
cpu->env.icache_line_size);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "i-cache-line-size",
|
||||
cpu->env.icache_line_size);
|
||||
if (cpu->env.id_tlbs) {
|
||||
qemu_fdt_setprop_cell(fdt, cp, "i-tlb-sets", cpu->env.nb_ways);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "i-tlb-size", cpu->env.tlb_per_way);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "d-tlb-sets", cpu->env.nb_ways);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "d-tlb-size", cpu->env.tlb_per_way);
|
||||
qemu_fdt_setprop_string(fdt, cp, "tlb-split", "");
|
||||
}
|
||||
qemu_fdt_setprop_cell(fdt, cp, "tlb-sets", cpu->env.nb_ways);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "tlb-size", cpu->env.nb_tlb);
|
||||
qemu_fdt_setprop_string(fdt, cp, "state", "running");
|
||||
if (cpu->env.insns_flags & PPC_ALTIVEC) {
|
||||
qemu_fdt_setprop_string(fdt, cp, "altivec", "");
|
||||
qemu_fdt_setprop_string(fdt, cp, "data-streams", "");
|
||||
}
|
||||
/*
|
||||
* FIXME What flags do data-streams, external-control and
|
||||
* performance-monitor depend on?
|
||||
*/
|
||||
qemu_fdt_setprop_string(fdt, cp, "external-control", "");
|
||||
if (cpu->env.insns_flags & PPC_FLOAT_FSQRT) {
|
||||
qemu_fdt_setprop_string(fdt, cp, "general-purpose", "");
|
||||
}
|
||||
qemu_fdt_setprop_string(fdt, cp, "performance-monitor", "");
|
||||
if (cpu->env.insns_flags & PPC_FLOAT_FRES) {
|
||||
qemu_fdt_setprop_string(fdt, cp, "graphics", "");
|
||||
}
|
||||
qemu_fdt_setprop_cell(fdt, cp, "reservation-granule-size", 4);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "timebase-frequency",
|
||||
cpu->env.tb_env->tb_freq);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", BUS_FREQ_HZ);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", BUS_FREQ_HZ * 7.5);
|
||||
qemu_fdt_setprop_cell(fdt, cp, "cpu-version", cpu->env.spr[SPR_PVR]);
|
||||
cells[0] = 0;
|
||||
cells[1] = 0;
|
||||
qemu_fdt_setprop(fdt, cp, "reg", cells, 2 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fdt, cp, "device_type", "cpu");
|
||||
qemu_fdt_setprop_string(fdt, cp, "name", strrchr(cp, '/') + 1);
|
||||
|
||||
/* memory */
|
||||
qemu_fdt_add_subnode(fdt, "/memory@0");
|
||||
cells[0] = 0;
|
||||
cells[1] = cpu_to_be32(machine->ram_size);
|
||||
qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0]));
|
||||
qemu_fdt_setprop_string(fdt, "/memory@0", "device_type", "memory");
|
||||
qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
|
||||
|
||||
qemu_fdt_add_subnode(fdt, "/chosen");
|
||||
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
|
||||
machine->kernel_cmdline ?: "");
|
||||
qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
|
||||
|
||||
qemu_fdt_add_subnode(fdt, "/openprom");
|
||||
qemu_fdt_setprop_string(fdt, "/openprom", "model", "Pegasos2,1.1");
|
||||
|
||||
return fdt;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#define FDT_MAX_ADDR 0x80000000 /* FDT must stay below that */
|
||||
#define FW_MAX_SIZE 0x400000
|
||||
#define FW_FILE_NAME "slof.bin"
|
||||
#define FW_FILE_NAME_VOF "vof.bin"
|
||||
#define FW_OVERHEAD 0x2800000
|
||||
#define KERNEL_LOAD_ADDR FW_MAX_SIZE
|
||||
|
||||
|
@ -880,6 +881,10 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)
|
|||
add_str(hypertas, "hcall-copy");
|
||||
add_str(hypertas, "hcall-debug");
|
||||
add_str(hypertas, "hcall-vphn");
|
||||
if (spapr_get_cap(spapr, SPAPR_CAP_RPT_INVALIDATE) == SPAPR_CAP_ON) {
|
||||
add_str(hypertas, "hcall-rpt-invalidate");
|
||||
}
|
||||
|
||||
add_str(qemu_hypertas, "hcall-memop1");
|
||||
|
||||
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
|
||||
|
@ -919,9 +924,13 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)
|
|||
*
|
||||
* The extra 8 bytes is required because Linux's FWNMI error log check
|
||||
* is off-by-one.
|
||||
*
|
||||
* RTAS_MIN_SIZE is required for the RTAS blob itself.
|
||||
*/
|
||||
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-size", RTAS_ERROR_LOG_MAX +
|
||||
ms->smp.max_cpus * sizeof(uint64_t)*2 + sizeof(uint64_t)));
|
||||
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-size", RTAS_MIN_SIZE +
|
||||
RTAS_ERROR_LOG_MAX +
|
||||
ms->smp.max_cpus * sizeof(uint64_t) * 2 +
|
||||
sizeof(uint64_t)));
|
||||
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-error-log-max",
|
||||
RTAS_ERROR_LOG_MAX));
|
||||
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate",
|
||||
|
@ -1639,22 +1648,29 @@ static void spapr_machine_reset(MachineState *machine)
|
|||
fdt_addr = MIN(spapr->rma_size, FDT_MAX_ADDR) - FDT_MAX_SIZE;
|
||||
|
||||
fdt = spapr_build_fdt(spapr, true, FDT_MAX_SIZE);
|
||||
if (spapr->vof) {
|
||||
spapr_vof_reset(spapr, fdt, &error_fatal);
|
||||
/*
|
||||
* Do not pack the FDT as the client may change properties.
|
||||
* VOF client does not expect the FDT so we do not load it to the VM.
|
||||
*/
|
||||
} else {
|
||||
rc = fdt_pack(fdt);
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
assert(rc == 0);
|
||||
|
||||
rc = fdt_pack(fdt);
|
||||
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
assert(rc == 0);
|
||||
|
||||
/* Load the fdt */
|
||||
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT,
|
||||
0, fdt_addr, 0);
|
||||
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
|
||||
}
|
||||
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
|
||||
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
|
||||
|
||||
g_free(spapr->fdt_blob);
|
||||
spapr->fdt_size = fdt_totalsize(fdt);
|
||||
spapr->fdt_initial_size = spapr->fdt_size;
|
||||
spapr->fdt_blob = fdt;
|
||||
|
||||
/* Set up the entry state */
|
||||
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, 0, fdt_addr, 0);
|
||||
first_ppc_cpu->env.gpr[5] = 0;
|
||||
|
||||
spapr->fwnmi_system_reset_addr = -1;
|
||||
|
@ -2018,6 +2034,7 @@ static const VMStateDescription vmstate_spapr = {
|
|||
&vmstate_spapr_cap_ccf_assist,
|
||||
&vmstate_spapr_cap_fwnmi,
|
||||
&vmstate_spapr_fwnmi,
|
||||
&vmstate_spapr_cap_rpt_invalidate,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
@ -2657,7 +2674,8 @@ static void spapr_machine_init(MachineState *machine)
|
|||
SpaprMachineState *spapr = SPAPR_MACHINE(machine);
|
||||
SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
|
||||
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
||||
const char *bios_name = machine->firmware ?: FW_FILE_NAME;
|
||||
const char *bios_default = spapr->vof ? FW_FILE_NAME_VOF : FW_FILE_NAME;
|
||||
const char *bios_name = machine->firmware ?: bios_default;
|
||||
const char *kernel_filename = machine->kernel_filename;
|
||||
const char *initrd_filename = machine->initrd_filename;
|
||||
PCIHostState *phb;
|
||||
|
@ -3014,6 +3032,10 @@ static void spapr_machine_init(MachineState *machine)
|
|||
}
|
||||
|
||||
qemu_cond_init(&spapr->fwnmi_machine_check_interlock_cond);
|
||||
if (spapr->vof) {
|
||||
spapr->vof->fw_size = fw_size; /* for claim() on itself */
|
||||
spapr_register_hypercall(KVMPPC_H_VOF_CLIENT, spapr_h_vof_client);
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFAULT_KVM_TYPE "auto"
|
||||
|
@ -3204,6 +3226,28 @@ static void spapr_set_resize_hpt(Object *obj, const char *value, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
static bool spapr_get_vof(Object *obj, Error **errp)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||
|
||||
return spapr->vof != NULL;
|
||||
}
|
||||
|
||||
static void spapr_set_vof(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||
|
||||
if (spapr->vof) {
|
||||
vof_cleanup(spapr->vof);
|
||||
g_free(spapr->vof);
|
||||
spapr->vof = NULL;
|
||||
}
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
spapr->vof = g_malloc0(sizeof(*spapr->vof));
|
||||
}
|
||||
|
||||
static char *spapr_get_ic_mode(Object *obj, Error **errp)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||
|
@ -3329,6 +3373,11 @@ static void spapr_instance_init(Object *obj)
|
|||
stringify(KERNEL_LOAD_ADDR)
|
||||
" for -kernel is the default");
|
||||
spapr->kernel_addr = KERNEL_LOAD_ADDR;
|
||||
|
||||
object_property_add_bool(obj, "x-vof", spapr_get_vof, spapr_set_vof);
|
||||
object_property_set_description(obj, "x-vof",
|
||||
"Enable Virtual Open Firmware (experimental)");
|
||||
|
||||
/* The machine class defines the default interrupt controller mode */
|
||||
spapr->irq = smc->irq;
|
||||
object_property_add_str(obj, "ic-mode", spapr_get_ic_mode,
|
||||
|
@ -4492,6 +4541,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
|
|||
XICSFabricClass *xic = XICS_FABRIC_CLASS(oc);
|
||||
InterruptStatsProviderClass *ispc = INTERRUPT_STATS_PROVIDER_CLASS(oc);
|
||||
XiveFabricClass *xfc = XIVE_FABRIC_CLASS(oc);
|
||||
VofMachineIfClass *vmc = VOF_MACHINE_CLASS(oc);
|
||||
|
||||
mc->desc = "pSeries Logical Partition (PAPR compliant)";
|
||||
mc->ignore_boot_device_suffixes = true;
|
||||
|
@ -4573,6 +4623,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
|
|||
smc->default_caps.caps[SPAPR_CAP_LARGE_DECREMENTER] = SPAPR_CAP_ON;
|
||||
smc->default_caps.caps[SPAPR_CAP_CCF_ASSIST] = SPAPR_CAP_ON;
|
||||
smc->default_caps.caps[SPAPR_CAP_FWNMI] = SPAPR_CAP_ON;
|
||||
smc->default_caps.caps[SPAPR_CAP_RPT_INVALIDATE] = SPAPR_CAP_OFF;
|
||||
spapr_caps_add_properties(smc);
|
||||
smc->irq = &spapr_irq_dual;
|
||||
smc->dr_phb_enabled = true;
|
||||
|
@ -4580,6 +4631,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
|
|||
smc->smp_threads_vsmt = true;
|
||||
smc->nr_xirqs = SPAPR_NR_XIRQS;
|
||||
xfc->match_nvt = spapr_match_nvt;
|
||||
vmc->client_architecture_support = spapr_vof_client_architecture_support;
|
||||
vmc->quiesce = spapr_vof_quiesce;
|
||||
vmc->setprop = spapr_vof_setprop;
|
||||
}
|
||||
|
||||
static const TypeInfo spapr_machine_info = {
|
||||
|
@ -4599,6 +4653,7 @@ static const TypeInfo spapr_machine_info = {
|
|||
{ TYPE_XICS_FABRIC },
|
||||
{ TYPE_INTERRUPT_STATS_PROVIDER },
|
||||
{ TYPE_XIVE_FABRIC },
|
||||
{ TYPE_VOF_MACHINE_IF },
|
||||
{ }
|
||||
},
|
||||
};
|
||||
|
|
|
@ -582,6 +582,37 @@ static void cap_fwnmi_apply(SpaprMachineState *spapr, uint8_t val,
|
|||
}
|
||||
}
|
||||
|
||||
static void cap_rpt_invalidate_apply(SpaprMachineState *spapr,
|
||||
uint8_t val, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
|
||||
if (!val) {
|
||||
/* capability disabled by default */
|
||||
return;
|
||||
}
|
||||
|
||||
if (tcg_enabled()) {
|
||||
error_setg(errp, "No H_RPT_INVALIDATE support in TCG");
|
||||
error_append_hint(errp,
|
||||
"Try appending -machine cap-rpt-invalidate=off\n");
|
||||
} else if (kvm_enabled()) {
|
||||
if (!kvmppc_has_cap_mmu_radix()) {
|
||||
error_setg(errp, "H_RPT_INVALIDATE only supported on Radix");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!kvmppc_has_cap_rpt_invalidate()) {
|
||||
error_setg(errp,
|
||||
"KVM implementation does not support H_RPT_INVALIDATE");
|
||||
error_append_hint(errp,
|
||||
"Try appending -machine cap-rpt-invalidate=off\n");
|
||||
} else {
|
||||
kvmppc_enable_h_rpt_invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
|
||||
[SPAPR_CAP_HTM] = {
|
||||
.name = "htm",
|
||||
|
@ -690,6 +721,15 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
|
|||
.type = "bool",
|
||||
.apply = cap_fwnmi_apply,
|
||||
},
|
||||
[SPAPR_CAP_RPT_INVALIDATE] = {
|
||||
.name = "rpt-invalidate",
|
||||
.description = "Allow H_RPT_INVALIDATE",
|
||||
.index = SPAPR_CAP_RPT_INVALIDATE,
|
||||
.get = spapr_cap_get_bool,
|
||||
.set = spapr_cap_set_bool,
|
||||
.type = "bool",
|
||||
.apply = cap_rpt_invalidate_apply,
|
||||
},
|
||||
};
|
||||
|
||||
static SpaprCapabilities default_caps_with_cpu(SpaprMachineState *spapr,
|
||||
|
@ -830,6 +870,7 @@ SPAPR_CAP_MIG_STATE(nested_kvm_hv, SPAPR_CAP_NESTED_KVM_HV);
|
|||
SPAPR_CAP_MIG_STATE(large_decr, SPAPR_CAP_LARGE_DECREMENTER);
|
||||
SPAPR_CAP_MIG_STATE(ccf_assist, SPAPR_CAP_CCF_ASSIST);
|
||||
SPAPR_CAP_MIG_STATE(fwnmi, SPAPR_CAP_FWNMI);
|
||||
SPAPR_CAP_MIG_STATE(rpt_invalidate, SPAPR_CAP_RPT_INVALIDATE);
|
||||
|
||||
void spapr_caps_init(SpaprMachineState *spapr)
|
||||
{
|
||||
|
|
|
@ -1233,8 +1233,7 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
|
|||
spapr_setup_hpt(spapr);
|
||||
}
|
||||
|
||||
fdt = spapr_build_fdt(spapr, false, fdt_bufsize);
|
||||
|
||||
fdt = spapr_build_fdt(spapr, spapr->vof != NULL, fdt_bufsize);
|
||||
g_free(spapr->fdt_blob);
|
||||
spapr->fdt_size = fdt_totalsize(fdt);
|
||||
spapr->fdt_initial_size = spapr->fdt_size;
|
||||
|
@ -1277,6 +1276,25 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|||
return ret;
|
||||
}
|
||||
|
||||
target_ulong spapr_vof_client_architecture_support(MachineState *ms,
|
||||
CPUState *cs,
|
||||
target_ulong ovec_addr)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(ms);
|
||||
|
||||
target_ulong ret = do_client_architecture_support(POWERPC_CPU(cs), spapr,
|
||||
ovec_addr, FDT_MAX_SIZE);
|
||||
|
||||
/*
|
||||
* This adds stdout and generates phandles for boottime and CAS FDTs.
|
||||
* It is alright to update the FDT here as do_client_architecture_support()
|
||||
* does not pack it.
|
||||
*/
|
||||
spapr_vof_client_dt_finalize(spapr, spapr->fdt_blob);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
|
||||
SpaprMachineState *spapr,
|
||||
target_ulong opcode,
|
||||
|
@ -1299,6 +1317,8 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
|
|||
behaviour |= H_CPU_BEHAV_L1D_FLUSH_PR;
|
||||
break;
|
||||
case SPAPR_CAP_FIXED:
|
||||
behaviour |= H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY;
|
||||
behaviour |= H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS;
|
||||
break;
|
||||
default: /* broken */
|
||||
assert(safe_cache == SPAPR_CAP_BROKEN);
|
||||
|
|
167
hw/ppc/spapr_vof.c
Normal file
167
hw/ppc/spapr_vof.c
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* SPAPR machine hooks to Virtual Open Firmware,
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu-common.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/ppc/spapr.h"
|
||||
#include "hw/ppc/spapr_vio.h"
|
||||
#include "hw/ppc/spapr_cpu_core.h"
|
||||
#include "hw/ppc/fdt.h"
|
||||
#include "hw/ppc/vof.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "qom/qom-qobject.h"
|
||||
#include "trace.h"
|
||||
|
||||
target_ulong spapr_h_vof_client(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
||||
target_ulong opcode, target_ulong *_args)
|
||||
{
|
||||
int ret = vof_client_call(MACHINE(spapr), spapr->vof, spapr->fdt_blob,
|
||||
ppc64_phys_to_real(_args[0]));
|
||||
|
||||
if (ret) {
|
||||
return H_PARAMETER;
|
||||
}
|
||||
return H_SUCCESS;
|
||||
}
|
||||
|
||||
void spapr_vof_client_dt_finalize(SpaprMachineState *spapr, void *fdt)
|
||||
{
|
||||
char *stdout_path = spapr_vio_stdout_path(spapr->vio_bus);
|
||||
|
||||
vof_build_dt(fdt, spapr->vof);
|
||||
|
||||
if (spapr->vof->bootargs) {
|
||||
int chosen;
|
||||
|
||||
_FDT(chosen = fdt_path_offset(fdt, "/chosen"));
|
||||
/*
|
||||
* If the client did not change "bootargs", spapr_dt_chosen() must have
|
||||
* stored machine->kernel_cmdline in it before getting here.
|
||||
*/
|
||||
_FDT(fdt_setprop_string(fdt, chosen, "bootargs", spapr->vof->bootargs));
|
||||
}
|
||||
|
||||
/*
|
||||
* SLOF-less setup requires an open instance of stdout for early
|
||||
* kernel printk. By now all phandles are settled so we can open
|
||||
* the default serial console.
|
||||
*/
|
||||
if (stdout_path) {
|
||||
_FDT(vof_client_open_store(fdt, spapr->vof, "/chosen", "stdout",
|
||||
stdout_path));
|
||||
}
|
||||
}
|
||||
|
||||
void spapr_vof_reset(SpaprMachineState *spapr, void *fdt, Error **errp)
|
||||
{
|
||||
target_ulong stack_ptr;
|
||||
Vof *vof = spapr->vof;
|
||||
PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
|
||||
|
||||
vof_init(vof, spapr->rma_size, errp);
|
||||
|
||||
stack_ptr = vof_claim(vof, 0, VOF_STACK_SIZE, VOF_STACK_SIZE);
|
||||
if (stack_ptr == -1) {
|
||||
error_setg(errp, "Memory allocation for stack failed");
|
||||
return;
|
||||
}
|
||||
/* Stack grows downwards plus reserve space for the minimum stack frame */
|
||||
stack_ptr += VOF_STACK_SIZE - 0x20;
|
||||
|
||||
if (spapr->kernel_size &&
|
||||
vof_claim(vof, spapr->kernel_addr, spapr->kernel_size, 0) == -1) {
|
||||
error_setg(errp, "Memory for kernel is in use");
|
||||
return;
|
||||
}
|
||||
|
||||
if (spapr->initrd_size &&
|
||||
vof_claim(vof, spapr->initrd_base, spapr->initrd_size, 0) == -1) {
|
||||
error_setg(errp, "Memory for initramdisk is in use");
|
||||
return;
|
||||
}
|
||||
|
||||
spapr_vof_client_dt_finalize(spapr, fdt);
|
||||
|
||||
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT,
|
||||
stack_ptr, spapr->initrd_base,
|
||||
spapr->initrd_size);
|
||||
/* VOF is 32bit BE so enforce MSR here */
|
||||
first_ppc_cpu->env.msr &= ~((1ULL << MSR_SF) | (1ULL << MSR_LE));
|
||||
|
||||
/*
|
||||
* At this point the expected allocation map is:
|
||||
*
|
||||
* 0..c38 - the initial firmware
|
||||
* 8000..10000 - stack
|
||||
* 400000.. - kernel
|
||||
* 3ea0000.. - initramdisk
|
||||
*
|
||||
* We skip writing FDT as nothing expects it; OF client interface is
|
||||
* going to be used for reading the device tree.
|
||||
*/
|
||||
}
|
||||
|
||||
void spapr_vof_quiesce(MachineState *ms)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(ms);
|
||||
|
||||
spapr->fdt_size = fdt_totalsize(spapr->fdt_blob);
|
||||
spapr->fdt_initial_size = spapr->fdt_size;
|
||||
}
|
||||
|
||||
bool spapr_vof_setprop(MachineState *ms, const char *path, const char *propname,
|
||||
void *val, int vallen)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(ms);
|
||||
|
||||
/*
|
||||
* We only allow changing properties which we know how to update in QEMU
|
||||
* OR
|
||||
* the ones which we know that they need to survive during "quiesce".
|
||||
*/
|
||||
|
||||
if (strcmp(path, "/rtas") == 0) {
|
||||
if (strcmp(propname, "linux,rtas-base") == 0 ||
|
||||
strcmp(propname, "linux,rtas-entry") == 0) {
|
||||
/* These need to survive quiesce so let them store in the FDT */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(path, "/chosen") == 0) {
|
||||
if (strcmp(propname, "bootargs") == 0) {
|
||||
Vof *vof = spapr->vof;
|
||||
|
||||
g_free(vof->bootargs);
|
||||
vof->bootargs = g_strndup(val, vallen);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(propname, "linux,initrd-start") == 0) {
|
||||
if (vallen == sizeof(uint32_t)) {
|
||||
spapr->initrd_base = ldl_be_p(val);
|
||||
return true;
|
||||
}
|
||||
if (vallen == sizeof(uint64_t)) {
|
||||
spapr->initrd_base = ldq_be_p(val);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (strcmp(propname, "linux,initrd-end") == 0) {
|
||||
if (vallen == sizeof(uint32_t)) {
|
||||
spapr->initrd_size = ldl_be_p(val) - spapr->initrd_base;
|
||||
return true;
|
||||
}
|
||||
if (vallen == sizeof(uint64_t)) {
|
||||
spapr->initrd_size = ldq_be_p(val) - spapr->initrd_base;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -71,6 +71,30 @@ spapr_rtas_ibm_configure_connector_invalid(uint32_t index) "DRC index: 0x%"PRIx3
|
|||
spapr_vio_h_reg_crq(uint64_t reg, uint64_t queue_addr, uint64_t queue_len) "CRQ for dev 0x%" PRIx64 " registered at 0x%" PRIx64 "/0x%" PRIx64
|
||||
spapr_vio_free_crq(uint32_t reg) "CRQ for dev 0x%" PRIx32 " freed"
|
||||
|
||||
# vof.c
|
||||
vof_error_str_truncated(const char *s, int len) "%s truncated to %d"
|
||||
vof_error_param(const char *method, int nargscheck, int nretcheck, int nargs, int nret) "%s takes/returns %d/%d, not %d/%d"
|
||||
vof_error_unknown_service(const char *service, int nargs, int nret) "\"%s\" args=%d rets=%d"
|
||||
vof_error_unknown_method(const char *method) "\"%s\""
|
||||
vof_error_unknown_ihandle_close(uint32_t ih) "ih=0x%x"
|
||||
vof_error_unknown_path(const char *path) "\"%s\""
|
||||
vof_error_write(uint32_t ih) "ih=0x%x"
|
||||
vof_finddevice(const char *path, uint32_t ph) "\"%s\" => ph=0x%x"
|
||||
vof_claim(uint32_t virt, uint32_t size, uint32_t align, uint32_t ret) "virt=0x%x size=0x%x align=0x%x => 0x%x"
|
||||
vof_release(uint32_t virt, uint32_t size, uint32_t ret) "virt=0x%x size=0x%x => 0x%x"
|
||||
vof_method(uint32_t ihandle, const char *method, uint32_t param, uint32_t ret, uint32_t ret2) "ih=0x%x \"%s\"(0x%x) => 0x%x 0x%x"
|
||||
vof_getprop(uint32_t ph, const char *prop, uint32_t ret, const char *val) "ph=0x%x \"%s\" => len=%d [%s]"
|
||||
vof_getproplen(uint32_t ph, const char *prop, uint32_t ret) "ph=0x%x \"%s\" => len=%d"
|
||||
vof_setprop(uint32_t ph, const char *prop, const char *val, uint32_t vallen, uint32_t ret) "ph=0x%x \"%s\" [%s] len=%d => ret=%d"
|
||||
vof_open(const char *path, uint32_t ph, uint32_t ih) "%s ph=0x%x => ih=0x%x"
|
||||
vof_interpret(const char *cmd, uint32_t param1, uint32_t param2, uint32_t ret, uint32_t ret2) "[%s] 0x%x 0x%x => 0x%x 0x%x"
|
||||
vof_package_to_path(uint32_t ph, const char *tmp, uint32_t ret) "ph=0x%x => %s len=%d"
|
||||
vof_instance_to_path(uint32_t ih, uint32_t ph, const char *tmp, uint32_t ret) "ih=0x%x ph=0x%x => %s len=%d"
|
||||
vof_instance_to_package(uint32_t ih, uint32_t ph) "ih=0x%x => ph=0x%x"
|
||||
vof_write(uint32_t ih, unsigned cb, const char *msg) "ih=0x%x [%u] \"%s\""
|
||||
vof_avail(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=0x%"PRIx64
|
||||
vof_claimed(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=0x%"PRIx64
|
||||
|
||||
# ppc.c
|
||||
ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
|
||||
|
||||
|
|
1053
hw/ppc/vof.c
Normal file
1053
hw/ppc/vof.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue