Skip to contentSkip to conversation

ppc-for-6.1 queue 20210729

GIT PULL Applied David Gibson 2 participants 7 messages Jul 29, 2021

lore
Share & tools
lore
#0 lore raw

The following changes since commit 69ea12b19a15ae006521cd5cc0f627f27f738746:

Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2021-07-27' into staging (2021-07-28 13:32:12 +0100)

are available in the Git repository at:

https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.1-20210729

for you to fetch changes up to 380e49297c302fdcf8e5d56abdbe07868d3af8d8:

kvm: ppc: Print meaningful message on KVM_CREATE_VM failure (2021-07-29 10:59:49 +1000)

----------------------------------------------------------------
ppc patch queue 2021-07-29

Here's a small batch of bufixes for the ppc target to go into qemu-6.1.

----------------------------------------------------------------
Alexey Kardashevskiy (1):
ppc/vof: Fix Coverity issues

BALATON Zoltan (2):
ppc/pegasos2: Fix spurious warning with -bios i2c/smbus_eeprom: Add feature bit to SPD data

Fabiano Rosas (1):
kvm: ppc: Print meaningful message on KVM_CREATE_VM failure

Matheus Ferst (1):
target/ppc: Ease L=0 requirement on cmp/cmpi/cmpl/cmpli for ppc32

 accel/kvm/kvm-all.c                        |   6 ++
 hw/i2c/smbus_eeprom.c                      |   2 +-
 hw/ppc/pegasos2.c                          |   2 +-
 hw/ppc/trace-events                        |   4 +-
 hw/ppc/vof.c                               | 139 +++++++++++++++--------------
 include/hw/ppc/vof.h                       |   2 +
 target/ppc/translate/fixedpoint-impl.c.inc |  58 +++++++++++-
 7 files changed, 142 insertions(+), 71 deletions(-)
#1 lore raw

[PULL 2/5] i2c/smbus_eeprom: Add feature bit to SPD data

From: BALATON Zoltan <[email protected]>

Add the differential clock input feature bit to the generated SPD data. Most guests don't seem to care but pegasos2 firmware version 1.2 checks for this bit and stops with unsupported module type error if it's not present. Since this feature is likely present on real memory modules add it in the general code rather than patching the generated SPD data in pegasos2 board only.

Message-Id: <19d42ade295d5297aa624a9eb757b8df18cf64d6.1626367844.git.balaton@eik.bme.hu>

---
 hw/i2c/smbus_eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/smbus_eeprom.c +1 -1
index 4d2bf99207..12c5741f38 100644
@@ -276,7 +276,7 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t ram_size)
     spd[18] = 12;   /* ~CAS latencies supported */
     spd[19] = (type == DDR2 ? 0 : 1); /* reserved / ~CS latencies supported */
     spd[20] = 2;    /* DIMM type / ~WE latencies */
-                    /* module features */
+    spd[21] = (type < DDR2 ? 0x20 : 0); /* module features */
                     /* memory chip features */
     spd[23] = 0x12; /* clock cycle time @ medium CAS latency */
                     /* data access time */
Signature · 1 line
2.31.1
#2 lore raw

[PULL 3/5] target/ppc: Ease L=0 requirement on cmp/cmpi/cmpl/cmpli for ppc32

In reply to David Gibson

From: Matheus Ferst <[email protected]>

In commit 8f0a4b6a9b, we started to require L=0 for ppc32 to match what The Programming Environments Manual say:

"For 32-bit implementations, the L field must be cleared, otherwise the instruction form is invalid."

The stricter behavior, however, broke AROS boot on sam460ex, which is a regression from 6.0. This patch partially reverts the change, raising the exception only for CPUs known to require L=0 (e500 and e500mc) and logging a guest error for other cases.

Both behaviors are acceptable by the PowerISA, which allows "the system illegal instruction error handler to be invoked or yield boundedly undefined results."

Fixes 8f0a4b6a9b ("target/ppc: Move cmp/cmpi/cmpl/cmpli to decodetree")

Message-Id: <[email protected]>

---
 target/ppc/translate/fixedpoint-impl.c.inc | 58 +++++++++++++++++++++-
 1 file changed, 56 insertions(+), 2 deletions(-)
