All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 00/22] host: Support macOS 12
@ 2022-03-06 23:17 Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 01/22] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé
                   ` (23 more replies)
  0 siblings, 24 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

Missing review:
 0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
 0013-osdep-Avoid-using-Clang-specific-__builtin_available.patch
 0014-meson-Resolve-the-entitlement.sh-script-once-for-goo.patch
 0015-meson-Log-QEMU_CXXFLAGS-content-in-summary.patch
 0016-configure-Pass-filtered-QEMU_OBJCFLAGS-to-meson.patch
 0017-ui-cocoa-Constify-qkeycode-translation-arrays.patch
 0020-ui-cocoa-capture-all-keys-and-combos-when-mouse-is-g.patch
 0021-ui-cocoa-add-option-to-swap-Option-and-Command.patch
 0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch

Since v6:
- Dropped merged patches
- Addressed Akihiko Odaki comments (squashed 2 patches, added R/T-b)
- Dropped 'configure: Disable out-of-line atomic operations on Aarch64'
- Add few macos patches on the list pending for 7.0 so tested by CI

Since v5:
- Fixed failed rebase between patches 10 and 16 (Akihiko)
- Include "ui/cocoa: Fix the leak of qemu_console_get_label"

Since v4:
- Use MAC_OS_X_VERSION_MIN_REQUIRED definition (Akihiko)
- Include patches from Akihiko

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

Akihiko Odaki (2):
  audio: Log context for audio bug
  coreaudio: Always return 0 in handle_voice_change

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

Carwyn Ellis (2):
  ui/cocoa: add option to disable left-command forwarding to guest
  ui/cocoa: release mouse when user switches away from QEMU window

Gustavo Noronha Silva (2):
  ui/cocoa: capture all keys and combos when mouse is grabbed
  ui/cocoa: add option to swap Option and Command

Philippe Mathieu-Daudé (14):
  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
  audio: Rename coreaudio extension to use Objective-C compiler
  osdep: Avoid using Clang-specific __builtin_available()
  meson: Resolve the entitlement.sh script once for good
  meson: Log QEMU_CXXFLAGS content in summary
  configure: Pass filtered QEMU_OBJCFLAGS to meson
  ui/cocoa: Constify qkeycode translation arrays
  gitlab-ci: Support macOS 12 via cirrus-run

 .gitlab-ci.d/cirrus.yml            |  16 ++++
 .gitlab-ci.d/cirrus/macos-12.vars  |  16 ++++
 audio/audio.c                      |  25 +++---
 audio/audio_template.h             |  27 +++----
 audio/{coreaudio.c => coreaudio.m} |  23 +++---
 audio/meson.build                  |   4 +-
 block/file-posix.c                 |  14 +++-
 configure                          |  31 ++++++++
 include/qemu/osdep.h               |  10 +--
 meson.build                        |  17 +++-
 qapi/ui.json                       |  29 +++++++
 qemu-options.hx                    |  15 ++++
 target/i386/hvf/vmx.h              |  19 +++--
 target/i386/hvf/x86.c              |   6 +-
 target/i386/hvf/x86.h              |  34 --------
 target/i386/hvf/x86_decode.c       |  12 ++-
 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/fp/meson.build               |   5 ++
 tests/lcitool/refresh              |   1 +
 ui/cocoa.m                         | 122 ++++++++++++++++++++++++++---
 23 files changed, 327 insertions(+), 122 deletions(-)
 create mode 100644 .gitlab-ci.d/cirrus/macos-12.vars
 rename audio/{coreaudio.c => coreaudio.m} (97%)

-- 
2.34.1



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

* [PATCH v7 01/22] configure: Allow passing extra Objective C compiler flags
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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.

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
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 81618708e4..e60156f90f 100755
--- a/configure
+++ b/configure
@@ -285,6 +285,7 @@ done
 
 EXTRA_CFLAGS=""
 EXTRA_CXXFLAGS=""
+EXTRA_OBJCFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
@@ -366,9 +367,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"
@@ -748,6 +752,8 @@ for opt do
   ;;
   --extra-cxxflags=*)
   ;;
+  --extra-objcflags=*)
+  ;;
   --extra-ldflags=*)
   ;;
   --enable-debug-info)
@@ -1172,6 +1178,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
@@ -3137,6 +3144,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 038502714a..b6e30d7463 100644
--- a/meson.build
+++ b/meson.build
@@ -3457,6 +3457,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] 48+ messages in thread

* [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 01/22] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-09 11:17   ` Alex Bennée
  2022-03-06 23:17 ` [PATCH v7 03/22] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Roman Bolshakov, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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)

Reported-by: Roman Bolshakov <roman@roolebo.dev>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/fp/meson.build | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/fp/meson.build b/tests/fp/meson.build
index 59776a00a7..8bd0979f67 100644
--- a/tests/fp/meson.build
+++ b/tests/fp/meson.build
@@ -37,6 +37,11 @@ tfcflags = [
   '-Wno-error',
 ]
 
+if cc.get_id() == 'clang'
+  # Clang does not support '#pragma STDC FENV_ACCESS'
+  tfcflags += [ '-Wno-ignored-pragmas' ]
+endif
+
 tfgencases = [
   tfdir / 'genCases_ui32.c',
   tfdir / 'genCases_ui64.c',
-- 
2.34.1



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

* [PATCH v7 03/22] hvf: Use standard CR0 and CR4 register definitions
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 01/22] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 04/22] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block,
	Philippe Mathieu-Daudé,
	Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

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] 48+ messages in thread

* [PATCH v7 04/22] hvf: Make hvf_get_segments() / hvf_put_segments() local
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 03/22] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 05/22] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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 05ec1bddc4..907f09f1b4 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 99ed8d608d..db6003d6bd 100644
--- a/target/i386/hvf/x86hvf.h
+++ b/target/i386/hvf/x86hvf.h
@@ -26,11 +26,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] 48+ messages in thread

* [PATCH v7 05/22] hvf: Remove deprecated hv_vcpu_flush() calls
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 04/22] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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 907f09f1b4..bec9fc5814 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] 48+ messages in thread

* [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 05/22] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-09 10:20   ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 07/22] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

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>
Message-Id: <20220219063831.35356-1-dirty@apple.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hvf/x86_decode.c | 12 ++++++++++--
 target/i386/hvf/x86hvf.c     |  8 ++++++++
 target/i386/hvf/x86hvf.h     |  1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c
index 062713b1a4..5d051252b4 100644
--- a/target/i386/hvf/x86_decode.c
+++ b/target/i386/hvf/x86_decode.c
@@ -24,8 +24,10 @@
 #include "vmx.h"
 #include "x86_mmu.h"
 #include "x86_descr.h"
+#include "x86hvf.h"
 
 #define OPCODE_ESCAPE   0xf
+#define X86_MAX_INSN_PREFIX_LENGTH (14)
 
 static void decode_invalid(CPUX86State *env, struct x86_decode *decode)
 {
@@ -541,7 +543,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 +1850,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 X86_MAX_INSN_PREFIX_LENGTH prefix bytes. */
+    for (int i = 0; i < X86_MAX_INSN_PREFIX_LENGTH; i++) {
         /*
          * REX prefix must come after legacy prefixes.
          * REX before legacy is ignored.
@@ -1892,6 +1896,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 +2096,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 bec9fc5814..a338c207b7 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -423,6 +423,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 db6003d6bd..427cdc1c13 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] 48+ messages in thread

* [PATCH v7 07/22] block/file-posix: Remove a deprecation warning on macOS 12
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 08/22] audio/coreaudio: " Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed by: Cameron Esfahani <dirty@apple.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-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] 48+ messages in thread

* [PATCH v7 08/22] audio/coreaudio: Remove a deprecation warning on macOS 12
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 07/22] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 09/22] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Roman Bolshakov, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
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 0f19d0ce01..23d7593eb9 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_MIN_REQUIRED < 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] 48+ messages in thread

* [PATCH v7 09/22] audio/dbus: Fix building with modules on macOS
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 08/22] audio/coreaudio: " Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 10/22] audio: Log context for audio bug Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Li Zhang,
	Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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] 48+ messages in thread

* [PATCH v7 10/22] audio: Log context for audio bug
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 09/22] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 11/22] coreaudio: Always return 0 in handle_voice_change Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Akihiko Odaki <akihiko.odaki@gmail.com>

Without this change audio_bug aborts when the bug condition is met,
which discards following useful logs. Call abort after such logs.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220306063202.27331-1-akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/audio.c          | 25 ++++++++++++-------------
 audio/audio_template.h | 27 ++++++++++++---------------
 2 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index a88572e713..6bc313d9f5 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -117,7 +117,6 @@ int audio_bug (const char *funcname, int cond)
             AUD_log (NULL, "I am sorry\n");
         }
         AUD_log (NULL, "Context:\n");
-        abort();
     }
 
     return cond;
@@ -138,7 +137,7 @@ static inline int audio_bits_to_index (int bits)
     default:
         audio_bug ("bits_to_index", 1);
         AUD_log (NULL, "invalid bits %d\n", bits);
-        return 0;
+        abort();
     }
 }
 
@@ -156,7 +155,7 @@ void *audio_calloc (const char *funcname, int nmemb, size_t size)
         AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n",
                  funcname);
         AUD_log (NULL, "nmemb=%d size=%zu (len=%zu)\n", nmemb, size, len);
-        return NULL;
+        abort();
     }
 
     return g_malloc0 (len);
@@ -543,7 +542,7 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw)
     size_t live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
     if (audio_bug(__func__, live > hw->conv_buf->size)) {
         dolog("live=%zu hw->conv_buf->size=%zu\n", live, hw->conv_buf->size);
-        return 0;
+        abort();
     }
     return live;
 }
@@ -581,7 +580,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size)
     }
     if (audio_bug(__func__, live > hw->conv_buf->size)) {
         dolog("live_in=%zu hw->conv_buf->size=%zu\n", live, hw->conv_buf->size);
-        return 0;
+        abort();
     }
 
     rpos = audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size);
@@ -656,7 +655,7 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
 
         if (audio_bug(__func__, live > hw->mix_buf->size)) {
             dolog("live=%zu hw->mix_buf->size=%zu\n", live, hw->mix_buf->size);
-            return 0;
+            abort();
         }
         return live;
     }
@@ -706,7 +705,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size)
     live = sw->total_hw_samples_mixed;
     if (audio_bug(__func__, live > hwsamples)) {
         dolog("live=%zu hw->mix_buf->size=%zu\n", live, hwsamples);
-        return 0;
+        abort();
     }
 
     if (live == hwsamples) {
@@ -998,7 +997,7 @@ static size_t audio_get_avail (SWVoiceIn *sw)
     if (audio_bug(__func__, live > sw->hw->conv_buf->size)) {
         dolog("live=%zu sw->hw->conv_buf->size=%zu\n", live,
               sw->hw->conv_buf->size);
-        return 0;
+        abort();
     }
 
     ldebug (
@@ -1028,7 +1027,7 @@ static size_t audio_get_free(SWVoiceOut *sw)
     if (audio_bug(__func__, live > sw->hw->mix_buf->size)) {
         dolog("live=%zu sw->hw->mix_buf->size=%zu\n", live,
               sw->hw->mix_buf->size);
-        return 0;
+        abort();
     }
 
     dead = sw->hw->mix_buf->size - live;
@@ -1170,7 +1169,7 @@ static void audio_run_out (AudioState *s)
 
         if (audio_bug(__func__, live > hw->mix_buf->size)) {
             dolog("live=%zu hw->mix_buf->size=%zu\n", live, hw->mix_buf->size);
-            continue;
+            abort();
         }
 
         if (hw->pending_disable && !nb_live) {
@@ -1203,7 +1202,7 @@ static void audio_run_out (AudioState *s)
         if (audio_bug(__func__, hw->mix_buf->pos >= hw->mix_buf->size)) {
             dolog("hw->mix_buf->pos=%zu hw->mix_buf->size=%zu played=%zu\n",
                   hw->mix_buf->pos, hw->mix_buf->size, played);
-            hw->mix_buf->pos = 0;
+            abort();
         }
 
 #ifdef DEBUG_OUT
@@ -1223,7 +1222,7 @@ static void audio_run_out (AudioState *s)
             if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) {
                 dolog("played=%zu sw->total_hw_samples_mixed=%zu\n",
                       played, sw->total_hw_samples_mixed);
-                played = sw->total_hw_samples_mixed;
+                abort();
             }
 
             sw->total_hw_samples_mixed -= played;
@@ -1346,7 +1345,7 @@ static void audio_run_capture (AudioState *s)
             if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)) {
                 dolog("captured=%zu sw->total_hw_samples_mixed=%zu\n",
                       captured, sw->total_hw_samples_mixed);
-                captured = sw->total_hw_samples_mixed;
+                abort();
             }
 
             sw->total_hw_samples_mixed -= captured;
diff --git a/audio/audio_template.h b/audio/audio_template.h
index d2d348638b..7192b19e73 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -59,12 +59,13 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
     if (audio_bug(__func__, !voice_size && max_voices)) {
         dolog ("drv=`%s' voice_size=0 max_voices=%d\n",
                drv->name, max_voices);
-        glue (s->nb_hw_voices_, TYPE) = 0;
+        abort();
     }
 
     if (audio_bug(__func__, voice_size && !max_voices)) {
         dolog ("drv=`%s' voice_size=%d max_voices=0\n",
                drv->name, voice_size);
+        abort();
     }
 }
 
@@ -81,6 +82,7 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
         size_t samples = hw->samples;
         if (audio_bug(__func__, samples == 0)) {
             dolog("Attempted to allocate empty buffer\n");
+            abort();
         }
 
         HWBUF = g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * samples);
@@ -252,12 +254,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
 
     if (audio_bug(__func__, !drv)) {
         dolog ("No host audio driver\n");
-        return NULL;
+        abort();
     }
 
     if (audio_bug(__func__, !drv->pcm_ops)) {
         dolog ("Host audio driver without pcm_ops\n");
-        return NULL;
+        abort();
     }
 
     hw = audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE));
@@ -275,12 +277,13 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
     QLIST_INIT (&hw->cap_head);
 #endif
     if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) {
-        goto err0;
+        g_free(hw);
+        return NULL;
     }
 
     if (audio_bug(__func__, hw->samples <= 0)) {
         dolog("hw->samples=%zd\n", hw->samples);
-        goto err1;
+        abort();
     }
 
     if (hw->info.is_float) {
@@ -309,12 +312,6 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
     audio_attach_capture (hw);
 #endif
     return hw;
-
- err1:
-    glue (hw->pcm_ops->fini_, TYPE) (hw);
- err0:
-    g_free (hw);
-    return NULL;
 }
 
 AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
