All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/13] host: Support macOS 12
@ 2022-02-11 16:34 Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 01/13] lcitool: refresh Philippe Mathieu-Daudé via
                   ` (12 more replies)
  0 siblings, 13 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

Few patches to be able to build QEMU on macOS 12 (Monterey).

This basically consists of adapting deprecated APIs.

CI job added to avoid bitrotting.

Since v3:
- Fix --enable-modules
- Ignore #pragma on softfloat3 tests
- Addressed Akihiko Odaki comments
- Include Cameron Esfahani patches

Since v2:
- Addressed Akihiko Odaki comments:
  . use __is_identifier(),
  . remove cocoa setAllowedFileTypes()
- Addressed Daniel Berrangé comment:
  . rebased on testing/next, update libvirt-ci/lcitool

Based on Alex's testing/next

Cameron Esfahani (3):
  hvf: Use standard CR0 and CR4 register definitions
  hvf: Fix OOB write in RDTSCP instruction decode
  hvf: Enable RDTSCP support

Philippe Mathieu-Daudé (10):
  lcitool: refresh
  configure: Allow passing extra Objective C compiler flags
  tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives
  hvf: Make hvf_get_segments() / hvf_put_segments() local
  hvf: Remove deprecated hv_vcpu_flush() calls
  block/file-posix: Remove a deprecation warning on macOS 12
  audio/coreaudio: Remove a deprecation warning on macOS 12
  audio/dbus: Fix building with modules on macOS
  ui/cocoa: Remove allowedFileTypes restriction in SavePanel
  gitlab-ci: Support macOS 12 via cirrus-run

 .gitlab-ci.d/cirrus.yml                    | 16 ++++++++++
 .gitlab-ci.d/cirrus/macos-12.vars          | 16 ++++++++++
 audio/coreaudio.c                          | 17 +++++++----
 audio/meson.build                          |  2 +-
 block/file-posix.c                         | 14 ++++++---
 configure                                  |  8 +++++
 meson.build                                |  5 ++++
 target/i386/hvf/hvf.c                      | 26 +++++++++++------
 target/i386/hvf/vmcs.h                     |  3 +-
 target/i386/hvf/vmx.h                      | 19 ++++++------
 target/i386/hvf/x86.c                      |  6 ++--
 target/i386/hvf/x86.h                      | 34 ----------------------
 target/i386/hvf/x86_cpuid.c                |  7 +++--
 target/i386/hvf/x86_decode.c               | 11 +++++--
 target/i386/hvf/x86_mmu.c                  |  2 +-
 target/i386/hvf/x86_task.c                 |  4 +--
 target/i386/hvf/x86hvf.c                   | 14 ++++++---
 target/i386/hvf/x86hvf.h                   |  3 +-
 tests/docker/dockerfiles/ubuntu1804.docker |  2 --
 tests/docker/dockerfiles/ubuntu2004.docker |  2 --
 tests/fp/meson.build                       |  1 +
 tests/lcitool/refresh                      |  1 +
 ui/cocoa.m                                 |  6 ----
 23 files changed, 127 insertions(+), 92 deletions(-)
 create mode 100644 .gitlab-ci.d/cirrus/macos-12.vars

-- 
2.34.1



^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v4 01/13] lcitool: refresh
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-12 15:14   ` Akihiko Odaki
  2022-02-11 16:34 ` [PATCH v4 02/13] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé via
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/docker/dockerfiles/ubuntu1804.docker | 2 --
 tests/docker/dockerfiles/ubuntu2004.docker | 2 --
 2 files changed, 4 deletions(-)

diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dockerfiles/ubuntu1804.docker
index 699f2dfc6a..040938277a 100644
--- a/tests/docker/dockerfiles/ubuntu1804.docker
+++ b/tests/docker/dockerfiles/ubuntu1804.docker
@@ -65,7 +65,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libpam0g-dev \
             libpcre2-dev \
             libpixman-1-dev \
-            libpmem-dev \
             libpng-dev \
             libpulse-dev \
             librbd-dev \
@@ -89,7 +88,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libvdeplug-dev \
             libvirglrenderer-dev \
             libvte-2.91-dev \
-            libxen-dev \
             libzstd-dev \
             llvm \
             locales \
diff --git a/tests/docker/dockerfiles/ubuntu2004.docker b/tests/docker/dockerfiles/ubuntu2004.docker
index 87513125b8..159e7f60c9 100644
--- a/tests/docker/dockerfiles/ubuntu2004.docker
+++ b/tests/docker/dockerfiles/ubuntu2004.docker
@@ -66,7 +66,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libpam0g-dev \
             libpcre2-dev \
             libpixman-1-dev \
-            libpmem-dev \
             libpng-dev \
             libpulse-dev \
             librbd-dev \
@@ -91,7 +90,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libvdeplug-dev \
             libvirglrenderer-dev \
             libvte-2.91-dev \
-            libxen-dev \
             libzstd-dev \
             llvm \
             locales \
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 02/13] configure: Allow passing extra Objective C compiler flags
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 01/13] lcitool: refresh Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 03/13] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé via
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

We can pass C/CPP/LD flags via CFLAGS/CXXFLAGS/LDFLAGS environment
variables, or via configure --extra-cflags / --extra-cxxflags /
--extra-ldflags options. Provide similar behavior for Objective C:
use existing flags from $OBJCFLAGS, or passed via --extra-objcflags.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 configure   | 8 ++++++++
 meson.build | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/configure b/configure
index 3a29eff5cc..06c03cebd3 100755
--- a/configure
+++ b/configure
@@ -287,6 +287,7 @@ done
 
 EXTRA_CFLAGS=""
 EXTRA_CXXFLAGS=""
+EXTRA_OBJCFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
@@ -391,9 +392,12 @@ for opt do
   --extra-cflags=*)
     EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
     EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
+    EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
     ;;
   --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
   ;;
+  --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
+  ;;
   --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
   ;;
   --enable-debug-info) debug_info="yes"
@@ -774,6 +778,8 @@ for opt do
   ;;
   --extra-cxxflags=*)
   ;;
+  --extra-objcflags=*)
+  ;;
   --extra-ldflags=*)
   ;;
   --enable-debug-info)
@@ -1312,6 +1318,7 @@ Advanced options (experts only):
   --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
   --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS
   --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
+  --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
   --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
   --cross-cc-cflags-ARCH=  use compiler flags when building ARCH guest tests
@@ -3724,6 +3731,7 @@ if test "$skip_meson" = no; then
   echo "[built-in options]" >> $cross
   echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
   echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
+  test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
   echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
   echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
   echo "[binaries]" >> $cross
diff --git a/meson.build b/meson.build
index ae5f7eec6e..df25e7a5e7 100644
--- a/meson.build
+++ b/meson.build
@@ -3292,6 +3292,11 @@ if link_language == 'cpp'
                                                + ['-O' + get_option('optimization')]
                                                + (get_option('debug') ? ['-g'] : []))}
 endif
+if targetos == 'darwin'
+  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args')
+                                               + ['-O' + get_option('optimization')]
+                                               + (get_option('debug') ? ['-g'] : []))}
+endif
 link_args = get_option(link_language + '_link_args')
 if link_args.length() > 0
   summary_info += {'LDFLAGS':         ' '.join(link_args)}
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 03/13] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 01/13] lcitool: refresh Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 02/13] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 04/13] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé via
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

Since we already use -Wno-unknown-pragmas, we can also use
-Wno-ignored-pragmas. This silences hundred of warnings using
clang 13 on macOS Monterey:

  [409/771] Compiling C object tests/fp/libtestfloat.a.p/berkeley-testfloat-3_source_test_az_f128_rx.c.o
  ../tests/fp/berkeley-testfloat-3/source/test_az_f128_rx.c:49:14: warning: '#pragma FENV_ACCESS' is not supported on this target - ignored [-Wignored-pragmas]
  #pragma STDC FENV_ACCESS ON
               ^
  1 warning generated.

Having:

  $ cc -v
  Apple clang version 13.0.0 (clang-1300.0.29.30)

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/fp/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/fp/meson.build b/tests/fp/meson.build
index 59776a00a7..5192264a08 100644
--- a/tests/fp/meson.build
+++ b/tests/fp/meson.build
@@ -30,6 +30,7 @@ tfcflags = [
   '-Wno-implicit-fallthrough',
   '-Wno-strict-prototypes',
   '-Wno-unknown-pragmas',
+  '-Wno-ignored-pragmas',
   '-Wno-uninitialized',
   '-Wno-missing-prototypes',
   '-Wno-return-type',
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 04/13] hvf: Use standard CR0 and CR4 register definitions
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (2 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 03/13] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé via
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé,
	Philippe Mathieu-Daudé

From: Cameron Esfahani <dirty@apple.com>

No need to have our own definitions of these registers.

Signed-off-by: Cameron Esfahani <dirty@apple.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/vmx.h      | 17 +++++++++--------
 target/i386/hvf/x86.c      |  6 +++---
 target/i386/hvf/x86.h      | 34 ----------------------------------
 target/i386/hvf/x86_mmu.c  |  2 +-
 target/i386/hvf/x86_task.c |  3 ++-
 5 files changed, 15 insertions(+), 47 deletions(-)

diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
index 6df87116f6..29b7deed3c 100644
--- a/target/i386/hvf/vmx.h
+++ b/target/i386/hvf/vmx.h
@@ -124,10 +124,11 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
     uint64_t efer = rvmcs(vcpu, VMCS_GUEST_IA32_EFER);
     uint64_t old_cr0 = rvmcs(vcpu, VMCS_GUEST_CR0);
     uint64_t changed_cr0 = old_cr0 ^ cr0;
-    uint64_t mask = CR0_PG | CR0_CD | CR0_NW | CR0_NE | CR0_ET;
+    uint64_t mask = CR0_PG_MASK | CR0_CD_MASK | CR0_NW_MASK |
+                    CR0_NE_MASK | CR0_ET_MASK;
     uint64_t entry_ctls;
 
-    if ((cr0 & CR0_PG) && (rvmcs(vcpu, VMCS_GUEST_CR4) & CR4_PAE) &&
+    if ((cr0 & CR0_PG_MASK) && (rvmcs(vcpu, VMCS_GUEST_CR4) & CR4_PAE_MASK) &&
         !(efer & MSR_EFER_LME)) {
         address_space_read(&address_space_memory,
                            rvmcs(vcpu, VMCS_GUEST_CR3) & ~0x1f,
@@ -142,8 +143,8 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
     wvmcs(vcpu, VMCS_CR0_SHADOW, cr0);
 
     if (efer & MSR_EFER_LME) {
-        if (changed_cr0 & CR0_PG) {
-            if (cr0 & CR0_PG) {
+        if (changed_cr0 & CR0_PG_MASK) {
+            if (cr0 & CR0_PG_MASK) {
                 enter_long_mode(vcpu, cr0, efer);
             } else {
                 exit_long_mode(vcpu, cr0, efer);
@@ -155,8 +156,8 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
     }
 
     /* Filter new CR0 after we are finished examining it above. */
-    cr0 = (cr0 & ~(mask & ~CR0_PG));
-    wvmcs(vcpu, VMCS_GUEST_CR0, cr0 | CR0_NE | CR0_ET);
+    cr0 = (cr0 & ~(mask & ~CR0_PG_MASK));
+    wvmcs(vcpu, VMCS_GUEST_CR0, cr0 | CR0_NE_MASK | CR0_ET_MASK);
 
     hv_vcpu_invalidate_tlb(vcpu);
     hv_vcpu_flush(vcpu);
@@ -164,11 +165,11 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
 
 static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4)
 {
-    uint64_t guest_cr4 = cr4 | CR4_VMXE;
+    uint64_t guest_cr4 = cr4 | CR4_VMXE_MASK;
 
     wvmcs(vcpu, VMCS_GUEST_CR4, guest_cr4);
     wvmcs(vcpu, VMCS_CR4_SHADOW, cr4);
-    wvmcs(vcpu, VMCS_CR4_MASK, CR4_VMXE);
+    wvmcs(vcpu, VMCS_CR4_MASK, CR4_VMXE_MASK);
 
     hv_vcpu_invalidate_tlb(vcpu);
     hv_vcpu_flush(vcpu);
diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c
index 2898bb70a8..91a3fe002c 100644
--- a/target/i386/hvf/x86.c
+++ b/target/i386/hvf/x86.c
@@ -119,7 +119,7 @@ bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc,
 bool x86_is_protected(struct CPUState *cpu)
 {
     uint64_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0);
-    return cr0 & CR0_PE;
+    return cr0 & CR0_PE_MASK;
 }
 
 bool x86_is_real(struct CPUState *cpu)
@@ -150,13 +150,13 @@ bool x86_is_long64_mode(struct CPUState *cpu)
 bool x86_is_paging_mode(struct CPUState *cpu)
 {
     uint64_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0);
-    return cr0 & CR0_PG;
+    return cr0 & CR0_PG_MASK;
 }
 
 bool x86_is_pae_enabled(struct CPUState *cpu)
 {
     uint64_t cr4 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR4);
-    return cr4 & CR4_PAE;
+    return cr4 & CR4_PAE_MASK;
 }
 
 target_ulong linear_addr(struct CPUState *cpu, target_ulong addr, X86Seg seg)
diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h
index 782664c2ea..947b98da41 100644
--- a/target/i386/hvf/x86.h
+++ b/target/i386/hvf/x86.h
@@ -42,40 +42,6 @@ typedef struct x86_register {
     };
 } __attribute__ ((__packed__)) x86_register;
 
-typedef enum x86_reg_cr0 {
-    CR0_PE =            (1L << 0),
-    CR0_MP =            (1L << 1),
-    CR0_EM =            (1L << 2),
-    CR0_TS =            (1L << 3),
-    CR0_ET =            (1L << 4),
-    CR0_NE =            (1L << 5),
-    CR0_WP =            (1L << 16),
-    CR0_AM =            (1L << 18),
-    CR0_NW =            (1L << 29),
-    CR0_CD =            (1L << 30),
-    CR0_PG =            (1L << 31),
-} x86_reg_cr0;
-
-typedef enum x86_reg_cr4 {
-    CR4_VME =            (1L << 0),
-    CR4_PVI =            (1L << 1),
-    CR4_TSD =            (1L << 2),
-    CR4_DE  =            (1L << 3),
-    CR4_PSE =            (1L << 4),
-    CR4_PAE =            (1L << 5),
-    CR4_MSE =            (1L << 6),
-    CR4_PGE =            (1L << 7),
-    CR4_PCE =            (1L << 8),
-    CR4_OSFXSR =         (1L << 9),
-    CR4_OSXMMEXCPT =     (1L << 10),
-    CR4_VMXE =           (1L << 13),
-    CR4_SMXE =           (1L << 14),
-    CR4_FSGSBASE =       (1L << 16),
-    CR4_PCIDE =          (1L << 17),
-    CR4_OSXSAVE =        (1L << 18),
-    CR4_SMEP =           (1L << 20),
-} x86_reg_cr4;
-
 /* 16 bit Task State Segment */
 typedef struct x86_tss_segment16 {
     uint16_t link;
diff --git a/target/i386/hvf/x86_mmu.c b/target/i386/hvf/x86_mmu.c
index e9ed0f5aa1..df0b91cd42 100644
--- a/target/i386/hvf/x86_mmu.c
+++ b/target/i386/hvf/x86_mmu.c
@@ -129,7 +129,7 @@ static bool test_pt_entry(struct CPUState *cpu, struct gpt_translation *pt,
 
     uint32_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0);
     /* check protection */
-    if (cr0 & CR0_WP) {
+    if (cr0 & CR0_WP_MASK) {
         if (pt->write_access && !pte_write_access(pte)) {
             return false;
         }
diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c
index 422156128b..e1301599e9 100644
--- a/target/i386/hvf/x86_task.c
+++ b/target/i386/hvf/x86_task.c
@@ -174,7 +174,8 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea
         //ret = task_switch_16(cpu, tss_sel, old_tss_sel, old_tss_base, &next_tss_desc);
         VM_PANIC("task_switch_16");
 
-    macvm_set_cr0(cpu->hvf->fd, rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0) | CR0_TS);
+    macvm_set_cr0(cpu->hvf->fd, rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0) |
+                                CR0_TS_MASK);
     x86_segment_descriptor_to_vmx(cpu, tss_sel, &next_tss_desc, &vmx_seg);
     vmx_write_segment_descriptor(cpu, &vmx_seg, R_TR);
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (3 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 04/13] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-14 12:49   ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 06/13] hvf: Enable RDTSCP support Philippe Mathieu-Daudé via
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

From: Cameron Esfahani <dirty@apple.com>

A guest could craft a specific stream of instructions that will have QEMU
write 0xF9 to inappropriate locations in memory.  Add additional asserts
to check for this.  Generate a #UD if there are more than 14 prefix bytes.

Found by Julian Stecklina <julian.stecklina@cyberus-technology.de>

Signed-off-by: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/x86_decode.c | 11 +++++++++--
 target/i386/hvf/x86hvf.c     |  8 ++++++++
 target/i386/hvf/x86hvf.h     |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c
index 062713b1a4..fbaf1813e8 100644
--- a/target/i386/hvf/x86_decode.c
+++ b/target/i386/hvf/x86_decode.c
@@ -24,6 +24,7 @@
 #include "vmx.h"
 #include "x86_mmu.h"
 #include "x86_descr.h"
+#include "x86hvf.h"
 
 #define OPCODE_ESCAPE   0xf
 
@@ -541,7 +542,8 @@ static void decode_lidtgroup(CPUX86State *env, struct x86_decode *decode)
     };
     decode->cmd = group[decode->modrm.reg];
     if (0xf9 == decode->modrm.modrm) {
-        decode->opcode[decode->len++] = decode->modrm.modrm;
+        VM_PANIC_ON(decode->opcode_len >= sizeof(decode->opcode));
+        decode->opcode[decode->opcode_len++] = decode->modrm.modrm;
         decode->cmd = X86_DECODE_CMD_RDTSCP;
     }
 }
@@ -1847,7 +1849,8 @@ void calc_modrm_operand(CPUX86State *env, struct x86_decode *decode,
 
 static void decode_prefix(CPUX86State *env, struct x86_decode *decode)
 {
-    while (1) {
+    /* At most 14 prefix bytes. */
+    for (int i = 0; i < 14; i++) {
         /*
          * REX prefix must come after legacy prefixes.
          * REX before legacy is ignored.
@@ -1892,6 +1895,8 @@ static void decode_prefix(CPUX86State *env, struct x86_decode *decode)
             return;
         }
     }
+    /* Too many prefixes!  Generate #UD. */
+    hvf_inject_ud(env);
 }
 
 void set_addressing_size(CPUX86State *env, struct x86_decode *decode)
@@ -2090,11 +2095,13 @@ static void decode_opcodes(CPUX86State *env, struct x86_decode *decode)
     uint8_t opcode;
 
     opcode = decode_byte(env, decode);
+    VM_PANIC_ON(decode->opcode_len >= sizeof(decode->opcode));
     decode->opcode[decode->opcode_len++] = opcode;
     if (opcode != OPCODE_ESCAPE) {
         decode_opcode_1(env, decode, opcode);
     } else {
         opcode = decode_byte(env, decode);
+        VM_PANIC_ON(decode->opcode_len >= sizeof(decode->opcode));
         decode->opcode[decode->opcode_len++] = opcode;
         decode_opcode_2(env, decode, opcode);
     }
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 05ec1bddc4..a805c125d9 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -425,6 +425,14 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
             & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR));
 }
 
+void hvf_inject_ud(CPUX86State *env)
+{
+    env->exception_nr = EXCP06_ILLOP;
+    env->exception_injected = 1;
+    env->has_error_code = false;
+    env->error_code = 0;
+}
+
 int hvf_process_events(CPUState *cpu_state)
 {
     X86CPU *cpu = X86_CPU(cpu_state);
diff --git a/target/i386/hvf/x86hvf.h b/target/i386/hvf/x86hvf.h
index 99ed8d608d..ef472a32f9 100644
--- a/target/i386/hvf/x86hvf.h
+++ b/target/i386/hvf/x86hvf.h
@@ -22,6 +22,7 @@
 
 int hvf_process_events(CPUState *);
 bool hvf_inject_interrupts(CPUState *);
+void hvf_inject_ud(CPUX86State *);
 void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg,
                      SegmentCache *qseg, bool is_tr);
 void hvf_get_segment(SegmentCache *qseg, struct vmx_segment *vmx_seg);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 06/13] hvf: Enable RDTSCP support
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (4 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 07/13] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé via
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

From: Cameron Esfahani <dirty@apple.com>

Pass through RDPID and RDTSCP support in CPUID if host supports it.
Correctly detect if CPU_BASED_TSC_OFFSET and CPU_BASED2_RDTSCP would
be supported in primary and secondary processor-based VM-execution
controls.  Enable RDTSCP in secondary processor controls if RDTSCP
support is indicated in CPUID.

Signed-off-by: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/hvf.c       | 26 +++++++++++++++++---------
 target/i386/hvf/vmcs.h      |  3 ++-
 target/i386/hvf/x86_cpuid.c |  7 ++++---
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 4ba6e82fab..4712fe66d4 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -221,6 +221,7 @@ int hvf_arch_init_vcpu(CPUState *cpu)
 {
     X86CPU *x86cpu = X86_CPU(cpu);
     CPUX86State *env = &x86cpu->env;
+    uint64_t reqCap;
 
     init_emu();
     init_decoder();
@@ -257,19 +258,26 @@ int hvf_arch_init_vcpu(CPUState *cpu)
     /* set VMCS control fields */
     wvmcs(cpu->hvf->fd, VMCS_PIN_BASED_CTLS,
           cap2ctrl(hvf_state->hvf_caps->vmx_cap_pinbased,
-          VMCS_PIN_BASED_CTLS_EXTINT |
-          VMCS_PIN_BASED_CTLS_NMI |
-          VMCS_PIN_BASED_CTLS_VNMI));
+                   VMCS_PIN_BASED_CTLS_EXTINT |
+                   VMCS_PIN_BASED_CTLS_NMI |
+                   VMCS_PIN_BASED_CTLS_VNMI));
     wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS,
           cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased,
-          VMCS_PRI_PROC_BASED_CTLS_HLT |
-          VMCS_PRI_PROC_BASED_CTLS_MWAIT |
-          VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET |
-          VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW) |
+                   VMCS_PRI_PROC_BASED_CTLS_HLT |
+                   VMCS_PRI_PROC_BASED_CTLS_MWAIT |
+                   VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET |
+                   VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW) |
           VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL);
+
+    reqCap = VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES;
+
+    /* Is RDTSCP support in CPUID?  If so, enable it in the VMCS. */
+    if (hvf_get_supported_cpuid(0x80000001, 0, R_EDX) & CPUID_EXT2_RDTSCP) {
+        reqCap |= VMCS_PRI_PROC_BASED2_CTLS_RDTSCP;
+    }
+
     wvmcs(cpu->hvf->fd, VMCS_SEC_PROC_BASED_CTLS,
-          cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased2,
-                   VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES));
+          cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased2, reqCap));
 
     wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry,
           0));
diff --git a/target/i386/hvf/vmcs.h b/target/i386/hvf/vmcs.h
index 42de7ebc3a..bb4c764557 100644
--- a/target/i386/hvf/vmcs.h
+++ b/target/i386/hvf/vmcs.h
@@ -354,7 +354,7 @@
 #define VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET (1 << 3)
 #define VMCS_PRI_PROC_BASED_CTLS_HLT (1 << 7)
 #define VMCS_PRI_PROC_BASED_CTLS_MWAIT         (1 << 10)
-#define VMCS_PRI_PROC_BASED_CTLS_TSC           (1 << 12)
+#define VMCS_PRI_PROC_BASED_CTLS_RDTSC         (1 << 12)
 #define VMCS_PRI_PROC_BASED_CTLS_CR8_LOAD      (1 << 19)
 #define VMCS_PRI_PROC_BASED_CTLS_CR8_STORE     (1 << 20)
 #define VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW    (1 << 21)
@@ -362,6 +362,7 @@
 #define VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL   (1 << 31)
 
 #define VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES (1 << 0)
+#define VMCS_PRI_PROC_BASED2_CTLS_RDTSCP        (1 << 3)
 #define VMCS_PRI_PROC_BASED2_CTLS_X2APIC        (1 << 4)
 
 enum task_switch_reason {
diff --git a/target/i386/hvf/x86_cpuid.c b/target/i386/hvf/x86_cpuid.c
index 32b0d131df..b11ddaa349 100644
--- a/target/i386/hvf/x86_cpuid.c
+++ b/target/i386/hvf/x86_cpuid.c
@@ -96,7 +96,8 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                 ebx &= ~CPUID_7_0_EBX_INVPCID;
             }
 
-            ecx &= CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_AVX512_VPOPCNTDQ;
+            ecx &= CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_AVX512_VPOPCNTDQ |
+                   CPUID_7_0_ECX_RDPID;
             edx &= CPUID_7_0_EDX_AVX512_4VNNIW | CPUID_7_0_EDX_AVX512_4FMAPS;
         } else {
             ebx = 0;
@@ -133,11 +134,11 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                 CPUID_FXSR | CPUID_EXT2_FXSR | CPUID_EXT2_PDPE1GB | CPUID_EXT2_3DNOWEXT |
                 CPUID_EXT2_3DNOW | CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX;
         hv_vmx_read_capability(HV_VMX_CAP_PROCBASED2, &cap);
-        if (!(cap & CPU_BASED2_RDTSCP)) {
+        if (!(cap2ctrl(cap, CPU_BASED2_RDTSCP) & CPU_BASED2_RDTSCP)) {
             edx &= ~CPUID_EXT2_RDTSCP;
         }
         hv_vmx_read_capability(HV_VMX_CAP_PROCBASED, &cap);
-        if (!(cap & CPU_BASED_TSC_OFFSET)) {
+        if (!(cap2ctrl(cap, CPU_BASED_TSC_OFFSET) & CPU_BASED_TSC_OFFSET)) {
             edx &= ~CPUID_EXT2_RDTSCP;
         }
         ecx &= CPUID_EXT3_LAHF_LM | CPUID_EXT3_CMP_LEG | CPUID_EXT3_CR8LEG |
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 07/13] hvf: Make hvf_get_segments() / hvf_put_segments() local
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (5 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 06/13] hvf: Enable RDTSCP support Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 08/13] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé via
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

Both hvf_get_segments/hvf_put_segments() functions are only
used within x86hvf.c: do not declare them as public API.

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/x86hvf.c | 4 ++--
 target/i386/hvf/x86hvf.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index a805c125d9..cff59f3144 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -83,7 +83,7 @@ void hvf_put_xsave(CPUState *cpu_state)
     }
 }
 
-void hvf_put_segments(CPUState *cpu_state)
+static void hvf_put_segments(CPUState *cpu_state)
 {
     CPUX86State *env = &X86_CPU(cpu_state)->env;
     struct vmx_segment seg;
@@ -166,7 +166,7 @@ void hvf_get_xsave(CPUState *cpu_state)
     x86_cpu_xrstor_all_areas(X86_CPU(cpu_state), xsave, xsave_len);
 }
 
-void hvf_get_segments(CPUState *cpu_state)
+static void hvf_get_segments(CPUState *cpu_state)
 {
     CPUX86State *env = &X86_CPU(cpu_state)->env;
 
diff --git a/target/i386/hvf/x86hvf.h b/target/i386/hvf/x86hvf.h
index ef472a32f9..427cdc1c13 100644
--- a/target/i386/hvf/x86hvf.h
+++ b/target/i386/hvf/x86hvf.h
@@ -27,11 +27,9 @@ void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg,
                      SegmentCache *qseg, bool is_tr);
 void hvf_get_segment(SegmentCache *qseg, struct vmx_segment *vmx_seg);
 void hvf_put_xsave(CPUState *cpu_state);
-void hvf_put_segments(CPUState *cpu_state);
 void hvf_put_msrs(CPUState *cpu_state);
 void hvf_get_xsave(CPUState *cpu_state);
 void hvf_get_msrs(CPUState *cpu_state);
 void vmx_clear_int_window_exiting(CPUState *cpu);
-void hvf_get_segments(CPUState *cpu_state);
 void vmx_update_tpr(CPUState *cpu);
 #endif
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 08/13] hvf: Remove deprecated hv_vcpu_flush() calls
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (6 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 07/13] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé via
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

When building on macOS 11 [*], we get:

  In file included from ../target/i386/hvf/hvf.c:59:
  ../target/i386/hvf/vmx.h:174:5: error: 'hv_vcpu_flush' is deprecated: first deprecated in macOS 11.0 - This API has no effect and always returns HV_UNSUPPORTED [-Werror,-Wdeprecated-declarations]
      hv_vcpu_flush(vcpu);
      ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Hypervisor.framework/Headers/hv.h:364:20: note: 'hv_vcpu_flush' has been explicitly marked deprecated here
  extern hv_return_t hv_vcpu_flush(hv_vcpuid_t vcpu)
                     ^

Since this call "has no effect", simply remove it ¯\_(ツ)_/¯

Not very useful deprecation doc:
https://developer.apple.com/documentation/hypervisor/1441386-hv_vcpu_flush

[*] Also 10.15 (Catalina):
    https://lore.kernel.org/qemu-devel/Yd3DmSqZ1SiJwd7P@roolebo.dev/

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/vmx.h      | 2 --
 target/i386/hvf/x86_task.c | 1 -
 target/i386/hvf/x86hvf.c   | 2 --
 3 files changed, 5 deletions(-)

diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
index 29b7deed3c..573ddc33c0 100644
--- a/target/i386/hvf/vmx.h
+++ b/target/i386/hvf/vmx.h
@@ -160,7 +160,6 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
     wvmcs(vcpu, VMCS_GUEST_CR0, cr0 | CR0_NE_MASK | CR0_ET_MASK);
 
     hv_vcpu_invalidate_tlb(vcpu);
-    hv_vcpu_flush(vcpu);
 }
 
 static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4)
@@ -172,7 +171,6 @@ static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4)
     wvmcs(vcpu, VMCS_CR4_MASK, CR4_VMXE_MASK);
 
     hv_vcpu_invalidate_tlb(vcpu);
-    hv_vcpu_flush(vcpu);
 }
 
 static inline void macvm_set_rip(CPUState *cpu, uint64_t rip)
diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c
index e1301599e9..d24daf6a41 100644
--- a/target/i386/hvf/x86_task.c
+++ b/target/i386/hvf/x86_task.c
@@ -182,5 +182,4 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea
     store_regs(cpu);
 
     hv_vcpu_invalidate_tlb(cpu->hvf->fd);
-    hv_vcpu_flush(cpu->hvf->fd);
 }
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index cff59f3144..a338c207b7 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -125,8 +125,6 @@ static void hvf_put_segments(CPUState *cpu_state)
 
     hvf_set_segment(cpu_state, &seg, &env->ldt, false);
     vmx_write_segment_descriptor(cpu_state, &seg, R_LDTR);
-    
-    hv_vcpu_flush(cpu_state->hvf->fd);
 }
     
 void hvf_put_msrs(CPUState *cpu_state)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (7 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 08/13] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-12 13:35   ` Christian Schoenebeck
  2022-02-14  3:27   ` Cameron Esfahani
  2022-02-11 16:34 ` [PATCH v4 10/13] audio/coreaudio: " Philippe Mathieu-Daudé via
                   ` (3 subsequent siblings)
  12 siblings, 2 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

When building on macOS 12 we get:

  block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
      kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
                   ^~~~~~~~~~~~
                   IOMainPort

Replace by IOMainPort, redefining it to IOMasterPort if not available.

Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 block/file-posix.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 1f1756e192..13393ad296 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -3319,17 +3319,23 @@ BlockDriver bdrv_file = {
 #if defined(__APPLE__) && defined(__MACH__)
 static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
                                 CFIndex maxPathSize, int flags);
+
+#if !defined(MAC_OS_VERSION_12_0) \
+    || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
+#define IOMainPort IOMasterPort
+#endif
+
 static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
 {
     kern_return_t kernResult = KERN_FAILURE;
-    mach_port_t     masterPort;
+    mach_port_t mainPort;
     CFMutableDictionaryRef  classesToMatch;
     const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
     char *mediaType = NULL;
 
-    kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
+    kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
     if ( KERN_SUCCESS != kernResult ) {
-        printf( "IOMasterPort returned %d\n", kernResult );
+        printf("IOMainPort returned %d\n", kernResult);
     }
 
     int index;
@@ -3342,7 +3348,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
         }
         CFDictionarySetValue(classesToMatch, CFSTR(kIOMediaEjectableKey),
                              kCFBooleanTrue);
-        kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch,
+        kernResult = IOServiceGetMatchingServices(mainPort, classesToMatch,
                                                   mediaIterator);
         if (kernResult != KERN_SUCCESS) {
             error_report("Note: IOServiceGetMatchingServices returned %d",
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (8 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-12 13:15   ` Christian Schoenebeck
  2022-02-12 15:23   ` Akihiko Odaki
  2022-02-11 16:34 ` [PATCH v4 11/13] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé via
                   ` (2 subsequent siblings)
  12 siblings, 2 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé,
	Roman Bolshakov

When building on macOS 12 we get:

  audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is deprecated: first deprecated in macOS 12.0 [-Werror,-Wdeprecated-declarations]
      kAudioObjectPropertyElementMaster
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      kAudioObjectPropertyElementMain
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
      kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
      ^

Replace by kAudioObjectPropertyElementMain, redefining it to
kAudioObjectPropertyElementMaster if not available.

Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Suggested-by: Roman Bolshakov <roman@roolebo.dev>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/coreaudio.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index d8a21d3e50..5b3aeaced0 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
     bool enabled;
 } coreaudioVoiceOut;
 
+#if !defined(MAC_OS_VERSION_12_0) \
+    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
+#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
+#endif
+
 static const AudioObjectPropertyAddress voice_addr = {
     kAudioHardwarePropertyDefaultOutputDevice,
     kAudioObjectPropertyScopeGlobal,
-    kAudioObjectPropertyElementMaster
+    kAudioObjectPropertyElementMain
 };
 
 static OSStatus coreaudio_get_voice(AudioDeviceID *id)
@@ -69,7 +74,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSizeRange,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,
@@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSize,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,
@@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSize,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectSetPropertyData(id,
@@ -121,7 +126,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyStreamFormat,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectSetPropertyData(id,
@@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyDeviceIsRunning,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 11/13] audio/dbus: Fix building with modules on macOS
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (9 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 10/13] audio/coreaudio: " Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel Philippe Mathieu-Daudé via
  2022-02-11 16:34 ` [PATCH v4 13/13] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé via
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

