From: Nicholas Piggin <npiggin@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [RFC PATCH 3/3] spapr: implement nested-hv support for the TCG virtual hypervisor
Date: Tue, 15 Feb 2022 09:28:08 +1000 [thread overview]
Message-ID: <1644881088.rvm7j0emi0.astroid@bobo.none> (raw)
In-Reply-To: <aaaf8ca4-9685-f600-9082-bc3a80eb59c9@kaod.org>
Excerpts from Cédric Le Goater's message of February 15, 2022 4:31 am:
> On 2/10/22 07:53, Nicholas Piggin wrote:
>> +void cpu_ppc_hdecr_init (CPUPPCState *env)
>> +{
>> + PowerPCCPU *cpu = env_archcpu(env);
>> +
>> + assert(env->tb_env->hdecr_timer == NULL);
>> +
>> + env->tb_env->hdecr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &cpu_ppc_hdecr_cb,
>> + cpu);
>> +}
>> +
>> +void cpu_ppc_hdecr_exit (CPUPPCState *env)
>> +{
>> + PowerPCCPU *cpu = env_archcpu(env);
>> +
>> + timer_free(env->tb_env->hdecr_timer);
>> + env->tb_env->hdecr_timer = NULL;
>> +
>> + cpu_ppc_hdecr_lower(cpu);
>> +}
>
>
> So these are called every time a L2 enters or exits ?
Yes.
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 3d6ec309dd..f0c3f726f2 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1273,6 +1273,8 @@ static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp,
>> if (msr_pr) {
>> hcall_dprintf("Hypercall made with MSR[PR]=1\n");
>> env->gpr[3] = H_PRIVILEGE;
>> + } else if (env->gpr[3] == KVMPPC_H_ENTER_NESTED) {
>> + spapr_enter_nested(cpu);
>
> Can not this be in the hcall table ?
See reply to Fabiano, I think it can be.
>> } else {
>> env->gpr[3] = spapr_hypercall(cpu, env->gpr[3], &env->gpr[4]);
>> }
>> @@ -4465,6 +4467,17 @@ PowerPCCPU *spapr_find_cpu(int vcpu_id)
>> return NULL;
>> }
>>
>> +static bool spapr_cpu_in_nested(PowerPCCPU *cpu)
>> +{
>> + return cpu->in_spapr_nested;
>> +}
>
> This handler is not very much used.
Yeah, I have improved that in the current code, hopefully doesn't
open-code cpu->in_spapr_nested anywhere outside spapr specifics.
>> +void spapr_enter_nested(PowerPCCPU *cpu)
>> +{
>> + SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
>> + CPUState *cs = CPU(cpu);
>> + CPUPPCState *env = &cpu->env;
>> + target_ulong hv_ptr = env->gpr[4];
>> + target_ulong regs_ptr = env->gpr[5];
>> + target_ulong hdec, now = cpu_ppc_load_tbl(env);
>> + struct kvmppc_hv_guest_state *hvstate;
>> + struct kvmppc_hv_guest_state hv_state;
>> + struct kvmppc_pt_regs *regs;
>> + hwaddr len;
>> + uint32_t cr;
>> + int i;
>> +
>> + if (cpu->in_spapr_nested) {
>> + env->gpr[3] = H_FUNCTION;
>> + return;
>> + }
>> + if (spapr->nested_ptcr == 0) {
>> + env->gpr[3] = H_NOT_AVAILABLE;
>> + return;
>> + }
>> +
>> + len = sizeof(*hvstate);
>> + hvstate = cpu_physical_memory_map(hv_ptr, &len,
>
> Are you writing to the state ? address_space_map() is a better pratice.
Yes, in exit_nested it gets written. I'll take a look at
address_space_map().
>> @@ -916,7 +924,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
>> env->nip += 4;
>>
>> /* "PAPR mode" built-in hypercall emulation */
>> - if ((lev == 1) && cpu->vhyp) {
>> + if ((lev == 1) && cpu->vhyp && !cpu->in_spapr_nested) {
>
> an helper for (cpu->vhyp && !cpu->in_spapr_nested) would help.
Yeah, I put some helpers in the mmu code since this patch which is
nicer. Will try to do the same for this.
Thanks,
Nick
next prev parent reply other threads:[~2022-02-14 23:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 6:53 [RFC PATCH 0/3] spapr: nested-hv support for TCG Nicholas Piggin
2022-02-10 6:53 ` [RFC PATCH 1/3] target/ppc: raise HV interrupts for partition table entry problems Nicholas Piggin
2022-02-10 6:53 ` [RFC PATCH 2/3] spapr: prevent hdec timer being set up under virtual hypervisor Nicholas Piggin
2022-02-10 6:53 ` [RFC PATCH 3/3] spapr: implement nested-hv support for the TCG " Nicholas Piggin
2022-02-14 14:32 ` Fabiano Rosas
2022-02-14 23:24 ` Nicholas Piggin
2022-02-14 18:31 ` Cédric Le Goater
2022-02-14 23:28 ` Nicholas Piggin [this message]
2022-02-15 2:57 ` 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=1644881088.rvm7j0emi0.astroid@bobo.none \
--to=npiggin@gmail.com \
--cc=clg@kaod.org \
--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 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.