qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>, qemu-ppc@nongnu.org
Cc: "Daniel\
	 Henrique Barboza" <danielhb413@gmail.com>,
	qemu-devel@nongnu.org, "Fabiano Rosas" <farosas@linux.ibm.com>
Subject: Re: [PATCH v2 9/9] spapr: implement nested-hv capability for the virtual hypervisor
Date: Wed, 16 Feb 2022 21:38:53 +1000	[thread overview]
Message-ID: <1645011231.6p1nag6ali.astroid@bobo.none> (raw)
In-Reply-To: <e8c5834c-22bc-a33d-832e-566284d1daeb@kaod.org>

Excerpts from Cédric Le Goater's message of February 16, 2022 8:52 pm:
> On 2/16/22 11:25, Nicholas Piggin wrote:
>> This implements the Nested KVM HV hcall API for spapr under TCG.
>> 
>> The L2 is switched in when the H_ENTER_NESTED hcall is made, and the
>> L1 is switched back in returned from the hcall when a HV exception
>> is sent to the vhyp. Register state is copied in and out according to
>> the nested KVM HV hcall API specification.
>> 
>> The hdecr timer is started when the L2 is switched in, and it provides
>> the HDEC / 0x980 return to L1.
>> 
>> The MMU re-uses the bare metal radix 2-level page table walker by
>> using the get_pate method to point the MMU to the nested partition
>> table entry. MMU faults due to partition scope errors raise HV
>> exceptions and accordingly are routed back to the L1.
>> 
>> The MMU does not tag translations for the L1 (direct) vs L2 (nested)
>> guests, so the TLB is flushed on any L1<->L2 transition (hcall entry
>> and exit).>
>> Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> 
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
> 
> Some last comments below,

[...]

>> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
>> index edbf3eeed0..852fe61b36 100644
>> --- a/include/hw/ppc/spapr.h
>> +++ b/include/hw/ppc/spapr.h
>> @@ -199,6 +199,9 @@ struct SpaprMachineState {
>>       bool has_graphics;
>>       uint32_t vsmt;       /* Virtual SMT mode (KVM's "core stride") */
>>   
>> +    /* Nested HV support (TCG only) */
>> +    uint64_t nested_ptcr;
>> +
> 
> this is new state to migrate.
> 

[...]

>> +/* Linux 64-bit powerpc pt_regs struct, used by nested HV */
>> +struct kvmppc_pt_regs {
>> +    uint64_t gpr[32];
>> +    uint64_t nip;
>> +    uint64_t msr;
>> +    uint64_t orig_gpr3;    /* Used for restarting system calls */
>> +    uint64_t ctr;
>> +    uint64_t link;
>> +    uint64_t xer;
>> +    uint64_t ccr;
>> +    uint64_t softe;        /* Soft enabled/disabled */
>> +    uint64_t trap;         /* Reason for being here */
>> +    uint64_t dar;          /* Fault registers */
>> +    uint64_t dsisr;        /* on 4xx/Book-E used for ESR */
>> +    uint64_t result;       /* Result of a system call */
>> +};
> 
> I think we need to start moving all the spapr hcall definitions under
> spapr_hcall.h. It can come later.

Sure.

[...]

>> diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h
>> index dab3dfc76c..b560514560 100644
>> --- a/include/hw/ppc/spapr_cpu_core.h
>> +++ b/include/hw/ppc/spapr_cpu_core.h
>> @@ -48,6 +48,11 @@ typedef struct SpaprCpuState {
>>       bool prod; /* not migrated, only used to improve dispatch latencies */
>>       struct ICPState *icp;
>>       struct XiveTCTX *tctx;
>> +
>> +    /* Fields for nested-HV support */
>> +    bool in_nested; /* true while the L2 is executing */
>> +    CPUPPCState *nested_host_state; /* holds the L1 state while L2 executes */
>> +    int64_t nested_tb_offset; /* L1->L2 TB offset */
> 
> This needs a new vmstate.

How about instead of the vmstate (we would need all the L1 state in
nested_host_state as well), we just add a migration blocker in the
L2 entry path. We could limit the max hdecr to say 1 second to
ensure it unblocks before long.

I know migration blockers are not preferred but in this case it gives
us some iterations to debug and optimise first, which might change
the data to migrate.

Thanks,
Nick


  reply	other threads:[~2022-02-16 11:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 10:25 [PATCH v2 0/9] ppc: nested KVM HV for spapr virtual hypervisor Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 1/9] target/ppc: raise HV interrupts for partition table entry problems Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 2/9] spapr: prevent hdec timer being set up under virtual hypervisor Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 3/9] ppc: allow the hdecr timer to be created/destroyed Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 4/9] target/ppc: add vhyp addressing mode helper for radix MMU Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 5/9] target/ppc: make vhyp get_pate method take lpid and return success Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 6/9] target/ppc: add helper for books vhyp hypercall handler Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 7/9] target/ppc: Add powerpc_reset_excp_state helper Nicholas Piggin
2022-02-16 10:25 ` [PATCH v2 8/9] target/ppc: Introduce a vhyp framework for nested HV support Nicholas Piggin
2022-02-16 10:38   ` Cédric Le Goater
2022-02-16 10:25 ` [PATCH v2 9/9] spapr: implement nested-hv capability for the virtual hypervisor Nicholas Piggin
2022-02-16 10:52   ` Cédric Le Goater
2022-02-16 11:38     ` Nicholas Piggin [this message]
2022-02-16 12:30       ` Nicholas Piggin
2022-02-17 17:11         ` Cédric Le Goater
2022-02-18  7:45 ` [PATCH v2 0/9] ppc: nested KVM HV for spapr " Cédric Le Goater

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=1645011231.6p1nag6ali.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=farosas@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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).