When configuring QEMU with --enable-modules we get on macOS:

  --- stderr ---
  Dependency ui-dbus cannot be satisfied

ui-dbus depends on pixman and opengl, so add these dependencies
to audio-dbus.

Fixes: 739362d420 ("audio: add "dbus" audio backend")
Reviewed-by: Li Zhang <lizhang@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/audio/meson.build b/audio/meson.build
index 0ac3791d0b..d9b295514f 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -28,7 +28,7 @@ endforeach
 
 if dbus_display
     module_ss = ss.source_set()
-    module_ss.add(when: gio, if_true: files('dbusaudio.c'))
+    module_ss.add(when: [gio, pixman, opengl, 'CONFIG_GIO'], if_true: files('dbusaudio.c'))
     audio_modules += {'dbus': module_ss}
 endif
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (10 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 11/13] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  2022-02-12 13:25   ` Christian Schoenebeck
  2022-02-14  3:26   ` Cameron Esfahani
  2022-02-11 16:34 ` [PATCH v4 13/13] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé via
  12 siblings, 2 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

setAllowedFileTypes is deprecated in macOS 12.

Per Akihiko Odaki [*]:

  An image file, which is being chosen by the panel, can be a
  raw file and have a variety of file extensions and many are not
  covered by the provided list (e.g. "udf"). Other platforms like
  GTK can provide an option to open a file with an extension not
  listed, but Cocoa can't. It forces the user to rename the file
  to give an extension in the list. Moreover, Cocoa does not tell
  which extensions are in the list so the user needs to read the
  source code, which is pretty bad.

Since this code is harming the usability rather than improving it,
simply remove the [NSSavePanel allowedFileTypes:] call, fixing:

  [2789/6622] Compiling Objective-C object libcommon.fa.p/ui_cocoa.m.o
  ui/cocoa.m:1411:16: error: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead [-Werror,-Wdeprecated-declarations]
      [openPanel setAllowedFileTypes: supportedImageFileTypes];
                 ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here
  @property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10.3,12.0));
                                                  ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
  FAILED: libcommon.fa.p/ui_cocoa.m.o

[*] https://lore.kernel.org/qemu-devel/4dde2e66-63cb-4390-9538-c032310db3e3@gmail.com/

Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 ui/cocoa.m | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index ac18e14ce0..7a1ddd4075 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -100,7 +100,6 @@ static int gArgc;
 static char **gArgv;
 static bool stretch_video;
 static NSTextField *pauseLabel;
-static NSArray * supportedImageFileTypes;
 
 static QemuSemaphore display_init_sem;
 static QemuSemaphore app_started_sem;
@@ -1168,10 +1167,6 @@ QemuCocoaView *cocoaView;
         [pauseLabel setTextColor: [NSColor blackColor]];
         [pauseLabel sizeToFit];
 
-        // set the supported image file types that can be opened
-        supportedImageFileTypes = [NSArray arrayWithObjects: @"img", @"iso", @"dmg",
-                                 @"qcow", @"qcow2", @"cloop", @"vmdk", @"cdr",
-                                  @"toast", nil];
         [self make_about_window];
     }
     return self;
@@ -1414,7 +1409,6 @@ QemuCocoaView *cocoaView;
     openPanel = [NSOpenPanel openPanel];
     [openPanel setCanChooseFiles: YES];
     [openPanel setAllowsMultipleSelection: NO];
-    [openPanel setAllowedFileTypes: supportedImageFileTypes];
     if([openPanel runModal] == NSModalResponseOK) {
         NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
         if(file == nil) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 13/13] gitlab-ci: Support macOS 12 via cirrus-run
  2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
                   ` (11 preceding siblings ...)
  2022-02-11 16:34 ` [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel Philippe Mathieu-Daudé via
@ 2022-02-11 16:34 ` Philippe Mathieu-Daudé via
  12 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-11 16:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Philippe Mathieu-Daudé

Add support for macOS 12 build on Cirrus-CI, similarly to commit
0e103a65ba1 ("gitlab: support for ... macOS 11 via cirrus-run"),
but with the following differences:
 - Enable modules (configure --enable-modules)
 - Do not run softfloat3 tests (make check-softfloat)

Generate the vars file by calling 'make lcitool-refresh'.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 .gitlab-ci.d/cirrus.yml           | 16 ++++++++++++++++
 .gitlab-ci.d/cirrus/macos-12.vars | 16 ++++++++++++++++
 tests/lcitool/refresh             |  1 +
 3 files changed, 33 insertions(+)
 create mode 100644 .gitlab-ci.d/cirrus/macos-12.vars

diff --git a/.gitlab-ci.d/cirrus.yml b/.gitlab-ci.d/cirrus.yml
index b96b22e269..b4e501d423 100644
--- a/.gitlab-ci.d/cirrus.yml
+++ b/.gitlab-ci.d/cirrus.yml
@@ -87,6 +87,22 @@ x64-macos-11-base-build:
     PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig
     TEST_TARGETS: check-unit check-block check-qapi-schema check-softfloat check-qtest-x86_64
 
+x64-macos-12-base-build:
+  extends: .cirrus_build_job
+  variables:
+    NAME: macos-12
+    CIRRUS_VM_INSTANCE_TYPE: osx_instance
+    CIRRUS_VM_IMAGE_SELECTOR: image
+    CIRRUS_VM_IMAGE_NAME: monterey-base
+    CIRRUS_VM_CPUS: 12
+    CIRRUS_VM_RAM: 24G
+    UPDATE_COMMAND: brew update
+    INSTALL_COMMAND: brew install
+    PATH_EXTRA: /usr/local/opt/ccache/libexec:/usr/local/opt/gettext/bin
+    PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig
+    CONFIGURE_ARGS: --enable-modules
+    TEST_TARGETS: check-unit check-block check-qapi-schema check-qtest-x86_64
+
 
 # The following jobs run VM-based tests via KVM on a Linux-based Cirrus-CI job
 .cirrus_kvm_job:
