qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>,
	qemu-block@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>,
	qemu-arm <qemu-arm@nongnu.org>
Subject: Re: [PATCH 3/3] sysemu/replay: Restrict icount to system emulation
Date: Thu, 7 Dec 2023 14:51:23 +0100	[thread overview]
Message-ID: <8665d22d-6606-49b4-91a9-124ca68775b2@linaro.org> (raw)
In-Reply-To: <41f23b62-15ae-4e1e-98ee-a3cbcf0f7789@linaro.org>

On 7/12/23 14:46, Philippe Mathieu-Daudé wrote:
> On 7/12/23 11:26, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/sysemu/cpu-timers.h |  2 +-
>>   include/sysemu/replay.h     |  9 ++++++---
>>   stubs/icount.c              | 19 -------------------
>>   3 files changed, 7 insertions(+), 23 deletions(-)
>>
>> diff --git a/include/sysemu/cpu-timers.h b/include/sysemu/cpu-timers.h
>> index 2e786fe7fb..188f67ee90 100644
>> --- a/include/sysemu/cpu-timers.h
>> +++ b/include/sysemu/cpu-timers.h
>> @@ -24,7 +24,7 @@ void cpu_timers_init(void);
>>    * 1 = Enabled - Fixed conversion of insn to ns via "shift" option
>>    * 2 = Enabled - Runtime adaptive algorithm to compute shift
>>    */
>> -#ifdef CONFIG_TCG
>> +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
>>   extern int use_icount;
>>   #define icount_enabled() (use_icount)
>>   #else
>> diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
>> index 02fa75c783..8102fa54f0 100644
>> --- a/include/sysemu/replay.h
>> +++ b/include/sysemu/replay.h
>> @@ -1,6 +1,3 @@
>> -#ifndef SYSEMU_REPLAY_H
>> -#define SYSEMU_REPLAY_H
>> -
>>   /*
>>    * QEMU replay (system interface)
>>    *
>> @@ -11,6 +8,12 @@
>>    * See the COPYING file in the top-level directory.
>>    *
>>    */
>> +#ifndef SYSEMU_REPLAY_H
>> +#define SYSEMU_REPLAY_H
>> +
>> +#ifdef CONFIG_USER_ONLY
>> +#error Cannot include this header from user emulation
>> +#endif
>>   #include "exec/replay-core.h"
>>   #include "qapi/qapi-types-misc.h"
>> diff --git a/stubs/icount.c b/stubs/icount.c
>> index c39a65da92..ec8d150069 100644
>> --- a/stubs/icount.c
>> +++ b/stubs/icount.c
>> @@ -5,30 +5,11 @@
>>   int use_icount;
>> -void icount_update(CPUState *cpu)
>> -{
>> -    abort();
>> -}
>>   int64_t icount_get_raw(void)
>>   {
>>       abort();
>>       return 0;
>>   }
>> -int64_t icount_get(void)
>> -{
>> -    abort();
>> -    return 0;
>> -}
>> -int64_t icount_to_ns(int64_t icount)
>> -{
>> -    abort();
>> -    return 0;
>> -}
> 
> Build failure on HVF due to:
> 
>    pmu_init()
>     -> pm_events[]
>      -> INST_RETIRED
>       -> instructions_ns_per()
>        -> icount_to_ns()
> 
> So we need to keep the icount_to_ns() stub until we restrict
> ARM PMU code to TCG.

Alternatively, we can use as a preliminary patch:

-- >8 --
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 20e13215bb..48ab1e0523 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -939,11 +939,13 @@ static bool instructions_supported(CPUARMState *env)

  static uint64_t instructions_get_count(CPUARMState *env)
  {
+    assert(icount_enabled());
      return (uint64_t)icount_get_raw();
  }

  static int64_t instructions_ns_per(uint64_t icount)
  {
+    assert(icount_enabled());
      return icount_to_ns((int64_t)icount);
  }
  #endif
---



      reply	other threads:[~2023-12-07 13:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 10:26 [PATCH 0/3] sysemu/replay: Restrict icount to TCG system emulation Philippe Mathieu-Daudé
2023-12-07 10:26 ` [PATCH 1/3] util/async: Only call icount_notify_exit() if icount is enabled Philippe Mathieu-Daudé
2023-12-07 10:26 ` [PATCH 2/3] sysemu/replay: Restrict icount to TCG emulation Philippe Mathieu-Daudé
2023-12-07 10:26 ` [PATCH 3/3] sysemu/replay: Restrict icount to system emulation Philippe Mathieu-Daudé
2023-12-07 13:46   ` Philippe Mathieu-Daudé
2023-12-07 13:51     ` Philippe Mathieu-Daudé [this message]

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=8665d22d-6606-49b4-91a9-124ca68775b2@linaro.org \
    --to=philmd@linaro.org \
    --cc=fam@euphon.net \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).