Darwin patches:

- Enable RDTSCP support on HVF
 - ui/cocoa: Take refresh rate into account
 
 Few buildsys fixes:
 
 - Restrict TCG to emulation
 - Remove a unused-but-set-variable warning
 - Allow running Avocado from pseudo-"in source tree" builds
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmLN8k0ACgkQ4+MsLN6t
 wN4xchAAnzdeE2l95qlAHztx+VMDZT9JzAI1aErexTk0fe1jZ+uapin+qcXq8ICu
 TOQbqZO0DjIfPiptuZsuJbapUIuc5kz7imSvBFst3kYvFXb0KAIcWaykkWvjzk3c
 Wt33cPuBhcWKB2g9YyNj8ac+HvAgQY5I2Qn80l23lOuNJP3iriY9+yJbNffO9TjV
 t3ZKTAvKDMmio098dQEDeMVfn7cIXGnv+Xiab4H4fVTo/gNG9jydfi140El4rXAR
 qvM0/rZ9cbcVzQUgkqvcc+xJCzCEgfJygezTKSi5XW9g6A4s0QeMe/oxThBdP6AY
 BuFEuyNq9FWwExVNFk+FS7zgZW5xRZLtZ5PLdeb7fQ0abllVDFL80OmaB/sahVno
 seSc3JPG7DLMLJy51H9sd1jlWMTgkdDT5fFfQ3A9pnMN81wJj7PM15AQgG3+129m
 bWyMe+wkod4c+C6o3+dr6xLkT/Oz0OsuaOP/IDsihtI3iqBorF6TEKck9kn9Vlz3
 05TbJFiE6tOXJ05H0Jsx/BQSUBTVIiGp5mBzJrSnzPxvN+AjZ4SEHpvWteXWS0Yf
 Zx7IK6pkWYBa1W/sqh96dwbt00Bpoheqdhmq3ZYdLjVll7H5fRR3IZgKN1p8CPr1
 NOJONUNYDMvpdpxFBl0HPLlLW5V7yRl7xjsXEWajYsvfMx6lpak=
 =3QvX
 -----END PGP SIGNATURE-----

Merge tag 'darwin-20220712' of https://github.com/philmd/qemu into staging

Darwin patches:

- Enable RDTSCP support on HVF
- ui/cocoa: Take refresh rate into account

Few buildsys fixes:

- Restrict TCG to emulation
- Remove a unused-but-set-variable warning
- Allow running Avocado from pseudo-"in source tree" builds

# gpg: Signature made Tue 12 Jul 2022 23:14:37 BST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'darwin-20220712' of https://github.com/philmd/qemu:
  avocado: Fix BUILD_DIR if it's equal to SOURCE_DIR
  ui/cocoa: Take refresh rate into account
  ui/cocoa: Fix switched_to_fullscreen warning
  configure: Restrict TCG to emulation
  hvf: Enable RDTSCP support

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-07-14 09:30:55 +01:00
commit 08c9f7eec7
8 changed files with 61 additions and 37 deletions

View File

@ -599,7 +599,7 @@ build-tools-and-docs-debian:
optional: true optional: true
variables: variables:
IMAGE: debian-amd64 IMAGE: debian-amd64
MAKE_CHECK_ARGS: check-unit check-softfloat ctags TAGS cscope MAKE_CHECK_ARGS: check-unit ctags TAGS cscope
CONFIGURE_ARGS: --disable-system --disable-user --enable-docs --enable-tools CONFIGURE_ARGS: --disable-system --disable-user --enable-docs --enable-tools
QEMU_JOB_PUBLISH: 1 QEMU_JOB_PUBLISH: 1
artifacts: artifacts:

20
configure vendored
View File