target/ppc/translate/fixedpoint-impl.c.inc +56 -2
index 8864ac4516..2e2518ee15 100644
@@ -171,8 +171,35 @@ TRANS64(PSTD, do_ldst_PLS_D, false, true, MO_Q)
 
 static bool do_cmp_X(DisasContext *ctx, arg_X_bfl *a, bool s)
 {
+    if ((ctx->insns_flags & PPC_64B) == 0) {
+        /*
+         * For 32-bit implementations, The Programming Environments Manual says
+         * that "the L field must be cleared, otherwise the instruction form is
+         * invalid." It seems, however, that most 32-bit CPUs ignore invalid
+         * forms (e.g., section "Instruction Formats" of the 405 and 440
+         * manuals, "Integer Compare Instructions" of the 601 manual), with the
+         * notable exception of the e500 and e500mc, where L=1 was reported to
+         * cause an exception.
+         */
+        if (a->l) {
+            if ((ctx->insns_flags2 & PPC2_BOOKE206)) {
+                /*
+                 * For 32-bit Book E v2.06 implementations (i.e. e500/e500mc),
+                 * generate an illegal instruction exception.
+                 */
+                return false;
+            } else {
+                qemu_log_mask(LOG_GUEST_ERROR,
+                        "Invalid form of CMP%s at 0x" TARGET_FMT_lx ", L = 1\n",
+                        s ? "" : "L", ctx->cia);
+            }
+        }
+        gen_op_cmp32(cpu_gpr[a->ra], cpu_gpr[a->rb], s, a->bf);
+        return true;
+    }
+
+    /* For 64-bit implementations, deal with bit L accordingly. */
     if (a->l) {
-        REQUIRE_64BIT(ctx);
         gen_op_cmp(cpu_gpr[a->ra], cpu_gpr[a->rb], s, a->bf);
     } else {
         gen_op_cmp32(cpu_gpr[a->ra], cpu_gpr[a->rb], s, a->bf);
@@ -182,8 +209,35 @@ static bool do_cmp_X(DisasContext *ctx, arg_X_bfl *a, bool s)
 
 static bool do_cmp_D(DisasContext *ctx, arg_D_bf *a, bool s)
 {
+    if ((ctx->insns_flags & PPC_64B) == 0) {
+        /*
+         * For 32-bit implementations, The Programming Environments Manual says
+         * that "the L field must be cleared, otherwise the instruction form is
+         * invalid." It seems, however, that most 32-bit CPUs ignore invalid
+         * forms (e.g., section "Instruction Formats" of the 405 and 440
+         * manuals, "Integer Compare Instructions" of the 601 manual), with the
+         * notable exception of the e500 and e500mc, where L=1 was reported to
+         * cause an exception.
+         */
+        if (a->l) {
+            if ((ctx->insns_flags2 & PPC2_BOOKE206)) {
+                /*
+                 * For 32-bit Book E v2.06 implementations (i.e. e500/e500mc),
+                 * generate an illegal instruction exception.
+                 */
+                return false;
+            } else {
+                qemu_log_mask(LOG_GUEST_ERROR,
+                        "Invalid form of CMP%s at 0x" TARGET_FMT_lx ", L = 1\n",
+                        s ? "I" : "LI", ctx->cia);
+            }
+        }
+        gen_op_cmp32(cpu_gpr[a->ra], tcg_constant_tl(a->imm), s, a->bf);
+        return true;
+    }
+
+    /* For 64-bit implementations, deal with bit L accordingly. */
     if (a->l) {
-        REQUIRE_64BIT(ctx);
         gen_op_cmp(cpu_gpr[a->ra], tcg_constant_tl(a->imm), s, a->bf);
     } else {
         gen_op_cmp32(cpu_gpr[a->ra], tcg_constant_tl(a->imm), s, a->bf);
Signature · 1 line
2.31.1
#3 lore raw

[PULL 5/5] kvm: ppc: Print meaningful message on KVM_CREATE_VM failure

In reply to David Gibson

From: Fabiano Rosas <[email protected]>

PowerPC has two KVM types (HV, PR) that translate into three kernel modules:

kvm.ko - common kvm code
kvm_hv.ko - kvm running with MSR_HV=1 or MSR_HV|PR=0 in a nested guest. kvm_pr.ko - kvm running in usermode MSR_PR=1.

Since the two KVM types can both be running at the same time, this creates a situation in which it is possible for one or both of the modules to fail to initialize, leaving the generic one behind. This leads QEMU to think it can create a guest, but KVM will fail when calling the type-specific code:

ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
qemu-kvm: failed to initialize KVM: Invalid argument

Ideally this would be solved kernel-side, but it might be a while until we can get rid of one of the modules. So in the meantime this patch tries to make this less confusing for the end user by adding a more elucidative message:

ioctl(KVM_CREATE_VM) failed: 22 Invalid argument PPC KVM module is not loaded. Try 'modprobe kvm_hv'.

[dwg: Fixed error in #elif which failed compile on !ppc hosts]

Message-Id: <[email protected]>

---
 accel/kvm/kvm-all.c | 6 ++++++
 1 file changed, 6 insertions(+)
accel/kvm/kvm-all.c +6 -0
index e5b10dd129..0125c17edb 100644
@@ -2397,6 +2397,12 @@ static int kvm_init(MachineState *ms)
                     "- for kernels supporting the vm.allocate_pgste sysctl, "
                     "whether it is enabled\n");
         }
+#elif defined(TARGET_PPC)
+        if (ret == -EINVAL) {
+            fprintf(stderr,
+                    "PPC KVM module is not loaded. Try modprobe kvm_%s.\n",
+                    (type == 2) ? "pr" : "hv");
+        }
 #endif
         goto err;
     }
Signature · 1 line
2.31.1
#4 lore raw

[PULL 1/5] ppc/pegasos2: Fix spurious warning with -bios

In reply to David Gibson

From: BALATON Zoltan <[email protected]>

The -append option is currently not compatible with -bios (as we don't yet emulate nvram so we can only put it in the environment with VOF). Therefore a warning is printed if -append is used with -bios but because the default value of kernel_cmdline seems to be an empty string instead of NULL this warning was printed even without -append when -bios is used. Only print warning if -append is given.

Message-Id: <483ac599a1407b766179aaea2794aed60cc09f53.1626367844.git.balaton@eik.bme.hu>

---
 hw/ppc/pegasos2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pegasos2.c +1 -1
index 9fad1854b1..b8ce859f1a 100644
@@ -191,7 +191,7 @@ static void pegasos2_init(MachineState *machine)
             warn_report("Option -kernel may be ineffective with -bios.");
         }
     }
-    if (machine->kernel_cmdline && !pm->vof) {
+    if (!pm->vof && machine->kernel_cmdline && machine->kernel_cmdline[0]) {
         warn_report("Option -append may be ineffective with -bios.");
     }
 }
Signature · 1 line
2.31.1
#5 lore raw

[PULL 4/5] ppc/vof: Fix Coverity issues

In reply to David Gibson

From: Alexey Kardashevskiy <[email protected]>

Coverity reported issues which are caused by mixing of signed return codes from DTC and unsigned return codes of the client interface.

This introduces PROM_ERROR and makes distinction between the error types.

This fixes NEGATIVE_RETURNS, OVERRUN issues reported by Coverity.

This adds a comment about the return parameters number in the VOF hcall. The reason for such counting is to keep the numbers look the same in vof_client_handle() and the Linux (an OF client).

vmc->client_architecture_support() returns target_ulong and we want to propagate this to the client (for example H_MULTI_THREADS_ACTIVE). The VOF path to do_client_architecture_support() needs chopping off the top 32bit but SLOF's H_CAS does not; and either way the return values are either 0 or 32bit negative error code. For now this chops the top 32bits.

This makes "claim" fail if the allocated address is above 4GB as the client interface is 32bit. This still allows claiming memory above 4GB as potentially initrd can be put there and the client can read the address from the FDT's "available" property.

Fixes CID 1458139, 1458138, 1458137, 1458133, 1458132

Message-Id: <[email protected]>

---
 hw/ppc/trace-events  |   4 +-
 hw/ppc/vof.c         | 139 +++++++++++++++++++++++--------------------
 include/hw/ppc/vof.h |   2 +
 3 files changed, 78 insertions(+), 67 deletions(-)
hw/ppc/trace-events +2 -2
index 6e90a01072..da6e74b80d 100644
@@ -88,8 +88,8 @@ vof_getproplen(uint32_t ph, const char *prop, uint32_t ret) "ph=0x%x \"%s\" => l
 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_package_to_path(uint32_t ph, const char *tmp, int ret) "ph=0x%x => %s len=%d"
+vof_instance_to_path(uint32_t ih, uint32_t ph, const char *tmp, int 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
hw/ppc/vof.c +74 -65

357 lines not on this page · raw message

include/hw/ppc/vof.h +2 -0
index 640be46163..97fdef758b 100644
@@ -55,4 +55,6 @@ struct VofMachineIfClass {
     address_space_write(&address_space_memory, \
     (pa), MEMTXATTRS_UNSPECIFIED, (buf), (size))
 
+#define PROM_ERROR          (~0U)
+
 #endif /* HW_VOF_H */
Signature · 1 line
2.31.1
#6 lore raw
In reply to David Gibson
Quoted 11 lines · David Gibson

The following changes since commit 69ea12b19a15ae006521cd5cc0f627f27f738746:

Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2021-07-27' into staging (2021-07-28 13:32:12 +0100)

are available in the Git repository at:

https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.1-20210729

for you to fetch changes up to 380e49297c302fdcf8e5d56abdbe07868d3af8d8:

Quoted 8 lines

kvm: ppc: Print meaningful message on KVM_CREATE_VM failure (2021-07-29 10:59:49 +1000)

----------------------------------------------------------------
ppc patch queue 2021-07-29

Here's a small batch of bufixes for the ppc target to go into qemu-6.1.

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM