From: Alexander Graf <agraf@csgraf.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Cameron Esfahani <dirty@apple.com>,
Roman Bolshakov <r.bolshakov@yadro.com>,
qemu-arm <qemu-arm@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 4/8] arm: Synchronize CPU on PSCI on
Date: Thu, 26 Nov 2020 23:16:21 +0100 [thread overview]
Message-ID: <785c216b-d4b5-b65f-1ddf-4c6374b72ece@csgraf.de> (raw)
In-Reply-To: <CAFEAcA_XZu07Fg3G05VWYDYTJfMSAzOH5yyd=rFLJVa73juDtw@mail.gmail.com>
On 26.11.20 22:47, Peter Maydell wrote:
> On Thu, 26 Nov 2020 at 21:36, Alexander Graf <agraf@csgraf.de> wrote:
>> We are going to reuse the TCG PSCI code for HVF. This however means that we
>> need to ensure that CPU register state is synchronized properly between the
>> two worlds.
>>
>> So let's make sure that at least on the PSCI on call, the secondary core gets
>> to sync its registers after reset, so that changes also propagate.
>>
>> Signed-off-by: Alexander Graf <agraf@csgraf.de>
>> ---
>> target/arm/arm-powerctl.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
>> index b75f813b40..256f7cfdcd 100644
>> --- a/target/arm/arm-powerctl.c
>> +++ b/target/arm/arm-powerctl.c
>> @@ -15,6 +15,7 @@
>> #include "arm-powerctl.h"
>> #include "qemu/log.h"
>> #include "qemu/main-loop.h"
>> +#include "sysemu/hw_accel.h"
>>
>> #ifndef DEBUG_ARM_POWERCTL
>> #define DEBUG_ARM_POWERCTL 0
>> @@ -66,6 +67,8 @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,
>> cpu_reset(target_cpu_state);
>> target_cpu_state->halted = 0;
>>
>> + cpu_synchronize_state(target_cpu_state);
>> +
>> if (info->target_aa64) {
>> if ((info->target_el < 3) && arm_feature(&target_cpu->env,
>> ARM_FEATURE_EL3))
> This looks weird. The CPU was off, so not running anything.
> Why doesn't the state we set up here get synchronized to
> HVF as part of the normal enter-guest-code process that we
> do when we do whatever HVF's equivalent of KVM_RUN is ?
>
> Also, we change more bits of CPU state later in this function,
> so if we do need to manually sychronize in this function this
> doesn't seem like the right place...
cpu_synchronize_state() sets the CPU registers into "dirty" state which
means that env now holds the current copy. On the next entry, we then
sync them back into HVF.
Without the cpu_synchronize_state() call, HVF never knows that the CPU
state is actually dirty. I guess it could as well live in cpu_reset()
somewhere, but we have to get the state switched over to dirty one way
or another.
One interesting thing to note here is that the CPU actually comes up in
"dirty" after init. But init is done on realization already. I'm not
sure why we lose the dirty state in between that and the reset.
Alex
next prev parent reply other threads:[~2020-11-26 22:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201126213600.40654-1-agraf@csgraf.de>
[not found] ` <20201126213600.40654-5-agraf@csgraf.de>
2020-11-26 21:47 ` [PATCH 4/8] arm: Synchronize CPU on PSCI on Peter Maydell
2020-11-26 22:16 ` Alexander Graf [this message]
2020-11-26 22:26 ` Peter Maydell
2020-11-26 23:32 ` Alexander Graf
2020-11-27 4:41 ` Paolo Bonzini
2020-11-27 10:58 ` Alexander Graf
2020-11-27 11:21 ` Paolo Bonzini
[not found] ` <20201126213600.40654-9-agraf@csgraf.de>
2020-11-26 21:54 ` [PATCH 8/8] hw/arm/virt: Disable highmem when on hypervisor.framework Peter Maydell
2020-11-26 22:17 ` Alexander Graf
2020-11-26 22:33 ` Peter Maydell
2020-11-26 21:50 [PATCH 0/8] hvf: Implement Apple Silicon Support Alexander Graf
2020-11-26 21:50 ` [PATCH 4/8] arm: Synchronize CPU on PSCI on Alexander Graf
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=785c216b-d4b5-b65f-1ddf-4c6374b72ece@csgraf.de \
--to=agraf@csgraf.de \
--cc=dirty@apple.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
--cc=richard.henderson@linaro.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.