From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: npiggin@gmail.com, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, clegoate@redhat.com, mikey@neuling.org,
amachhiw@linux.vnet.ibm.com, vaibhav@linux.ibm.com,
sbhat@linux.ibm.com, danielhb413@gmail.com
Subject: [PATCH v3 14/15] spapr: nested: Introduce cap-nested-papr for Nested PAPR API
Date: Thu, 18 Jan 2024 10:54:37 +0530 [thread overview]
Message-ID: <20240118052438.1475437-15-harshpb@linux.ibm.com> (raw)
In-Reply-To: <20240118052438.1475437-1-harshpb@linux.ibm.com>
Introduce a SPAPR capability cap-nested-papr which enables nested PAPR
API for nested guests. This new API is to enable support for KVM on PowerVM
and the support in Linux kernel has already merged upstream.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
include/hw/ppc/spapr.h | 5 +++-
hw/ppc/spapr.c | 2 ++
hw/ppc/spapr_caps.c | 55 ++++++++++++++++++++++++++++++++++++++++++
hw/ppc/spapr_nested.c | 2 --
4 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 4d3dbd4e7a..379b64b0d7 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -81,8 +81,10 @@ typedef enum {
#define SPAPR_CAP_RPT_INVALIDATE 0x0B
/* Support for AIL modes */
#define SPAPR_CAP_AIL_MODE_3 0x0C
+/* Nested PAPR */
+#define SPAPR_CAP_NESTED_PAPR 0x0D
/* Num Caps */
-#define SPAPR_CAP_NUM (SPAPR_CAP_AIL_MODE_3 + 1)
+#define SPAPR_CAP_NUM (SPAPR_CAP_NESTED_PAPR + 1)
/*
* Capability Values
@@ -993,6 +995,7 @@ extern const VMStateDescription vmstate_spapr_cap_sbbc;
extern const VMStateDescription vmstate_spapr_cap_ibs;
extern const VMStateDescription vmstate_spapr_cap_hpt_maxpagesize;
extern const VMStateDescription vmstate_spapr_cap_nested_kvm_hv;
+extern const VMStateDescription vmstate_spapr_cap_nested_papr;
extern const VMStateDescription vmstate_spapr_cap_large_decr;
extern const VMStateDescription vmstate_spapr_cap_ccf_assist;
extern const VMStateDescription vmstate_spapr_cap_fwnmi;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index b87532343c..b34a1b61a6 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2120,6 +2120,7 @@ static const VMStateDescription vmstate_spapr = {
&vmstate_spapr_cap_fwnmi,
&vmstate_spapr_fwnmi,
&vmstate_spapr_cap_rpt_invalidate,
+ &vmstate_spapr_cap_nested_papr,
NULL
}
};
@@ -4696,6 +4697,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
smc->default_caps.caps[SPAPR_CAP_IBS] = SPAPR_CAP_WORKAROUND;
smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] = 16; /* 64kiB */
smc->default_caps.caps[SPAPR_CAP_NESTED_KVM_HV] = SPAPR_CAP_OFF;
+ smc->default_caps.caps[SPAPR_CAP_NESTED_PAPR] = SPAPR_CAP_OFF;
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;
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index c3c83f6e68..4c0080120e 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -487,11 +487,56 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
error_append_hint(errp, "Try appending -machine cap-nested-hv=off "
"or use threads=1 with -smp\n");
}
+ if (spapr->nested.api) {
+ warn_report("nested.api already set as %d, re-init to kvm-hv",
+ spapr->nested.api);
+ }
spapr->nested.api = NESTED_API_KVM_HV;
spapr_register_nested_hv();
}
}
+static void cap_nested_papr_apply(SpaprMachineState *spapr,
+ uint8_t val, Error **errp)
+{
+ ERRP_GUARD();
+ PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
+ CPUPPCState *env = &cpu->env;
+
+ if (!val) {
+ /* capability disabled by default */
+ return;
+ }
+
+ if (tcg_enabled()) {
+ if (!(env->insns_flags2 & PPC2_ISA300)) {
+ error_setg(errp, "Nested-PAPR only supported on POWER9 and later");
+ error_append_hint(errp,
+ "Try appending -machine cap-nested-papr=off\n");
+ return;
+ }
+ } else if (kvm_enabled()) {
+ /*
+ * this gets executed in L1 qemu when L2 is launched,
+ * needs kvm-hv support in L1 kernel.
+ */
+ if (!kvmppc_has_cap_nested_kvm_hv()) {
+ error_setg(errp,
+ "KVM implementation does not support Nested-HV");
+ } else if (kvmppc_set_cap_nested_kvm_hv(val) < 0) {
+ error_setg(errp, "Error enabling Nested-HV with KVM");
+ }
+ }
+ if (spapr->nested.api) {
+ warn_report("nested.api already set as %d, re-init to nested-papr",
+ spapr->nested.api);
+ }
+ spapr->nested.api = NESTED_API_PAPR;
+ spapr->nested.capabilities_set = false;
+ spapr_register_nested_papr();
+ spapr_nested_gsb_init();
+}
+
static void cap_large_decr_apply(SpaprMachineState *spapr,
uint8_t val, Error **errp)
{
@@ -737,6 +782,15 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
.type = "bool",
.apply = cap_nested_kvm_hv_apply,
},
+ [SPAPR_CAP_NESTED_PAPR] = {
+ .name = "nested-papr",
+ .description = "Allow Nested HV (PAPR API)",
+ .index = SPAPR_CAP_NESTED_PAPR,
+ .get = spapr_cap_get_bool,
+ .set = spapr_cap_set_bool,
+ .type = "bool",
+ .apply = cap_nested_papr_apply,
+ },
[SPAPR_CAP_LARGE_DECREMENTER] = {
.name = "large-decr",
.description = "Allow Large Decrementer",
@@ -921,6 +975,7 @@ SPAPR_CAP_MIG_STATE(sbbc, SPAPR_CAP_SBBC);
SPAPR_CAP_MIG_STATE(ibs, SPAPR_CAP_IBS);
SPAPR_CAP_MIG_STATE(hpt_maxpagesize, SPAPR_CAP_HPT_MAXPAGESIZE);
SPAPR_CAP_MIG_STATE(nested_kvm_hv, SPAPR_CAP_NESTED_KVM_HV);
+SPAPR_CAP_MIG_STATE(nested_papr, SPAPR_CAP_NESTED_PAPR);
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);
diff --git a/hw/ppc/spapr_nested.c b/hw/ppc/spapr_nested.c
index e7e5e72006..b91413e09a 100644
--- a/hw/ppc/spapr_nested.c
+++ b/hw/ppc/spapr_nested.c
@@ -13,8 +13,6 @@
void spapr_nested_init(SpaprMachineState *spapr)
{
spapr->nested.api = 0;
- spapr->nested.capabilities_set = false;
- spapr_nested_gsb_init();
}
uint8_t spapr_nested_api(SpaprMachineState *spapr)
--
2.39.3
next prev parent reply other threads:[~2024-01-18 5:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 5:24 [PATCH v3 00/15] Nested PAPR API (KVM on PowerVM) Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 01/15] spapr: nested: register nested-hv api hcalls only for cap-nested-hv Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 02/15] spapr: nested: move nested part of spapr_get_pate into spapr_nested.c Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 03/15] spapr: nested: Introduce SpaprMachineStateNested to store related info Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 04/15] spapr: nested: keep nested-hv related code restricted to its API Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 05/15] spapr: nested: Document Nested PAPR API Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 06/15] spapr: nested: Introduce H_GUEST_[GET|SET]_CAPABILITIES hcalls Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 07/15] spapr: nested: Introduce H_GUEST_[CREATE|DELETE] hcalls Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 08/15] spapr: nested: Introduce H_GUEST_CREATE_VCPU hcall Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 09/15] spapr: nested: Extend nested_ppc_state for nested PAPR API Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 10/15] spapr: nested: Initialize the GSB elements lookup table Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 11/15] spapr: nested: Introduce H_GUEST_[GET|SET]_STATE hcalls Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 12/15] spapr: nested: Use correct source for parttbl info for nested PAPR API Harsh Prateek Bora
2024-01-18 5:24 ` [PATCH v3 13/15] spapr: nested: Introduce H_GUEST_RUN_VCPU hcall Harsh Prateek Bora
2024-01-18 5:24 ` Harsh Prateek Bora [this message]
2024-01-18 5:24 ` [PATCH v3 15/15] spapr: nested: Set the PCR when logical PVR is set Harsh Prateek Bora
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=20240118052438.1475437-15-harshpb@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=amachhiw@linux.vnet.ibm.com \
--cc=clegoate@redhat.com \
--cc=danielhb413@gmail.com \
--cc=mikey@neuling.org \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sbhat@linux.ibm.com \
--cc=vaibhav@linux.ibm.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).