@ -329,7 +329,7 @@ fi
fdt="auto" fdt="auto"
# 2. Automatically enable/disable other options # 2. Automatically enable/disable other options
tcg="enabled" tcg="auto"
cfi="false" cfi="false"
# parse CC options second # parse CC options second
@ -1409,11 +1409,6 @@ EOF
fi fi
fi fi
if test "$tcg" = "enabled"; then
git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
fi
if test -z "${target_list+xxx}" ; then if test -z "${target_list+xxx}" ; then
default_targets=yes default_targets=yes
for target in $default_target_list; do for target in $default_target_list; do
@ -1444,6 +1439,19 @@ case " $target_list " in
;; ;;
esac esac
if test "$tcg" = "auto"; then
if test -z "$target_list"; then
tcg="disabled"
else
tcg="enabled"
fi
fi
if test "$tcg" = "enabled"; then
git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
fi
feature_not_found() { feature_not_found() {
feature=$1 feature=$1
remedy=$2 remedy=$2

View File

@ -583,7 +583,8 @@ if get_option('attr').allowed()
endif endif
endif endif
cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa')) cocoa = dependency('appleframeworks', modules: ['Cocoa', 'CoreVideo'],
required: get_option('cocoa'))
if cocoa.found() and get_option('sdl').enabled() if cocoa.found() and get_option('sdl').enabled()
error('Cocoa and SDL cannot be enabled at the same time') error('Cocoa and SDL cannot be enabled at the same time')
endif endif

View File

@ -221,6 +221,7 @@ int hvf_arch_init_vcpu(CPUState *cpu)
{ {
X86CPU *x86cpu = X86_CPU(cpu); X86CPU *x86cpu = X86_CPU(cpu);
CPUX86State *env = &x86cpu->env; CPUX86State *env = &x86cpu->env;
uint64_t reqCap;
init_emu(); init_emu();
init_decoder(); init_decoder();
@ -257,19 +258,26 @@ int hvf_arch_init_vcpu(CPUState *cpu)
/* set VMCS control fields */ /* set VMCS control fields */
wvmcs(cpu->hvf->fd, VMCS_PIN_BASED_CTLS, wvmcs(cpu->hvf->fd, VMCS_PIN_BASED_CTLS,
cap2ctrl(hvf_state->hvf_caps->vmx_cap_pinbased, cap2ctrl(hvf_state->hvf_caps->vmx_cap_pinbased,
VMCS_PIN_BASED_CTLS_EXTINT | VMCS_PIN_BASED_CTLS_EXTINT |
VMCS_PIN_BASED_CTLS_NMI | VMCS_PIN_BASED_CTLS_NMI |
VMCS_PIN_BASED_CTLS_VNMI)); VMCS_PIN_BASED_CTLS_VNMI));
wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS,
cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased, cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased,
VMCS_PRI_PROC_BASED_CTLS_HLT | VMCS_PRI_PROC_BASED_CTLS_HLT |
VMCS_PRI_PROC_BASED_CTLS_MWAIT | VMCS_PRI_PROC_BASED_CTLS_MWAIT |
VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET | VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET |
VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW) | VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW) |
VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL); VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL);
reqCap = VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES;
/* Is RDTSCP support in CPUID? If so, enable it in the VMCS. */
if (hvf_get_supported_cpuid(0x80000001, 0, R_EDX) & CPUID_EXT2_RDTSCP) {
reqCap |= VMCS_PRI_PROC_BASED2_CTLS_RDTSCP;
}
wvmcs(cpu->hvf->fd, VMCS_SEC_PROC_BASED_CTLS, wvmcs(cpu->hvf->fd, VMCS_SEC_PROC_BASED_CTLS,
cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased2, cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased2, reqCap));
VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES));
wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry, wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry,
0)); 0));

View File

