Skip to content

Commit

Permalink
Update patches for Lutris Wine 6.21
Browse files Browse the repository at this point in the history
tannisroot committed Nov 14, 2021
1 parent 1e2b9c9 commit e901da3
Showing 71 changed files with 7,438 additions and 4,780 deletions.
3 changes: 3 additions & 0 deletions runners/wine/build-preparation/build.bash
Original file line number Diff line number Diff line change
@@ -54,11 +54,14 @@ GetSources() {
if [ -d "${root_dir}/wine-tkg-git/" ]; then
git -C "${root_dir}/wine-tkg-git/" fetch
git -C "${root_dir}/wine-tkg-git/" clean -fx "${root_dir}/wine-tkg-git/wine-tkg-git/wine-tkg-userpatches/" || true
git -C "${root_dir}/wine-tkg-git/" clean -fx "${root_dir}/wine-tkg-git/wine-tkg-git/wine-tkg-patches/" || true
rm -rf "${root_dir}/wine-tkg-git/wine-tkg-git/src/" || true
git -C "${root_dir}/wine-tkg-git/" rm "${root_dir}/wine-tkg-git/wine-tkg-git/*.{mypatch,myrevert,patch}" || true
git -C "${root_dir}/wine-tkg-git/" reset --hard origin/master
git -C "${root_dir}/wine-tkg-git/" am < "${root_dir}/commit-2915f92"
else
git clone https://github.com/Frogging-Family/wine-tkg-git.git "${root_dir}/wine-tkg-git/"
git -C "${root_dir}/wine-tkg-git/" am < "${root_dir}/commit-2915f92"
fi
}

49 changes: 49 additions & 0 deletions runners/wine/build-preparation/commit-2915f92
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 2915f92bb388c6f347efcb3d0f7079d1fa05cc6a Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Thu, 13 Nov 2021 14:50:18 +0100
Subject: Hotfixer: Allow to rollback to non-PE FAudio using
`_non_pe_faudio="true"`


diff --git a/wine-tkg-git/wine-tkg-patches/hotfixes/hotfixer b/wine-tkg-git/wine-tkg-patches/hotfixes/hotfixer
index c2cd4ac..76113d9 100755
--- a/wine-tkg-git/wine-tkg-patches/hotfixes/hotfixer
+++ b/wine-tkg-git/wine-tkg-patches/hotfixes/hotfixer
@@ -524,6 +524,15 @@ else
fi
fi

