From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
dbarboza@redhat.com, qemu-devel@nongnu.org, groug@kaod.org,
qemu-ppc@nonngu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: [PULL 03/20] ppc: Add a return value to ppc_set_compat() and ppc_set_compat_all()
Date: Fri, 9 Oct 2020 21:19:34 +1100 [thread overview]
Message-ID: <20201009101951.1569252-4-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20201009101951.1569252-1-david@gibson.dropbear.id.au>
From: Greg Kurz <groug@kaod.org>
As recommended in "qapi/error.h", indicate success / failure with a
return value. Since ppc_set_compat() is called from a VMState handler,
let's make it an int so that it propagates any negative errno returned
by kvmppc_set_compat(). Do the same for ppc_set_compat_all() for
consistency, even if it isn't called in a context where a negative errno
is required on failure.
This will allow to simplify error handling in the callers.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200914123505.612812-3-groug@kaod.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
target/ppc/compat.c | 26 +++++++++++++++-----------
target/ppc/cpu.h | 4 ++--
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
index 08aede88dc..e9bec5ffed 100644
--- a/target/ppc/compat.c
+++ b/target/ppc/compat.c
@@ -158,7 +158,7 @@ bool ppc_type_check_compat(const char *cputype, uint32_t compat_pvr,
return pcc_compat(pcc, compat_pvr, min_compat_pvr, max_compat_pvr);
}
-void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
+int ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
{
const CompatInfo *compat = compat_by_pvr(compat_pvr);
CPUPPCState *env = &cpu->env;
@@ -169,11 +169,11 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
pcr = 0;
} else if (!compat) {
error_setg(errp, "Unknown compatibility PVR 0x%08"PRIx32, compat_pvr);
- return;
+ return -EINVAL;
} else if (!ppc_check_compat(cpu, compat_pvr, 0, 0)) {
error_setg(errp, "Compatibility PVR 0x%08"PRIx32" not valid for CPU",
compat_pvr);
- return;
+ return -EINVAL;
} else {
pcr = compat->pcr;
}
@@ -185,17 +185,19 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
if (ret < 0) {
error_setg_errno(errp, -ret,
"Unable to set CPU compatibility mode in KVM");
- return;
+ return ret;
}
}
cpu->compat_pvr = compat_pvr;
env->spr[SPR_PCR] = pcr & pcc->pcr_mask;
+ return 0;
}
typedef struct {
uint32_t compat_pvr;
- Error *err;
+ Error **errp;
+ int ret;
} SetCompatState;
static void do_set_compat(CPUState *cs, run_on_cpu_data arg)
@@ -203,26 +205,28 @@ static void do_set_compat(CPUState *cs, run_on_cpu_data arg)
PowerPCCPU *cpu = POWERPC_CPU(cs);
SetCompatState *s = arg.host_ptr;
- ppc_set_compat(cpu, s->compat_pvr, &s->err);
+ s->ret = ppc_set_compat(cpu, s->compat_pvr, s->errp);
}
-void ppc_set_compat_all(uint32_t compat_pvr, Error **errp)
+int ppc_set_compat_all(uint32_t compat_pvr, Error **errp)
{
CPUState *cs;
CPU_FOREACH(cs) {
SetCompatState s = {
.compat_pvr = compat_pvr,
- .err = NULL,
+ .errp = errp,
+ .ret = 0,
};
run_on_cpu(cs, do_set_compat, RUN_ON_CPU_HOST_PTR(&s));
- if (s.err) {
- error_propagate(errp, s.err);
- return;
+ if (s.ret < 0) {
+ return s.ret;
}
}
+
+ return 0;
}
int ppc_compat_max_vthreads(PowerPCCPU *cpu)
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 766e9c5c26..e8aa185d4f 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1352,10 +1352,10 @@ bool ppc_check_compat(PowerPCCPU *cpu, uint32_t compat_pvr,
bool ppc_type_check_compat(const char *cputype, uint32_t compat_pvr,
uint32_t min_compat_pvr, uint32_t max_compat_pvr);
-void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp);
+int ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp);
#if !defined(CONFIG_USER_ONLY)
-void ppc_set_compat_all(uint32_t compat_pvr, Error **errp);
+int ppc_set_compat_all(uint32_t compat_pvr, Error **errp);
#endif
int ppc_compat_max_vthreads(PowerPCCPU *cpu);
void ppc_compat_add_property(Object *obj, const char *name,
--
2.26.2
next prev parent reply other threads:[~2020-10-09 10:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 10:19 [PULL 00/20] ppc-for-5.2 queue 20201009 David Gibson
2020-10-09 10:19 ` [PULL 01/20] spapr: Handle HPT allocation failure in nested guest David Gibson
2020-10-09 10:19 ` [PULL 02/20] spapr: Fix error leak in spapr_realize_vcpu() David Gibson
2020-10-09 10:19 ` David Gibson [this message]
2020-10-09 10:19 ` [PULL 04/20] ppc: Fix return value in cpu_post_load() error path David Gibson
2020-10-09 10:19 ` [PULL 05/20] spapr: Simplify error handling in callers of ppc_set_compat() David Gibson
2020-10-09 10:19 ` [PULL 06/20] spapr: Get rid of cas_check_pvr() error reporting David Gibson
2020-10-09 10:19 ` [PULL 07/20] spapr: Simplify error handling in do_client_architecture_support() David Gibson
2020-10-09 10:19 ` [PULL 08/20] spapr: Simplify error handling in spapr_vio_busdev_realize() David Gibson
2020-10-09 10:19 ` [PULL 09/20] spapr: Add a return value to spapr_drc_attach() David Gibson
2020-10-09 10:19 ` [PULL 10/20] spapr: Simplify error handling in prop_get_fdt() David Gibson
2020-10-09 10:19 ` [PULL 11/20] spapr: Add a return value to spapr_set_vcpu_id() David Gibson
2020-10-09 10:19 ` [PULL 12/20] spapr: Simplify error handling in spapr_cpu_core_realize() David Gibson
2020-10-09 10:19 ` [PULL 13/20] spapr: Add a return value to spapr_nvdimm_validate() David Gibson
2020-10-09 10:19 ` [PULL 14/20] spapr: Add a return value to spapr_check_pagesize() David Gibson
2020-10-09 10:19 ` [PULL 15/20] ppc/pnv: Increase max firmware size David Gibson
2020-10-09 10:19 ` [PULL 16/20] spapr: add spapr_machine_using_legacy_numa() helper David Gibson
2020-10-09 10:19 ` [PULL 17/20] spapr_numa: forbid asymmetrical NUMA setups David Gibson
2020-10-09 10:19 ` [PULL 18/20] spapr_numa: change reference-points and maxdomain settings David Gibson
2020-10-09 10:19 ` [PULL 19/20] spapr_numa: consider user input when defining associativity David Gibson
2020-10-09 10:19 ` [PULL 20/20] specs/ppc-spapr-numa: update with new NUMA support David Gibson
2020-10-09 16:22 ` [PULL 00/20] ppc-for-5.2 queue 20201009 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009101951.1569252-4-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=dbarboza@redhat.com \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nonngu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).