Skip to contentSkip to conversation

whpx: i386: documentation and demoting some warnings

PATCH Superseded Mohamed Mediouni 2 participants 7 messages Mar 26 Arm/Amlogic Meson SoC support

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover whpx: i386: documentation and demoting some warnings

Demoting some warnings that appeared too often
and adding some documentation.

Mohamed Mediouni (3):
docs: add WHPX section with initial info
whpx: i386: trace unsupported MSR accesses
target/i386: emulate: LOG_GUEST_ERROR for read/write from unmapped
MMIO

 MAINTAINERS                   |   1 +
 docs/system/index.rst         |   1 +
 docs/system/whpx.rst          | 144 ++++++++++++++++++++++++++++++++++
 meson.build                   |   1 +
 target/i386/emulate/x86_mmu.c |   6 +-
 target/i386/whpx/trace-events |   1 +
 target/i386/whpx/trace.h      |   2 +
 target/i386/whpx/whpx-all.c   |   5 +-
 8 files changed, 156 insertions(+), 5 deletions(-)
 create mode 100644 docs/system/whpx.rst
 create mode 100644 target/i386/whpx/trace-events
 create mode 100644 target/i386/whpx/trace.h
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

PATCH v4 1/3 docs: add WHPX section with initial info

---
 MAINTAINERS           |   1 +
 docs/system/index.rst |   1 +
 docs/system/whpx.rst  | 144 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 docs/system/whpx.rst
MAINTAINERS +1 -0
index cd8ba14450..eb7132e39d 100644
@@ -582,6 +582,7 @@ F: include/system/whpx.h
 F: include/system/whpx-accel-ops.h
 F: include/system/whpx-common.h
 F: include/system/whpx-internal.h
+F: docs/system/whpx.rst
 
 MSHV
 M: Magnus Kulke <[email protected]>
docs/system/index.rst +1 -0
index bb948e2993..4509630fa4 100644
@@ -40,6 +40,7 @@ or Hypervisor.Framework.
    confidential-guest-support
    igvm
    nitro
+   whpx
    vm-templating
    sriov
    qemu-colo
docs/system/whpx.rst new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.50.1 (Apple Git-155)
#3 lore raw

PATCH v4 2/3 whpx: i386: trace unsupported MSR accesses

In reply to Mohamed Mediouni

Not actionable information for users, so stop
having it displayed unconditionally.

---
 meson.build                   | 1 +
 target/i386/whpx/trace-events | 1 +
 target/i386/whpx/trace.h      | 2 ++
 target/i386/whpx/whpx-all.c   | 5 +++--
 4 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 target/i386/whpx/trace-events
 create mode 100644 target/i386/whpx/trace.h
meson.build +1 -0
index e6f17dd5f7..c19c5afa46 100644
@@ -3692,6 +3692,7 @@ if have_system or have_user
     'target/hppa',
     'target/i386',
     'target/i386/kvm',
+    'target/i386/whpx',
     'target/loongarch',
     'target/mips/tcg',
     'target/ppc',
target/i386/whpx/trace-events new file +1 -0
new file mode 100644
index 0000000000..ebdfa34b28
@@ -0,0 +1 @@
+whpx_unsupported_msr_access(uint32_t msr, int is_write) "WHPX: Unsupported MSR access (0x%x), IsWrite=%i"
target/i386/whpx/trace.h new file +2 -0
new file mode 100644
index 0000000000..b7c090deff
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include "trace/trace-target_i386_whpx.h"
target/i386/whpx/whpx-all.c +3 -2
index acae61e089..e56ae2b343 100644
@@ -41,6 +41,7 @@
 #include "emulate/x86_emu.h"
 #include "emulate/x86_flags.h"
 #include "emulate/x86_mmu.h"
+#include "trace.h"
 
 #include <winhvplatform.h>
 