@ -354,7 +354,7 @@
#define VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET (1 << 3) #define VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET (1 << 3)
#define VMCS_PRI_PROC_BASED_CTLS_HLT (1 << 7) #define VMCS_PRI_PROC_BASED_CTLS_HLT (1 << 7)
#define VMCS_PRI_PROC_BASED_CTLS_MWAIT (1 << 10) #define VMCS_PRI_PROC_BASED_CTLS_MWAIT (1 << 10)
#define VMCS_PRI_PROC_BASED_CTLS_TSC (1 << 12) #define VMCS_PRI_PROC_BASED_CTLS_RDTSC (1 << 12)
#define VMCS_PRI_PROC_BASED_CTLS_CR8_LOAD (1 << 19) #define VMCS_PRI_PROC_BASED_CTLS_CR8_LOAD (1 << 19)
#define VMCS_PRI_PROC_BASED_CTLS_CR8_STORE (1 << 20) #define VMCS_PRI_PROC_BASED_CTLS_CR8_STORE (1 << 20)
#define VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW (1 << 21) #define VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW (1 << 21)
@ -362,6 +362,7 @@
#define VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL (1 << 31) #define VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL (1 << 31)
#define VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES (1 << 0) #define VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES (1 << 0)
#define VMCS_PRI_PROC_BASED2_CTLS_RDTSCP (1 << 3)
#define VMCS_PRI_PROC_BASED2_CTLS_X2APIC (1 << 4) #define VMCS_PRI_PROC_BASED2_CTLS_X2APIC (1 << 4)
enum task_switch_reason { enum task_switch_reason {

View File

@ -95,7 +95,8 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
ebx &= ~CPUID_7_0_EBX_INVPCID; ebx &= ~CPUID_7_0_EBX_INVPCID;
} }
ecx &= CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_AVX512_VPOPCNTDQ; ecx &= CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_AVX512_VPOPCNTDQ |
CPUID_7_0_ECX_RDPID;
edx &= CPUID_7_0_EDX_AVX512_4VNNIW | CPUID_7_0_EDX_AVX512_4FMAPS; edx &= CPUID_7_0_EDX_AVX512_4VNNIW | CPUID_7_0_EDX_AVX512_4FMAPS;
} else { } else {
ebx = 0; ebx = 0;
@ -132,11 +133,11 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
CPUID_FXSR | CPUID_EXT2_FXSR | CPUID_EXT2_PDPE1GB | CPUID_EXT2_3DNOWEXT | CPUID_FXSR | CPUID_EXT2_FXSR | CPUID_EXT2_PDPE1GB | CPUID_EXT2_3DNOWEXT |
CPUID_EXT2_3DNOW | CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX; CPUID_EXT2_3DNOW | CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX;
hv_vmx_read_capability(HV_VMX_CAP_PROCBASED2, &cap); hv_vmx_read_capability(HV_VMX_CAP_PROCBASED2, &cap);
if (!(cap & CPU_BASED2_RDTSCP)) { if (!(cap2ctrl(cap, CPU_BASED2_RDTSCP) & CPU_BASED2_RDTSCP)) {
edx &= ~CPUID_EXT2_RDTSCP; edx &= ~CPUID_EXT2_RDTSCP;
} }
hv_vmx_read_capability(HV_VMX_CAP_PROCBASED, &cap); hv_vmx_read_capability(HV_VMX_CAP_PROCBASED, &cap);
if (!(cap & CPU_BASED_TSC_OFFSET)) { if (!(cap2ctrl(cap, CPU_BASED_TSC_OFFSET) & CPU_BASED_TSC_OFFSET)) {
edx &= ~CPUID_EXT2_RDTSCP; edx &= ~CPUID_EXT2_RDTSCP;
} }
ecx &= CPUID_EXT3_LAHF_LM | CPUID_EXT3_CMP_LEG | CPUID_EXT3_CR8LEG | ecx &= CPUID_EXT3_LAHF_LM | CPUID_EXT3_CMP_LEG | CPUID_EXT3_CR8LEG |

View File

@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
# qemu binary path does not match arch for powerpc, handle it # qemu binary path does not match arch for powerpc, handle it
if 'ppc64le' in arch: if 'ppc64le' in arch:
arch = 'ppc64' arch = 'ppc64'
qemu_bin_relative_path = os.path.join(".", bin_prefix + arch) qemu_bin_name = bin_prefix + arch
if is_readable_executable_file(qemu_bin_relative_path): qemu_bin_paths = [
return qemu_bin_relative_path os.path.join(".", qemu_bin_name),
os.path.join(BUILD_DIR, qemu_bin_name),
qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR, os.path.join(BUILD_DIR, "build", qemu_bin_name),
qemu_bin_relative_path) ]
if is_readable_executable_file(qemu_bin_from_bld_dir_path): for path in qemu_bin_paths:
return qemu_bin_from_bld_dir_path if is_readable_executable_file(path):
return path
return None return None

View File

@ -561,8 +561,20 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
CGDirectDisplayID display = [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]; CGDirectDisplayID display = [[description objectForKey:@"NSScreenNumber"] unsignedIntValue];
NSSize screenSize = [[[self window] screen] frame].size; NSSize screenSize = [[[self window] screen] frame].size;
CGSize screenPhysicalSize = CGDisplayScreenSize(display); CGSize screenPhysicalSize = CGDisplayScreenSize(display);
CVDisplayLinkRef displayLink;
frameSize = isFullscreen ? screenSize : [self frame].size; frameSize = isFullscreen ? screenSize : [self frame].size;
if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) {
CVTime period = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink);
CVDisplayLinkRelease(displayLink);
if (!(period.flags & kCVTimeIsIndefinite)) {
update_displaychangelistener(&dcl,
1000 * period.timeValue / period.timeScale);
info.refresh_rate = (int64_t)1000 * period.timeScale / period.timeValue;
}
}
info.width_mm = frameSize.width / screenSize.width * screenPhysicalSize.width; info.width_mm = frameSize.width / screenSize.width * screenPhysicalSize.width;
info.height_mm = frameSize.height / screenSize.height * screenPhysicalSize.height; info.height_mm = frameSize.height / screenSize.height * screenPhysicalSize.height;
} else { } else {
@ -800,7 +812,6 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
int buttons = 0; int buttons = 0;
int keycode = 0; int keycode = 0;
bool mouse_event = false; bool mouse_event = false;
static bool switched_to_fullscreen = false;
// Location of event in virtual screen coordinates // Location of event in virtual screen coordinates
NSPoint p = [self screenLocationOfEvent:event]; NSPoint p = [self screenLocationOfEvent:event];
NSUInteger modifiers = [event modifierFlags]; NSUInteger modifiers = [event modifierFlags];
@ -952,13 +963,6 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
// forward command key combos to the host UI unless the mouse is grabbed // forward command key combos to the host UI unless the mouse is grabbed
if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) { if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) {
/*
* Prevent the command key from being stuck down in the guest
* when using Command-F to switch to full screen mode.
*/
if (keycode == Q_KEY_CODE_F) {
switched_to_fullscreen = true;
}
return false; return false;
} }