Skip to content

Commit 27577cd

Browse files
committed
Add patches for 7.0
Derived from latest 6.19 patches
1 parent 321be2e commit 27577cd

16 files changed

Lines changed: 9859 additions & 0 deletions

‎patches/7.0/0001-secureboot.patch‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
From b4783e81efa316c49be93a4e137585235d1458d6 Mon Sep 17 00:00:00 2001
2+
From: Maximilian Luz <[email protected]>
3+
Date: Sun, 9 Jun 2024 19:48:58 +0200
4+
Subject: [PATCH] Revert "efi/x86: Set the PE/COFF header's NX compat flag
5+
unconditionally"
6+
7+
This reverts commit 891f8890a4a3663da7056542757022870b499bc1.
8+
9+
Revert because of compatibility issues of MS Surface devices and GRUB
10+
with NX. In short, these devices get stuck on boot with NX advertised.
11+
So to not advertise it, add the respective option back in.
12+
13+
Signed-off-by: Maximilian Luz <[email protected]>
14+
Patchset: secureboot
15+
---
16+
arch/x86/boot/header.S | 4 ++++
17+
1 file changed, 4 insertions(+)
18+
19+
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
20+
index 9bea5a1e2c52..25848f886ad6 100644
21+
--- a/arch/x86/boot/header.S
22+
+++ b/arch/x86/boot/header.S
23+
@@ -111,7 +111,11 @@ extra_header_fields:
24+
.long salign # SizeOfHeaders
25+
.long 0 # CheckSum
26+
.word IMAGE_SUBSYSTEM_EFI_APPLICATION # Subsystem (EFI application)
27+
+#ifdef CONFIG_EFI_DXE_MEM_ATTRIBUTES
28+
.word IMAGE_DLLCHARACTERISTICS_NX_COMPAT # DllCharacteristics
29+
+#else
30+
+ .word 0 # DllCharacteristics
31+
+#endif
32+
#ifdef CONFIG_X86_32
33+
.long 0 # SizeOfStackReserve
34+
.long 0 # SizeOfStackCommit
35+
--
36+
2.54.0
37+
38+
From 787e9e306657e1ece62e32d5d447d426336e9935 Mon Sep 17 00:00:00 2001
39+
From: "J. Eduardo" <[email protected]>
40+
Date: Sun, 25 Aug 2024 14:17:45 +0200
41+
Subject: [PATCH] PM: hibernate: Add a lockdown_hibernate parameter
42+
43+
This allows the user to tell the kernel that they know better (namely,
44+
they secured their swap properly), and that it can enable hibernation.
45+
46+
Signed-off-by: Kelvie Wong <[email protected]>
47+
Link: https://github.com/linux-surface/kernel/pull/158
48+
Link: https://gist.github.com/brknkfr/95d1925ccdbb7a2d18947c168dfabbee
49+
Patchset: secureboot
50+
---
51+
Documentation/admin-guide/kernel-parameters.txt | 5 +++++
52+
kernel/power/hibernate.c | 10 +++++++++-
53+
2 files changed, 14 insertions(+), 1 deletion(-)
54+
55+
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
56+
index 03a550630644..dac47a83fe44 100644
57+
--- a/Documentation/admin-guide/kernel-parameters.txt
58+
+++ b/Documentation/admin-guide/kernel-parameters.txt
59+
@@ -3574,6 +3574,11 @@ Kernel parameters
60+
to extract confidential information from the kernel
61+
are also disabled.
62+
63+
+ lockdown_hibernate [HIBERNATION]
64+
+ Enable hibernation even if lockdown is enabled. Enable this only if
65+
+ your swap is encrypted and secured properly, as an attacker can
66+
+ modify the kernel offline during hibernation.
67+
+
68+
locktorture.acq_writer_lim= [KNL]
69+
Set the time limit in jiffies for a lock
70+
acquisition. Acquisitions exceeding this limit
71+
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
72+
index af8d07bafe02..9e151554d5a0 100644
73+
--- a/kernel/power/hibernate.c
74+
+++ b/kernel/power/hibernate.c
75+
@@ -38,6 +38,7 @@
76+
#include "power.h"
77+
78+
79+
+static int lockdown_hibernate;
80+
static int nocompress;
81+
static int noresume;
82+
static int nohibernate;
83+
@@ -109,7 +110,7 @@ bool hibernation_in_progress(void)
84+
bool hibernation_available(void)
85+
{
86+
return nohibernate == 0 &&
87+
- !security_locked_down(LOCKDOWN_HIBERNATION) &&
88+
+ (lockdown_hibernate || !security_locked_down(LOCKDOWN_HIBERNATION)) &&
89+
!secretmem_active() && !cxl_mem_active();
90+
}
91+
92+
@@ -1493,6 +1494,12 @@ static int __init nohibernate_setup(char *str)
93+
return 1;
94+
}
95+
96+
+static int __init lockdown_hibernate_setup(char *str)
97+
+{
98+
+ lockdown_hibernate = 1;
99+
+ return 1;
100+
+}
101+
+
102+
static const char * const comp_alg_enabled[] = {
103+
#if IS_ENABLED(CONFIG_CRYPTO_LZO)
104+
COMPRESSION_ALGO_LZO,
105+
@@ -1550,3 +1557,4 @@ __setup("hibernate=", hibernate_setup);
106+
__setup("resumewait", resumewait_setup);
107+
__setup("resumedelay=", resumedelay_setup);
108+
__setup("nohibernate", nohibernate_setup);
109+
+__setup("lockdown_hibernate", lockdown_hibernate_setup);
110+
--
111+
2.54.0
112+

‎patches/7.0/0002-surface3.patch‎

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
From f92f8ec52735c40c41e2b6ba22e38d412e3cff43 Mon Sep 17 00:00:00 2001
2+
From: Tsuchiya Yuto <[email protected]>
3+
Date: Sun, 18 Oct 2020 16:42:44 +0900
4+
Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI
5+
table
6+
7+
On some Surface 3, the DMI table gets corrupted for unknown reasons
8+
and breaks existing DMI matching used for device-specific quirks.
9+
10+
This commit adds the (broken) DMI data into dmi_system_id tables used
11+
for quirks so that each driver can enable quirks even on the affected
12+
systems.
13+
14+
On affected systems, DMI data will look like this:
15+
$ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\
16+
chassis_vendor,product_name,sys_vendor}
17+
/sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc.
18+
/sys/devices/virtual/dmi/id/board_name:OEMB
19+
/sys/devices/virtual/dmi/id/board_vendor:OEMB
20+
/sys/devices/virtual/dmi/id/chassis_vendor:OEMB
21+
/sys/devices/virtual/dmi/id/product_name:OEMB
22+
/sys/devices/virtual/dmi/id/sys_vendor:OEMB
23+
24+
Expected:
25+
$ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\
26+
chassis_vendor,product_name,sys_vendor}
27+
/sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc.
28+
/sys/devices/virtual/dmi/id/board_name:Surface 3
29+
/sys/devices/virtual/dmi/id/board_vendor:Microsoft Corporation
30+
/sys/devices/virtual/dmi/id/chassis_vendor:Microsoft Corporation
31+
/sys/devices/virtual/dmi/id/product_name:Surface 3
32+
/sys/devices/virtual/dmi/id/sys_vendor:Microsoft Corporation
33+
34+
Signed-off-by: Tsuchiya Yuto <[email protected]>
35+
Patchset: surface3
36+
---
37+
drivers/platform/surface/surface3-wmi.c | 7 +++++++
38+
sound/soc/codecs/rt5645.c | 9 +++++++++
39+
sound/soc/intel/common/soc-acpi-intel-cht-match.c | 8 ++++++++
40+
3 files changed, 24 insertions(+)
41+
42+
diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
43+
index 6c8fb7a4dde4..22797a53f4d8 100644
44+
--- a/drivers/platform/surface/surface3-wmi.c
45+
+++ b/drivers/platform/surface/surface3-wmi.c
46+
@@ -37,6 +37,13 @@ static const struct dmi_system_id surface3_dmi_table[] = {
47+
DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
48+
},
49+
},
50+
+ {
51+
+ .matches = {
52+
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
53+
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
54+
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
55+
+ },
56+
+ },
57+
#endif
58+
{ }
59+
};
60+
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
61+
index f7701b8d0d3c..0708c2fe8f61 100644
62+
--- a/sound/soc/codecs/rt5645.c
63+
+++ b/sound/soc/codecs/rt5645.c
64+
@@ -3793,6 +3793,15 @@ static const struct dmi_system_id dmi_platform_data[] = {
65+
},
66+
.driver_data = (void *)&intel_braswell_platform_data,
67+
},
68+
+ {
69+
+ .ident = "Microsoft Surface 3",
70+
+ .matches = {
71+
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
72+
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
73+
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
74+
+ },
75+
+ .driver_data = (void *)&intel_braswell_platform_data,
76+
+ },
77+
{
78+
/*
79+
* Match for the GPDwin which unfortunately uses somewhat
80+
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
81+
index e4c3492a0c28..0b930c91bccb 100644
82+
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
83+
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
84+
@@ -27,6 +27,14 @@ static const struct dmi_system_id cht_table[] = {
85+
DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
86+
},
87+
},
88+
+ {
89+
+ .callback = cht_surface_quirk_cb,
90+
+ .matches = {
91+
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
92+
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
93+
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
94+
+ },
95+
+ },
96+
{ }
97+
};
98+
99+
--
100+
2.54.0
101+
102+
From d4fd452b9de4b6826ceaec28d6179cafe313285f Mon Sep 17 00:00:00 2001
103+
From: kitakar5525 <[email protected]>
104+
Date: Fri, 6 Dec 2019 23:10:30 +0900
105+
Subject: [PATCH] surface3-spi: workaround: disable DMA mode to avoid crash by
106+
default
107+
108+
On Arch Linux kernel at least after 4.19, touch input is broken after suspend
109+
(s2idle).
110+
111+
kern :err : [ +0.203408] Surface3-spi spi-MSHW0037:00: SPI transfer timed out
112+
113+
On recent stable Arch Linux kernel (at least after 5.1), touch input will
114+
crash after the first touch.
115+
116+
kern :err : [ +0.203592] Surface3-spi spi-MSHW0037:00: SPI transfer timed out
117+
kern :err : [ +0.000173] spi_master spi1: failed to transfer one message from queue
118+
119+
I found on an affected system (Arch Linux kernel, etc.), the touchscreen
120+
driver uses DMA mode by default. Then, we found some kernels with different
121+
kernel config (5.1 kernel config from Jakeday [1] or Chromium OS kernel
122+
chromeos-4.19 [2]) will use PIO mode by default and no such issues there.
123+
124+
So, this commit disables DMA mode on the touchscreen driver side as a quick
125+
workaround to avoid touch input crash.
126+
We may need to properly set up DMA mode to use the touchscreen driver with
127+
DMA mode.
128+
129+
You can still switch DMA/PIO mode if you want:
130+
131+
switch to DMA mode (maybe broken)
132+
echo 1 | sudo tee /sys/module/surface3_spi/parameters/use_dma
133+
back to PIO mode
134+
echo 0 | sudo tee /sys/module/surface3_spi/parameters/use_dma
135+
136+
Link to issue: https://github.com/jakeday/linux-surface/issues/596
137+
138+
References:
139+
[1] https://github.com/jakeday/linux-surface/blob/master/configs/5.1/config
140+
[2] https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/heads/chromeos-4.19
141+
142+
Tested on Arch Linux 5.4.1 with Surface 3, which will use DMA by default.
143+
This commit made the driver use PIO by default and no touch input crash.
144+
Also tested on chromeos-4.19 4.19.90 with Surface 3, which will use PIO by default
145+
even without this commit. After this commit, it still uses PIO and confirmed
146+
no functional changes regarding touch input.
147+
148+
More details:
149+
We can confirm which mode the touchscreen driver uses; first, enable
150+
debug output:
151+
152+
echo "file drivers/spi/spi-pxa2xx.c +p" | sudo tee /sys/kernel/debug/dynamic_debug/control
153+
echo "file drivers/input/touchscreen/surface3_spi.c +p" | sudo tee /sys/kernel/debug/dynamic_debug/control
154+
155+
Then, try to make a touch input and see dmesg log
156+
157+
(On Arch Linux kernel, uses DMA)
158+
kern :debug : [ +0.006383] Surface3-spi spi-MSHW0037:00: 7692307 Hz actual, DMA
159+
kern :debug : [ +0.000495] Surface3-spi spi-MSHW0037:00: surface3_spi_irq_handler received
160+
-> ff ff ff ff a5 5a e7 7e 01 d2 00 80 01 03 03 18 00 e4 01 00 04 1a 04 1a e3 0c e3 0c b0 00
161+
c5 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
162+
163+
(On the kernels I referenced above, uses PIO)
164+
kern :debug : [ +0.009260] Surface3-spi spi-MSHW0037:00: 7692307 Hz actual, PIO
165+
kern :debug : [ +0.001105] Surface3-spi spi-MSHW0037:00: surface3_spi_irq_handler received
166+
-> ff ff ff ff a5 5a e7 7e 01 d2 00 80 01 03 03 24 00 e4 01 00 58 0b 58 0b 83 12 83 12 26 01
167+
95 01 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
168+
169+
Note (2025-03-08): This patch was originally dropped due to the
170+
comments in [3]. However, according to the commments in [4] it is still
171+
required.
172+
173+
[3]: https://github.com/linux-surface/kernel/commit/a3421c12bed0e46c28518bcb8c6b22f237c6dc7a
174+
[4]: https://github.com/linux-surface/linux-surface/issues/1184
175+
176+
Patchset: surface3
177+
---
178+
drivers/input/touchscreen/surface3_spi.c | 26 ++++++++++++++++++++++++
179+
1 file changed, 26 insertions(+)
180+
181+
diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c
182+
index 6074b7730e86..6aa3e1d6f160 100644
183+
--- a/drivers/input/touchscreen/surface3_spi.c
184+
+++ b/drivers/input/touchscreen/surface3_spi.c
185+
@@ -25,6 +25,12 @@
186+
#define SURFACE3_REPORT_TOUCH 0xd2
187+
#define SURFACE3_REPORT_PEN 0x16
188+
189+
+bool use_dma = false;
190+
+module_param(use_dma, bool, 0644);
191+
+MODULE_PARM_DESC(use_dma,
192+
+ "Disable DMA mode if you encounter touch input crash. "
193+
+ "(default: false, disabled to avoid crash)");
194+
+
195+
struct surface3_ts_data {
196+
struct spi_device *spi;
197+
struct gpio_desc *gpiod_rst[2];
198+
@@ -317,6 +323,13 @@ static int surface3_spi_create_pen_input(struct surface3_ts_data *data)
199+
return 0;
200+
}
201+
202+
+static bool surface3_spi_can_dma(struct spi_controller *ctlr,
203+
+ struct spi_device *spi,
204+
+ struct spi_transfer *tfr)
205+
+{
206+
+ return use_dma;
207+
+}
208+
+
209+
static int surface3_spi_probe(struct spi_device *spi)
210+
{
211+
struct surface3_ts_data *data;
212+
@@ -359,6 +372,19 @@ static int surface3_spi_probe(struct spi_device *spi)
213+
if (error)
214+
return error;
215+
216+
+ /*
217+
+ * Set up DMA
218+
+ *
219+
+ * TODO: Currently, touch input with DMA seems to be broken.
220+
+ * On 4.19 LTS, touch input will crash after suspend.
221+
+ * On recent stable kernel (at least after 5.1), touch input will crash after
222+
+ * the first touch. No problem with PIO on those kernels.
223+
+ * Maybe we need to configure DMA here.
224+
+ *
225+
+ * Link to issue: https://github.com/jakeday/linux-surface/issues/596
226+
+ */
227+
+ spi->controller->can_dma = surface3_spi_can_dma;
228+
+
229+
return 0;
230+
}
231+
232+
--
233+
2.54.0
234+

0 commit comments

Comments
 (0)