qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/7] target/i386: implement RDPID in TCG


From: Richard Henderson
Subject: Re: [PATCH 6/7] target/i386: implement RDPID in TCG
Date: Mon, 19 Jun 2023 09:40:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

On 6/18/23 23:51, Paolo Bonzini wrote:
RDPID corresponds to a RDMSR(TSC_AUX); however, it is unprivileged
so for user-mode emulation we must provide the value that the kernel
places in the MSR.  For Linux, it is a combination of the current CPU
and the current NUMA node, both of which can be retrieved with getcpu(2).
For BSD, just return 0.

RDTSCP is reimplemented as RDTSC + RDPID ECX; the differences in terms
of serializability are not relevant to QEMU.

Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
---
  linux-user/i386/target_cpu.h   |  8 ++++++++
  linux-user/x86_64/target_cpu.h |  1 +
  target/i386/cpu.c              | 10 +++++++++-
  target/i386/helper.h           |  2 +-
  target/i386/tcg/misc_helper.c  | 21 +++++++++++++++------
  target/i386/tcg/translate.c    | 15 +++++++++++++--
  6 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h
index 52caf788cc3..3539f790222 100644
--- a/linux-user/i386/target_cpu.h
+++ b/linux-user/i386/target_cpu.h
@@ -54,4 +54,12 @@ static inline abi_ulong get_sp_from_cpustate(CPUX86State 
*state)
  {
      return state->regs[R_ESP];
  }
+
+static inline uint32_t get_cpunode(void)
+{
+    unsigned cpu, node;
+    getcpu(&cpu, &node);
+    return (node << 12) | (cpu & 0xfff);
+}
+

What is our minimum glibc version?  This requires 2.29.

Also, not especially fond of the placement. target/ including linux-user/ header isn't nice. Might as well just place these 3 lines in misc_helper.c to begin.

r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]