@@ -435,7 +432,7 @@ void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw)
     if (sw) {
         if (audio_bug(__func__, !card)) {
             dolog ("card=%p\n", card);
-            return;
+            abort();
         }
 
         glue (audio_close_, TYPE) (sw);
@@ -457,7 +454,7 @@ SW *glue (AUD_open_, TYPE) (
     if (audio_bug(__func__, !card || !name || !callback_fn || !as)) {
         dolog ("card=%p name=%p callback_fn=%p as=%p\n",
                card, name, callback_fn, as);
-        goto fail;
+        abort();
     }
 
     s = card->state;
@@ -468,12 +465,12 @@ SW *glue (AUD_open_, TYPE) (
 
     if (audio_bug(__func__, audio_validate_settings(as))) {
         audio_print_settings (as);
-        goto fail;
+        abort();
     }
 
     if (audio_bug(__func__, !s->drv)) {
         dolog ("Can not open `%s' (no host audio driver)\n", name);
-        goto fail;
+        abort();
     }
 
     if (sw && audio_pcm_info_eq (&sw->info, as)) {
-- 
2.34.1



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

* [PATCH v7 11/22] coreaudio: Always return 0 in handle_voice_change
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 10/22] audio: Log context for audio bug Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 12/22] audio: Rename coreaudio extension to use Objective-C compiler Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Akihiko Odaki <akihiko.odaki@gmail.com>

handle_voice_change() is a CoreAudio callback function as of CoreAudio type
AudioObjectPropertyListenerProc, and for the latter MacOSX.sdk/System/
Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h
says "The return value is currently unused and should always be 0.".

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220306123410.61063-1-akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/coreaudio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index 23d7593eb9..3186b68474 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -545,7 +545,6 @@ static OSStatus handle_voice_change(
     const AudioObjectPropertyAddress *in_addresses,
     void *in_client_data)
 {
-    OSStatus status;
     coreaudioVoiceOut *core = in_client_data;
 
     qemu_mutex_lock_iothread();
@@ -554,13 +553,12 @@ static OSStatus handle_voice_change(
         fini_out_device(core);
     }
 
-    status = init_out_device(core);
-    if (!status) {
+    if (!init_out_device(core)) {
         update_device_playback_state(core);
     }
 
     qemu_mutex_unlock_iothread();
-    return status;
+    return 0;
 }
 
 static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
-- 
2.34.1



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

* [PATCH v7 12/22] audio: Rename coreaudio extension to use Objective-C compiler
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 11/22] coreaudio: Always return 0 in handle_voice_change Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available() Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

The coreaudio library includes Objective-C declarations (using the
caret '^' symbol to declare block references [*]). When building
with a C compiler we get:

  [175/839] Compiling C object libcommon.fa.p/audio_coreaudio.c.o
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:18,
                     from ../../audio/coreaudio.c:26:
    /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:162:2: error: expected identifier or '(' before '^' token
      162 | (^AudioObjectPropertyListenerBlock)(    UInt32                              inNumberAddresses,
          |  ^
    FAILED: libcommon.fa.p/audio_coreaudio.c.o

Rename the file to use the Objective-C default extension (.m) so
meson calls the correct compiler.

[*] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/{coreaudio.c => coreaudio.m} | 0
 audio/meson.build                  | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename audio/{coreaudio.c => coreaudio.m} (100%)

diff --git a/audio/coreaudio.c b/audio/coreaudio.m
similarity index 100%
rename from audio/coreaudio.c
rename to audio/coreaudio.m
diff --git a/audio/meson.build b/audio/meson.build
index d9b295514f..94dab16891 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -7,7 +7,7 @@ softmmu_ss.add(files(
   'wavcapture.c',
 ))
 
-softmmu_ss.add(when: coreaudio, if_true: files('coreaudio.c'))
+softmmu_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
 softmmu_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
 
 audio_modules = {}
-- 
2.34.1



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

* [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available()
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 12/22] audio: Rename coreaudio extension to use Objective-C compiler Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07  4:11   ` Akihiko Odaki
  2022-03-06 23:17 ` [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Remove the Clang specific __builtin_available() to allow building
with GCC, otherwise we get:

  include/qemu/osdep.h: In function 'qemu_thread_jit_write':
  include/qemu/osdep.h:787:9: warning: implicit declaration of function '__builtin_available'; did you mean '__builtin_scalbl'? [-Wimplicit-function-declaration]
    787 |     if (__builtin_available(macOS 11.0, *)) {
        |         ^~~~~~~~~~~~~~~~~~~
        |         __builtin_scalbl
  include/qemu/osdep.h:787:9: warning: nested extern declaration of '__builtin_available' [-Wnested-externs]
  include/qemu/osdep.h:787:29: error: 'macOS' undeclared (first use in this function)
    787 |     if (__builtin_available(macOS 11.0, *)) {
        |                             ^~~~~
  include/qemu/osdep.h:787:29: note: each undeclared identifier is reported only once for each function it appears in
  include/qemu/osdep.h:787:34: error: expected ')' before numeric constant
    787 |     if (__builtin_available(macOS 11.0, *)) {
        |                            ~     ^~~~~
        |                                  )

Beside, on macOS Catalina we get 2254 times:

  include/qemu/osdep.h:780:5: warning: 'pthread_jit_write_protect_np' is only available on macOS 11.0 or newer [-Wunguarded-availability-new]
      pthread_jit_write_protect_np(true);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by using a stricker toolchain version low range, replacing
MAC_OS_X_VERSION_MAX_ALLOWED by MAC_OS_X_VERSION_MIN_REQUIRED.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/qemu/osdep.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 7bcce3bceb..488a286300 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -642,19 +642,15 @@ size_t qemu_get_host_physmem(void);
  * for the current thread.
  */
 #if defined(MAC_OS_VERSION_11_0) && \
-    MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
+    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
 static inline void qemu_thread_jit_execute(void)
 {
-    if (__builtin_available(macOS 11.0, *)) {
-        pthread_jit_write_protect_np(true);
-    }
+    pthread_jit_write_protect_np(true);
 }
 
 static inline void qemu_thread_jit_write(void)
 {
-    if (__builtin_available(macOS 11.0, *)) {
-        pthread_jit_write_protect_np(false);
-    }
+    pthread_jit_write_protect_np(false);
 }
 #else
 static inline void qemu_thread_jit_write(void) {}
-- 
2.34.1



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

* [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available() Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07  4:13   ` Akihiko Odaki
  2022-03-06 23:17 ` [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Commit 235b523dba ("meson: Use find_program() to resolve the
entitlement.sh script") didn't correctly fixed the issue, as
the script is still resolved for each target. Move the check
earlier, before processing each target.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index b6e30d7463..8ca2b7c8c2 100644
--- a/meson.build
+++ b/meson.build
@@ -3063,6 +3063,10 @@ common_all = static_library('common',
 
 feature_to_c = find_program('scripts/feature_to_c.sh')
 
+if targetos == 'darwin'
+  entitlement = find_program('scripts/entitlement.sh')
+endif
+
 emulators = {}
 foreach target : target_dirs
   config_target = config_target_mak[target]
@@ -3220,7 +3224,6 @@ foreach target : target_dirs
         install_input += meson.current_source_dir() / entitlements
       endif
 
-      entitlement = find_program('scripts/entitlement.sh')
       emulators += {exe['name'] : custom_target(exe['name'],
                    input: build_input,
                    output: exe['name'],
-- 
2.34.1



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

* [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07  4:13   ` Akihiko Odaki
  2022-03-06 23:17 ` [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

diff --git a/meson.build b/meson.build
index 8ca2b7c8c2..0d38b2e72a 100644
--- a/meson.build
+++ b/meson.build
@@ -3470,6 +3470,7 @@ if link_args.length() > 0
   summary_info += {'LDFLAGS':         ' '.join(link_args)}
 endif
 summary_info += {'QEMU_CFLAGS':       config_host['QEMU_CFLAGS']}
+summary_info += {'QEMU_CXXFLAGS':     config_host['QEMU_CXXFLAGS']}
 summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
 summary_info += {'profiler':          get_option('profiler')}
 summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
-- 
2.34.1



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

* [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07  4:15   ` Akihiko Odaki
  2022-03-06 23:17 ` [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Paolo Bonzini, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Filter unsupported Objective-C options, to avoid
'unknown-warning-option' warnings when using Clang:

  [34/373] Compiling Objective-C object libcommon.fa.p/audio_coreaudio.m.o
  warning: unknown warning option '-Wold-style-declaration'; did you mean '-Wout-of-line-declaration'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wimplicit-fallthrough=2'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
  2 warnings generated.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 configure   | 23 +++++++++++++++++++++++
 meson.build |  6 +++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index e60156f90f..7d1f35603b 100755
--- a/configure
+++ b/configure
@@ -77,6 +77,7 @@ TMPB="qemu-conf"
 TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
+TMPM="${TMPDIR1}/${TMPB}.m"
 TMPE="${TMPDIR1}/${TMPB}.exe"
 
 rm -f config.log
@@ -148,6 +149,10 @@ do_cxx() {
     do_compiler "$cxx" $CPU_CFLAGS "$@"
 }
 
+do_objc() {
+    do_compiler "$objcc" $CPU_CFLAGS "$@"
+}
+
 # Append $2 to the variable named $1, with space separation
 add_to() {
     eval $1=\${$1:+\"\$$1 \"}\$2
@@ -1445,10 +1450,27 @@ cc_has_warning_flag() {
     compile_prog "-Werror $optflag" ""
 }
 
+objcc_has_warning_flag() {
+    cat > $TMPM <<EOF
+int main(void) { return 0; }
+EOF
+
+    # Use the positive sense of the flag when testing for -Wno-wombat
+    # support (gcc will happily accept the -Wno- form of unknown
+    # warning options).
+    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
+    do_objc -Werror $optflag \
+      $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
+      -o $TMPE $TMPM $QEMU_LDFLAGS
+}
+
 for flag in $gcc_flags; do
     if cc_has_warning_flag $flag ; then
         QEMU_CFLAGS="$QEMU_CFLAGS $flag"
     fi
+    if objcc_has_warning_flag $flag ; then
+        QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag"
+    fi
 done
 
 if test "$stack_protector" != "no"; then
@@ -2990,6 +3012,7 @@ echo "LD=$ld" >> $config_host_mak
 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
+echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
diff --git a/meson.build b/meson.build
index 0d38b2e72a..a770e80a32 100644
--- a/meson.build
+++ b/meson.build
@@ -173,11 +173,13 @@ endif
 
 qemu_cflags = config_host['QEMU_CFLAGS'].split()
 qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
+qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
 qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
 
 if get_option('gprof')
   qemu_cflags += ['-p']
   qemu_cxxflags += ['-p']
+  qemu_objcflags += ['-p']
   qemu_ldflags += ['-p']
 endif
 
@@ -216,8 +218,9 @@ if get_option('fuzzing')
   endif
 endif
 
-add_global_arguments(qemu_cflags, native: false, language: ['c', 'objc'])
+add_global_arguments(qemu_cflags, native: false, language: ['c'])
 add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
+add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
 add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
 
 if targetos == 'linux'
@@ -3471,6 +3474,7 @@ if link_args.length() > 0
 endif
 summary_info += {'QEMU_CFLAGS':       config_host['QEMU_CFLAGS']}
 summary_info += {'QEMU_CXXFLAGS':     config_host['QEMU_CXXFLAGS']}
+summary_info += {'QEMU_OBJCFLAGS':    config_host['QEMU_OBJCFLAGS']}
 summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
 summary_info += {'profiler':          get_option('profiler')}
 summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
-- 
2.34.1



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

* [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07  4:16   ` Akihiko Odaki
  2022-03-06 23:17 ` [PATCH v7 18/22] ui/cocoa: add option to disable left-command forwarding to guest Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 ui/cocoa.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 8ab9ab5e84..a6db8ebfb6 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -671,7 +671,7 @@ QemuCocoaView *cocoaView;
 
     /* translates Macintosh keycodes to QEMU's keysym */
 
-    int without_control_translation[] = {
+    static const int without_control_translation[] = {
         [0 ... 0xff] = 0,   // invalid key
 
         [kVK_UpArrow]       = QEMU_KEY_UP,
@@ -686,7 +686,7 @@ QemuCocoaView *cocoaView;
         [kVK_Delete]        = QEMU_KEY_BACKSPACE,
     };
 
-    int with_control_translation[] = {
+    static const int with_control_translation[] = {
         [0 ... 0xff] = 0,   // invalid key
 
         [kVK_UpArrow]       = QEMU_KEY_CTRL_UP,
-- 
2.34.1



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

* [PATCH v7 18/22] ui/cocoa: add option to disable left-command forwarding to guest
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 19/22] ui/cocoa: release mouse when user switches away from QEMU window Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Carwyn Ellis, Alex Bennée

From: Carwyn Ellis <carwynellis@gmail.com>

When switching between guest and host on a Mac using command-tab the
command key is sent to the guest which can trigger functionality in the
guest OS. Specifying left-command-key=off disables forwarding this key
to the guest. Defaults to enabled.

Also updated the cocoa display documentation to reference the new
left-command-key option along with the existing show-cursor option.

Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
[PMD: Set QAPI structure @since tag to 7.0]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 qapi/ui.json    | 18 ++++++++++++++++++
 qemu-options.hx | 12 ++++++++++++
 ui/cocoa.m      |  8 +++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 4a13f883a3..4dea35a819 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1260,6 +1260,23 @@
 { 'struct'  : 'DisplayCurses',
   'data'    : { '*charset'       : 'str' } }
 
+##
+# @DisplayCocoa:
+#
+# Cocoa display options.
+#
+# @left-command-key: Enable/disable forwarding of left command key to
+#                    guest. Allows command-tab window switching on the
+#                    host without sending this key to the guest when
+#                    "off". Defaults to "on"
+#
+# Since: 7.0
+##
+{ 'struct': 'DisplayCocoa',
+  'data': {
+      '*left-command-key': 'bool'
+  } }
+
 ##
 # @DisplayType:
 #
@@ -1338,6 +1355,7 @@
   'discriminator' : 'type',
   'data'    : {
       'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' },
+      'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' },
       'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
       'egl-headless': { 'type': 'DisplayEGLHeadless',
                         'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
diff --git a/qemu-options.hx b/qemu-options.hx
index 094a6c1d7c..ffaeab61ed 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1922,6 +1922,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 #if defined(CONFIG_DBUS_DISPLAY)
     "-display dbus[,addr=<dbusaddr>]\n"
     "             [,gl=on|core|es|off][,rendernode=<file>]\n"
+#endif
+#if defined(CONFIG_COCOA)
+    "-display cocoa[,show-cursor=on|off][,left-command-key=on|off]\n"
 #endif
     "-display none\n"
     "                select display backend type\n"
@@ -2009,6 +2012,15 @@ SRST
         ``charset=CP850`` for IBM CP850 encoding. The default is
         ``CP437``.
 
+    ``cocoa``
+        Display video output in a Cocoa window. Mac only. This interface
+        provides drop-down menus and other UI elements to configure and
+        control the VM during runtime. Valid parameters are:
+
+        ``show-cursor=on|off`` :  Force showing the mouse cursor
+
+        ``left-command-key=on|off`` : Disable forwarding left command key to host
+
     ``egl-headless[,rendernode=<file>]``
         Offload all OpenGL operations to a local DRI device. For any
         graphical display, this display needs to be paired with either
diff --git a/ui/cocoa.m b/ui/cocoa.m
index a6db8ebfb6..319af5045b 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -95,6 +95,7 @@ static DisplayChangeListener dcl = {
 };
 static int last_buttons;
 static int cursor_hide = 1;
+static int left_command_key_enabled = 1;
 
 static int gArgc;
 static char **gArgv;
@@ -853,7 +854,8 @@ QemuCocoaView *cocoaView;
                 /* Don't pass command key changes to guest unless mouse is grabbed */
                 case kVK_Command:
                     if (isMouseGrabbed &&
-                        !!(modifiers & NSEventModifierFlagCommand)) {
+                        !!(modifiers & NSEventModifierFlagCommand) &&
+                        left_command_key_enabled) {
                         [self toggleKey:Q_KEY_CODE_META_L];
                     }
                     break;
@@ -2068,6 +2070,10 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
         cursor_hide = 0;
     }
 
+    if (opts->u.cocoa.has_left_command_key && !opts->u.cocoa.left_command_key) {
+        left_command_key_enabled = 0;
+    }
+
     // register vga output callbacks
     register_displaychangelistener(&dcl);
 
-- 
2.34.1



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

* [PATCH v7 19/22] ui/cocoa: release mouse when user switches away from QEMU window
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 18/22] ui/cocoa: add option to disable left-command forwarding to guest Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-06 23:17 ` [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Carwyn Ellis, Alex Bennée

From: Carwyn Ellis <carwynellis@gmail.com>

This resolves an issue where using command-tab to switch between QEMU
and other windows on the host can leave the mouse pointer visible.

By releasing the mouse when the user switches away, the user must left
click on the QEMU window when switching back in order to hide the
pointer and return control to the guest.

This appraoch ensures that the calls to NSCursor hide and unhide are
always balanced and thus work correctly when invoked.

Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 ui/cocoa.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 319af5045b..31f0846c30 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1264,6 +1264,7 @@ QemuCocoaView *cocoaView;
 - (void) applicationWillResignActive: (NSNotification *)aNotification
 {
     COCOA_DEBUG("QemuCocoaAppController: applicationWillResignActive\n");
+    [cocoaView ungrabMouse];
     [cocoaView raiseAllKeys];
 }
 
@@ -2066,6 +2067,7 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
             [(QemuCocoaAppController *)[[NSApplication sharedApplication] delegate] toggleFullScreen: nil];
         });
     }
+
     if (opts->has_show_cursor && opts->show_cursor) {
         cursor_hide = 0;
     }
-- 
2.34.1



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

* [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 19/22] ui/cocoa: release mouse when user switches away from QEMU window Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07 17:01   ` Will Cohen
  2022-03-06 23:17 ` [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Markus Armbruster, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée,
	Gustavo Noronha Silva

From: Gustavo Noronha Silva <gustavo@noronha.dev.br>

Applications such as Gnome may use Alt-Tab and Super-Tab for different
purposes, some use Ctrl-arrows so we want to allow qemu to handle
everything when it captures the mouse/keyboard.

However, Mac OS handles some combos like Command-Tab and Ctrl-arrows
at an earlier part of the event handling chain, not letting qemu see it.

We add a global Event Tap that allows qemu to see all events when the
mouse is grabbed. Note that this requires additional permissions.

See:

https://developer.apple.com/documentation/coregraphics/1454426-cgeventtapcreate?language=objc#discussion
https://support.apple.com/en-in/guide/mac-help/mh32356/mac

Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
Message-Id: <20210713213200.2547-2-gustavo@noronha.dev.br>
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20220306121119.45631-2-akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 qapi/ui.json    |  8 +++++-
 qemu-options.hx |  3 +++
 ui/cocoa.m      | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 4dea35a819..1d60d5fc78 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1270,11 +1270,17 @@
 #                    host without sending this key to the guest when
 #                    "off". Defaults to "on"
 #
+# @full-grab: Capture all key presses, including system combos. This
+#             requires accessibility permissions, since it performs
+#             a global grab on key events. (default: off)
+#             See https://support.apple.com/en-in/guide/mac-help/mh32356/mac
+#
 # Since: 7.0
 ##
 { 'struct': 'DisplayCocoa',
   'data': {
-      '*left-command-key': 'bool'
+      '*left-command-key': 'bool',
+      '*full-grab': 'bool'
   } }
 
 ##
diff --git a/qemu-options.hx b/qemu-options.hx
index ffaeab61ed..2e6d54db4f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1916,6 +1916,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 #if defined(CONFIG_CURSES)
     "-display curses[,charset=<encoding>]\n"
 #endif
+#if defined(CONFIG_COCOA)
+    "-display cocoa[,full_grab=on|off]\n"
+#endif
 #if defined(CONFIG_OPENGL)
     "-display egl-headless[,rendernode=<file>]\n"
 #endif
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 31f0846c30..ca1cab1ae6 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -309,11 +309,13 @@ static void handleAnyDeviceErrors(Error * err)
     BOOL isMouseGrabbed;
     BOOL isFullscreen;
     BOOL isAbsoluteEnabled;
+    CFMachPortRef eventsTap;
 }
 - (void) switchSurface:(pixman_image_t *)image;
 - (void) grabMouse;
 - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;
+- (void) setFullGrab:(id)sender;
 - (void) handleMonitorInput:(NSEvent *)event;
 - (bool) handleEvent:(NSEvent *)event;
 - (bool) handleEventLocked:(NSEvent *)event;
@@ -336,6 +338,19 @@ static void handleAnyDeviceErrors(Error * err)
 
 QemuCocoaView *cocoaView;
 
+static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef cgEvent, void *userInfo)
+{
+    QemuCocoaView *cocoaView = userInfo;
+    NSEvent *event = [NSEvent eventWithCGEvent:cgEvent];
+    if ([cocoaView isMouseGrabbed] && [cocoaView handleEvent:event]) {
+        COCOA_DEBUG("Global events tap: qemu handled the event, capturing!\n");
+        return NULL;
+    }
+    COCOA_DEBUG("Global events tap: qemu did not handle the event, letting it through...\n");
+
+    return cgEvent;
+}
+
 @implementation QemuCocoaView
 - (id)initWithFrame:(NSRect)frameRect
 {
@@ -361,6 +376,11 @@ QemuCocoaView *cocoaView;
     }
 
     qkbd_state_free(kbd);
+
+    if (eventsTap) {
+        CFRelease(eventsTap);
+    }
+
     [super dealloc];
 }
 
@@ -655,6 +675,36 @@ QemuCocoaView *cocoaView;
     }
 }
 
+- (void) setFullGrab:(id)sender
+{
+    COCOA_DEBUG("QemuCocoaView: setFullGrab\n");
+
+    CGEventMask mask = CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventKeyUp) | CGEventMaskBit(kCGEventFlagsChanged);
+    eventsTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault,
+                                 mask, handleTapEvent, self);
+    if (!eventsTap) {
+        warn_report("Could not create event tap, system key combos will not be captured.\n");
+        return;
+    } else {
+        COCOA_DEBUG("Global events tap created! Will capture system key combos.\n");
+    }
+
+    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
+    if (!runLoop) {
+        warn_report("Could not obtain current CF RunLoop, system key combos will not be captured.\n");
+        return;
+    }
+
+    CFRunLoopSourceRef tapEventsSrc = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventsTap, 0);
+    if (!tapEventsSrc ) {
+        warn_report("Could not obtain current CF RunLoop, system key combos will not be captured.\n");
+        return;
+    }
+
+    CFRunLoopAddSource(runLoop, tapEventsSrc, kCFRunLoopDefaultMode);
+    CFRelease(tapEventsSrc);
+}
+
 - (void) toggleKey: (int)keycode {
     qkbd_state_key_event(kbd, keycode, !qkbd_state_key_get(kbd, keycode));
 }
@@ -1284,6 +1334,13 @@ QemuCocoaView *cocoaView;
     [cocoaView toggleFullScreen:sender];
 }
 
+- (void) setFullGrab:(id)sender
+{
+    COCOA_DEBUG("QemuCocoaAppController: setFullGrab\n");
+
+    [cocoaView setFullGrab:sender];
+}
+
 /* Tries to find then open the specified filename */
 - (void) openDocumentation: (NSString *) filename
 {
@@ -2060,11 +2117,17 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
     qemu_sem_wait(&app_started_sem);
     COCOA_DEBUG("cocoa_display_init: app start completed\n");
 
+    QemuCocoaAppController *controller = (QemuCocoaAppController *)[[NSApplication sharedApplication] delegate];
     /* if fullscreen mode is to be used */
     if (opts->has_full_screen && opts->full_screen) {
         dispatch_async(dispatch_get_main_queue(), ^{
             [NSApp activateIgnoringOtherApps: YES];
-            [(QemuCocoaAppController *)[[NSApplication sharedApplication] delegate] toggleFullScreen: nil];
+            [controller toggleFullScreen: nil];
+        });
+    }
+    if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [controller setFullGrab: nil];
         });
     }
 
-- 
2.34.1



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

* [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-07 17:00   ` Will Cohen
  2022-03-06 23:17 ` [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Markus Armbruster, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée,
	Gustavo Noronha Silva

From: Gustavo Noronha Silva <gustavo@noronha.dev.br>

On Mac OS X the Option key maps to Alt and Command to Super/Meta. This change
swaps them around so that Alt is the key closer to the space bar and Meta/Super
is between Control and Alt, like on non-Mac keyboards.

It is a cocoa display option, disabled by default.

Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
Message-Id: <20210713213200.2547-3-gustavo@noronha.dev.br>
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20220306121119.45631-3-akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 qapi/ui.json    |  7 ++++++-
 qemu-options.hx |  2 +-
 ui/cocoa.m      | 49 +++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 1d60d5fc78..664da9e462 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1275,12 +1275,17 @@
 #             a global grab on key events. (default: off)
 #             See https://support.apple.com/en-in/guide/mac-help/mh32356/mac
 #
+# @swap-opt-cmd: Swap the Option and Command keys so that their key codes match
+#                their position on non-Mac keyboards and you can use Meta/Super
+#                and Alt where you expect them. (default: off)
+#
 # Since: 7.0
 ##
 { 'struct': 'DisplayCocoa',
   'data': {
       '*left-command-key': 'bool',
-      '*full-grab': 'bool'
+      '*full-grab': 'bool',
+      '*swap-opt-cmd': 'bool'
   } }
 
 ##
diff --git a/qemu-options.hx b/qemu-options.hx
index 2e6d54db4f..f443b0f33a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1917,7 +1917,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
     "-display curses[,charset=<encoding>]\n"
 #endif
 #if defined(CONFIG_COCOA)
-    "-display cocoa[,full_grab=on|off]\n"
+    "-display cocoa[,full-grab=on|off][,swap-opt-cmd=on|off]\n"
 #endif
 #if defined(CONFIG_OPENGL)
     "-display egl-headless[,rendernode=<file>]\n"
diff --git a/ui/cocoa.m b/ui/cocoa.m
index ca1cab1ae6..c0a948201d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -96,6 +96,7 @@ static DisplayChangeListener dcl = {
 static int last_buttons;
 static int cursor_hide = 1;
 static int left_command_key_enabled = 1;
+static bool swap_opt_cmd;
 
 static int gArgc;
 static char **gArgv;
@@ -854,12 +855,22 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
         qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false);
     }
     if (!(modifiers & NSEventModifierFlagOption)) {
-        qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
-        qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+        if (swap_opt_cmd) {
+            qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+            qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+        } else {
+            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+        }
     }
     if (!(modifiers & NSEventModifierFlagCommand)) {
-        qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
-        qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+        if (swap_opt_cmd) {
+            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+        } else {
+            qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+            qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+        }
     }
 
     switch ([event type]) {
@@ -891,29 +902,44 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
 
                 case kVK_Option:
                     if (!!(modifiers & NSEventModifierFlagOption)) {
-                        [self toggleKey:Q_KEY_CODE_ALT];
+                        if (swap_opt_cmd) {
+                            [self toggleKey:Q_KEY_CODE_META_L];
+                        } else {
+                            [self toggleKey:Q_KEY_CODE_ALT];
+                        }
                     }
                     break;
 
                 case kVK_RightOption:
                     if (!!(modifiers & NSEventModifierFlagOption)) {
-                        [self toggleKey:Q_KEY_CODE_ALT_R];
+                        if (swap_opt_cmd) {
+                            [self toggleKey:Q_KEY_CODE_META_R];
+                        } else {
+                            [self toggleKey:Q_KEY_CODE_ALT_R];
+                        }
                     }
                     break;
 
                 /* Don't pass command key changes to guest unless mouse is grabbed */
                 case kVK_Command:
                     if (isMouseGrabbed &&
-                        !!(modifiers & NSEventModifierFlagCommand) &&
-                        left_command_key_enabled) {
-                        [self toggleKey:Q_KEY_CODE_META_L];
+                        !!(modifiers & NSEventModifierFlagCommand)) {
+                        if (swap_opt_cmd) {
+                            [self toggleKey:Q_KEY_CODE_ALT];
+                        } else {
+                            [self toggleKey:Q_KEY_CODE_META_L];
+                        }
                     }
                     break;
 
                 case kVK_RightCommand:
                     if (isMouseGrabbed &&
                         !!(modifiers & NSEventModifierFlagCommand)) {
-                        [self toggleKey:Q_KEY_CODE_META_R];
+                        if (swap_opt_cmd) {
+                            [self toggleKey:Q_KEY_CODE_ALT_R];
+                        } else {
+                            [self toggleKey:Q_KEY_CODE_META_R];
+                        }
                     }
                     break;
             }
@@ -2134,6 +2160,9 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
     if (opts->has_show_cursor && opts->show_cursor) {
         cursor_hide = 0;
     }
+    if (opts->u.cocoa.has_swap_opt_cmd) {
+        swap_opt_cmd = opts->u.cocoa.swap_opt_cmd;
+    }
 
     if (opts->u.cocoa.has_left_command_key && !opts->u.cocoa.left_command_key) {
         left_command_key_enabled = 0;
-- 
2.34.1



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

* [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command Philippe Mathieu-Daudé
@ 2022-03-06 23:17 ` Philippe Mathieu-Daudé
  2022-03-09 10:24   ` Philippe Mathieu-Daudé
  2022-03-09 10:28   ` Daniel P. Berrangé
  2022-03-15 12:48 ` [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
  2022-05-03  9:40 ` Claudio Fontana
  23 siblings, 2 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-06 23:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

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)
 - Run Aarch64 qtests instead of x86_64 ones

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..be1dce5d4e 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-aarch64
+
 
 # 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 1f00281b44..e2f0bbd1b1 100755
--- a/tests/lcitool/refresh
+++ b/tests/lcitool/refresh
@@ -105,6 +105,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] 48+ messages in thread

* Re: [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available()
  2022-03-06 23:17 ` [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available() Philippe Mathieu-Daudé
@ 2022-03-07  4:11   ` Akihiko Odaki
  0 siblings, 0 replies; 48+ messages in thread
From: Akihiko Odaki @ 2022-03-07  4:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Alex Bennée

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>

On Mon, Mar 7, 2022 at 8:19 AM Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Remove the Clang specific __builtin_available() to allow building
> with GCC, otherwise we get:
>
>   include/qemu/osdep.h: In function 'qemu_thread_jit_write':
>   include/qemu/osdep.h:787:9: warning: implicit declaration of function '__builtin_available'; did you mean '__builtin_scalbl'? [-Wimplicit-function-declaration]
>     787 |     if (__builtin_available(macOS 11.0, *)) {
>         |         ^~~~~~~~~~~~~~~~~~~
>         |         __builtin_scalbl
>   include/qemu/osdep.h:787:9: warning: nested extern declaration of '__builtin_available' [-Wnested-externs]
>   include/qemu/osdep.h:787:29: error: 'macOS' undeclared (first use in this function)
>     787 |     if (__builtin_available(macOS 11.0, *)) {
>         |                             ^~~~~
>   include/qemu/osdep.h:787:29: note: each undeclared identifier is reported only once for each function it appears in
>   include/qemu/osdep.h:787:34: error: expected ')' before numeric constant
>     787 |     if (__builtin_available(macOS 11.0, *)) {
>         |                            ~     ^~~~~
>         |                                  )
>
> Beside, on macOS Catalina we get 2254 times:
>
>   include/qemu/osdep.h:780:5: warning: 'pthread_jit_write_protect_np' is only available on macOS 11.0 or newer [-Wunguarded-availability-new]
>       pthread_jit_write_protect_np(true);
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Fix by using a stricker toolchain version low range, replacing
> MAC_OS_X_VERSION_MAX_ALLOWED by MAC_OS_X_VERSION_MIN_REQUIRED.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/qemu/osdep.h | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 7bcce3bceb..488a286300 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -642,19 +642,15 @@ size_t qemu_get_host_physmem(void);
>   * for the current thread.
>   */
>  #if defined(MAC_OS_VERSION_11_0) && \
> -    MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
> +    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
>  static inline void qemu_thread_jit_execute(void)
>  {
> -    if (__builtin_available(macOS 11.0, *)) {
> -        pthread_jit_write_protect_np(true);
> -    }
> +    pthread_jit_write_protect_np(true);
>  }
>
>  static inline void qemu_thread_jit_write(void)
>  {
> -    if (__builtin_available(macOS 11.0, *)) {
> -        pthread_jit_write_protect_np(false);
> -    }
> +    pthread_jit_write_protect_np(false);
>  }
>  #else
>  static inline void qemu_thread_jit_write(void) {}
> --
> 2.34.1
>


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

* Re: [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good
  2022-03-06 23:17 ` [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good Philippe Mathieu-Daudé
@ 2022-03-07  4:13   ` Akihiko Odaki
  0 siblings, 0 replies; 48+ messages in thread
From: Akihiko Odaki @ 2022-03-07  4:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Alex Bennée

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>

On Mon, Mar 7, 2022 at 8:19 AM Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Commit 235b523dba ("meson: Use find_program() to resolve the
> entitlement.sh script") didn't correctly fixed the issue, as
> the script is still resolved for each target. Move the check
> earlier, before processing each target.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  meson.build | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index b6e30d7463..8ca2b7c8c2 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3063,6 +3063,10 @@ common_all = static_library('common',
>
>  feature_to_c = find_program('scripts/feature_to_c.sh')
>
> +if targetos == 'darwin'
> +  entitlement = find_program('scripts/entitlement.sh')
> +endif
> +
>  emulators = {}
>  foreach target : target_dirs
>    config_target = config_target_mak[target]
> @@ -3220,7 +3224,6 @@ foreach target : target_dirs
>          install_input += meson.current_source_dir() / entitlements
>        endif
>
> -      entitlement = find_program('scripts/entitlement.sh')
>        emulators += {exe['name'] : custom_target(exe['name'],
>                     input: build_input,
>                     output: exe['name'],
> --
> 2.34.1
>


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

* Re: [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary
  2022-03-06 23:17 ` [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary Philippe Mathieu-Daudé
@ 2022-03-07  4:13   ` Akihiko Odaki
  0 siblings, 0 replies; 48+ messages in thread
From: Akihiko Odaki @ 2022-03-07  4:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Alex Bennée

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>

On Mon, Mar 7, 2022 at 8:19 AM Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  meson.build | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/meson.build b/meson.build
> index 8ca2b7c8c2..0d38b2e72a 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3470,6 +3470,7 @@ if link_args.length() > 0
>    summary_info += {'LDFLAGS':         ' '.join(link_args)}
>  endif
>  summary_info += {'QEMU_CFLAGS':       config_host['QEMU_CFLAGS']}
> +summary_info += {'QEMU_CXXFLAGS':     config_host['QEMU_CXXFLAGS']}
>  summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
>  summary_info += {'profiler':          get_option('profiler')}
>  summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
> --
> 2.34.1
>


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

* Re: [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson
  2022-03-06 23:17 ` [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson Philippe Mathieu-Daudé
@ 2022-03-07  4:15   ` Akihiko Odaki
  0 siblings, 0 replies; 48+ messages in thread
From: Akihiko Odaki @ 2022-03-07  4:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Paolo Bonzini, Alex Bennée

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>

On Mon, Mar 7, 2022 at 8:19 AM Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Filter unsupported Objective-C options, to avoid
> 'unknown-warning-option' warnings when using Clang:
>
>   [34/373] Compiling Objective-C object libcommon.fa.p/audio_coreaudio.m.o
>   warning: unknown warning option '-Wold-style-declaration'; did you mean '-Wout-of-line-declaration'? [-Wunknown-warning-option]
>   warning: unknown warning option '-Wimplicit-fallthrough=2'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
>   2 warnings generated.
>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  configure   | 23 +++++++++++++++++++++++
>  meson.build |  6 +++++-
>  2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index e60156f90f..7d1f35603b 100755
> --- a/configure
> +++ b/configure
> @@ -77,6 +77,7 @@ TMPB="qemu-conf"
>  TMPC="${TMPDIR1}/${TMPB}.c"
>  TMPO="${TMPDIR1}/${TMPB}.o"
>  TMPCXX="${TMPDIR1}/${TMPB}.cxx"
> +TMPM="${TMPDIR1}/${TMPB}.m"
>  TMPE="${TMPDIR1}/${TMPB}.exe"
>
>  rm -f config.log
> @@ -148,6 +149,10 @@ do_cxx() {
>      do_compiler "$cxx" $CPU_CFLAGS "$@"
>  }
>
> +do_objc() {
> +    do_compiler "$objcc" $CPU_CFLAGS "$@"
> +}
> +
>  # Append $2 to the variable named $1, with space separation
>  add_to() {
>      eval $1=\${$1:+\"\$$1 \"}\$2
> @@ -1445,10 +1450,27 @@ cc_has_warning_flag() {
>      compile_prog "-Werror $optflag" ""
>  }
>
> +objcc_has_warning_flag() {
> +    cat > $TMPM <<EOF
> +int main(void) { return 0; }
> +EOF
> +
> +    # Use the positive sense of the flag when testing for -Wno-wombat
> +    # support (gcc will happily accept the -Wno- form of unknown
> +    # warning options).
> +    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
> +    do_objc -Werror $optflag \
> +      $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
> +      -o $TMPE $TMPM $QEMU_LDFLAGS
> +}
> +
>  for flag in $gcc_flags; do
>      if cc_has_warning_flag $flag ; then
>          QEMU_CFLAGS="$QEMU_CFLAGS $flag"
>      fi
> +    if objcc_has_warning_flag $flag ; then
> +        QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag"
> +    fi
>  done
>
>  if test "$stack_protector" != "no"; then
> @@ -2990,6 +3012,7 @@ echo "LD=$ld" >> $config_host_mak
>  echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
>  echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
>  echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
> +echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
>  echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
>  echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
>  echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
> diff --git a/meson.build b/meson.build
> index 0d38b2e72a..a770e80a32 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -173,11 +173,13 @@ endif
>
>  qemu_cflags = config_host['QEMU_CFLAGS'].split()
>  qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
> +qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
>  qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
>
>  if get_option('gprof')
>    qemu_cflags += ['-p']
>    qemu_cxxflags += ['-p']
> +  qemu_objcflags += ['-p']
>    qemu_ldflags += ['-p']
>  endif
>
> @@ -216,8 +218,9 @@ if get_option('fuzzing')
>    endif
>  endif
>
> -add_global_arguments(qemu_cflags, native: false, language: ['c', 'objc'])
> +add_global_arguments(qemu_cflags, native: false, language: ['c'])
>  add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
> +add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
>  add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
>
>  if targetos == 'linux'
> @@ -3471,6 +3474,7 @@ if link_args.length() > 0
>  endif
>  summary_info += {'QEMU_CFLAGS':       config_host['QEMU_CFLAGS']}
>  summary_info += {'QEMU_CXXFLAGS':     config_host['QEMU_CXXFLAGS']}
> +summary_info += {'QEMU_OBJCFLAGS':    config_host['QEMU_OBJCFLAGS']}
>  summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
>  summary_info += {'profiler':          get_option('profiler')}
>  summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
> --
> 2.34.1
>


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

* Re: [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays
  2022-03-06 23:17 ` [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays Philippe Mathieu-Daudé
@ 2022-03-07  4:16   ` Akihiko Odaki
  0 siblings, 0 replies; 48+ messages in thread
From: Akihiko Odaki @ 2022-03-07  4:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Alex Bennée

Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>

On Mon, Mar 7, 2022 at 8:19 AM Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  ui/cocoa.m | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 8ab9ab5e84..a6db8ebfb6 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -671,7 +671,7 @@ QemuCocoaView *cocoaView;
>
>      /* translates Macintosh keycodes to QEMU's keysym */
>
> -    int without_control_translation[] = {
> +    static const int without_control_translation[] = {
>          [0 ... 0xff] = 0,   // invalid key
>
>          [kVK_UpArrow]       = QEMU_KEY_UP,
> @@ -686,7 +686,7 @@ QemuCocoaView *cocoaView;
>          [kVK_Delete]        = QEMU_KEY_BACKSPACE,
>      };
>
> -    int with_control_translation[] = {
> +    static const int with_control_translation[] = {
>          [0 ... 0xff] = 0,   // invalid key
>
>          [kVK_UpArrow]       = QEMU_KEY_CTRL_UP,
> --
> 2.34.1
>


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

* Re: [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command
  2022-03-06 23:17 ` [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command Philippe Mathieu-Daudé
@ 2022-03-07 17:00   ` Will Cohen
  0 siblings, 0 replies; 48+ messages in thread
From: Will Cohen @ 2022-03-07 17:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Markus Armbruster,
	Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée,
	Gustavo Noronha Silva

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

On Sun, Mar 6, 2022 at 6:19 PM Philippe Mathieu-Daudé <
philippe.mathieu.daude@gmail.com> wrote:

> From: Gustavo Noronha Silva <gustavo@noronha.dev.br>
>
> On Mac OS X the Option key maps to Alt and Command to Super/Meta. This
> change
> swaps them around so that Alt is the key closer to the space bar and
> Meta/Super
> is between Control and Alt, like on non-Mac keyboards.
>
> It is a cocoa display option, disabled by default.
>
> Acked-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
> Message-Id: <20210713213200.2547-3-gustavo@noronha.dev.br>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Message-Id: <20220306121119.45631-3-akihiko.odaki@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  qapi/ui.json    |  7 ++++++-
>  qemu-options.hx |  2 +-
>  ui/cocoa.m      | 49 +++++++++++++++++++++++++++++++++++++++----------
>  3 files changed, 46 insertions(+), 12 deletions(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 1d60d5fc78..664da9e462 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1275,12 +1275,17 @@
>  #             a global grab on key events. (default: off)
>  #             See
> https://support.apple.com/en-in/guide/mac-help/mh32356/mac
>  #
> +# @swap-opt-cmd: Swap the Option and Command keys so that their key codes
> match
> +#                their position on non-Mac keyboards and you can use
> Meta/Super
> +#                and Alt where you expect them. (default: off)
> +#
>  # Since: 7.0
>  ##
>  { 'struct': 'DisplayCocoa',
>    'data': {
>        '*left-command-key': 'bool',
> -      '*full-grab': 'bool'
> +      '*full-grab': 'bool',
> +      '*swap-opt-cmd': 'bool'
>    } }
>
>  ##
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 2e6d54db4f..f443b0f33a 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1917,7 +1917,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
>      "-display curses[,charset=<encoding>]\n"
>  #endif
>  #if defined(CONFIG_COCOA)
> -    "-display cocoa[,full_grab=on|off]\n"
> +    "-display cocoa[,full-grab=on|off][,swap-opt-cmd=on|off]\n"
>  #endif
>  #if defined(CONFIG_OPENGL)
>      "-display egl-headless[,rendernode=<file>]\n"
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index ca1cab1ae6..c0a948201d 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -96,6 +96,7 @@ static DisplayChangeListener dcl = {
>  static int last_buttons;
>  static int cursor_hide = 1;
>  static int left_command_key_enabled = 1;
> +static bool swap_opt_cmd;
>
>  static int gArgc;
>  static char **gArgv;
> @@ -854,12 +855,22 @@ static CGEventRef handleTapEvent(CGEventTapProxy
> proxy, CGEventType type, CGEven
>          qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false);
>      }
>      if (!(modifiers & NSEventModifierFlagOption)) {
> -        qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
> -        qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
> +        if (swap_opt_cmd) {
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
> +        } else {
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
> +        }
>      }
>      if (!(modifiers & NSEventModifierFlagCommand)) {
> -        qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
> -        qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
> +        if (swap_opt_cmd) {
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
> +        } else {
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
> +            qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
> +        }
>      }
>
>      switch ([event type]) {
> @@ -891,29 +902,44 @@ static CGEventRef handleTapEvent(CGEventTapProxy
> proxy, CGEventType type, CGEven
>
>                  case kVK_Option:
>                      if (!!(modifiers & NSEventModifierFlagOption)) {
> -                        [self toggleKey:Q_KEY_CODE_ALT];
> +                        if (swap_opt_cmd) {
> +                            [self toggleKey:Q_KEY_CODE_META_L];
> +                        } else {
> +                            [self toggleKey:Q_KEY_CODE_ALT];
> +                        }
>                      }
>                      break;
>
>                  case kVK_RightOption:
>                      if (!!(modifiers & NSEventModifierFlagOption)) {
> -                        [self toggleKey:Q_KEY_CODE_ALT_R];
> +                        if (swap_opt_cmd) {
> +                            [self toggleKey:Q_KEY_CODE_META_R];
> +                        } else {
> +                            [self toggleKey:Q_KEY_CODE_ALT_R];
> +                        }
>                      }
>                      break;
>
>                  /* Don't pass command key changes to guest unless mouse
> is grabbed */
>                  case kVK_Command:
>                      if (isMouseGrabbed &&
> -                        !!(modifiers & NSEventModifierFlagCommand) &&
> -                        left_command_key_enabled) {
> -                        [self toggleKey:Q_KEY_CODE_META_L];
> +                        !!(modifiers & NSEventModifierFlagCommand)) {
> +                        if (swap_opt_cmd) {
> +                            [self toggleKey:Q_KEY_CODE_ALT];
> +                        } else {
> +                            [self toggleKey:Q_KEY_CODE_META_L];
> +                        }
>                      }
>                      break;
>
>                  case kVK_RightCommand:
>                      if (isMouseGrabbed &&
>                          !!(modifiers & NSEventModifierFlagCommand)) {
> -                        [self toggleKey:Q_KEY_CODE_META_R];
> +                        if (swap_opt_cmd) {
> +                            [self toggleKey:Q_KEY_CODE_ALT_R];
> +                        } else {
> +                            [self toggleKey:Q_KEY_CODE_META_R];
> +                        }
>                      }
>                      break;
>              }
> @@ -2134,6 +2160,9 @@ static void cocoa_display_init(DisplayState *ds,
> DisplayOptions *opts)
>      if (opts->has_show_cursor && opts->show_cursor) {
>          cursor_hide = 0;
>      }
> +    if (opts->u.cocoa.has_swap_opt_cmd) {
> +        swap_opt_cmd = opts->u.cocoa.swap_opt_cmd;
> +    }
>
>      if (opts->u.cocoa.has_left_command_key &&
> !opts->u.cocoa.left_command_key) {
>          left_command_key_enabled = 0;
> --
> 2.34.1
>
> Reviewed-by: Will Cohen <wwcohen@gmail.com>

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

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

* Re: [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed
  2022-03-06 23:17 ` [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed Philippe Mathieu-Daudé
@ 2022-03-07 17:01   ` Will Cohen
  0 siblings, 0 replies; 48+ messages in thread
From: Will Cohen @ 2022-03-07 17:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Markus Armbruster,
	Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu Developers, Roman Bolshakov,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée,
	Gustavo Noronha Silva

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

On Sun, Mar 6, 2022 at 6:19 PM Philippe Mathieu-Daudé <
philippe.mathieu.daude@gmail.com> wrote:

> From: Gustavo Noronha Silva <gustavo@noronha.dev.br>
>
> Applications such as Gnome may use Alt-Tab and Super-Tab for different
> purposes, some use Ctrl-arrows so we want to allow qemu to handle
> everything when it captures the mouse/keyboard.
>
> However, Mac OS handles some combos like Command-Tab and Ctrl-arrows
> at an earlier part of the event handling chain, not letting qemu see it.
>
> We add a global Event Tap that allows qemu to see all events when the
> mouse is grabbed. Note that this requires additional permissions.
>
> See:
>
>
> https://developer.apple.com/documentation/coregraphics/1454426-cgeventtapcreate?language=objc#discussion
> https://support.apple.com/en-in/guide/mac-help/mh32356/mac
>
> Acked-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
> Message-Id: <20210713213200.2547-2-gustavo@noronha.dev.br>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Message-Id: <20220306121119.45631-2-akihiko.odaki@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  qapi/ui.json    |  8 +++++-
>  qemu-options.hx |  3 +++
>  ui/cocoa.m      | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 74 insertions(+), 2 deletions(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 4dea35a819..1d60d5fc78 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1270,11 +1270,17 @@
>  #                    host without sending this key to the guest when
>  #                    "off". Defaults to "on"
>  #
> +# @full-grab: Capture all key presses, including system combos. This
> +#             requires accessibility permissions, since it performs
> +#             a global grab on key events. (default: off)
> +#             See
> https://support.apple.com/en-in/guide/mac-help/mh32356/mac
> +#
>  # Since: 7.0
>  ##
>  { 'struct': 'DisplayCocoa',
>    'data': {
> -      '*left-command-key': 'bool'
> +      '*left-command-key': 'bool',
> +      '*full-grab': 'bool'
>    } }
>
>  ##
> diff --git a/qemu-options.hx b/qemu-options.hx
> index ffaeab61ed..2e6d54db4f 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1916,6 +1916,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
>  #if defined(CONFIG_CURSES)
>      "-display curses[,charset=<encoding>]\n"
>  #endif
> +#if defined(CONFIG_COCOA)
> +    "-display cocoa[,full_grab=on|off]\n"
> +#endif
>  #if defined(CONFIG_OPENGL)
>      "-display egl-headless[,rendernode=<file>]\n"
>  #endif
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 31f0846c30..ca1cab1ae6 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -309,11 +309,13 @@ static void handleAnyDeviceErrors(Error * err)
>      BOOL isMouseGrabbed;
>      BOOL isFullscreen;
>      BOOL isAbsoluteEnabled;
> +    CFMachPortRef eventsTap;
>  }
>  - (void) switchSurface:(pixman_image_t *)image;
>  - (void) grabMouse;
>  - (void) ungrabMouse;
>  - (void) toggleFullScreen:(id)sender;
> +- (void) setFullGrab:(id)sender;
>  - (void) handleMonitorInput:(NSEvent *)event;
>  - (bool) handleEvent:(NSEvent *)event;
>  - (bool) handleEventLocked:(NSEvent *)event;
> @@ -336,6 +338,19 @@ static void handleAnyDeviceErrors(Error * err)
>
>  QemuCocoaView *cocoaView;
>
> +static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type,
> CGEventRef cgEvent, void *userInfo)
> +{
> +    QemuCocoaView *cocoaView = userInfo;
> +    NSEvent *event = [NSEvent eventWithCGEvent:cgEvent];
> +    if ([cocoaView isMouseGrabbed] && [cocoaView handleEvent:event]) {
> +        COCOA_DEBUG("Global events tap: qemu handled the event,
> capturing!\n");
> +        return NULL;
> +    }
> +    COCOA_DEBUG("Global events tap: qemu did not handle the event,
> letting it through...\n");
> +
> +    return cgEvent;
> +}
> +
>  @implementation QemuCocoaView
>  - (id)initWithFrame:(NSRect)frameRect
>  {
> @@ -361,6 +376,11 @@ QemuCocoaView *cocoaView;
>      }
>
>      qkbd_state_free(kbd);
> +
> +    if (eventsTap) {
> +        CFRelease(eventsTap);
> +    }
> +
>      [super dealloc];
>  }
>
> @@ -655,6 +675,36 @@ QemuCocoaView *cocoaView;
>      }
>  }
>
> +- (void) setFullGrab:(id)sender
> +{
> +    COCOA_DEBUG("QemuCocoaView: setFullGrab\n");
> +
> +    CGEventMask mask = CGEventMaskBit(kCGEventKeyDown) |
> CGEventMaskBit(kCGEventKeyUp) | CGEventMaskBit(kCGEventFlagsChanged);
> +    eventsTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap,
> kCGEventTapOptionDefault,
> +                                 mask, handleTapEvent, self);
> +    if (!eventsTap) {
> +        warn_report("Could not create event tap, system key combos will
> not be captured.\n");
> +        return;
> +    } else {
> +        COCOA_DEBUG("Global events tap created! Will capture system key
> combos.\n");
> +    }
> +
> +    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
> +    if (!runLoop) {
> +        warn_report("Could not obtain current CF RunLoop, system key
> combos will not be captured.\n");
> +        return;
> +    }
> +
> +    CFRunLoopSourceRef tapEventsSrc =
> CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventsTap, 0);
> +    if (!tapEventsSrc ) {
> +        warn_report("Could not obtain current CF RunLoop, system key
> combos will not be captured.\n");
> +        return;
> +    }
> +
> +    CFRunLoopAddSource(runLoop, tapEventsSrc, kCFRunLoopDefaultMode);
> +    CFRelease(tapEventsSrc);
> +}
> +
>  - (void) toggleKey: (int)keycode {
>      qkbd_state_key_event(kbd, keycode, !qkbd_state_key_get(kbd, keycode));
>  }
> @@ -1284,6 +1334,13 @@ QemuCocoaView *cocoaView;
>      [cocoaView toggleFullScreen:sender];
>  }
>
> +- (void) setFullGrab:(id)sender
> +{
> +    COCOA_DEBUG("QemuCocoaAppController: setFullGrab\n");
> +
> +    [cocoaView setFullGrab:sender];
> +}
> +
>  /* Tries to find then open the specified filename */
>  - (void) openDocumentation: (NSString *) filename
>  {
> @@ -2060,11 +2117,17 @@ static void cocoa_display_init(DisplayState *ds,
> DisplayOptions *opts)
>      qemu_sem_wait(&app_started_sem);
>      COCOA_DEBUG("cocoa_display_init: app start completed\n");
>
> +    QemuCocoaAppController *controller = (QemuCocoaAppController
> *)[[NSApplication sharedApplication] delegate];
>      /* if fullscreen mode is to be used */
>      if (opts->has_full_screen && opts->full_screen) {
>          dispatch_async(dispatch_get_main_queue(), ^{
>              [NSApp activateIgnoringOtherApps: YES];
> -            [(QemuCocoaAppController *)[[NSApplication sharedApplication]
> delegate] toggleFullScreen: nil];
> +            [controller toggleFullScreen: nil];
> +        });
> +    }
> +    if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) {
> +        dispatch_async(dispatch_get_main_queue(), ^{
> +            [controller setFullGrab: nil];
>          });
>      }
>
> --
> 2.34.1
>
> Reviewed-by: Will Cohen <wwcohen@gmail.com>

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

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

* Re: [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode
  2022-03-06 23:17 ` [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé
@ 2022-03-09 10:20   ` Philippe Mathieu-Daudé
  2022-03-15 12:58     ` Peter Maydell
  0 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-09 10:20 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini
  Cc: Peter Maydell, Thomas Huth, Sergio Lopez, qemu-block,
	Julian Stecklina, Alexander Graf, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

Hi Paolo,

I forgot to Cc you. Could you Ack this patch?

On 7/3/22 00:17, 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>
> Message-Id: <20220219063831.35356-1-dirty@apple.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/i386/hvf/x86_decode.c | 12 ++++++++++--
>   target/i386/hvf/x86hvf.c     |  8 ++++++++
>   target/i386/hvf/x86hvf.h     |  1 +
>   3 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c
> index 062713b1a4..5d051252b4 100644
> --- a/target/i386/hvf/x86_decode.c
> +++ b/target/i386/hvf/x86_decode.c
> @@ -24,8 +24,10 @@
>   #include "vmx.h"
>   #include "x86_mmu.h"
>   #include "x86_descr.h"
> +#include "x86hvf.h"
>   
>   #define OPCODE_ESCAPE   0xf
> +#define X86_MAX_INSN_PREFIX_LENGTH (14)
>   
>   static void decode_invalid(CPUX86State *env, struct x86_decode *decode)
>   {
> @@ -541,7 +543,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 +1850,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 X86_MAX_INSN_PREFIX_LENGTH prefix bytes. */
> +    for (int i = 0; i < X86_MAX_INSN_PREFIX_LENGTH; i++) {
>           /*
>            * REX prefix must come after legacy prefixes.
>            * REX before legacy is ignored.
> @@ -1892,6 +1896,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 +2096,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 bec9fc5814..a338c207b7 100644
> --- a/target/i386/hvf/x86hvf.c
> +++ b/target/i386/hvf/x86hvf.c
> @@ -423,6 +423,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 db6003d6bd..427cdc1c13 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);



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-06 23:17 ` [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
@ 2022-03-09 10:24   ` Philippe Mathieu-Daudé
  2022-03-09 11:58     ` Thomas Huth
  2022-03-09 10:28   ` Daniel P. Berrangé
  1 sibling, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-09 10:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, Daniel P. Berrangé,
	qemu-block, Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

Hi Alex, Thomas, Daniel,

Could you ack this patch?

On 7/3/22 00:17, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> 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)
>   - Run Aarch64 qtests instead of x86_64 ones
> 
> 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..be1dce5d4e 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-aarch64
> +
>   
>   # 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 1f00281b44..e2f0bbd1b1 100755
> --- a/tests/lcitool/refresh
> +++ b/tests/lcitool/refresh
> @@ -105,6 +105,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:



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-06 23:17 ` [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
  2022-03-09 10:24   ` Philippe Mathieu-Daudé
@ 2022-03-09 10:28   ` Daniel P. Berrangé
  1 sibling, 0 replies; 48+ messages in thread
From: Daniel P. Berrangé @ 2022-03-09 10:28 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	qemu-devel, Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Gerd Hoffmann, Akihiko Odaki,
	Alex Bennée

On Mon, Mar 07, 2022 at 12:17:53AM +0100, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> 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)
>  - Run Aarch64 qtests instead of x86_64 ones
> 
> 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

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives
  2022-03-06 23:17 ` [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé
@ 2022-03-09 11:17   ` Alex Bennée
  0 siblings, 0 replies; 48+ messages in thread
From: Alex Bennée @ 2022-03-09 11:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu-devel, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Akihiko Odaki, Roman Bolshakov


Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> writes:

> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> 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)
>
> Reported-by: Roman Bolshakov <roman@roolebo.dev>
> Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 10:24   ` Philippe Mathieu-Daudé
@ 2022-03-09 11:58     ` Thomas Huth
  2022-03-09 12:33       ` Daniel P. Berrangé
  0 siblings, 1 reply; 48+ messages in thread
From: Thomas Huth @ 2022-03-09 11:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Daniel P. Berrangé,
	qemu-block, Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

On 09/03/2022 11.24, Philippe Mathieu-Daudé wrote:
> Hi Alex, Thomas, Daniel,
> 
> Could you ack this patch?

Basically fine for me, but can we really run additional cirrus-ci jobs by 
default? IIRC the parallel execution of those were quite limited for the 
free tier, so did you look close that we don't run into additional timeouts 
yet, due to delayed cirrus-ci jobs?

  Thomas


> On 7/3/22 00:17, Philippe Mathieu-Daudé wrote:
>> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>
>> 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)
>>   - Run Aarch64 qtests instead of x86_64 ones
>>
>> 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



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 11:58     ` Thomas Huth
@ 2022-03-09 12:33       ` Daniel P. Berrangé
  2022-03-09 12:50         ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 48+ messages in thread
From: Daniel P. Berrangé @ 2022-03-09 12:33 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Peter Maydell, qemu-block, Christian Schoenebeck, qemu-devel,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Philippe Mathieu-Daudé,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée

On Wed, Mar 09, 2022 at 12:58:42PM +0100, Thomas Huth wrote:
> On 09/03/2022 11.24, Philippe Mathieu-Daudé wrote:
> > Hi Alex, Thomas, Daniel,
> > 
> > Could you ack this patch?
>
> Basically fine for me, but can we really run additional cirrus-ci jobs by
> default? IIRC the parallel execution of those were quite limited for the
> free tier, so did you look close that we don't run into additional timeouts
> yet, due to delayed cirrus-ci jobs?

You can run 2 jobs in parallel in Cirrus. Beyond that they
get queued/serialized

We have a 1 hour job timeout.

We have to expect jobs will sometimes run slower than normal.

IOW if we have a job on Cirrus taking 30 minutes normally, we
expect it will sometimes take 45 minutes.

All this means that if we want Cirrus to be reliable and not
time out, we can really only have 2 jobs by default, unless
we can get the job execution time down to around 20 minutes
to allow for serialization.

We used to have terrible problems with cirrus timeouts when
we were running 4 jobs concurrently (2 on staging and 2 on
master). We addressed that in 9968de0a4a5470bd7b98dcd2fae5d5269908f16b
by disabling the jobs on master.

IOW, we really need to choose 1 macOS job and 1 FreeBSD job
and others need to be marked manual.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 12:33       ` Daniel P. Berrangé
@ 2022-03-09 12:50         ` Philippe Mathieu-Daudé
  2022-03-09 12:52           ` Thomas Huth
  2022-03-09 13:02           ` Daniel P. Berrangé
  0 siblings, 2 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-09 12:50 UTC (permalink / raw)
  To: Daniel P. Berrangé, Thomas Huth, Peter Maydell, Alex Bennée
  Cc: qemu-block, Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu-devel, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Akihiko Odaki

On 9/3/22 13:33, Daniel P. Berrangé wrote:
> On Wed, Mar 09, 2022 at 12:58:42PM +0100, Thomas Huth wrote:

>> Basically fine for me, but can we really run additional cirrus-ci jobs by
>> default? IIRC the parallel execution of those were quite limited for the
>> free tier, so did you look close that we don't run into additional timeouts
>> yet, due to delayed cirrus-ci jobs?
> 
> You can run 2 jobs in parallel in Cirrus. Beyond that they
> get queued/serialized
> 
> We have a 1 hour job timeout.
> 
> We have to expect jobs will sometimes run slower than normal.
> 
> IOW if we have a job on Cirrus taking 30 minutes normally, we
> expect it will sometimes take 45 minutes.
> 
> All this means that if we want Cirrus to be reliable and not
> time out, we can really only have 2 jobs by default, unless
> we can get the job execution time down to around 20 minutes
> to allow for serialization.
> 
> We used to have terrible problems with cirrus timeouts when
> we were running 4 jobs concurrently (2 on staging and 2 on
> master). We addressed that in 9968de0a4a5470bd7b98dcd2fae5d5269908f16b
> by disabling the jobs on master.
> 
> IOW, we really need to choose 1 macOS job and 1 FreeBSD job
> and others need to be marked manual.

Not sure which job to choose yet. Per the first google hits we
still want to cover Catalina first:
https://www.statista.com/statistics/944559/worldwide-macos-version-market-share/

Would it be beneficial to have a 1 per OS job during PR, and
other jobs run nightly (once a day, not per PR)?


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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 12:50         ` Philippe Mathieu-Daudé
@ 2022-03-09 12:52           ` Thomas Huth
  2022-03-09 12:55             ` Daniel P. Berrangé
  2022-03-09 13:02           ` Daniel P. Berrangé
  1 sibling, 1 reply; 48+ messages in thread
From: Thomas Huth @ 2022-03-09 12:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Daniel P. Berrangé,
	Peter Maydell, Alex Bennée
  Cc: qemu-block, Christian Schoenebeck, Philippe Mathieu-Daudé,
	Cameron Esfahani, qemu-devel, Roman Bolshakov, Will Cohen,
	Gerd Hoffmann, Akihiko Odaki

On 09/03/2022 13.50, Philippe Mathieu-Daudé wrote:

> Would it be beneficial to have a 1 per OS job during PR, and
> other jobs run nightly (once a day, not per PR)?

Is there a way to trigger nightly runs in gitlab?

  Thomas




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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 12:52           ` Thomas Huth
@ 2022-03-09 12:55             ` Daniel P. Berrangé
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel P. Berrangé @ 2022-03-09 12:55 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Peter Maydell, qemu-block, Christian Schoenebeck, qemu-devel,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Philippe Mathieu-Daudé,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée

On Wed, Mar 09, 2022 at 01:52:15PM +0100, Thomas Huth wrote:
> On 09/03/2022 13.50, Philippe Mathieu-Daudé wrote:
> 
> > Would it be beneficial to have a 1 per OS job during PR, and
> > other jobs run nightly (once a day, not per PR)?
> 
> Is there a way to trigger nightly runs in gitlab?

Yes, in the repo CI settings create a scheduled job, using cron syntax.
Relies on the job "rules" in the config file not excluding scheduled
execution of course.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 12:50         ` Philippe Mathieu-Daudé
  2022-03-09 12:52           ` Thomas Huth
@ 2022-03-09 13:02           ` Daniel P. Berrangé
  2022-03-09 13:09             ` Peter Maydell
  1 sibling, 1 reply; 48+ messages in thread
From: Daniel P. Berrangé @ 2022-03-09 13:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	qemu-devel, Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Gerd Hoffmann, Akihiko Odaki,
	Alex Bennée

On Wed, Mar 09, 2022 at 01:50:34PM +0100, Philippe Mathieu-Daudé wrote:
> On 9/3/22 13:33, Daniel P. Berrangé wrote:
> > On Wed, Mar 09, 2022 at 12:58:42PM +0100, Thomas Huth wrote:
> 
> > > Basically fine for me, but can we really run additional cirrus-ci jobs by
> > > default? IIRC the parallel execution of those were quite limited for the
> > > free tier, so did you look close that we don't run into additional timeouts
> > > yet, due to delayed cirrus-ci jobs?
> > 
> > You can run 2 jobs in parallel in Cirrus. Beyond that they
> > get queued/serialized
> > 
> > We have a 1 hour job timeout.
> > 
> > We have to expect jobs will sometimes run slower than normal.
> > 
> > IOW if we have a job on Cirrus taking 30 minutes normally, we
> > expect it will sometimes take 45 minutes.
> > 
> > All this means that if we want Cirrus to be reliable and not
> > time out, we can really only have 2 jobs by default, unless
> > we can get the job execution time down to around 20 minutes
> > to allow for serialization.
> > 
> > We used to have terrible problems with cirrus timeouts when
> > we were running 4 jobs concurrently (2 on staging and 2 on
> > master). We addressed that in 9968de0a4a5470bd7b98dcd2fae5d5269908f16b
> > by disabling the jobs on master.
> > 
> > IOW, we really need to choose 1 macOS job and 1 FreeBSD job
> > and others need to be marked manual.
> 
> Not sure which job to choose yet. Per the first google hits we
> still want to cover Catalina first:
> https://www.statista.com/statistics/944559/worldwide-macos-version-market-share/

My general gut feeling is usually to prioritize testing older versions
as they tend to be more widely used, and we want to avoid regresions
on stuff that has been around the longest. Compatibility problems with
new releases tend to get reported by users/maintainers and would not
be regressions, but rather enhancements to support the new platform.

But it is not really an easy decision, as clearly we would prefer to
test both old and new if we had the ability.

Having one as a nightly job is a reasonable compromise. 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 13:02           ` Daniel P. Berrangé
@ 2022-03-09 13:09             ` Peter Maydell
  2022-03-09 13:40               ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 48+ messages in thread
From: Peter Maydell @ 2022-03-09 13:09 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Thomas Huth, qemu-block, Christian Schoenebeck, qemu-devel,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Philippe Mathieu-Daudé,
	Gerd Hoffmann, Akihiko Odaki, Alex Bennée

On Wed, 9 Mar 2022 at 13:02, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Mar 09, 2022 at 01:50:34PM +0100, Philippe Mathieu-Daudé wrote:
> > Not sure which job to choose yet. Per the first google hits we
> > still want to cover Catalina first:
> > https://www.statista.com/statistics/944559/worldwide-macos-version-market-share/

...that page says that the figures for Catalina are "incorrectly
high", so not a very useful set of data for these purposes I think.

> My general gut feeling is usually to prioritize testing older versions
> as they tend to be more widely used, and we want to avoid regresions
> on stuff that has been around the longest. Compatibility problems with
> new releases tend to get reported by users/maintainers and would not
> be regressions, but rather enhancements to support the new platform.

Note that technically speaking Catalina (10.15) has already fallen off
the end of our support policy (which currently requires Big Sur (11)
and Monterey (12) support, as the two most recent versions). My
personal macos x86 laptop is still running Catalina, though,
because Big Sur dropped support for that hardware :-/
That suggests that maybe Big Sur would be what we should go for
now if we have to pick just one for the CI.

thanks
-- PMM


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

* Re: [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run
  2022-03-09 13:09             ` Peter Maydell
@ 2022-03-09 13:40               ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-09 13:40 UTC (permalink / raw)
  To: Peter Maydell, Daniel P. Berrangé
  Cc: Thomas Huth, qemu-block, Christian Schoenebeck, qemu-devel,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Gerd Hoffmann, Akihiko Odaki,
	Alex Bennée

On 9/3/22 14:09, Peter Maydell wrote:
> On Wed, 9 Mar 2022 at 13:02, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>
>> On Wed, Mar 09, 2022 at 01:50:34PM +0100, Philippe Mathieu-Daudé wrote:
>>> Not sure which job to choose yet. Per the first google hits we
>>> still want to cover Catalina first:
>>> https://www.statista.com/statistics/944559/worldwide-macos-version-market-share/
> 
> ...that page says that the figures for Catalina are "incorrectly
> high", so not a very useful set of data for these purposes I think.
> 
>> My general gut feeling is usually to prioritize testing older versions
>> as they tend to be more widely used, and we want to avoid regresions
>> on stuff that has been around the longest. Compatibility problems with
>> new releases tend to get reported by users/maintainers and would not
>> be regressions, but rather enhancements to support the new platform.
> 
> Note that technically speaking Catalina (10.15) has already fallen off
> the end of our support policy (which currently requires Big Sur (11)
> and Monterey (12) support, as the two most recent versions). My
> personal macos x86 laptop is still running Catalina, though,
> because Big Sur dropped support for that hardware :-/
> That suggests that maybe Big Sur would be what we should go for
> now if we have to pick just one for the CI.

OK. Since I'm running Monterey (12) on my workstation, I'll make this
job manual / nightly, and keep the Big Sur (11) on CI.

I'll let Daniel / Thomas / Alex decide which FreeBSD job to demote to
manual.

Regards,

Phil.


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

* Re: [PATCH v7 00/22] host: Support macOS 12
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2022-03-06 23:17 ` [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
@ 2022-03-15 12:48 ` Philippe Mathieu-Daudé
  2022-05-03  9:40 ` Claudio Fontana
  23 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-15 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

On 7/3/22 00:17, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Few patches to be able to build QEMU on macOS 12 (Monterey).
> 
> Missing review:
>   0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
>   0013-osdep-Avoid-using-Clang-specific-__builtin_available.patch
>   0014-meson-Resolve-the-entitlement.sh-script-once-for-goo.patch
>   0015-meson-Log-QEMU_CXXFLAGS-content-in-summary.patch
>   0016-configure-Pass-filtered-QEMU_OBJCFLAGS-to-meson.patch
>   0017-ui-cocoa-Constify-qkeycode-translation-arrays.patch
>   0020-ui-cocoa-capture-all-keys-and-combos-when-mouse-is-g.patch
>   0021-ui-cocoa-add-option-to-swap-Option-and-Command.patch
>   0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch

Queuing reviewed patches; IOW all except:

    0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
    0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch

Thanks,

Phil.


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

* Re: [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode
  2022-03-09 10:20   ` Philippe Mathieu-Daudé
@ 2022-03-15 12:58     ` Peter Maydell
  2022-03-15 13:00       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 48+ messages in thread
From: Peter Maydell @ 2022-03-15 12:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Alexander Graf, Thomas Huth, Sergio Lopez, qemu-block,
	Julian Stecklina, Christian Schoenebeck, qemu-devel,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Roman Bolshakov, Will Cohen, Gerd Hoffmann, Akihiko Odaki,
	Paolo Bonzini, Alex Bennée

On Wed, 9 Mar 2022 at 10:20, Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> Hi Paolo,
>
> I forgot to Cc you. Could you Ack this patch?

I had review comments on the version of this patch in v5 which
still need to be addressed:

https://lore.kernel.org/qemu-devel/CAFEAcA8yaBOD3KXc-DY94oqzC5wkCENPkePgVCybqR=9NmdQFQ@mail.gmail.com/

thanks
-- PMM


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

* Re: [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode
  2022-03-15 12:58     ` Peter Maydell
@ 2022-03-15 13:00       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 48+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-15 13:00 UTC (permalink / raw)
  To: Peter Maydell, Cameron Esfahani
  Cc: Alexander Graf, Thomas Huth, Sergio Lopez, qemu-block,
	Julian Stecklina, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	qemu-devel, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Paolo Bonzini, Alex Bennée

On 15/3/22 13:58, Peter Maydell wrote:
> On Wed, 9 Mar 2022 at 10:20, Philippe Mathieu-Daudé
> <philippe.mathieu.daude@gmail.com> wrote:
>>
>> Hi Paolo,
>>
>> I forgot to Cc you. Could you Ack this patch?
> 
> I had review comments on the version of this patch in v5 which
> still need to be addressed:
> 
> https://lore.kernel.org/qemu-devel/CAFEAcA8yaBOD3KXc-DY94oqzC5wkCENPkePgVCybqR=9NmdQFQ@mail.gmail.com/

Thanks for pointing at your comments, I totally missed them.

I'll let Cameron address them.

Regards,

Phil.


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

* Re: [PATCH v7 00/22] host: Support macOS 12
  2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2022-03-15 12:48 ` [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
@ 2022-05-03  9:40 ` Claudio Fontana
  2022-05-09 12:31   ` Philippe Mathieu-Daudé via
  23 siblings, 1 reply; 48+ messages in thread
From: Claudio Fontana @ 2022-05-03  9:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Philippe Mathieu-Daudé,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée

On 3/7/22 12:17 AM, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Few patches to be able to build QEMU on macOS 12 (Monterey).
> 
> Missing review:
>  0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
>  0013-osdep-Avoid-using-Clang-specific-__builtin_available.patch
>  0014-meson-Resolve-the-entitlement.sh-script-once-for-goo.patch
>  0015-meson-Log-QEMU_CXXFLAGS-content-in-summary.patch
>  0016-configure-Pass-filtered-QEMU_OBJCFLAGS-to-meson.patch
>  0017-ui-cocoa-Constify-qkeycode-translation-arrays.patch
>  0020-ui-cocoa-capture-all-keys-and-combos-when-mouse-is-g.patch
>  0021-ui-cocoa-add-option-to-swap-Option-and-Command.patch
>  0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch
> 
> Since v6:
> - Dropped merged patches
> - Addressed Akihiko Odaki comments (squashed 2 patches, added R/T-b)
> - Dropped 'configure: Disable out-of-line atomic operations on Aarch64'
> - Add few macos patches on the list pending for 7.0 so tested by CI


Hi Philippe, I did not find v6 somehow,

and I was looking for patch:

"[PATCH v5 06/16] hvf: Enable RDTSCP support"

was it dropped / merged with something else? I do not see it in latest git, nor in this respin,
maybe it is in your tree somewhere?

Thanks,

Claudio

> 
> Since v5:
> - Fixed failed rebase between patches 10 and 16 (Akihiko)
> - Include "ui/cocoa: Fix the leak of qemu_console_get_label"
> 
> Since v4:
> - Use MAC_OS_X_VERSION_MIN_REQUIRED definition (Akihiko)
> - Include patches from Akihiko
> 
> 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
> 
> Akihiko Odaki (2):
>   audio: Log context for audio bug
>   coreaudio: Always return 0 in handle_voice_change
> 
> Cameron Esfahani (2):
>   hvf: Use standard CR0 and CR4 register definitions
>   hvf: Fix OOB write in RDTSCP instruction decode
> 
> Carwyn Ellis (2):
>   ui/cocoa: add option to disable left-command forwarding to guest
>   ui/cocoa: release mouse when user switches away from QEMU window
> 
> Gustavo Noronha Silva (2):
>   ui/cocoa: capture all keys and combos when mouse is grabbed
>   ui/cocoa: add option to swap Option and Command
> 
> Philippe Mathieu-Daudé (14):
>   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
>   audio: Rename coreaudio extension to use Objective-C compiler
>   osdep: Avoid using Clang-specific __builtin_available()
>   meson: Resolve the entitlement.sh script once for good
>   meson: Log QEMU_CXXFLAGS content in summary
>   configure: Pass filtered QEMU_OBJCFLAGS to meson
>   ui/cocoa: Constify qkeycode translation arrays
>   gitlab-ci: Support macOS 12 via cirrus-run
> 
>  .gitlab-ci.d/cirrus.yml            |  16 ++++
>  .gitlab-ci.d/cirrus/macos-12.vars  |  16 ++++
>  audio/audio.c                      |  25 +++---
>  audio/audio_template.h             |  27 +++----
>  audio/{coreaudio.c => coreaudio.m} |  23 +++---
>  audio/meson.build                  |   4 +-
>  block/file-posix.c                 |  14 +++-
>  configure                          |  31 ++++++++
>  include/qemu/osdep.h               |  10 +--
>  meson.build                        |  17 +++-
>  qapi/ui.json                       |  29 +++++++
>  qemu-options.hx                    |  15 ++++
>  target/i386/hvf/vmx.h              |  19 +++--
>  target/i386/hvf/x86.c              |   6 +-
>  target/i386/hvf/x86.h              |  34 --------
>  target/i386/hvf/x86_decode.c       |  12 ++-
>  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/fp/meson.build               |   5 ++
>  tests/lcitool/refresh              |   1 +
>  ui/cocoa.m                         | 122 ++++++++++++++++++++++++++---
>  23 files changed, 327 insertions(+), 122 deletions(-)
>  create mode 100644 .gitlab-ci.d/cirrus/macos-12.vars
>  rename audio/{coreaudio.c => coreaudio.m} (97%)
> 



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

* Re: [PATCH v7 00/22] host: Support macOS 12
  2022-05-03  9:40 ` Claudio Fontana
@ 2022-05-09 12:31   ` Philippe Mathieu-Daudé via
  2022-05-09 13:08     ` Claudio Fontana
  0 siblings, 1 reply; 48+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-05-09 12:31 UTC (permalink / raw)
  To: Claudio Fontana, Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée, Silvio Moioli

On 3/5/22 11:40, Claudio Fontana wrote:
> On 3/7/22 12:17 AM, Philippe Mathieu-Daudé wrote:
>> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>
>> Few patches to be able to build QEMU on macOS 12 (Monterey).
>>
>> Missing review:
>>   0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
>>   0013-osdep-Avoid-using-Clang-specific-__builtin_available.patch
>>   0014-meson-Resolve-the-entitlement.sh-script-once-for-goo.patch
>>   0015-meson-Log-QEMU_CXXFLAGS-content-in-summary.patch
>>   0016-configure-Pass-filtered-QEMU_OBJCFLAGS-to-meson.patch
>>   0017-ui-cocoa-Constify-qkeycode-translation-arrays.patch
>>   0020-ui-cocoa-capture-all-keys-and-combos-when-mouse-is-g.patch
>>   0021-ui-cocoa-add-option-to-swap-Option-and-Command.patch
>>   0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch
>>
>> Since v6:
>> - Dropped merged patches
>> - Addressed Akihiko Odaki comments (squashed 2 patches, added R/T-b)
>> - Dropped 'configure: Disable out-of-line atomic operations on Aarch64'
>> - Add few macos patches on the list pending for 7.0 so tested by CI
> 
> 
> Hi Philippe, I did not find v6 somehow,
> 
> and I was looking for patch:
> 
> "[PATCH v5 06/16] hvf: Enable RDTSCP support"
> 
> was it dropped / merged with something else? I do not see it in latest git, nor in this respin,
> maybe it is in your tree somewhere?

The patch stayed unreviewed during 2 months, so I dropped it.

Now it got at least a Tested-by tag from Silvio, I'll include it in the
next PR.

Regards,

Phil.


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

* Re: [PATCH v7 00/22] host: Support macOS 12
  2022-05-09 12:31   ` Philippe Mathieu-Daudé via
@ 2022-05-09 13:08     ` Claudio Fontana
  0 siblings, 0 replies; 48+ messages in thread
From: Claudio Fontana @ 2022-05-09 13:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Thomas Huth, qemu-block, Christian Schoenebeck,
	Cameron Esfahani, Roman Bolshakov, Will Cohen, Gerd Hoffmann,
	Akihiko Odaki, Alex Bennée, Silvio Moioli

On 5/9/22 2:31 PM, Philippe Mathieu-Daudé wrote:
> On 3/5/22 11:40, Claudio Fontana wrote:
>> On 3/7/22 12:17 AM, Philippe Mathieu-Daudé wrote:
>>> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>
>>> Few patches to be able to build QEMU on macOS 12 (Monterey).
>>>
>>> Missing review:
>>>   0006-hvf-Fix-OOB-write-in-RDTSCP-instruction-decode.patch
>>>   0013-osdep-Avoid-using-Clang-specific-__builtin_available.patch
>>>   0014-meson-Resolve-the-entitlement.sh-script-once-for-goo.patch
>>>   0015-meson-Log-QEMU_CXXFLAGS-content-in-summary.patch
>>>   0016-configure-Pass-filtered-QEMU_OBJCFLAGS-to-meson.patch
>>>   0017-ui-cocoa-Constify-qkeycode-translation-arrays.patch
>>>   0020-ui-cocoa-capture-all-keys-and-combos-when-mouse-is-g.patch
>>>   0021-ui-cocoa-add-option-to-swap-Option-and-Command.patch
>>>   0022-gitlab-ci-Support-macOS-12-via-cirrus-run.patch
>>>
>>> Since v6:
>>> - Dropped merged patches
>>> - Addressed Akihiko Odaki comments (squashed 2 patches, added R/T-b)
>>> - Dropped 'configure: Disable out-of-line atomic operations on Aarch64'
>>> - Add few macos patches on the list pending for 7.0 so tested by CI
>>
>>
>> Hi Philippe, I did not find v6 somehow,
>>
>> and I was looking for patch:
>>
>> "[PATCH v5 06/16] hvf: Enable RDTSCP support"
>>
>> was it dropped / merged with something else? I do not see it in latest git, nor in this respin,
>> maybe it is in your tree somewhere?
> 
> The patch stayed unreviewed during 2 months, so I dropped it.
> 
> Now it got at least a Tested-by tag from Silvio, I'll include it in the
> next PR.
> 
> Regards,
> 
> Phil.
> 

Awesome, thanks for the update!

Claudio



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

end of thread, other threads:[~2022-05-09 13:36 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-06 23:17 [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 01/22] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 02/22] tests/fp/berkeley-testfloat-3: Ignore ignored #pragma directives Philippe Mathieu-Daudé
2022-03-09 11:17   ` Alex Bennée
2022-03-06 23:17 ` [PATCH v7 03/22] hvf: Use standard CR0 and CR4 register definitions Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 04/22] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 05/22] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 06/22] hvf: Fix OOB write in RDTSCP instruction decode Philippe Mathieu-Daudé
2022-03-09 10:20   ` Philippe Mathieu-Daudé
2022-03-15 12:58     ` Peter Maydell
2022-03-15 13:00       ` Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 07/22] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 08/22] audio/coreaudio: " Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 09/22] audio/dbus: Fix building with modules on macOS Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 10/22] audio: Log context for audio bug Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 11/22] coreaudio: Always return 0 in handle_voice_change Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 12/22] audio: Rename coreaudio extension to use Objective-C compiler Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 13/22] osdep: Avoid using Clang-specific __builtin_available() Philippe Mathieu-Daudé
2022-03-07  4:11   ` Akihiko Odaki
2022-03-06 23:17 ` [PATCH v7 14/22] meson: Resolve the entitlement.sh script once for good Philippe Mathieu-Daudé
2022-03-07  4:13   ` Akihiko Odaki
2022-03-06 23:17 ` [PATCH v7 15/22] meson: Log QEMU_CXXFLAGS content in summary Philippe Mathieu-Daudé
2022-03-07  4:13   ` Akihiko Odaki
2022-03-06 23:17 ` [PATCH v7 16/22] configure: Pass filtered QEMU_OBJCFLAGS to meson Philippe Mathieu-Daudé
2022-03-07  4:15   ` Akihiko Odaki
2022-03-06 23:17 ` [PATCH v7 17/22] ui/cocoa: Constify qkeycode translation arrays Philippe Mathieu-Daudé
2022-03-07  4:16   ` Akihiko Odaki
2022-03-06 23:17 ` [PATCH v7 18/22] ui/cocoa: add option to disable left-command forwarding to guest Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 19/22] ui/cocoa: release mouse when user switches away from QEMU window Philippe Mathieu-Daudé
2022-03-06 23:17 ` [PATCH v7 20/22] ui/cocoa: capture all keys and combos when mouse is grabbed Philippe Mathieu-Daudé
2022-03-07 17:01   ` Will Cohen
2022-03-06 23:17 ` [PATCH v7 21/22] ui/cocoa: add option to swap Option and Command Philippe Mathieu-Daudé
2022-03-07 17:00   ` Will Cohen
2022-03-06 23:17 ` [PATCH v7 22/22] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
2022-03-09 10:24   ` Philippe Mathieu-Daudé
2022-03-09 11:58     ` Thomas Huth
2022-03-09 12:33       ` Daniel P. Berrangé
2022-03-09 12:50         ` Philippe Mathieu-Daudé
2022-03-09 12:52           ` Thomas Huth
2022-03-09 12:55             ` Daniel P. Berrangé
2022-03-09 13:02           ` Daniel P. Berrangé
2022-03-09 13:09             ` Peter Maydell
2022-03-09 13:40               ` Philippe Mathieu-Daudé
2022-03-09 10:28   ` Daniel P. Berrangé
2022-03-15 12:48 ` [PATCH v7 00/22] host: Support macOS 12 Philippe Mathieu-Daudé
2022-05-03  9:40 ` Claudio Fontana
2022-05-09 12:31   ` Philippe Mathieu-Daudé via
2022-05-09 13:08     ` Claudio Fontana

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.