diff --git a/.gitlab-ci.d/cirrus/macos-12.vars b/.gitlab-ci.d/cirrus/macos-12.vars
new file mode 100644
index 0000000000..a793258c64
--- /dev/null
+++ b/.gitlab-ci.d/cirrus/macos-12.vars
@@ -0,0 +1,16 @@
+# THIS FILE WAS AUTO-GENERATED
+#
+#  $ lcitool variables macos-12 qemu
+#
+# https://gitlab.com/libvirt/libvirt-ci
+
+CCACHE='/usr/local/bin/ccache'
+CPAN_PKGS='Test::Harness'
+CROSS_PKGS=''
+MAKE='/usr/local/bin/gmake'
+NINJA='/usr/local/bin/ninja'
+PACKAGING_COMMAND='brew'
+PIP3='/usr/local/bin/pip3'
+PKGS='bash bc bzip2 capstone ccache cpanminus ctags curl dbus diffutils dtc gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson ncurses nettle ninja perl pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy sparse spice-protocol tesseract texinfo usbredir vde vte3 zlib zstd'
+PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme virtualenv'
+PYTHON='/usr/local/bin/python3'
diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh
index 4ab90a310a..a714e2851d 100755
--- a/tests/lcitool/refresh
+++ b/tests/lcitool/refresh
@@ -89,6 +89,7 @@ try:
    generate_cirrus("freebsd-12")
    generate_cirrus("freebsd-13")
    generate_cirrus("macos-11")
