initial commit
imported from https://salsa.debian.org/kernel-team/linux.git commit 9d5cc9d9d6501d7f1dd7e194d4b245bd0b6c6a22 version 6.11.4-1
This commit is contained in:
74
debian/patches/features/x86/intel-iommu-add-kconfig-option-to-exclude-igpu-by-default.patch
vendored
Normal file
74
debian/patches/features/x86/intel-iommu-add-kconfig-option-to-exclude-igpu-by-default.patch
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
From: Ben Hutchings <ben@decadent.org.uk>
|
||||
Date: Wed, 21 Aug 2019 00:32:16 +0100
|
||||
Subject: intel-iommu: Add Kconfig option to exclude iGPU by default
|
||||
Bug-Debian: https://bugs.debian.org/935270
|
||||
Bug-Kali: https://bugs.kali.org/view.php?id=5644
|
||||
|
||||
There is still laptop firmware that touches the integrated GPU behind
|
||||
the operating system's back, and doesn't say so in the RMRR table.
|
||||
Enabling the IOMMU for all devices causes breakage.
|
||||
|
||||
Replace CONFIG_INTEL_IOMMU_DEFAULT_ON with a 3-way choice
|
||||
corresponding to "on", "off", and "on,intgpu_off".
|
||||
|
||||
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
||||
---
|
||||
--- a/drivers/iommu/intel/Kconfig
|
||||
+++ b/drivers/iommu/intel/Kconfig
|
||||
@@ -57,13 +57,24 @@ config INTEL_IOMMU_SVM
|
||||
to access DMA resources through process address space by
|
||||
means of a Process Address Space ID (PASID).
|
||||
|
||||
-config INTEL_IOMMU_DEFAULT_ON
|
||||
- bool "Enable Intel DMA Remapping Devices by default"
|
||||
- default y
|
||||
+choice
|
||||
+ prompt "Default state of Intel DMA Remapping Devices"
|
||||
+ default INTEL_IOMMU_DEFAULT_ON
|
||||
help
|
||||
- Selecting this option will enable a DMAR device at boot time if
|
||||
- one is found. If this option is not selected, DMAR support can
|
||||
- be enabled by passing intel_iommu=on to the kernel.
|
||||
+ Choose whether Intel DMA Remapping Devices should be enabled
|
||||
+ by default. This can be overridden at boot time using the
|
||||
+ intel_iommu= kernel parameter.
|
||||
+
|
||||
+config INTEL_IOMMU_DEFAULT_ON
|
||||
+ bool "Enable"
|
||||
+
|
||||
+config INTEL_IOMMU_DEFAULT_ON_INTGPU_OFF
|
||||
+ bool "Enable, excluding integrated GPU"
|
||||
+
|
||||
+config INTEL_IOMMU_DEFAULT_OFF
|
||||
+ bool "Disable"
|
||||
+
|
||||
+endchoice
|
||||
|
||||
config INTEL_IOMMU_FLOPPY_WA
|
||||
def_bool y
|
||||
--- a/drivers/iommu/intel/iommu.c
|
||||
+++ b/drivers/iommu/intel/iommu.c
|
||||
@@ -218,13 +218,13 @@ static LIST_HEAD(dmar_satc_units);
|
||||
|
||||
static void intel_iommu_domain_free(struct iommu_domain *domain);
|
||||
|
||||
-int dmar_disabled = !IS_ENABLED(CONFIG_INTEL_IOMMU_DEFAULT_ON);
|
||||
+int dmar_disabled = IS_ENABLED(CONFIG_INTEL_IOMMU_DEFAULT_OFF);
|
||||
int intel_iommu_sm = IS_ENABLED(CONFIG_INTEL_IOMMU_SCALABLE_MODE_DEFAULT_ON);
|
||||
|
||||
int intel_iommu_enabled = 0;
|
||||
EXPORT_SYMBOL_GPL(intel_iommu_enabled);
|
||||
|
||||
-static int dmar_map_intgpu = 1;
|
||||
+static int dmar_map_intgpu = IS_ENABLED(CONFIG_INTEL_IOMMU_DEFAULT_ON);
|
||||
static int intel_iommu_superpage = 1;
|
||||
static int iommu_identity_mapping;
|
||||
static int iommu_skip_te_disable;
|
||||
@@ -263,6 +263,7 @@ static int __init intel_iommu_setup(char
|
||||
while (*str) {
|
||||
if (!strncmp(str, "on", 2)) {
|
||||
dmar_disabled = 0;
|
||||
+ dmar_map_intgpu = 1;
|
||||
pr_info("IOMMU enabled\n");
|
||||
} else if (!strncmp(str, "off", 3)) {
|
||||
dmar_disabled = 1;
|
90
debian/patches/features/x86/intel-iommu-add-option-to-exclude-integrated-gpu-only.patch
vendored
Normal file
90
debian/patches/features/x86/intel-iommu-add-option-to-exclude-integrated-gpu-only.patch
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
From: Ben Hutchings <ben@decadent.org.uk>
|
||||
Date: Wed, 21 Aug 2019 00:05:30 +0100
|
||||
Subject: intel-iommu: Add option to exclude integrated GPU only
|
||||
Bug-Debian: https://bugs.debian.org/935270
|
||||
Bug-Kali: https://bugs.kali.org/view.php?id=5644
|
||||
|
||||
There is still laptop firmware that touches the integrated GPU behind
|
||||
the operating system's back, and doesn't say so in the RMRR table.
|
||||
Enabling the IOMMU for all devices causes breakage, but turning it off
|
||||
for all graphics devices seems like a major weakness.
|
||||
|
||||
Add an option, intel_iommu=intgpu_off, to exclude only integrated GPUs
|
||||
from remapping. This is a narrower exclusion than igfx_off: it only
|
||||
affects Intel devices on the root bus. Devices attached through an
|
||||
external port (Thunderbolt or ExpressCard) won't be on the root bus.
|
||||
|
||||
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
||||
---
|
||||
Documentation/admin-guide/kernel-parameters.txt | 2 ++
|
||||
drivers/iommu/intel/iommu.c | 14 ++++++++++++++
|
||||
2 files changed, 16 insertions(+)
|
||||
|
||||
--- a/Documentation/admin-guide/kernel-parameters.txt
|
||||
+++ b/Documentation/admin-guide/kernel-parameters.txt
|
||||
@@ -2174,6 +2174,8 @@
|
||||
bypassed by not enabling DMAR with this option. In
|
||||
this case, gfx device will use physical address for
|
||||
DMA.
|
||||
+ intgpu_off [Default Off]
|
||||
+ Bypass the DMAR unit for an integrated GPU only.
|
||||
strict [Default Off]
|
||||
Deprecated, equivalent to iommu.strict=1.
|
||||
sp_off [Default Off]
|
||||
--- a/drivers/iommu/intel/iommu.c
|
||||
+++ b/drivers/iommu/intel/iommu.c
|
||||
@@ -35,6 +35,9 @@
|
||||
#define CONTEXT_SIZE VTD_PAGE_SIZE
|
||||
|
||||
#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
|
||||
+#define IS_INTGPU_DEVICE(pdev) (IS_GFX_DEVICE(pdev) && \
|
||||
+ (pdev)->vendor == 0x8086 && \
|
||||
+ pci_is_root_bus((pdev)->bus))
|
||||
#define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
|
||||
#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
|
||||
#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
|
||||
@@ -221,12 +224,14 @@ int intel_iommu_sm = IS_ENABLED(CONFIG_I
|
||||
int intel_iommu_enabled = 0;
|
||||
EXPORT_SYMBOL_GPL(intel_iommu_enabled);
|
||||
|
||||
+static int dmar_map_intgpu = 1;
|
||||
static int intel_iommu_superpage = 1;
|
||||
static int iommu_identity_mapping;
|
||||
static int iommu_skip_te_disable;
|
||||
static int disable_igfx_iommu;
|
||||
|
||||
#define IDENTMAP_AZALIA 4
|
||||
+#define IDENTMAP_INTGPU 8
|
||||
|
||||
const struct iommu_ops intel_iommu_ops;
|
||||
static const struct iommu_dirty_ops intel_dirty_ops;
|
||||
@@ -266,6 +271,9 @@ static int __init intel_iommu_setup(char
|
||||
} else if (!strncmp(str, "igfx_off", 8)) {
|
||||
disable_igfx_iommu = 1;
|
||||
pr_info("Disable GFX device mapping\n");
|
||||
+ } else if (!strncmp(str, "intgpu_off", 10)) {
|
||||
+ dmar_map_intgpu = 0;
|
||||
+ pr_info("Disable integrated GPU device mapping\n");
|
||||
} else if (!strncmp(str, "forcedac", 8)) {
|
||||
pr_warn("intel_iommu=forcedac deprecated; use iommu.forcedac instead\n");
|
||||
iommu_dma_forcedac = true;
|
||||
@@ -2401,6 +2409,9 @@ static int device_def_domain_type(struct
|
||||
|
||||
if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev))
|
||||
return IOMMU_DOMAIN_IDENTITY;
|
||||
+
|
||||
+ if ((iommu_identity_mapping & IDENTMAP_INTGPU) && IS_INTGPU_DEVICE(pdev))
|
||||
+ return IOMMU_DOMAIN_IDENTITY;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2701,6 +2712,9 @@ static int __init init_dmars(void)
|
||||
iommu_set_root_entry(iommu);
|
||||
}
|
||||
|
||||
+ if (!dmar_map_intgpu)
|
||||
+ iommu_identity_mapping |= IDENTMAP_INTGPU;
|
||||
+
|
||||
check_tylersburg_isoch();
|
||||
|
||||
ret = si_domain_init(hw_pass_through);
|
180
debian/patches/features/x86/x86-make-x32-syscall-support-conditional.patch
vendored
Normal file
180
debian/patches/features/x86/x86-make-x32-syscall-support-conditional.patch
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
From: Ben Hutchings <ben@decadent.org.uk>
|
||||
Date: Mon, 12 Feb 2018 23:59:26 +0000
|
||||
Subject: x86: Make x32 syscall support conditional on a kernel parameter
|
||||
Bug-Debian: https://bugs.debian.org/708070
|
||||
Forwarded: https://lore.kernel.org/lkml/1415245982.3398.53.camel@decadent.org.uk/T/#u
|
||||
|
||||
Enabling x32 in the standard amd64 kernel would increase its attack
|
||||
surface while provide no benefit to the vast majority of its users.
|
||||
No-one seems interested in regularly checking for vulnerabilities
|
||||
specific to x32 (at least no-one with a white hat).
|
||||
|
||||
Still, adding another flavour just to turn on x32 seems wasteful. And
|
||||
the only differences on syscall entry are a few instructions that mask
|
||||
out the x32 flag and compare the syscall number.
|
||||
|
||||
Use a static key to control whether x32 syscalls are really enabled, a
|
||||
Kconfig parameter to set its default value and a kernel parameter
|
||||
"syscall.x32" to change it at boot time.
|
||||
|
||||
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
||||
---
|
||||
.../admin-guide/kernel-parameters.txt | 4 ++
|
||||
arch/x86/Kconfig | 8 ++++
|
||||
arch/x86/entry/common.c | 3 +-
|
||||
arch/x86/entry/syscall_64.c | 46 +++++++++++++++++++
|
||||
arch/x86/include/asm/elf.h | 6 ++-
|
||||
arch/x86/include/asm/syscall.h | 13 ++++++
|
||||
6 files changed, 78 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/Documentation/admin-guide/kernel-parameters.txt
|
||||
+++ b/Documentation/admin-guide/kernel-parameters.txt
|
||||
@@ -6498,6 +6498,10 @@
|
||||
later by a loaded module cannot be set this way.
|
||||
Example: sysctl.vm.swappiness=40
|
||||
|
||||
+ syscall.x32= [KNL,x86_64] Enable/disable use of x32 syscalls on
|
||||
+ an x86_64 kernel where CONFIG_X86_X32 is enabled.
|
||||
+ Default depends on CONFIG_X86_X32_DISABLED.
|
||||
+
|
||||
sysrq_always_enabled
|
||||
[KNL]
|
||||
Ignore sysrq setting - this boot parameter will
|
||||
--- a/arch/x86/Kconfig
|
||||
+++ b/arch/x86/Kconfig
|
||||
@@ -3058,6 +3058,14 @@ config COMPAT_32
|
||||
select HAVE_UID16
|
||||
select OLD_SIGSUSPEND3
|
||||
|
||||
+config X86_X32_DISABLED
|
||||
+ bool "x32 ABI disabled by default"
|
||||
+ depends on X86_X32_ABI
|
||||
+ default n
|
||||
+ help
|
||||
+ Disable the x32 ABI unless explicitly enabled using the
|
||||
+ kernel paramter "syscall.x32=y".
|
||||
+
|
||||
config COMPAT
|
||||
def_bool y
|
||||
depends on IA32_EMULATION || X86_X32_ABI
|
||||
--- a/arch/x86/entry/common.c
|
||||
+++ b/arch/x86/entry/common.c
|
||||
@@ -64,7 +64,7 @@ static __always_inline bool do_syscall_x
|
||||
*/
|
||||
unsigned int xnr = nr - __X32_SYSCALL_BIT;
|
||||
|
||||
- if (IS_ENABLED(CONFIG_X86_X32_ABI) && likely(xnr < X32_NR_syscalls)) {
|
||||
+ if (IS_ENABLED(CONFIG_X86_X32_ABI) && unlikely(x32_enabled) && likely(xnr < X32_NR_syscalls)) {
|
||||
xnr = array_index_nospec(xnr, X32_NR_syscalls);
|
||||
regs->ax = x32_sys_call(regs, xnr);
|
||||
return true;
|
||||
--- a/arch/x86/entry/syscall_x32.c
|
||||
+++ b/arch/x86/entry/syscall_x32.c
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/sys.h>
|
||||
#include <linux/cache.h>
|
||||
+#include <linux/moduleparam.h>
|
||||
+#undef MODULE_PARAM_PREFIX
|
||||
+#define MODULE_PARAM_PREFIX "syscall."
|
||||
#include <linux/syscalls.h>
|
||||
#include <asm/syscall.h>
|
||||
|
||||
@@ -20,3 +23,46 @@
|
||||
default: return __x64_sys_ni_syscall(regs);
|
||||
}
|
||||
};
|
||||
+
|
||||
+/* Maybe enable x32 syscalls */
|
||||
+
|
||||
+#if defined(CONFIG_X86_X32_DISABLED)
|
||||
+DEFINE_STATIC_KEY_FALSE(x32_enabled_skey);
|
||||
+#else
|
||||
+DEFINE_STATIC_KEY_TRUE(x32_enabled_skey);
|
||||
+#endif
|
||||
+
|
||||
+static int __init x32_param_set(const char *val, const struct kernel_param *p)
|
||||
+{
|
||||
+ bool enabled;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = kstrtobool(val, &enabled);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ if (IS_ENABLED(CONFIG_X86_X32_DISABLED)) {
|
||||
+ if (enabled) {
|
||||
+ static_key_enable(&x32_enabled_skey.key);
|
||||
+ pr_info("Enabled x32 syscalls\n");
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (!enabled) {
|
||||
+ static_key_disable(&x32_enabled_skey.key);
|
||||
+ pr_info("Disabled x32 syscalls\n");
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int x32_param_get(char *buffer, const struct kernel_param *p)
|
||||
+{
|
||||
+ return sprintf(buffer, "%c\n",
|
||||
+ static_key_enabled(&x32_enabled_skey) ? 'Y' : 'N');
|
||||
+}
|
||||
+
|
||||
+static const struct kernel_param_ops x32_param_ops = {
|
||||
+ .set = x32_param_set,
|
||||
+ .get = x32_param_get,
|
||||
+};
|
||||
+
|
||||
+arch_param_cb(x32, &x32_param_ops, NULL, 0444);
|
||||
--- a/arch/x86/include/asm/elf.h
|
||||
+++ b/arch/x86/include/asm/elf.h
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <asm/user.h>
|
||||
#include <asm/auxvec.h>
|
||||
#include <asm/fsgsbase.h>
|
||||
+#ifndef COMPILE_OFFSETS /* avoid a circular dependency on asm-offsets.h */
|
||||
+#include <asm/syscall.h>
|
||||
+#endif
|
||||
|
||||
typedef unsigned long elf_greg_t;
|
||||
|
||||
@@ -151,7 +154,8 @@ do { \
|
||||
|
||||
#define compat_elf_check_arch(x) \
|
||||
((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \
|
||||
- (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64))
|
||||
+ (IS_ENABLED(CONFIG_X86_X32_ABI) && x32_enabled && \
|
||||
+ (x)->e_machine == EM_X86_64))
|
||||
|
||||
static inline void elf_common_init(struct thread_struct *t,
|
||||
struct pt_regs *regs, const u16 ds)
|
||||
--- a/arch/x86/include/asm/syscall.h
|
||||
+++ b/arch/x86/include/asm/syscall.h
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <uapi/linux/audit.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/err.h>
|
||||
+#include <linux/jump_label.h>
|
||||
#include <asm/thread_info.h> /* for TS_COMPAT */
|
||||
#include <asm/unistd.h>
|
||||
|
||||
@@ -28,6 +29,18 @@ extern const sys_call_ptr_t ia32_sys_cal
|
||||
extern long x32_sys_call(const struct pt_regs *, unsigned int nr);
|
||||
extern long x64_sys_call(const struct pt_regs *, unsigned int nr);
|
||||
|
||||
+#if defined(CONFIG_X86_X32_ABI)
|
||||
+#if defined(CONFIG_X86_X32_DISABLED)
|
||||
+DECLARE_STATIC_KEY_FALSE(x32_enabled_skey);
|
||||
+#define x32_enabled static_branch_unlikely(&x32_enabled_skey)
|
||||
+#else
|
||||
+DECLARE_STATIC_KEY_TRUE(x32_enabled_skey);
|
||||
+#define x32_enabled static_branch_likely(&x32_enabled_skey)
|
||||
+#endif
|
||||
+#else
|
||||
+#define x32_enabled 0
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Only the low 32 bits of orig_ax are meaningful, so we return int.
|
||||
* This importantly ignores the high bits on 64-bit, so comparisons
|
28
debian/patches/features/x86/x86-memtest-WARN-if-bad-RAM-found.patch
vendored
Normal file
28
debian/patches/features/x86/x86-memtest-WARN-if-bad-RAM-found.patch
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
From: Ben Hutchings <ben@decadent.org.uk>
|
||||
Date: Mon, 5 Dec 2011 04:00:58 +0000
|
||||
Subject: x86: memtest: WARN if bad RAM found
|
||||
Bug-Debian: https://bugs.debian.org/613321
|
||||
Forwarded: https://lore.kernel.org/all/20120402150522.GA4980@burratino/
|
||||
|
||||
Since this is not a particularly thorough test, if we find any bad
|
||||
bits of RAM then there is a fair chance that there are other bad bits
|
||||
we fail to detect.
|
||||
|
||||
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
||||
---
|
||||
mm/memtest.c | 2 ++
|
||||
1 files changed, 2 insertions(+), 0 deletions(-)
|
||||
|
||||
--- a/mm/memtest.c
|
||||
+++ b/mm/memtest.c
|
||||
@@ -26,6 +26,10 @@ static u64 patterns[] __initdata = {
|
||||
|
||||
static void __init reserve_bad_mem(u64 pattern, phys_addr_t start_bad, phys_addr_t end_bad)
|
||||
{
|
||||
+#ifdef CONFIG_X86
|
||||
+ WARN_ONCE(1, "Bad RAM detected. Use memtest86+ to perform a thorough test\n"
|
||||
+ "and the memmap= parameter to reserve the bad areas.");
|
||||
+#endif
|
||||
pr_info(" %016llx bad mem addr %pa - %pa reserved\n",
|
||||
cpu_to_be64(pattern), &start_bad, &end_bad);
|
||||
memblock_reserve(start_bad, end_bad - start_bad);
|
Reference in New Issue
Block a user