@@ -1921,8 +1922,8 @@ int whpx_vcpu_run(CPUState *cpu)
                         1 : 3;
 
             if (!is_known_msr) {
-                warn_report("WHPX: Unsupported MSR access (0x%x), IsWrite=%i", 
-                vcpu->exit_ctx.MsrAccess.MsrNumber, vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite);
+                trace_whpx_unsupported_msr_access(vcpu->exit_ctx.MsrAccess.MsrNumber,
+                    vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite);
             }
 
             hr = whp_dispatch.WHvSetVirtualProcessorRegisters(
Signature · 1 line
2.50.1 (Apple Git-155)
#4 lore raw

PATCH v4 3/3 target/i386: emulate: LOG_GUEST_ERROR for read/write from unmapped MMIO

In reply to Mohamed Mediouni

ReactOS's install ISO does a bunch of 4-byte accesses to 0xffdff124. This doesn't happen for the boot ISO.

It looks to be an access relative to the Windows KPCR which is at 0xffdff000 but mistakenly done prior to paging being on...

https://geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/i386_x/kpcr.htm

---
 target/i386/emulate/x86_mmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/i386/emulate/x86_mmu.c +3 -3
index c69ae96acb..815d01d97f 100644
@@ -21,7 +21,7 @@
 #include "cpu.h"
 #include "system/address-spaces.h"
 #include "system/memory.h"
-#include "qemu/error-report.h"
+#include "qemu/log.h"
 #include "emulate/x86.h"
 #include "emulate/x86_emu.h"
 #include "emulate/x86_mmu.h"
@@ -287,7 +287,7 @@ static MMUTranslateResult x86_write_mem_ex(CPUState *cpu, void *data, target_ulo
                             MEMTXATTRS_UNSPECIFIED, data, copy);
 
         if (mem_tx_res == MEMTX_DECODE_ERROR) {
-            warn_report("write to unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
+            qemu_log_mask(LOG_GUEST_ERROR, "write to unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
             return MMU_TRANSLATE_GPA_UNMAPPED;
         } else if (mem_tx_res == MEMTX_ACCESS_ERROR) {
             return MMU_TRANSLATE_GPA_NO_WRITE_ACCESS;
@@ -339,7 +339,7 @@ static MMUTranslateResult x86_read_mem_ex(CPUState *cpu, void *data, target_ulon
                            data, copy);
 
         if (mem_tx_res == MEMTX_DECODE_ERROR) {
-            warn_report("read from unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
+            qemu_log_mask(LOG_GUEST_ERROR, "read from unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
             return MMU_TRANSLATE_GPA_UNMAPPED;
         } else if (mem_tx_res == MEMTX_ACCESS_ERROR) {
             return MMU_TRANSLATE_GPA_NO_READ_ACCESS;
Signature · 1 line
2.50.1 (Apple Git-155)
#5 lore raw

Re: [PATCH v4 3/3] target/i386: emulate: LOG_GUEST_ERROR for read/write from unmapped MMIO

Quoted 7 lines · Mohamed Mediouni

ReactOS's install ISO does a bunch of 4-byte accesses to 0xffdff124. This doesn't happen for the boot ISO.

Quoted 7 lines

It looks to be an access relative to the Windows KPCR which is at 0xffdff000 but mistakenly done prior to paging being on...

https://geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/i386_x/kpcr.htm

Thinking about it more, this is not necessary.

Because -d invalid_mem logs this already…

Sending a new revision… (and got it confirmed that ReactOS does the same thing under TCG…)

Quoted 38 lines

---
target/i386/emulate/x86_mmu.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
target/i386/emulate/x86_mmu.c +3 -3
index c69ae96acb..815d01d97f 100644
@@ -21,7 +21,7 @@
 #include "cpu.h"
 #include "system/address-spaces.h"
 #include "system/memory.h"
-#include "qemu/error-report.h"
+#include "qemu/log.h"
 #include "emulate/x86.h"
 #include "emulate/x86_emu.h"
 #include "emulate/x86_mmu.h"
@@ -287,7 +287,7 @@ static MMUTranslateResult x86_write_mem_ex(CPUState *cpu, void *data, target_ulo
                            MEMTXATTRS_UNSPECIFIED, data, copy);
 
        if (mem_tx_res == MEMTX_DECODE_ERROR) {
-            warn_report("write to unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
+            qemu_log_mask(LOG_GUEST_ERROR, "write to unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
            return MMU_TRANSLATE_GPA_UNMAPPED;
        } else if (mem_tx_res == MEMTX_ACCESS_ERROR) {
            return MMU_TRANSLATE_GPA_NO_WRITE_ACCESS;
@@ -339,7 +339,7 @@ static MMUTranslateResult x86_read_mem_ex(CPUState *cpu, void *data, target_ulon
                           data, copy);
 
        if (mem_tx_res == MEMTX_DECODE_ERROR) {
-            warn_report("read from unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
+            qemu_log_mask(LOG_GUEST_ERROR, "read from unmapped mmio region gpa=0x%" PRIx64 " size=%i", gpa, bytes);
            return MMU_TRANSLATE_GPA_UNMAPPED;
        } else if (mem_tx_res == MEMTX_ACCESS_ERROR) {
            return MMU_TRANSLATE_GPA_NO_READ_ACCESS;
Signature · 1 line
2.50.1 (Apple Git-155)
Reviewed-by on v4 3/3
#6 lore raw

Re: [PATCH v4 3/3] target/i386: emulate: LOG_GUEST_ERROR for read/write from unmapped MMIO

In reply to Mohamed Mediouni
Quoted 7 lines · Mohamed Mediouni

ReactOS's install ISO does a bunch of 4-byte accesses to 0xffdff124. This doesn't happen for the boot ISO.

It looks to be an access relative to the Windows KPCR which is at 0xffdff000 but mistakenly done prior to paging being on...

Quoted 7 lines

https://geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/i386_x/kpcr.htm

---
  target/i386/emulate/x86_mmu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)