Commit 7cc0cdcd authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-4.2-sf1-v3' into staging



RISC-V Patches for the 4.2 Soft Freeze, Part 1, v3

This contains quite a few patches that I'd like to target for 4.2.
They're mostly emulation fixes for the sifive_u board, which now much
more closely matches the hardware and can therefor run the same fireware
as what gets loaded onto the board.  Additional user-visible
improvements include:

* support for loading initrd files from the command line into Linux, via
  /chosen/linux,initrd-{start,end} device tree nodes.
* The conversion of LOG_TRACE to trace events.
* The addition of clock DT nodes for our uart and ethernet.

This also includes some preliminary work for the H extension patches,
but does not include the H extension patches as I haven't had time to
review them yet.

This passes my OE boot test on 32-bit and 64-bit virt machines, as well
as a 64-bit upstream Linux boot on the sifive_u machine.  It has been
fixed to actually pass "make check" this time.

Changes since v2 (never made it to the list):

* Sets the sifive_u machine default core count to 2 instead of 5.

Changes since v1 <20190910190513.21160-1-palmer@sifive.com>:

* Sets the sifive_u machine default core count to 5 instead of 1, as
  it's impossible to have a single core sifive_u machine.

# gpg: Signature made Tue 17 Sep 2019 16:43:30 BST
# gpg:                using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41
# gpg:                issuer "palmer@dabbelt.com"
# gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [unknown]
# gpg:                 aka "Palmer Dabbelt <palmer@sifive.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 00CE 76D1 8349 60DF CE88  6DF8 EF4C A150 2CCB AB41

* remotes/palmer/tags/riscv-for-master-4.2-sf1-v3: (48 commits)
  gdbstub: riscv: fix the fflags registers
  target/riscv: Use TB_FLAGS_MSTATUS_FS for floating point
  target/riscv: Fix mstatus dirty mask
  target/riscv: Use both register name and ABI name
  riscv: sifive_u: Update model and compatible strings in device tree
  riscv: sifive_u: Remove handcrafted clock nodes for UART and ethernet
  riscv: sifive_u: Fix broken GEM support
  riscv: sifive_u: Instantiate OTP memory with a serial number
  riscv: sifive: Implement a model for SiFive FU540 OTP
  riscv: roms: Update default bios for sifive_u machine
  riscv: sifive_u: Change UART node name in device tree
  riscv: sifive_u: Update UART base addresses and IRQs
  riscv: sifive_u: Reference PRCI clocks in UART and ethernet nodes
  riscv: sifive_u: Add PRCI block to the SoC
  riscv: sifive_u: Generate hfclk and rtcclk nodes
  riscv: sifive: Implement PRCI model for FU540
  riscv: sifive_u: Update PLIC hart topology configuration string
  riscv: sifive_u: Update hart configuration to reflect the real FU540 SoC
  riscv: sifive_u: Set the minimum number of cpus to 2
  riscv: hart: Add a "hartid-base" property to RISC-V hart array
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents f3964112 b3e86929
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ STEXI
Show virtual to physical memory mappings.
ETEXI

