From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Harsh Prateek Bora" <harshpb@linux.ibm.com>, <qemu-ppc@nongnu.org>
Cc: <clegoate@redhat.com>, <qemu-devel@nongnu.org>,
<mikey@neuling.org>, <vaibhav@linux.ibm.com>,
<jniethe5@gmail.com>, <sbhat@linux.ibm.com>,
<kconsul@linux.vnet.ibm.com>, <danielhb413@gmail.com>
Subject: Re: [PATCH v2 11/14] spapr: nested: Use correct source for parttbl info for nested PAPR API.
Date: Wed, 29 Nov 2023 14:15:17 +1000 [thread overview]
Message-ID: <CXB065Z14ATU.3V8KU00E4QYP8@wheely> (raw)
In-Reply-To: <20231012104951.194876-12-harshpb@linux.ibm.com>
On Thu Oct 12, 2023 at 8:49 PM AEST, Harsh Prateek Bora wrote:
> For nested PAPR API, we use SpaprMachineStateNestedGuest struct to store
> partition table info, use the same in spapr_get_pate_nested() as well.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
> hw/ppc/spapr.c | 5 +---
> hw/ppc/spapr_nested.c | 49 +++++++++++++++++++++++------------
> include/hw/ppc/spapr_nested.h | 3 +++
> 3 files changed, 36 insertions(+), 21 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 14196fdd11..e1f7b29842 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1356,10 +1356,7 @@ static bool spapr_get_pate(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu,
> return true;
> } else {
> assert(spapr->nested.api);
> - if (spapr->nested.api == NESTED_API_KVM_HV) {
> - return spapr_get_pate_nested(spapr, cpu, lpid, entry);
> - }
> - return false;
> + return spapr_get_pate_nested(spapr, cpu, lpid, entry);
If you don't permit the api to be changed to PAPR at the start, then you
don't need to juggle this back and forth.
> }
> }
>
> diff --git a/hw/ppc/spapr_nested.c b/hw/ppc/spapr_nested.c
> index f41b0c0944..1917d8bb13 100644
> --- a/hw/ppc/spapr_nested.c
> +++ b/hw/ppc/spapr_nested.c
> @@ -19,29 +19,45 @@ void spapr_nested_init(SpaprMachineState *spapr)
> bool spapr_get_pate_nested(SpaprMachineState *spapr, PowerPCCPU *cpu,
> target_ulong lpid, ppc_v3_pate_t *entry)
> {
> - uint64_t patb, pats;
> + if (spapr->nested.api == NESTED_API_KVM_HV) {
Maybe split out the implementations into two functions?
And actually instead of open coding the API test, I'm thinking
maybe you should add a helper function
spapr_cpu_nested_api(cpu) which returns NESTED_API_... and you
can just hard code it to return spapr->nested.api for now.
That should avoid a bunch of churn when we permit guests to
run with different APIs.
> + uint64_t patb, pats;
>
> - assert(lpid != 0);
> + assert(lpid != 0);
>
> - patb = spapr->nested.ptcr & PTCR_PATB;
> - pats = spapr->nested.ptcr & PTCR_PATS;
> + patb = spapr->nested.ptcr & PTCR_PATB;
> + pats = spapr->nested.ptcr & PTCR_PATS;
>
> - /* Check if partition table is properly aligned */
> - if (patb & MAKE_64BIT_MASK(0, pats + 12)) {
> - return false;
> - }
> + /* Check if partition table is properly aligned */
> + if (patb & MAKE_64BIT_MASK(0, pats + 12)) {
> + return false;
> + }
>
> - /* Calculate number of entries */
> - pats = 1ull << (pats + 12 - 4);
> - if (pats <= lpid) {
> - return false;
> + /* Calculate number of entries */
> + pats = 1ull << (pats + 12 - 4);
> + if (pats <= lpid) {
> + return false;
> + }
> +
> + /* Grab entry */
> + patb += 16 * lpid;
> + entry->dw0 = ldq_phys(CPU(cpu)->as, patb);
> + entry->dw1 = ldq_phys(CPU(cpu)->as, patb + 8);
> + return true;
> }
> +#ifdef CONFIG_TCG
Nested spapr is entirely TCG, no? If we're not properly guarding the
nested code with CONFIG_TCG, that should go as an initial prep patch.
Thanks,
Nick
> + /* Nested PAPR API */
> + SpaprMachineStateNestedGuest *guest;
> + assert(lpid != 0);
> + guest = spapr_get_nested_guest(spapr, lpid);
> + assert(guest != NULL);
> +
> + entry->dw0 = guest->parttbl[0];
> + entry->dw1 = guest->parttbl[1];
>
> - /* Grab entry */
> - patb += 16 * lpid;
> - entry->dw0 = ldq_phys(CPU(cpu)->as, patb);
> - entry->dw1 = ldq_phys(CPU(cpu)->as, patb + 8);
> return true;
> +#else
> + return false;
> +#endif
> }
>
> #ifdef CONFIG_TCG
> @@ -412,7 +428,6 @@ void spapr_exit_nested(PowerPCCPU *cpu, int excp)
> address_space_unmap(CPU(cpu)->as, regs, len, len, true);
> }
>
> -static
> SpaprMachineStateNestedGuest *spapr_get_nested_guest(SpaprMachineState *spapr,
> target_ulong guestid)
> {
> diff --git a/include/hw/ppc/spapr_nested.h b/include/hw/ppc/spapr_nested.h
> index d27688b1b8..e04202ecb4 100644
> --- a/include/hw/ppc/spapr_nested.h
> +++ b/include/hw/ppc/spapr_nested.h
> @@ -457,4 +457,7 @@ bool spapr_get_pate_nested(SpaprMachineState *spapr, PowerPCCPU *cpu,
> void spapr_register_nested_papr(void);
> void spapr_nested_init(SpaprMachineState *spapr);
> void spapr_nested_gsb_init(void);
> +SpaprMachineStateNestedGuest *spapr_get_nested_guest(SpaprMachineState *spapr,
> + target_ulong lpid);
> +
> #endif /* HW_SPAPR_NESTED_H */
next prev parent reply other threads:[~2023-11-29 4:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 10:49 [PATCH v2 00/14] Nested PAPR API (KVM on PowerVM) Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 01/14] spapr: nested: move nested part of spapr_get_pate into spapr_nested.c Harsh Prateek Bora
2023-11-29 3:47 ` Nicholas Piggin
2023-10-12 10:49 ` [PATCH v2 02/14] spapr: nested: Introduce SpaprMachineStateNested to store related info Harsh Prateek Bora
2023-11-29 3:48 ` Nicholas Piggin
2023-10-12 10:49 ` [PATCH v2 03/14] spapr: nested: Document Nested PAPR API Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 04/14] spapr: nested: Introduce cap-nested-papr for " Harsh Prateek Bora
2023-11-29 4:01 ` Nicholas Piggin
2023-11-30 6:19 ` Harsh Prateek Bora
2023-11-30 11:11 ` Nicholas Piggin
2023-12-01 5:34 ` Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 05/14] spapr: nested: register nested-hv api hcalls only for cap-nested-hv Harsh Prateek Bora
2023-11-29 4:03 ` Nicholas Piggin
2023-10-12 10:49 ` [PATCH v2 06/14] spapr: nested: Introduce H_GUEST_[GET|SET]_CAPABILITIES hcalls Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 07/14] spapr: nested: Introduce H_GUEST_[CREATE|DELETE] hcalls Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 08/14] spapr: nested: Introduce H_GUEST_CREATE_VPCU hcall Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 09/14] spapr: nested: Initialize the GSB elements lookup table Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 10/14] spapr: nested: Introduce H_GUEST_[GET|SET]_STATE hcalls Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 11/14] spapr: nested: Use correct source for parttbl info for nested PAPR API Harsh Prateek Bora
2023-11-29 4:15 ` Nicholas Piggin [this message]
2023-10-12 10:49 ` [PATCH v2 12/14] spapr: nested: rename nested_host_state to nested_hv_host Harsh Prateek Bora
2023-10-12 10:49 ` [PATCH v2 13/14] spapr: nested: keep nested-hv exit code restricted to its API Harsh Prateek Bora
2023-11-29 4:16 ` Nicholas Piggin
2023-10-12 10:49 ` [PATCH v2 14/14] spapr: nested: Introduce H_GUEST_RUN_VCPU hcall Harsh Prateek Bora
2023-11-29 4:58 ` Nicholas Piggin
2023-11-13 13:15 ` [PATCH v2 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=CXB065Z14ATU.3V8KU00E4QYP8@wheely \
--to=npiggin@gmail.com \
--cc=clegoate@redhat.com \
--cc=danielhb413@gmail.com \
--cc=harshpb@linux.ibm.com \
--cc=jniethe5@gmail.com \
--cc=kconsul@linux.vnet.ibm.com \
--cc=mikey@neuling.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.