+# Test - Rollback to non-PE FAudio
+if [ "$_non_pe_faudio" = "true" ]; then
+ warning "Rolling back to non-PE FAudio"
+ _hotfix_mainlinereverts+=(da89825f98e4f0cb3875735345a455512b36b665 babaf916ab12c7a9128409f717878919ccc5826b 22c26a2dde318b5b370fc269cab871e5a8bc4231 d8be85863fedf6982944d06ebd1ce5904cb3d4e1 6b45777121fcd50d9b7d5b649c6710063b549892)
+ if [ "$_use_staging" = "true" ] && ( cd "${srcdir}"/"${_stgsrcdir}" && git merge-base --is-ancestor 6fd31b354c7693c85e62113f3db0cf6488c63c15 HEAD ); then
+ _hotfixes+=("$_where"/wine-tkg-patches/hotfixes/non-PE-FAudio/6fd31b3)
+ fi
+fi
+
# Disable vr support patchset for 5.20-6.12
if ( cd "${srcdir}"/"${_winesrcdir}" && ! git merge-base --is-ancestor 12d33d21d33788fd46898ea42e9592d33b6e7c8e HEAD ); then
_steamvr_support="false"
diff --git a/wine-tkg-git/wine-tkg-patches/hotfixes/non-PE-FAudio/6fd31b3.mystagingrevert b/wine-tkg-git/wine-tkg-patches/hotfixes/non-PE-FAudio/6fd31b3.mystagingrevert
new file mode 100644
index 0000000..7097e16
--- /dev/null
+++ b/wine-tkg-git/wine-tkg-patches/hotfixes/non-PE-FAudio/6fd31b3.mystagingrevert
@@ -0,0 +1,16 @@
+diff --git a/patches/xactengine-initial/0001-x3daudio1_7-Create-import-library.patch b/patches/xactengine-initial/0001-x3daudio1_7-Create-import-library.patch
+index 0c84c6f85..bf00b0bdf 100644
+--- a/patches/xactengine-initial/0001-x3daudio1_7-Create-import-library.patch
++++ b/patches/xactengine-initial/0001-x3daudio1_7-Create-import-library.patch
+@@ -16,8 +16,8 @@ index 267a93fd6da..5438bc6d801 100644
+ MODULE = x3daudio1_7.dll
+ +IMPORTLIB = x3daudio1_7
+ PARENTSRC = ../xaudio2_7
+- EXTRALIBS = $(FAUDIO_LIBS)
+- EXTRAINCL = $(FAUDIO_CFLAGS)
++ IMPORTS = $(FAUDIO_PE_LIBS)
++ EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+ --
+-2.28.0
++2.33.0
+
199 changes: 162 additions & 37 deletions runners/wine/build-preparation/fshack-patches/1-QPC.mypatch
Original file line number Diff line number Diff line change
@@ -367,9 +367,9 @@ index ff88ae16d8d..2750e229109 100644
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -406,6 +409,26 @@ static const int user_shared_data_timeout = 16;
static void set_user_shared_data_time(void)
{
timeout_t tick_count = monotonic_time / 10000;
timeout_t timezone_bias;
struct tm *tm;
time_t now;
+ unsigned __int64 tsc, qpc_bias, qpc_freq = user_shared_data->QpcFrequency;
+ unsigned int aux, qpc_shift = user_shared_data->QpcShift;
+ unsigned int qpc_bypass = user_shared_data->QpcBypassEnabled;
@@ -391,25 +391,16 @@ index ff88ae16d8d..2750e229109 100644
+
+ qpc_bias = ((monotonic_time * qpc_freq / 10000000) << qpc_shift) - tsc;

/* on X86 there should be total store order guarantees, so volatile is enough
* to ensure the stores aren't reordered by the compiler, and then they will
if (monotonic_time - last_timezone_update > TICKS_PER_SEC)
{
@@ -424,6 +447,7 @@ static void set_user_shared_data_time(void)
user_shared_data->TickCount.LowPart = tick_count;
user_shared_data->TickCount.High1Time = tick_count >> 32;
*(volatile ULONG *)&user_shared_data->TickCountLowDeprecated = tick_count;
atomic_store_ulong(&user_shared_data->TickCount.LowPart, tick_count);
atomic_store_long(&user_shared_data->TickCount.High1Time, tick_count >> 32);
atomic_store_ulong(&user_shared_data->TickCountLowDeprecated, tick_count);
+ user_shared_data->QpcBias = qpc_bias;
#else
__atomic_store_n(&user_shared_data->SystemTime.High2Time, current_time >> 32, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->SystemTime.LowPart, current_time, __ATOMIC_SEQ_CST);
@@ -437,6 +461,7 @@ static void set_user_shared_data_time(void)
__atomic_store_n(&user_shared_data->TickCount.LowPart, tick_count, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->TickCount.High1Time, tick_count >> 32, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->TickCountLowDeprecated, tick_count, __ATOMIC_SEQ_CST);
+ __atomic_store_n(&user_shared_data->QpcBias, qpc_bias, __ATOMIC_SEQ_CST);
#endif
}


void set_current_time(void)
From 0f850e60fb84ce75c6d2666bd1ddca67a956a658 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Wed, 28 Apr 2021 11:50:36 +0200
@@ -879,9 +870,9 @@ index 2750e229109..7a1cd4bcddc 100644
+ return (ah * bh) + (m >> 32);
+}
+
static void set_user_shared_data_time(void)
static void atomic_store_ulong(volatile ULONG *ptr, ULONG value)
{
timeout_t tick_count = monotonic_time / 10000;
/* on x86 there should be total store order guarantees, so volatile is
@@ -428,7 +437,13 @@ static void set_user_shared_data_time(void)
}
#endif
@@ -898,29 +889,17 @@ index 2750e229109..7a1cd4bcddc 100644
/* on X86 there should be total store order guarantees, so volatile is enough
* to ensure the stores aren't reordered by the compiler, and then they will
@@ -447,7 +462,10 @@ static void set_user_shared_data_time(void)
user_shared_data->TickCount.LowPart = tick_count;
user_shared_data->TickCount.High1Time = tick_count >> 32;
*(volatile ULONG *)&user_shared_data->TickCountLowDeprecated = tick_count;
atomic_store_ulong(&user_shared_data->TickCount.LowPart, tick_count);
atomic_store_long(&user_shared_data->TickCount.High1Time, tick_count >> 32);
atomic_store_ulong(&user_shared_data->TickCountLowDeprecated, tick_count);
- user_shared_data->QpcBias = qpc_bias;
+ if (qpc_bypass & SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE)
+ hypervisor_shared_data->QpcBias = qpc_bias;
+ else
+ user_shared_data->QpcBias = qpc_bias;
#else
__atomic_store_n(&user_shared_data->SystemTime.High2Time, current_time >> 32, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->SystemTime.LowPart, current_time, __ATOMIC_SEQ_CST);
@@ -461,7 +479,10 @@ static void set_user_shared_data_time(void)
__atomic_store_n(&user_shared_data->TickCount.LowPart, tick_count, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->TickCount.High1Time, tick_count >> 32, __ATOMIC_SEQ_CST);
__atomic_store_n(&user_shared_data->TickCountLowDeprecated, tick_count, __ATOMIC_SEQ_CST);
- __atomic_store_n(&user_shared_data->QpcBias, qpc_bias, __ATOMIC_SEQ_CST);
+ if (qpc_bypass & SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE)
+ __atomic_store_n(&hypervisor_shared_data->QpcBias, qpc_bias, __ATOMIC_SEQ_CST);
+ else
+ __atomic_store_n(&user_shared_data->QpcBias, qpc_bias, __ATOMIC_SEQ_CST);
#endif
}


void set_current_time(void)
diff --git a/server/file.h b/server/file.h
index 3f0c3a559b3..719af8c01b3 100644
--- a/server/file.h
@@ -1204,3 +1183,149 @@ index 0662feac9ce..dc0e645dd09 100644
create_dynamic_registry_keys();
create_environment_registry_keys();
create_computer_name_keys();
From 9490a634610c111aba940c527200f3fdba113e96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Thu, 7 Oct 2021 17:50:51 +0200
Subject: [PATCH] wineboot: Calibrate TSC frequency after reading CPU
capabilities.

To support old CPUs without rdtscp / rdtsc instructions.
---
programs/wineboot/wineboot.c | 50 ++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 17 deletions(-)

diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index f82e2cfc26a..1baedd084a3 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -243,7 +243,7 @@ static void initialize_xstate_features(struct _KUSER_SHARED_DATA *data)
TRACE("XSAVE feature 2 %#x, %#x, %#x, %#x.\n", regs[0], regs[1], regs[2], regs[3]);
}

-static UINT64 read_tsc_frequency(void)
+static UINT64 read_tsc_frequency(BOOL use_rdtscp)
{
UINT64 freq = 0;

@@ -287,16 +287,30 @@ static UINT64 read_tsc_frequency(void)
LONGLONG time0, time1, tsc0, tsc1, tsc2, tsc3, freq0, freq1, error;
unsigned int aux;
UINT retries = 50;
+ int regs[4];

do
{
- tsc0 = __rdtscp(&aux);
- time0 = RtlGetSystemTimePrecise();
- tsc1 = __rdtscp(&aux);
- Sleep(1);
- tsc2 = __rdtscp(&aux);
- time1 = RtlGetSystemTimePrecise();
- tsc3 = __rdtscp(&aux);
+ if (use_rdtscp)
+ {
+ tsc0 = __rdtscp(&aux);
+ time0 = RtlGetSystemTimePrecise();
+ tsc1 = __rdtscp(&aux);
+ Sleep(1);
+ tsc2 = __rdtscp(&aux);
+ time1 = RtlGetSystemTimePrecise();
+ tsc3 = __rdtscp(&aux);
+ }
+ else
+ {
+ tsc0 = __rdtsc(); __cpuid(regs, 0);
+ time0 = RtlGetSystemTimePrecise();
+ tsc1 = __rdtsc(); __cpuid(regs, 0);
+ Sleep(1);
+ tsc2 = __rdtsc(); __cpuid(regs, 0);
+ time1 = RtlGetSystemTimePrecise();
+ tsc3 = __rdtsc(); __cpuid(regs, 0);
+ }

freq0 = (tsc2 - tsc0) * 10000000 / (time1 - time0);
freq1 = (tsc3 - tsc1) * 10000000 / (time1 - time0);
@@ -339,7 +353,7 @@ static BOOL is_tsc_trusted_by_the_kernel(void)
return ret;
}

-static void initialize_qpc_features(struct _KUSER_SHARED_DATA *data, UINT64 tsc_frequency)
+static void initialize_qpc_features(struct _KUSER_SHARED_DATA *data, UINT64 *tsc_frequency)
{
int regs[4];

@@ -388,7 +402,9 @@ static void initialize_qpc_features(struct _KUSER_SHARED_DATA *data, UINT64 tsc_
else
data->QpcBypassEnabled |= SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_MFENCE;

- if ((data->QpcFrequency = (tsc_frequency >> 10)))
+ *tsc_frequency = read_tsc_frequency((regs[3] & (1 << 27)) != 0);
+
+ if ((data->QpcFrequency = (*tsc_frequency >> 10)))
{
data->QpcShift = 10;
data->QpcBias = 0;
@@ -410,12 +426,13 @@ static void initialize_xstate_features(struct _KUSER_SHARED_DATA *data)
{
}

-static void initialize_qpc_features(struct _KUSER_SHARED_DATA *data)
+static void initialize_qpc_features(struct _KUSER_SHARED_DATA *data, UINT64 *tsc_frequency)
{
data->QpcBypassEnabled = 0;
data->QpcFrequency = TICKSPERSEC;
data->QpcShift = 0;
data->QpcBias = 0;
+ *tsc_frequency = 0;
}

#endif
@@ -478,7 +495,7 @@ static void create_hypervisor_shared_data(UINT64 tsc_frequency)
hypervisor_shared_data->QpcMultiplier = 0;
hypervisor_shared_data->QpcBias = 0;

- if (user_shared_data->QpcBypassEnabled & SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED)
+ if ((user_shared_data->QpcBypassEnabled & SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED) && tsc_frequency)
{
hypervisor_shared_data->QpcMultiplier = muldiv_tsc((UINT64)5000 << 32, (UINT64)2000 << 32, tsc_frequency);
user_shared_data->QpcBypassEnabled |= SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE;
@@ -495,7 +512,7 @@ static void create_hypervisor_shared_data(UINT64 tsc_frequency)
UnmapViewOfFile( hypervisor_shared_data );
}

-static void create_user_shared_data(UINT64 tsc_frequency)
+static void create_user_shared_data(UINT64 *tsc_frequency)
{
struct _KUSER_SHARED_DATA *data;
RTL_OSVERSIONINFOEXW version;
@@ -970,6 +987,7 @@ static void create_hardware_registry_keys(UINT64 tsc_frequency)
KEY_ALL_ACCESS, NULL, &hkey, NULL ))
{
DWORD tsc_freq_mhz = (DWORD)(tsc_frequency / 1000000ull); /* Hz -> Mhz */
+ if (!tsc_freq_mhz) tsc_freq_mhz = power_info[i].MaxMhz;

RegSetValueExW( hkey, L"FeatureSet", 0, REG_DWORD, (BYTE *)&sci.FeatureSet, sizeof(DWORD) );
set_reg_value( hkey, L"Identifier", id );
@@ -1929,12 +1947,10 @@ int __cdecl main( int argc, char *argv[] )
BOOL end_session, force, init, kill, restart, shutdown, update;
HANDLE event;
OBJECT_ATTRIBUTES attr;
- UINT64 tsc_frequency;
+ UINT64 tsc_frequency = 0;
UNICODE_STRING nameW;
BOOL is_wow64;

- tsc_frequency = read_tsc_frequency();
-
end_session = force = init = kill = restart = shutdown = update = FALSE;
GetWindowsDirectoryW( windowsdir, MAX_PATH );
if( !SetCurrentDirectoryW( windowsdir ) )
@@ -2017,7 +2033,7 @@ int __cdecl main( int argc, char *argv[] )

ResetEvent( event ); /* in case this is a restart */

- create_user_shared_data(tsc_frequency);
+ create_user_shared_data(&tsc_frequency);
create_hypervisor_shared_data(tsc_frequency);
create_hardware_registry_keys(tsc_frequency);
create_dynamic_registry_keys();
Loading

0 comments on commit e901da3

Please sign in to comment.