#if defined(TARGET_I386)
#if defined(TARGET_I386) || defined(TARGET_RISCV)
    {
        .name       = "mem",
        .args_type  = "",
+2 −0
Original line number Diff line number Diff line
@@ -12,12 +12,14 @@ config SIFIVE_E
    bool
    select HART
    select SIFIVE
    select UNIMP

config SIFIVE_U
    bool
    select CADENCE
    select HART
    select SIFIVE
    select UNIMP

config SPIKE
    bool
+3 −1
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@ obj-y += boot.o
obj-$(CONFIG_SPIKE) += riscv_htif.o
obj-$(CONFIG_HART) += riscv_hart.o
obj-$(CONFIG_SIFIVE_E) += sifive_e.o
obj-$(CONFIG_SIFIVE_E) += sifive_e_prci.o
obj-$(CONFIG_SIFIVE) += sifive_clint.o
obj-$(CONFIG_SIFIVE) += sifive_gpio.o
obj-$(CONFIG_SIFIVE) += sifive_prci.o
obj-$(CONFIG_SIFIVE) += sifive_plic.o
obj-$(CONFIG_SIFIVE) += sifive_test.o
obj-$(CONFIG_SIFIVE_U) += sifive_u.o
obj-$(CONFIG_SIFIVE_U) += sifive_u_otp.o
obj-$(CONFIG_SIFIVE_U) += sifive_u_prci.o
obj-$(CONFIG_SIFIVE) += sifive_uart.o
obj-$(CONFIG_SPIKE) += spike.o
obj-$(CONFIG_RISCV_VIRT) += virt.o
+17 −9
Original line number Diff line number Diff line
@@ -69,25 +69,33 @@ void riscv_find_and_load_firmware(MachineState *machine,
         * so then in the future we can make "-bios default" the default option
         * if no -bios option is set without breaking anything.
         */
        firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
                                           default_machine_firmware);
        if (firmware_filename == NULL) {
            error_report("Unable to load the default RISC-V firmware \"%s\"",
                         default_machine_firmware);
            exit(1);
        }
        firmware_filename = riscv_find_firmware(default_machine_firmware);
    } else {
        firmware_filename = machine->firmware;
        if (strcmp(firmware_filename, "none")) {
            firmware_filename = riscv_find_firmware(firmware_filename);
        }
    }

    if (strcmp(firmware_filename, "none")) {
        /* If not "none" load the firmware */
        riscv_load_firmware(firmware_filename, firmware_load_addr);
        g_free(firmware_filename);
    }
}

    if (!strcmp(machine->firmware, "default")) {
        g_free(firmware_filename);
char *riscv_find_firmware(const char *firmware_filename)
{
    char *filename;

    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware_filename);
    if (filename == NULL) {
        error_report("Unable to load the RISC-V firmware \"%s\"",
                     firmware_filename);
        exit(1);
    }

    return filename;
}

target_ulong riscv_load_firmware(const char *firmware_filename,
+21 −13
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 *
 * Copyright (c) 2017 SiFive, Inc.
 *
 * Holds the state of a heterogenous array of RISC-V harts
 * Holds the state of a homogeneous array of RISC-V harts
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
@@ -29,6 +29,7 @@

static Property riscv_harts_props[] = {
    DEFINE_PROP_UINT32("num-harts", RISCVHartArrayState, num_harts, 1),
    DEFINE_PROP_UINT32("hartid-base", RISCVHartArrayState, hartid_base, 0),
    DEFINE_PROP_STRING("cpu-type", RISCVHartArrayState, cpu_type),
    DEFINE_PROP_END_OF_LIST(),
};
@@ -39,27 +40,34 @@ static void riscv_harts_cpu_reset(void *opaque)
    cpu_reset(CPU(cpu));
}

static void riscv_harts_realize(DeviceState *dev, Error **errp)
static void riscv_hart_realize(RISCVHartArrayState *s, int idx,
                               char *cpu_type, Error **errp)
{
    RISCVHartArrayState *s = RISCV_HART_ARRAY(dev);
    Error *err = NULL;
    int n;

    s->harts = g_new0(RISCVCPU, s->num_harts);

    for (n = 0; n < s->num_harts; n++) {
        object_initialize_child(OBJECT(s), "harts[*]", &s->harts[n],
                                sizeof(RISCVCPU), s->cpu_type,
    object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx],
                            sizeof(RISCVCPU), cpu_type,
                            &error_abort, NULL);
        s->harts[n].env.mhartid = n;
        qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]);
        object_property_set_bool(OBJECT(&s->harts[n]), true,
    s->harts[idx].env.mhartid = s->hartid_base + idx;
    qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
    object_property_set_bool(OBJECT(&s->harts[idx]), true,
                             "realized", &err);
    if (err) {
        error_propagate(errp, err);
        return;
    }
}

static void riscv_harts_realize(DeviceState *dev, Error **errp)
{
    RISCVHartArrayState *s = RISCV_HART_ARRAY(dev);
    int n;

    s->harts = g_new0(RISCVCPU, s->num_harts);

    for (n = 0; n < s->num_harts; n++) {
        riscv_hart_realize(s, n, s->cpu_type, errp);
    }
}

static void riscv_harts_class_init(ObjectClass *klass, void *data)
Loading