+   generate_cirrus("macos-12")
 
    sys.exit(0)
 except Exception as ex:
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 ` [PATCH v4 10/13] audio/coreaudio: " Philippe Mathieu-Daudé via
@ 2022-02-12 13:15   ` Christian Schoenebeck
  2022-02-12 15:23   ` Akihiko Odaki
  1 sibling, 0 replies; 26+ messages in thread
From: Christian Schoenebeck @ 2022-02-12 13:15 UTC (permalink / raw)
  To: qemu-devel, Philippe Mathieu-Daudé
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Roman Bolshakov, Li Zhang, Roman Bolshakov

On Freitag, 11. Februar 2022 17:34:31 CET Philippe Mathieu-Daudé via wrote:
> When building on macOS 12 we get:
> 
>   audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is
> deprecated: first deprecated in macOS 12.0
> [-Werror,-Wdeprecated-declarations] kAudioObjectPropertyElementMaster
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       kAudioObjectPropertyElementMain
>  
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Framewor
> ks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note:
> 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated
> here kAudioObjectPropertyElementMaster
> API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain",
> macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) =
> kAudioObjectPropertyElementMain ^
> 
> Replace by kAudioObjectPropertyElementMain, redefining it to
> kAudioObjectPropertyElementMaster if not available.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

>  audio/coreaudio.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index d8a21d3e50..5b3aeaced0 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>      bool enabled;
>  } coreaudioVoiceOut;
> 
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> +#endif
> +
>  static const AudioObjectPropertyAddress voice_addr = {
>      kAudioHardwarePropertyDefaultOutputDevice,
>      kAudioObjectPropertyScopeGlobal,
> -    kAudioObjectPropertyElementMaster
> +    kAudioObjectPropertyElementMain
>  };
> 
>  static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> @@ -69,7 +74,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID
> id, AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSizeRange,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,
> @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id,
> UInt32 *framesize) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSize,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,
> @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID
> id, UInt32 *framesize) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSize,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectSetPropertyData(id,
> @@ -121,7 +126,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID
> id, AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyStreamFormat,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectSetPropertyData(id,
> @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID
> id, UInt32 *result) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyDeviceIsRunning,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel
  2022-02-11 16:34 ` [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel Philippe Mathieu-Daudé via
@ 2022-02-12 13:25   ` Christian Schoenebeck
  2022-02-14  3:26   ` Cameron Esfahani
  1 sibling, 0 replies; 26+ messages in thread
From: Christian Schoenebeck @ 2022-02-12 13:25 UTC (permalink / raw)
  To: qemu-devel, Philippe Mathieu-Daudé
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Roman Bolshakov, Li Zhang

On Freitag, 11. Februar 2022 17:34:33 CET Philippe Mathieu-Daudé via wrote:
> setAllowedFileTypes is deprecated in macOS 12.
> 
> Per Akihiko Odaki [*]:
> 
>   An image file, which is being chosen by the panel, can be a
>   raw file and have a variety of file extensions and many are not
>   covered by the provided list (e.g. "udf"). Other platforms like
>   GTK can provide an option to open a file with an extension not
>   listed, but Cocoa can't. It forces the user to rename the file
>   to give an extension in the list. Moreover, Cocoa does not tell
>   which extensions are in the list so the user needs to read the
>   source code, which is pretty bad.
> 
> Since this code is harming the usability rather than improving it,
> simply remove the [NSSavePanel allowedFileTypes:] call, fixing:
> 
>   [2789/6622] Compiling Objective-C object libcommon.fa.p/ui_cocoa.m.o
>   ui/cocoa.m:1411:16: error: 'setAllowedFileTypes:' is deprecated: first
> deprecated in macOS 12.0 - Use -allowedContentTypes instead
> [-Werror,-Wdeprecated-declarations] [openPanel setAllowedFileTypes:
> supportedImageFileTypes];
>                  ^
>  
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Framewor
> ks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property
> 'allowedFileTypes' is declared deprecated here @property (nullable, copy)
> NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use
> -allowedContentTypes instead", macos(10.3,12.0)); ^
>  
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Framewor
> ks/AppKit.framework/Headers/NSSavePanel.h:215:49: note:
> 'setAllowedFileTypes:' has been explicitly marked deprecated here FAILED:
> libcommon.fa.p/ui_cocoa.m.o
> 
> [*]
> https://lore.kernel.org/qemu-devel/4dde2e66-63cb-4390-9538-c032310db3e3@gma
> il.com/
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

>  ui/cocoa.m | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index ac18e14ce0..7a1ddd4075 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -100,7 +100,6 @@ static int gArgc;
>  static char **gArgv;
>  static bool stretch_video;
>  static NSTextField *pauseLabel;
> -static NSArray * supportedImageFileTypes;
> 
>  static QemuSemaphore display_init_sem;
>  static QemuSemaphore app_started_sem;
> @@ -1168,10 +1167,6 @@ QemuCocoaView *cocoaView;
>          [pauseLabel setTextColor: [NSColor blackColor]];
>          [pauseLabel sizeToFit];
> 
> -        // set the supported image file types that can be opened
> -        supportedImageFileTypes = [NSArray arrayWithObjects: @"img",
> @"iso", @"dmg", -                                 @"qcow", @"qcow2",
> @"cloop", @"vmdk", @"cdr", -                                  @"toast",
> nil];
>          [self make_about_window];
>      }
>      return self;
> @@ -1414,7 +1409,6 @@ QemuCocoaView *cocoaView;
>      openPanel = [NSOpenPanel openPanel];
>      [openPanel setCanChooseFiles: YES];
>      [openPanel setAllowsMultipleSelection: NO];
> -    [openPanel setAllowedFileTypes: supportedImageFileTypes];
>      if([openPanel runModal] == NSModalResponseOK) {
>          NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
>          if(file == nil) {




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 ` [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé via
@ 2022-02-12 13:35   ` Christian Schoenebeck
  2022-02-14  3:27   ` Cameron Esfahani
  1 sibling, 0 replies; 26+ messages in thread
From: Christian Schoenebeck @ 2022-02-12 13:35 UTC (permalink / raw)
  To: qemu-devel, Philippe Mathieu-Daudé
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Roman Bolshakov, Li Zhang

On Freitag, 11. Februar 2022 17:34:30 CET Philippe Mathieu-Daudé via wrote:
> When building on macOS 12 we get:
> 
>   block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first
> deprecated in macOS 12.0 [-Wdeprecated-declarations] kernResult =
> IOMasterPort( MACH_PORT_NULL, &masterPort );
>                    ^~~~~~~~~~~~
>                    IOMainPort
> 
> Replace by IOMainPort, redefining it to IOMasterPort if not available.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

>  block/file-posix.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 1f1756e192..13393ad296 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -3319,17 +3319,23 @@ BlockDriver bdrv_file = {
>  #if defined(__APPLE__) && defined(__MACH__)
>  static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
> CFIndex maxPathSize, int flags);
> +
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
> +#define IOMainPort IOMasterPort
> +#endif
> +
>  static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
>  {
>      kern_return_t kernResult = KERN_FAILURE;
> -    mach_port_t     masterPort;
> +    mach_port_t mainPort;
>      CFMutableDictionaryRef  classesToMatch;
>      const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
>      char *mediaType = NULL;
> 
> -    kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
> +    kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
>      if ( KERN_SUCCESS != kernResult ) {
> -        printf( "IOMasterPort returned %d\n", kernResult );
> +        printf("IOMainPort returned %d\n", kernResult);
>      }
> 
>      int index;
> @@ -3342,7 +3348,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t
> *mediaIterator) }
>          CFDictionarySetValue(classesToMatch, CFSTR(kIOMediaEjectableKey),
>                               kCFBooleanTrue);
> -        kernResult = IOServiceGetMatchingServices(masterPort,
> classesToMatch, +        kernResult =
> IOServiceGetMatchingServices(mainPort, classesToMatch, mediaIterator); if
> (kernResult != KERN_SUCCESS) {
>              error_report("Note: IOServiceGetMatchingServices returned %d",




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 01/13] lcitool: refresh
  2022-02-11 16:34 ` [PATCH v4 01/13] lcitool: refresh Philippe Mathieu-Daudé via
@ 2022-02-12 15:14   ` Akihiko Odaki
  2022-02-14 12:10     ` Philippe Mathieu-Daudé via
  0 siblings, 1 reply; 26+ messages in thread
From: Akihiko Odaki @ 2022-02-12 15:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Li Zhang, Christian Schoenebeck, Cameron Esfahani,
	Roman Bolshakov, Will Cohen, Alex Bennée

On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   tests/docker/dockerfiles/ubuntu1804.docker | 2 --
>   tests/docker/dockerfiles/ubuntu2004.docker | 2 --
>   2 files changed, 4 deletions(-)
> 
> diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dockerfiles/ubuntu1804.docker
> index 699f2dfc6a..040938277a 100644
> --- a/tests/docker/dockerfiles/ubuntu1804.docker
> +++ b/tests/docker/dockerfiles/ubuntu1804.docker
> @@ -65,7 +65,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>               libpam0g-dev \
>               libpcre2-dev \
>               libpixman-1-dev \
> -            libpmem-dev \
>               libpng-dev \
>               libpulse-dev \
>               librbd-dev \
> @@ -89,7 +88,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>               libvdeplug-dev \
>               libvirglrenderer-dev \
>               libvte-2.91-dev \
> -            libxen-dev \
>               libzstd-dev \
>               llvm \
>               locales \
> diff --git a/tests/docker/dockerfiles/ubuntu2004.docker b/tests/docker/dockerfiles/ubuntu2004.docker
> index 87513125b8..159e7f60c9 100644
> --- a/tests/docker/dockerfiles/ubuntu2004.docker
> +++ b/tests/docker/dockerfiles/ubuntu2004.docker
> @@ -66,7 +66,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>               libpam0g-dev \
>               libpcre2-dev \
>               libpixman-1-dev \
> -            libpmem-dev \
>               libpng-dev \
>               libpulse-dev \
>               librbd-dev \
> @@ -91,7 +90,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>               libvdeplug-dev \
>               libvirglrenderer-dev \
>               libvte-2.91-dev \
> -            libxen-dev \
>               libzstd-dev \
>               llvm \
>               locales \

This can't be applied to master.

% git am ~/mbox.txt
Applying: lcitool: refresh
error: patch failed: tests/docker/dockerfiles/ubuntu1804.docker:89
error: tests/docker/dockerfiles/ubuntu1804.docker: patch does not apply
error: patch failed: tests/docker/dockerfiles/ubuntu2004.docker:91
error: tests/docker/dockerfiles/ubuntu2004.docker: patch does not apply
Patch failed at 0001 lcitool: refresh

Regards,
Akihiko Odaki


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 ` [PATCH v4 10/13] audio/coreaudio: " Philippe Mathieu-Daudé via
  2022-02-12 13:15   ` Christian Schoenebeck
@ 2022-02-12 15:23   ` Akihiko Odaki
  2022-02-12 17:27     ` Christian Schoenebeck
  2022-02-14 12:43     ` Philippe Mathieu-Daudé via
  1 sibling, 2 replies; 26+ messages in thread
From: Akihiko Odaki @ 2022-02-12 15:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Li Zhang, Christian Schoenebeck, Cameron Esfahani,
	Roman Bolshakov, Will Cohen, Roman Bolshakov, Alex Bennée

On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
> When building on macOS 12 we get:
> 
>    audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is deprecated: first deprecated in macOS 12.0 [-Werror,-Wdeprecated-declarations]
>        kAudioObjectPropertyElementMaster
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>        kAudioObjectPropertyElementMain
>    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
>        kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
>        ^
> 
> Replace by kAudioObjectPropertyElementMain, redefining it to
> kAudioObjectPropertyElementMaster if not available.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>   audio/coreaudio.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index d8a21d3e50..5b3aeaced0 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>       bool enabled;
>   } coreaudioVoiceOut;
>   
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> +#endif
> +

Unless I have missed something, we have found 
MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the 
following thread:
https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/

Regards,
Akihiko Odaki

>   static const AudioObjectPropertyAddress voice_addr = {
>       kAudioHardwarePropertyDefaultOutputDevice,
>       kAudioObjectPropertyScopeGlobal,
> -    kAudioObjectPropertyElementMaster
> +    kAudioObjectPropertyElementMain
>   };
>   
>   static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> @@ -69,7 +74,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSizeRange,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,
> @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSize,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,
> @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSize,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectSetPropertyData(id,
> @@ -121,7 +126,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyStreamFormat,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectSetPropertyData(id,
> @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyDeviceIsRunning,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-12 15:23   ` Akihiko Odaki
@ 2022-02-12 17:27     ` Christian Schoenebeck
  2022-02-12 17:41       ` Christian Schoenebeck
  2022-02-14 12:43     ` Philippe Mathieu-Daudé via
  1 sibling, 1 reply; 26+ messages in thread
From: Christian Schoenebeck @ 2022-02-12 17:27 UTC (permalink / raw)
  To: Akihiko Odaki
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Cameron Esfahani, Peter Maydell, Will Cohen,
	Alex Bennée, Roman Bolshakov, Li Zhang, Roman Bolshakov

On Samstag, 12. Februar 2022 16:23:49 CET Akihiko Odaki wrote:
> On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
> > When building on macOS 12 we get:
> >    audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is
> >    deprecated: first deprecated in macOS 12.0
> >    [-Werror,-Wdeprecated-declarations]>    
> >        kAudioObjectPropertyElementMaster
> >        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >        kAudioObjectPropertyElementMain
> >    
> >    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Fram
> >    eworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note:
> >    'kAudioObjectPropertyElementMaster' has been explicitly marked
> >    deprecated here>    
> >        kAudioObjectPropertyElementMaster
> >        API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain",
> >        macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0,
> >        15.0)) = kAudioObjectPropertyElementMain ^
> > 
> > Replace by kAudioObjectPropertyElementMain, redefining it to
> > kAudioObjectPropertyElementMaster if not available.
> > 
> > Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > ---
> > 
> >   audio/coreaudio.c | 17 +++++++++++------
> >   1 file changed, 11 insertions(+), 6 deletions(-)
> > 
> > diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> > index d8a21d3e50..5b3aeaced0 100644
> > --- a/audio/coreaudio.c
> > +++ b/audio/coreaudio.c
> > @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
> > 
> >       bool enabled;
> >   
> >   } coreaudioVoiceOut;
> > 
> > +#if !defined(MAC_OS_VERSION_12_0) \
> > +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> > +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> > +#endif
> > +
> 
> Unless I have missed something, we have found
> MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the
> following thread:
> https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/
> 
> Regards,
> Akihiko Odaki

Well, MAC_OS_X_VERSION_MIN_REQUIRED would work as well, note though that it 
would effectively result with older SDKs (Xcode <= 13.0) to this:

enum {
  MAIN,
  MASTER = MAIN
};

#define MAIN MASTER

int main() {
   int k = MAIN;
}

Which compiles and works (as both enums reflect the same value anyway), but 
strictly the defined preprocessor macro would mask (with older SDKs) the 
already existing enum. Not that I would care, just noting.

On practical side though, your solution (MAC_OS_X_VERSION_MIN_REQUIRED) would 
avoid deprecation warnings in future. So yes, maybe it's a bit better.

Best regards,
Christian Schoenebeck

> 
> >   static const AudioObjectPropertyAddress voice_addr = {
> >   
> >       kAudioHardwarePropertyDefaultOutputDevice,
> >       kAudioObjectPropertyScopeGlobal,
> > 
> > -    kAudioObjectPropertyElementMaster
> > +    kAudioObjectPropertyElementMain
> > 
> >   };
> >   
> >   static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> > 
> > @@ -69,7 +74,7 @@ static OSStatus
> > coreaudio_get_framesizerange(AudioDeviceID id,> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSizeRange,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,
> > 
> > @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID
> > id, UInt32 *framesize)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSize,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,
> > 
> > @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID
> > id, UInt32 *framesize)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSize,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectSetPropertyData(id,
> > 
> > @@ -121,7 +126,7 @@ static OSStatus
> > coreaudio_set_streamformat(AudioDeviceID id,> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyStreamFormat,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectSetPropertyData(id,
> > 
> > @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID
> > id, UInt32 *result)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyDeviceIsRunning,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-12 17:27     ` Christian Schoenebeck
@ 2022-02-12 17:41       ` Christian Schoenebeck
  0 siblings, 0 replies; 26+ messages in thread
From: Christian Schoenebeck @ 2022-02-12 17:41 UTC (permalink / raw)
  To: Akihiko Odaki
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Cameron Esfahani, Peter Maydell, Will Cohen,
	Alex Bennée, Roman Bolshakov, Li Zhang, Roman Bolshakov

On Samstag, 12. Februar 2022 18:27:18 CET Christian Schoenebeck wrote:
> On Samstag, 12. Februar 2022 16:23:49 CET Akihiko Odaki wrote:
> > On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
> > > When building on macOS 12 we get:
> > >    audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is
> > >    deprecated: first deprecated in macOS 12.0
> > >    [-Werror,-Wdeprecated-declarations]>
> > >    
> > >        kAudioObjectPropertyElementMaster
> > >        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >        kAudioObjectPropertyElementMain
> > >    
> > >    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Fr
> > >    am
> > >    eworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note:
> > >    'kAudioObjectPropertyElementMaster' has been explicitly marked
> > >    deprecated here>
> > >    
> > >        kAudioObjectPropertyElementMaster
> > >        API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain"
> > >        ,
> > >        macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0,
> > >        15.0)) = kAudioObjectPropertyElementMain ^
> > > 
> > > Replace by kAudioObjectPropertyElementMain, redefining it to
> > > kAudioObjectPropertyElementMaster if not available.
> > > 
> > > Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > > Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > > Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > ---
> > > 
> > >   audio/coreaudio.c | 17 +++++++++++------
> > >   1 file changed, 11 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> > > index d8a21d3e50..5b3aeaced0 100644
> > > --- a/audio/coreaudio.c
> > > +++ b/audio/coreaudio.c
> > > @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
> > > 
> > >       bool enabled;
> > >   
> > >   } coreaudioVoiceOut;
> > > 
> > > +#if !defined(MAC_OS_VERSION_12_0) \
> > > +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> > > +#define kAudioObjectPropertyElementMain
> > > kAudioObjectPropertyElementMaster
> > > +#endif
> > > +
> > 
> > Unless I have missed something, we have found
> > MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the
> > following thread:
> > https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com
> > /
> > 
> > Regards,
> > Akihiko Odaki
> 
> Well, MAC_OS_X_VERSION_MIN_REQUIRED would work as well, note though that it
> would effectively result with older SDKs (Xcode <= 13.0) to this:
> 
> enum {
>   MAIN,
>   MASTER = MAIN
> };
> 
> #define MAIN MASTER
> 
> int main() {
>    int k = MAIN;
> }
> 
> Which compiles and works (as both enums reflect the same value anyway), but
> strictly the defined preprocessor macro would mask (with older SDKs) the
> already existing enum. Not that I would care, just noting.
> 
> On practical side though, your solution (MAC_OS_X_VERSION_MIN_REQUIRED)
> would avoid deprecation warnings in future. So yes, maybe it's a bit
> better.

Correction: it would result in this masking scenario with recent SDK (e.g. 
Xcode 13.2.1) and targeting a minimum deployment target macOs <12.0 (not when 
compiling directly with Xcode <13.1).

Best regards,
Christian Schoenebeck




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel
  2022-02-11 16:34 ` [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel Philippe Mathieu-Daudé via
  2022-02-12 13:25   ` Christian Schoenebeck
@ 2022-02-14  3:26   ` Cameron Esfahani
  1 sibling, 0 replies; 26+ messages in thread
From: Cameron Esfahani @ 2022-02-14  3:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Cameron Esfahani via, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang

[-- Attachment #1: Type: text/plain, Size: 3593 bytes --]

Reviewed-by: Cameron Esfahani <dirty@apple.com <mailto:dirty@apple.com>>


> On Feb 11, 2022, at 8:34 AM, Philippe Mathieu-Daudé via <qemu-devel@nongnu.org> wrote:
> 
> setAllowedFileTypes is deprecated in macOS 12.
> 
> Per Akihiko Odaki [*]:
> 
>  An image file, which is being chosen by the panel, can be a
>  raw file and have a variety of file extensions and many are not
>  covered by the provided list (e.g. "udf"). Other platforms like
>  GTK can provide an option to open a file with an extension not
>  listed, but Cocoa can't. It forces the user to rename the file
>  to give an extension in the list. Moreover, Cocoa does not tell
>  which extensions are in the list so the user needs to read the
>  source code, which is pretty bad.
> 
> Since this code is harming the usability rather than improving it,
> simply remove the [NSSavePanel allowedFileTypes:] call, fixing:
> 
>  [2789/6622] Compiling Objective-C object libcommon.fa.p/ui_cocoa.m.o
>  ui/cocoa.m:1411:16: error: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead [-Werror,-Wdeprecated-declarations]
>      [openPanel setAllowedFileTypes: supportedImageFileTypes];
>                 ^
>  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here
>  @property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10.3,12.0));
>                                                  ^
>  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
>  FAILED: libcommon.fa.p/ui_cocoa.m.o
> 
> [*] https://lore.kernel.org/qemu-devel/4dde2e66-63cb-4390-9538-c032310db3e3@gmail.com/
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> ui/cocoa.m | 6 ------
> 1 file changed, 6 deletions(-)
> 
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index ac18e14ce0..7a1ddd4075 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -100,7 +100,6 @@ static int gArgc;
> static char **gArgv;
> static bool stretch_video;
> static NSTextField *pauseLabel;
> -static NSArray * supportedImageFileTypes;
> 
> static QemuSemaphore display_init_sem;
> static QemuSemaphore app_started_sem;
> @@ -1168,10 +1167,6 @@ QemuCocoaView *cocoaView;
>         [pauseLabel setTextColor: [NSColor blackColor]];
>         [pauseLabel sizeToFit];
> 
> -        // set the supported image file types that can be opened
> -        supportedImageFileTypes = [NSArray arrayWithObjects: @"img", @"iso", @"dmg",
> -                                 @"qcow", @"qcow2", @"cloop", @"vmdk", @"cdr",
> -                                  @"toast", nil];
>         [self make_about_window];
>     }
>     return self;
> @@ -1414,7 +1409,6 @@ QemuCocoaView *cocoaView;
>     openPanel = [NSOpenPanel openPanel];
>     [openPanel setCanChooseFiles: YES];
>     [openPanel setAllowsMultipleSelection: NO];
> -    [openPanel setAllowedFileTypes: supportedImageFileTypes];
>     if([openPanel runModal] == NSModalResponseOK) {
>         NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
>         if(file == nil) {
> -- 
> 2.34.1
> 
> 


[-- Attachment #2: Type: text/html, Size: 6243 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12
  2022-02-11 16:34 ` [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé via
  2022-02-12 13:35   ` Christian Schoenebeck
@ 2022-02-14  3:27   ` Cameron Esfahani
  1 sibling, 0 replies; 26+ messages in thread
From: Cameron Esfahani @ 2022-02-14  3:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Cameron Esfahani via, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang

[-- Attachment #1: Type: text/plain, Size: 2624 bytes --]

Reviewed by: Cameron Esfahani <dirty@apple.com <mailto:dirty@apple.com>>

> On Feb 11, 2022, at 8:34 AM, Philippe Mathieu-Daudé via <qemu-devel@nongnu.org> wrote:
> 
> When building on macOS 12 we get:
> 
>  block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
>      kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
>                   ^~~~~~~~~~~~
>                   IOMainPort
> 
> Replace by IOMainPort, redefining it to IOMasterPort if not available.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> block/file-posix.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 1f1756e192..13393ad296 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -3319,17 +3319,23 @@ BlockDriver bdrv_file = {
> #if defined(__APPLE__) && defined(__MACH__)
> static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
>                                 CFIndex maxPathSize, int flags);
> +
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
> +#define IOMainPort IOMasterPort
> +#endif
> +
> static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
> {
>     kern_return_t kernResult = KERN_FAILURE;
> -    mach_port_t     masterPort;
> +    mach_port_t mainPort;
>     CFMutableDictionaryRef  classesToMatch;
>     const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
>     char *mediaType = NULL;
> 
> -    kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
> +    kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
>     if ( KERN_SUCCESS != kernResult ) {
> -        printf( "IOMasterPort returned %d\n", kernResult );
> +        printf("IOMainPort returned %d\n", kernResult);
>     }
> 
>     int index;
> @@ -3342,7 +3348,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
>         }
>         CFDictionarySetValue(classesToMatch, CFSTR(kIOMediaEjectableKey),
>                              kCFBooleanTrue);
> -        kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch,
> +        kernResult = IOServiceGetMatchingServices(mainPort, classesToMatch,
>                                                   mediaIterator);
>         if (kernResult != KERN_SUCCESS) {
>             error_report("Note: IOServiceGetMatchingServices returned %d",
> -- 
> 2.34.1
> 
> 


[-- Attachment #2: Type: text/html, Size: 5107 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 01/13] lcitool: refresh
  2022-02-12 15:14   ` Akihiko Odaki
@ 2022-02-14 12:10     ` Philippe Mathieu-Daudé via
  0 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-14 12:10 UTC (permalink / raw)
  To: Akihiko Odaki, qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Alex Bennée,
	Christian Schoenebeck, Roman Bolshakov, Li Zhang

On 12/2/22 16:14, Akihiko Odaki wrote:
> On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>   tests/docker/dockerfiles/ubuntu1804.docker | 2 --
>>   tests/docker/dockerfiles/ubuntu2004.docker | 2 --
>>   2 files changed, 4 deletions(-)

>> diff --git a/tests/docker/dockerfiles/ubuntu2004.docker 
>> b/tests/docker/dockerfiles/ubuntu2004.docker
>> index 87513125b8..159e7f60c9 100644
>> --- a/tests/docker/dockerfiles/ubuntu2004.docker
>> +++ b/tests/docker/dockerfiles/ubuntu2004.docker
>> @@ -66,7 +66,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>>               libpam0g-dev \
>>               libpcre2-dev \
>>               libpixman-1-dev \
>> -            libpmem-dev \
>>               libpng-dev \
>>               libpulse-dev \
>>               librbd-dev \
>> @@ -91,7 +90,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
>>               libvdeplug-dev \
>>               libvirglrenderer-dev \
>>               libvte-2.91-dev \
>> -            libxen-dev \
>>               libzstd-dev \
>>               llvm \
>>               locales \
> 
> This can't be applied to master.
> 
> % git am ~/mbox.txt
> Applying: lcitool: refresh
> error: patch failed: tests/docker/dockerfiles/ubuntu1804.docker:89
> error: tests/docker/dockerfiles/ubuntu1804.docker: patch does not apply
> error: patch failed: tests/docker/dockerfiles/ubuntu2004.docker:91
> error: tests/docker/dockerfiles/ubuntu2004.docker: patch does not apply
> Patch failed at 0001 lcitool: refresh

This was based on the testing/next tree which is now merged,
so this should now applies directly.



^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 10/13] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-02-12 15:23   ` Akihiko Odaki
  2022-02-12 17:27     ` Christian Schoenebeck
@ 2022-02-14 12:43     ` Philippe Mathieu-Daudé via
  1 sibling, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-14 12:43 UTC (permalink / raw)
  To: Akihiko Odaki, qemu-devel
  Cc: Cameron Esfahani, Peter Maydell, Will Cohen, Alex Bennée,
	Christian Schoenebeck, Roman Bolshakov, Li Zhang,
	Roman Bolshakov

On 12/2/22 16:23, Akihiko Odaki wrote:
> On 2022/02/12 1:34, Philippe Mathieu-Daudé via wrote:
>> When building on macOS 12 we get:
>>
>>    audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' 
>> is deprecated: first deprecated in macOS 12.0 
>> [-Werror,-Wdeprecated-declarations]
>>        kAudioObjectPropertyElementMaster
>>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>        kAudioObjectPropertyElementMain
>>    
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: 
>> note: 'kAudioObjectPropertyElementMaster' has been explicitly marked 
>> deprecated here
>>        kAudioObjectPropertyElementMaster 
>> API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", 
>> macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) 
>> = kAudioObjectPropertyElementMain
>>        ^
>>
>> Replace by kAudioObjectPropertyElementMain, redefining it to
>> kAudioObjectPropertyElementMaster if not available.
>>
>> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
>> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
>> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
>> ---
>>   audio/coreaudio.c | 17 +++++++++++------
>>   1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
>> index d8a21d3e50..5b3aeaced0 100644
>> --- a/audio/coreaudio.c
>> +++ b/audio/coreaudio.c
>> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>>       bool enabled;
>>   } coreaudioVoiceOut;
>> +#if !defined(MAC_OS_VERSION_12_0) \
>> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
>> +#define kAudioObjectPropertyElementMain 
>> kAudioObjectPropertyElementMaster
>> +#endif
>> +
> 
> Unless I have missed something, we have found 
> MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the 
> following thread:
> https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/

I was reading the v3 comments and missed the v2 ones.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode
  2022-02-11 16:34 ` [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé via
@ 2022-02-14 12:49   ` Philippe Mathieu-Daudé via
  0 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-14 12:49 UTC (permalink / raw)
  To: Cameron Esfahani
  Cc: qemu-devel, Peter Maydell, Will Cohen, Akihiko Odaki,
	Alex Bennée, Christian Schoenebeck, Roman Bolshakov,
	Li Zhang, Julian Stecklina

Hi Cameron,

On 11/2/22 17:34, Philippe Mathieu-Daudé wrote:
> From: Cameron Esfahani <dirty@apple.com>
> 
> A guest could craft a specific stream of instructions that will have QEMU
> write 0xF9 to inappropriate locations in memory.  Add additional asserts
> to check for this.  Generate a #UD if there are more than 14 prefix bytes.
> 
> Found by Julian Stecklina <julian.stecklina@cyberus-technology.de>
> 
> Signed-off-by: Cameron Esfahani <dirty@apple.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/i386/hvf/x86_decode.c | 11 +++++++++--
>   target/i386/hvf/x86hvf.c     |  8 ++++++++
>   target/i386/hvf/x86hvf.h     |  1 +
>   3 files changed, 18 insertions(+), 2 deletions(-)

> @@ -1847,7 +1849,8 @@ void calc_modrm_operand(CPUX86State *env, struct x86_decode *decode,
>   
>   static void decode_prefix(CPUX86State *env, struct x86_decode *decode)
>   {
> -    while (1) {
> +    /* At most 14 prefix bytes. */
> +    for (int i = 0; i < 14; i++) {

Could we have a definition instead of this magic '14' number?

>           /*
>            * REX prefix must come after legacy prefixes.
>            * REX before legacy is ignored.
> @@ -1892,6 +1895,8 @@ static void decode_prefix(CPUX86State *env, struct x86_decode *decode)
>               return;
>           }
>       }
> +    /* Too many prefixes!  Generate #UD. */
> +    hvf_inject_ud(env);
>   }


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2022-02-14 13:39 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 16:34 [PATCH v4 00/13] host: Support macOS 12 Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 01/13] lcitool: refresh Philippe Mathieu-Daudé via
2022-02-12 15:14   ` Akihiko Odaki
2022-02-14 12:10     ` Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 02/13] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 03/13] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 04/13] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé via
2022-02-14 12:49   ` Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 06/13] hvf: Enable RDTSCP support Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 07/13] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 08/13] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 09/13] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé via
2022-02-12 13:35   ` Christian Schoenebeck
2022-02-14  3:27   ` Cameron Esfahani
2022-02-11 16:34 ` [PATCH v4 10/13] audio/coreaudio: " Philippe Mathieu-Daudé via
2022-02-12 13:15   ` Christian Schoenebeck
2022-02-12 15:23   ` Akihiko Odaki
2022-02-12 17:27     ` Christian Schoenebeck
2022-02-12 17:41       ` Christian Schoenebeck
2022-02-14 12:43     ` Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 11/13] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé via
2022-02-11 16:34 ` [PATCH v4 12/13] ui/cocoa: Remove allowedFileTypes restriction in SavePanel Philippe Mathieu-Daudé via
2022-02-12 13:25   ` Christian Schoenebeck
2022-02-14  3:26   ` Cameron Esfahani
2022-02-11 16:34 ` [PATCH v4 13/13] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé via

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.