From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: clg@kaod.org, mikey@neuling.org, amachhiw@linux.vnet.ibm.com,
vaibhav@linux.ibm.com, sbhat@linux.ibm.com,
danielhb413@gmail.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v5 14/14] spapr: nested: Introduce cap-nested-papr for Nested PAPR API
Date: Tue, 12 Mar 2024 18:48:27 +0530 [thread overview]
Message-ID: <c374d5f6-c99e-44ed-8e4e-09eb8e80e721@linux.ibm.com> (raw)
In-Reply-To: <c8f6dc45-33e0-431d-8650-bb7e7f516b54@linux.ibm.com>
Hi Nick,
Updated incremental fix below:
On 3/12/24 18:21, Harsh Prateek Bora wrote:
>
>
> On 3/12/24 18:17, Harsh Prateek Bora wrote:
>> Hi Nick,
>>
>> On 3/12/24 17:41, Harsh Prateek Bora wrote:
>>> Hi Nick,
>>>
>>> On 3/12/24 17:21, Nicholas Piggin wrote:
>>>> On Fri Mar 8, 2024 at 9:19 PM AEST, Harsh Prateek Bora wrote:
>>>>> 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 | 6 +++-
>>>>> hw/ppc/spapr.c | 2 ++
>>>>> hw/ppc/spapr_caps.c | 62
>>>>> ++++++++++++++++++++++++++++++++++++++++++
>>>>> hw/ppc/spapr_nested.c | 8 ++++--
>>>>> 4 files changed, 74 insertions(+), 4 deletions(-)
>>>>>
<snip>
>>>>> +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;
>>>>> + }
>>>>> + if (spapr_nested_api(spapr) &&
>>>>> + spapr_nested_api(spapr) != NESTED_API_PAPR) {
>>>>> + error_setg(errp, "Nested-HV APIs are mutually
>>>>> exclusive/incompatible");
>>>>> + error_append_hint(errp, "Please use either
>>>>> cap-nested-hv or "
>>>>> + "cap-nested-papr to proceed.\n");
>>>>> + return;
>>>>> + } else {
>>>>> + spapr->nested.api = NESTED_API_PAPR;
>>>>> + }
>>>>> +
>>>>> + } 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");
>>>>> + }
>>>>
>>>> I'll just disable this on KVM for now. With that changed,
>>>>
>>>> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>>>>
>>>
>>> AFAIK, v2 api also expects this capability to be enabled on L1 kernel.
>>> I guess the reason is the L1 implementation has used the same capab and
>>> extended to be used with v2 api. So, this check is needed in L1 Qemu for
>>> now. We may revisit L1 implementation later to see if a change is
>>> appropriate.
>>
>> Please ignore above response. I think my observation was based on
>> older version of L1 implementation. This doesnt seem to be an issue
>> with upstream L1. You may disable the kvm_enabled() path for now. I
>> just tested and it works fine.
>
> Here's the incremental fix:
>
Updated to keep error_setg for kvm_enabled() case:
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index d6d5a6b8df..92d8966d60 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -527,18 +527,9 @@ static void cap_nested_papr_apply(SpaprMachineState
*spapr,
} else {
spapr->nested.api = NESTED_API_PAPR;
}
-
} 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");
- }
+ "KVM implementation does not support Nested-PAPR");
}
}
>
> regards,
> Harsh
>>
>> regards,
>> Harsh
>>
>>>
>>> regards,
>>> Harsh
>>>
>>>>> }
>>>>> }
>>>>> @@ -735,6 +787,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",
>>>>> @@ -919,6 +980,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 597dba7fdc..8db9dc19e3 100644
>>>>> --- a/hw/ppc/spapr_nested.c
>>>>> +++ b/hw/ppc/spapr_nested.c
>>>>> @@ -13,13 +13,15 @@
>>>>> void spapr_nested_reset(SpaprMachineState *spapr)
>>>>> {
>>>>> if (spapr_get_cap(spapr, SPAPR_CAP_NESTED_KVM_HV)) {
>>>>> - spapr->nested.api = NESTED_API_KVM_HV;
>>>>> spapr_unregister_nested_hv();
>>>>> spapr_register_nested_hv();
>>>>> - } else {
>>>>> - spapr->nested.api = 0;
>>>>> + } else if (spapr_get_cap(spapr, SPAPR_CAP_NESTED_PAPR)) {
>>>>> spapr->nested.capabilities_set = false;
>>>>> + spapr_unregister_nested_papr();
>>>>> + spapr_register_nested_papr();
>>>>> spapr_nested_gsb_init();
>>>>> + } else {
>>>>> + spapr->nested.api = 0;
>>>>> }
>>>>> }
>>>>
>
next prev parent reply other threads:[~2024-03-12 13:19 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-08 11:19 [PATCH v5 00/14] Nested PAPR API (KVM on PowerVM) Harsh Prateek Bora
2024-03-08 11:19 ` [PATCH v5 01/14] spapr: nested: register nested-hv api hcalls only for cap-nested-hv Harsh Prateek Bora
2024-03-08 11:19 ` [PATCH v5 02/14] spapr: nested: move nested part of spapr_get_pate into spapr_nested.c Harsh Prateek Bora
2024-03-08 11:19 ` [PATCH v5 03/14] spapr: nested: Introduce SpaprMachineStateNested to store related info Harsh Prateek Bora
2024-03-08 11:19 ` [PATCH v5 04/14] spapr: nested: keep nested-hv related code restricted to its API Harsh Prateek Bora
2024-03-12 11:30 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 05/14] spapr: nested: Document Nested PAPR API Harsh Prateek Bora
2024-03-12 11:30 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 06/14] spapr: nested: Introduce H_GUEST_[GET|SET]_CAPABILITIES hcalls Harsh Prateek Bora
2024-03-12 11:30 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 07/14] spapr: nested: Introduce H_GUEST_[CREATE|DELETE] hcalls Harsh Prateek Bora
2024-03-12 11:30 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 08/14] spapr: nested: Introduce H_GUEST_CREATE_VCPU hcall Harsh Prateek Bora
2024-03-12 11:30 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 09/14] spapr: nested: Extend nested_ppc_state for nested PAPR API Harsh Prateek Bora
2024-03-12 11:37 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 10/14] spapr: nested: Initialize the GSB elements lookup table Harsh Prateek Bora
2024-03-12 11:38 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 11/14] spapr: nested: Introduce H_GUEST_[GET|SET]_STATE hcalls Harsh Prateek Bora
2024-03-12 11:38 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 12/14] spapr: nested: Use correct source for parttbl info for nested PAPR API Harsh Prateek Bora
2024-03-12 11:41 ` Nicholas Piggin
2024-03-12 11:58 ` Harsh Prateek Bora
2024-03-08 11:19 ` [PATCH v5 13/14] spapr: nested: Introduce H_GUEST_RUN_VCPU hcall Harsh Prateek Bora
2024-03-12 11:42 ` Nicholas Piggin
2024-03-08 11:19 ` [PATCH v5 14/14] spapr: nested: Introduce cap-nested-papr for Nested PAPR API Harsh Prateek Bora
2024-03-12 11:45 ` Nicholas Piggin
2024-03-12 11:51 ` Nicholas Piggin
2024-03-12 12:11 ` Harsh Prateek Bora
2024-03-12 12:46 ` Nicholas Piggin
2024-03-12 12:47 ` Harsh Prateek Bora
2024-03-12 12:51 ` Harsh Prateek Bora
2024-03-12 13:18 ` Harsh Prateek Bora [this message]
2024-03-12 5:52 ` [PATCH v5 00/14] Nested PAPR API (KVM on PowerVM) Nicholas Piggin
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=c374d5f6-c99e-44ed-8e4e-09eb8e80e721@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=amachhiw@linux.vnet.ibm.com \
--cc=clg@kaod.org \
--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).