diff --git a/0001-ACPI-LPSS-Only-call-pwm_add_table-for-the-first-PWM-.patch b/0001-ACPI-LPSS-Only-call-pwm_add_table-for-the-first-PWM-.patch new file mode 100644 index 000000000..ecfc34c6d --- /dev/null +++ b/0001-ACPI-LPSS-Only-call-pwm_add_table-for-the-first-PWM-.patch @@ -0,0 +1,70 @@ +From 92fe05e58babf15d7ddadfccd8bc383ea7e46e55 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 5 Jul 2017 22:02:59 +0200 +Subject: [PATCH] ACPI / LPSS: Only call pwm_add_table for the first PWM + controller + +At least on the UP board SBC both PWMs are enabled leading to us +trying to add the same pwm_lookup twice, which leads to the following: + +[ 0.902224] list_add double add: new=ffffffffb8efd400, + prev=ffffffffb8efd400, next=ffffffffb8eeede0. +[ 0.912466] ------------[ cut here ]------------ +[ 0.917624] kernel BUG at lib/list_debug.c:31! +[ 0.922588] invalid opcode: 0000 [#1] SMP +... +[ 1.027450] Call Trace: +[ 1.030185] pwm_add_table+0x4c/0x90 +[ 1.034181] bsw_pwm_setup+0x1a/0x20 +[ 1.038175] acpi_lpss_create_device+0xfe/0x420 +... + +This commit fixes this by only calling pwm_add_table for the first +PWM controller (which is the one used for the backlight). + +Cc: stable@vger.kernel.org +BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1458599 +Fixes: bf7696a12071 ("acpi: lpss: call pwm_add_table() for BSW...") +Fixes: 04434ab5120a ("ACPI / LPSS: Call pwm_add_table() for Bay Trail...") +[labbott@redhat.com: Rebase to 4.11] +Signed-off-by: Hans de Goede +--- + drivers/acpi/acpi_lpss.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c +index 5edfd9c..d973e56 100644 +--- a/drivers/acpi/acpi_lpss.c ++++ b/drivers/acpi/acpi_lpss.c +@@ -85,6 +85,7 @@ static const struct lpss_device_desc lpss_dma_desc = { + }; + + struct lpss_private_data { ++ struct acpi_device *adev; + void __iomem *mmio_base; + resource_size_t mmio_size; + unsigned int fixed_clk_rate; +@@ -164,6 +165,12 @@ static struct pwm_lookup bsw_pwm_lookup[] = { + + static void bsw_pwm_setup(struct lpss_private_data *pdata) + { ++ struct acpi_device *adev = pdata->adev; ++ ++ /* Only call pwm_add_table for the first PWM controller */ ++ if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1")) ++ return; ++ + pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup)); + } + +@@ -439,6 +446,7 @@ static int acpi_lpss_create_device(struct acpi_device *adev, + goto err_out; + } + ++ pdata->adev = adev; + pdata->dev_desc = dev_desc; + + if (dev_desc->setup) +-- +2.7.5 + diff --git a/0001-SUNRPC-Refactor-svc_set_num_threads.patch b/0001-SUNRPC-Refactor-svc_set_num_threads.patch new file mode 100644 index 000000000..d29b5fc4d --- /dev/null +++ b/0001-SUNRPC-Refactor-svc_set_num_threads.patch @@ -0,0 +1,156 @@ +From 9e0d87680d689f1758185851c3da6eafb16e71e1 Mon Sep 17 00:00:00 2001 +From: Trond Myklebust +Date: Wed, 26 Apr 2017 11:55:26 -0400 +Subject: [PATCH] SUNRPC: Refactor svc_set_num_threads() + +Refactor to separate out the functions of starting and stopping threads +so that they can be used in other helpers. + +Signed-off-by: Trond Myklebust +Tested-and-reviewed-by: Kinglong Mee +Signed-off-by: J. Bruce Fields +--- + net/sunrpc/svc.c | 96 ++++++++++++++++++++++++++++++++++---------------------- + 1 file changed, 58 insertions(+), 38 deletions(-) + +diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c +index a08aeb5..98dc33a 100644 +--- a/net/sunrpc/svc.c ++++ b/net/sunrpc/svc.c +@@ -702,59 +702,32 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state) + return task; + } + +-/* +- * Create or destroy enough new threads to make the number +- * of threads the given number. If `pool' is non-NULL, applies +- * only to threads in that pool, otherwise round-robins between +- * all pools. Caller must ensure that mutual exclusion between this and +- * server startup or shutdown. +- * +- * Destroying threads relies on the service threads filling in +- * rqstp->rq_task, which only the nfs ones do. Assumes the serv +- * has been created using svc_create_pooled(). +- * +- * Based on code that used to be in nfsd_svc() but tweaked +- * to be pool-aware. +- */ +-int +-svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ++/* create new threads */ ++static int ++svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) + { + struct svc_rqst *rqstp; + struct task_struct *task; + struct svc_pool *chosen_pool; +- int error = 0; + unsigned int state = serv->sv_nrthreads-1; + int node; + +- if (pool == NULL) { +- /* The -1 assumes caller has done a svc_get() */ +- nrservs -= (serv->sv_nrthreads-1); +- } else { +- spin_lock_bh(&pool->sp_lock); +- nrservs -= pool->sp_nrthreads; +- spin_unlock_bh(&pool->sp_lock); +- } +- +- /* create new threads */ +- while (nrservs > 0) { ++ do { + nrservs--; + chosen_pool = choose_pool(serv, pool, &state); + + node = svc_pool_map_get_node(chosen_pool->sp_id); + rqstp = svc_prepare_thread(serv, chosen_pool, node); +- if (IS_ERR(rqstp)) { +- error = PTR_ERR(rqstp); +- break; +- } ++ if (IS_ERR(rqstp)) ++ return PTR_ERR(rqstp); + + __module_get(serv->sv_ops->svo_module); + task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp, + node, "%s", serv->sv_name); + if (IS_ERR(task)) { +- error = PTR_ERR(task); + module_put(serv->sv_ops->svo_module); + svc_exit_thread(rqstp); +- break; ++ return PTR_ERR(task); + } + + rqstp->rq_task = task; +@@ -763,15 +736,62 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) + + svc_sock_update_bufs(serv); + wake_up_process(task); +- } ++ } while (nrservs > 0); ++ ++ return 0; ++} ++ ++ ++/* destroy old threads */ ++static int ++svc_signal_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ++{ ++ struct task_struct *task; ++ unsigned int state = serv->sv_nrthreads-1; ++ + /* destroy old threads */ +- while (nrservs < 0 && +- (task = choose_victim(serv, pool, &state)) != NULL) { ++ do { ++ task = choose_victim(serv, pool, &state); ++ if (task == NULL) ++ break; + send_sig(SIGINT, task, 1); + nrservs++; ++ } while (nrservs < 0); ++ ++ return 0; ++} ++ ++/* ++ * Create or destroy enough new threads to make the number ++ * of threads the given number. If `pool' is non-NULL, applies ++ * only to threads in that pool, otherwise round-robins between ++ * all pools. Caller must ensure that mutual exclusion between this and ++ * server startup or shutdown. ++ * ++ * Destroying threads relies on the service threads filling in ++ * rqstp->rq_task, which only the nfs ones do. Assumes the serv ++ * has been created using svc_create_pooled(). ++ * ++ * Based on code that used to be in nfsd_svc() but tweaked ++ * to be pool-aware. ++ */ ++int ++svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ++{ ++ if (pool == NULL) { ++ /* The -1 assumes caller has done a svc_get() */ ++ nrservs -= (serv->sv_nrthreads-1); ++ } else { ++ spin_lock_bh(&pool->sp_lock); ++ nrservs -= pool->sp_nrthreads; ++ spin_unlock_bh(&pool->sp_lock); + } + +- return error; ++ if (nrservs > 0) ++ return svc_start_kthreads(serv, pool, nrservs); ++ if (nrservs < 0) ++ return svc_signal_kthreads(serv, pool, nrservs); ++ return 0; + } + EXPORT_SYMBOL_GPL(svc_set_num_threads); + +-- +2.9.4 + diff --git a/0001-iio-Use-event-header-from-kernel-tree.patch b/0001-iio-Use-event-header-from-kernel-tree.patch new file mode 100644 index 000000000..1724db3fd --- /dev/null +++ b/0001-iio-Use-event-header-from-kernel-tree.patch @@ -0,0 +1,64 @@ +From 0eadbb65c0026fb4eec89c54f6b48a0febd87f92 Mon Sep 17 00:00:00 2001 +From: Laura Abbott +Date: Fri, 9 Sep 2016 08:19:17 -0700 +Subject: [PATCH] iio: Use type header from kernel tree +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +To: Jonathan Cameron +To: Hartmut Knaack +To: Lars-Peter Clausen +To: Peter Meerwald-Stadler +Cc: linux-iio@vger.kernel.org +Cc: linux-kernel@vger.kernel.org + + +The iio tools have been updated as new event types have been added to +the kernel. The tools currently use the standard system headers which +means that the system may not have the newest defintitions. This leads +to build failures when building newer tools on older hosts: + +gcc -Wall -g -D_GNU_SOURCE -c -o iio_event_monitor.o +iio_event_monitor.c +iio_event_monitor.c:59:3: error: ‘IIO_UVINDEX’ undeclared here (not in a +function) + [IIO_UVINDEX] = "uvindex", + ^~~~~~~~~~~ +iio_event_monitor.c:59:3: error: array index in initializer not of +integer type +iio_event_monitor.c:59:3: note: (near initialization for +‘iio_chan_type_name_spec’) +iio_event_monitor.c:97:3: error: ‘IIO_MOD_LIGHT_UV’ undeclared here (not +in a function) + [IIO_MOD_LIGHT_UV] = "uv", + ^~~~~~~~~~~~~~~~ +iio_event_monitor.c:97:3: error: array index in initializer not of +integer type +iio_event_monitor.c:97:3: note: (near initialization for +‘iio_modifier_names’) +: recipe for target 'iio_event_monitor.o' failed + +Switch to using the header from the kernel tree to ensure the newest +defintions are always picked up. + +Signed-off-by: Laura Abbott +--- + tools/iio/iio_event_monitor.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c +index d9b7e0f..f02523d 100644 +--- a/tools/iio/iio_event_monitor.c ++++ b/tools/iio/iio_event_monitor.c +@@ -26,7 +26,7 @@ + #include + #include "iio_utils.h" + #include +-#include ++#include "../../include/uapi/linux/iio/types.h" + + static const char * const iio_chan_type_name_spec[] = { + [IIO_VOLTAGE] = "voltage", +-- +2.7.4 + diff --git a/0001-ipv6-avoid-overflow-of-offset-in-ip6_find_1stfragopt.patch b/0001-ipv6-avoid-overflow-of-offset-in-ip6_find_1stfragopt.patch new file mode 100644 index 000000000..be8b6c6a0 --- /dev/null +++ b/0001-ipv6-avoid-overflow-of-offset-in-ip6_find_1stfragopt.patch @@ -0,0 +1,54 @@ +From 6399f1fae4ec29fab5ec76070435555e256ca3a6 Mon Sep 17 00:00:00 2001 +From: Sabrina Dubroca +Date: Wed, 19 Jul 2017 22:28:55 +0200 +Subject: [PATCH] ipv6: avoid overflow of offset in ip6_find_1stfragopt + +In some cases, offset can overflow and can cause an infinite loop in +ip6_find_1stfragopt(). Make it unsigned int to prevent the overflow, and +cap it at IPV6_MAXPLEN, since packets larger than that should be invalid. + +This problem has been here since before the beginning of git history. + +Signed-off-by: Sabrina Dubroca +Acked-by: Hannes Frederic Sowa +Signed-off-by: David S. Miller +--- + net/ipv6/output_core.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c +index e9065b8..abb2c30 100644 +--- a/net/ipv6/output_core.c ++++ b/net/ipv6/output_core.c +@@ -78,7 +78,7 @@ EXPORT_SYMBOL(ipv6_select_ident); + + int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) + { +- u16 offset = sizeof(struct ipv6hdr); ++ unsigned int offset = sizeof(struct ipv6hdr); + unsigned int packet_len = skb_tail_pointer(skb) - + skb_network_header(skb); + int found_rhdr = 0; +@@ -86,6 +86,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) + + while (offset <= packet_len) { + struct ipv6_opt_hdr *exthdr; ++ unsigned int len; + + switch (**nexthdr) { + +@@ -111,7 +112,10 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) + + exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + + offset); +- offset += ipv6_optlen(exthdr); ++ len = ipv6_optlen(exthdr); ++ if (len + offset >= IPV6_MAXPLEN) ++ return -EINVAL; ++ offset += len; + *nexthdr = &exthdr->nexthdr; + } + +-- +2.9.4 + diff --git a/0001-mm-CONFIG_NR_ZONES_EXTENDED.patch b/0001-mm-CONFIG_NR_ZONES_EXTENDED.patch deleted file mode 100644 index 44ef3662b..000000000 --- a/0001-mm-CONFIG_NR_ZONES_EXTENDED.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 8b368e8e961944105945fbe36f3f264252bfd19a Mon Sep 17 00:00:00 2001 -From: Dan Williams -Date: Thu, 25 Feb 2016 01:02:30 +0000 -Subject: [PATCH] mm: CONFIG_NR_ZONES_EXTENDED - -ZONE_DEVICE (merged in 4.3) and ZONE_CMA (proposed) are examples of new mm -zones that are bumping up against the current maximum limit of 4 zones, -i.e. 2 bits in page->flags. When adding a zone this equation still needs -to be satisified: - - SECTIONS_WIDTH + ZONES_WIDTH + NODES_SHIFT + LAST_CPUPID_SHIFT - <= BITS_PER_LONG - NR_PAGEFLAGS - -ZONE_DEVICE currently tries to satisfy this equation by requiring that -ZONE_DMA be disabled, but this is untenable given generic kernels want to -support ZONE_DEVICE and ZONE_DMA simultaneously. ZONE_CMA would like to -increase the amount of memory covered per section, but that limits the -minimum granularity at which consecutive memory ranges can be added via -devm_memremap_pages(). - -The trade-off of what is acceptable to sacrifice depends heavily on the -platform. For example, ZONE_CMA is targeted for 32-bit platforms where -page->flags is constrained, but those platforms likely do not care about -the minimum granularity of memory hotplug. A big iron machine with 1024 -numa nodes can likely sacrifice ZONE_DMA where a general purpose -distribution kernel can not. - -CONFIG_NR_ZONES_EXTENDED is a configuration symbol that gets selected when -the number of configured zones exceeds 4. It documents the configuration -symbols and definitions that get modified when ZONES_WIDTH is greater than -2. - -For now, it steals a bit from NODES_SHIFT. Later on it can be used to -document the definitions that get modified when a 32-bit configuration -wants more zone bits. - -Note that GFP_ZONE_TABLE poses an interesting constraint since -include/linux/gfp.h gets included by the 32-bit portion of a 64-bit build. -We need to be careful to only build the table for zones that have a -corresponding gfp_t flag. GFP_ZONES_SHIFT is introduced for this purpose. -This patch does not attempt to solve the problem of adding a new zone -that also has a corresponding GFP_ flag. - -Link: https://bugzilla.kernel.org/show_bug.cgi?id=110931 -Fixes: 033fbae988fc ("mm: ZONE_DEVICE for "device memory"") -Signed-off-by: Dan Williams -Reported-by: Mark -Cc: Mel Gorman -Cc: Rik van Riel -Cc: Joonsoo Kim -Cc: Dave Hansen -Cc: Sudip Mukherjee -Signed-off-by: Andrew Morton ---- - arch/x86/Kconfig | 6 ++++-- - include/linux/gfp.h | 33 ++++++++++++++++++++------------- - include/linux/page-flags-layout.h | 2 ++ - mm/Kconfig | 7 +++++-- - 4 files changed, 31 insertions(+), 17 deletions(-) - -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig -index 3fef519..b94704a 100644 ---- a/arch/x86/Kconfig -+++ b/arch/x86/Kconfig -@@ -1409,8 +1409,10 @@ config NUMA_EMU - - config NODES_SHIFT - int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP -- range 1 10 -- default "10" if MAXSMP -+ range 1 10 if !NR_ZONES_EXTENDED -+ range 1 9 if NR_ZONES_EXTENDED -+ default "10" if MAXSMP && !NR_ZONES_EXTENDED -+ default "9" if MAXSMP && NR_ZONES_EXTENDED - default "6" if X86_64 - default "3" - depends on NEED_MULTIPLE_NODES -diff --git a/include/linux/gfp.h b/include/linux/gfp.h -index af1f2b2..d201d8a 100644 ---- a/include/linux/gfp.h -+++ b/include/linux/gfp.h -@@ -329,22 +329,29 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) - * 0xe => BAD (MOVABLE+DMA32+HIGHMEM) - * 0xf => BAD (MOVABLE+DMA32+HIGHMEM+DMA) - * -- * ZONES_SHIFT must be <= 2 on 32 bit platforms. -+ * GFP_ZONES_SHIFT must be <= 2 on 32 bit platforms. - */ - --#if 16 * ZONES_SHIFT > BITS_PER_LONG --#error ZONES_SHIFT too large to create GFP_ZONE_TABLE integer -+#if defined(CONFIG_ZONE_DEVICE) && (MAX_NR_ZONES-1) <= 4 -+/* ZONE_DEVICE is not a valid GFP zone specifier */ -+#define GFP_ZONES_SHIFT 2 -+#else -+#define GFP_ZONES_SHIFT ZONES_SHIFT -+#endif -+ -+#if 16 * GFP_ZONES_SHIFT > BITS_PER_LONG -+#error GFP_ZONES_SHIFT too large to create GFP_ZONE_TABLE integer - #endif - - #define GFP_ZONE_TABLE ( \ -- (ZONE_NORMAL << 0 * ZONES_SHIFT) \ -- | (OPT_ZONE_DMA << ___GFP_DMA * ZONES_SHIFT) \ -- | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * ZONES_SHIFT) \ -- | (OPT_ZONE_DMA32 << ___GFP_DMA32 * ZONES_SHIFT) \ -- | (ZONE_NORMAL << ___GFP_MOVABLE * ZONES_SHIFT) \ -- | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * ZONES_SHIFT) \ -- | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * ZONES_SHIFT) \ -- | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * ZONES_SHIFT) \ -+ (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT) \ -+ | (OPT_ZONE_DMA << ___GFP_DMA * GFP_ZONES_SHIFT) \ -+ | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * GFP_ZONES_SHIFT) \ -+ | (OPT_ZONE_DMA32 << ___GFP_DMA32 * GFP_ZONES_SHIFT) \ -+ | (ZONE_NORMAL << ___GFP_MOVABLE * GFP_ZONES_SHIFT) \ -+ | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT) \ -+ | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT) \ -+ | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT) \ - ) - - /* -@@ -369,8 +376,8 @@ static inline enum zone_type gfp_zone(gfp_t flags) - enum zone_type z; - int bit = (__force int) (flags & GFP_ZONEMASK); - -- z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & -- ((1 << ZONES_SHIFT) - 1); -+ z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) & -+ ((1 << GFP_ZONES_SHIFT) - 1); - VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1); - return z; - } -diff --git a/include/linux/page-flags-layout.h b/include/linux/page-flags-layout.h -index da52366..77b078c 100644 ---- a/include/linux/page-flags-layout.h -+++ b/include/linux/page-flags-layout.h -@@ -17,6 +17,8 @@ - #define ZONES_SHIFT 1 - #elif MAX_NR_ZONES <= 4 - #define ZONES_SHIFT 2 -+#elif MAX_NR_ZONES <= 8 -+#define ZONES_SHIFT 3 - #else - #error ZONES_SHIFT -- too many zones configured adjust calculation - #endif -diff --git a/mm/Kconfig b/mm/Kconfig -index 031a329..7826216 100644 ---- a/mm/Kconfig -+++ b/mm/Kconfig -@@ -652,8 +652,6 @@ config IDLE_PAGE_TRACKING - - config ZONE_DEVICE - bool "Device memory (pmem, etc...) hotplug support" -- default !ZONE_DMA -- depends on !ZONE_DMA - depends on MEMORY_HOTPLUG - depends on MEMORY_HOTREMOVE - depends on X86_64 #arch_add_memory() comprehends device memory -@@ -667,5 +665,10 @@ config ZONE_DEVICE - - If FS_DAX is enabled, then say Y. - -+config NR_ZONES_EXTENDED -+ bool -+ default n if !64BIT -+ default y if ZONE_DEVICE && ZONE_DMA && ZONE_DMA32 -+ - config FRAME_VECTOR - bool --- -2.5.0 - diff --git a/0001-platform-x86-thinkpad_acpi-guard-generic-hotkey-case.patch b/0001-platform-x86-thinkpad_acpi-guard-generic-hotkey-case.patch new file mode 100644 index 000000000..847c70ce8 --- /dev/null +++ b/0001-platform-x86-thinkpad_acpi-guard-generic-hotkey-case.patch @@ -0,0 +1,71 @@ +From 6bb84c0f9da1144e0d443798a76d5769b7d554af Mon Sep 17 00:00:00 2001 +From: Christian Kellner +Date: Tue, 28 Feb 2017 17:10:56 +0100 +Subject: [PATCH 1/2] platform/x86: thinkpad_acpi: guard generic hotkey case + +Currently when dispatching hotkeys we check if the scancode is in +the range of 0 and TPACPI_HOTKEY_MAP_LEN, although the bottom 20 +entries in the hotkey keymap are already adaptive keycodes. +Therefore we introduce a TP_ACPI_HOTKEYSCAN_ADAPTIVE_START and +ensure that we are in the range 0 and ADAPTIVE_START for the generic +keycode case. + +Signed-off-by: Christian Kellner +Reviewed-by: Hans de Goede +Acked-by: Henrique de Moraes Holschuh +Signed-off-by: Andy Shevchenko +--- + drivers/platform/x86/thinkpad_acpi.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 1d18b32..e2b962f 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -1922,7 +1922,9 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ + TP_ACPI_HOTKEYSCAN_UNK7, + TP_ACPI_HOTKEYSCAN_UNK8, + +- TP_ACPI_HOTKEYSCAN_MUTE2, ++ /* Adaptive keyboard keycodes */ ++ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, ++ TP_ACPI_HOTKEYSCAN_MUTE2 = TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, + TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO, + TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL, + TP_ACPI_HOTKEYSCAN_CLOUD, +@@ -3656,7 +3658,6 @@ static const int adaptive_keyboard_modes[] = { + #define DFR_CHANGE_ROW 0x101 + #define DFR_SHOW_QUICKVIEW_ROW 0x102 + #define FIRST_ADAPTIVE_KEY 0x103 +-#define ADAPTIVE_KEY_OFFSET 0x020 + + /* press Fn key a while second, it will switch to Function Mode. Then + * release Fn key, previous mode be restored. +@@ -3747,12 +3748,13 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) + default: + if (scancode < FIRST_ADAPTIVE_KEY || + scancode >= FIRST_ADAPTIVE_KEY + TPACPI_HOTKEY_MAP_LEN - +- ADAPTIVE_KEY_OFFSET) { ++ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { + pr_info("Unhandled adaptive keyboard key: 0x%x\n", + scancode); + return false; + } +- keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + ADAPTIVE_KEY_OFFSET]; ++ keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + ++ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START]; + if (keycode != KEY_RESERVED) { + mutex_lock(&tpacpi_inputdev_send_mutex); + +@@ -3778,7 +3780,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, + *ignore_acpi_ev = false; + + /* HKEY event 0x1001 is scancode 0x00 */ +- if (scancode > 0 && scancode <= TPACPI_HOTKEY_MAP_LEN) { ++ if (scancode > 0 && scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { + scancode--; + if (!(hotkey_source_mask & (1 << scancode))) { + tpacpi_input_send_key_masked(scancode); +-- +2.9.4 + diff --git a/0001-vsock-Fix-blocking-ops-call-in-prepare_to_wait.patch b/0001-vsock-Fix-blocking-ops-call-in-prepare_to_wait.patch deleted file mode 100644 index 6d871b10d..000000000 --- a/0001-vsock-Fix-blocking-ops-call-in-prepare_to_wait.patch +++ /dev/null @@ -1,170 +0,0 @@ -From b5671c331cc2e78c83fc826a69dff461903c0fd5 Mon Sep 17 00:00:00 2001 -From: Laura Abbott -Date: Mon, 25 Jan 2016 15:10:02 -0800 -Subject: [PATCHv2] vsock: Fix blocking ops call in prepare_to_wait -To: "David S. Miller" -Cc: netdev@vger.kernel.org -Cc: linux-kernel@vger.kernel.org -To: Aditya Asarwade -To: Thomas Hellstrom -To: Jorgen Hansen - -We receoved a bug report from someone using vmware: - -WARNING: CPU: 3 PID: 660 at kernel/sched/core.c:7389 -__might_sleep+0x7d/0x90() -do not call blocking ops when !TASK_RUNNING; state=1 set at -[] prepare_to_wait+0x2d/0x90 -Modules linked in: vmw_vsock_vmci_transport vsock snd_seq_midi -snd_seq_midi_event snd_ens1371 iosf_mbi gameport snd_rawmidi -snd_ac97_codec ac97_bus snd_seq coretemp snd_seq_device snd_pcm -snd_timer snd soundcore ppdev crct10dif_pclmul crc32_pclmul -ghash_clmulni_intel vmw_vmci vmw_balloon i2c_piix4 shpchp parport_pc -parport acpi_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc btrfs -xor raid6_pq 8021q garp stp llc mrp crc32c_intel serio_raw mptspi vmwgfx -drm_kms_helper ttm drm scsi_transport_spi mptscsih e1000 ata_generic -mptbase pata_acpi -CPU: 3 PID: 660 Comm: vmtoolsd Not tainted -4.2.0-0.rc1.git3.1.fc23.x86_64 #1 -Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop -Reference Platform, BIOS 6.00 05/20/2014 - 0000000000000000 0000000049e617f3 ffff88006ac37ac8 ffffffff818641f5 - 0000000000000000 ffff88006ac37b20 ffff88006ac37b08 ffffffff810ab446 - ffff880068009f40 ffffffff81c63bc0 0000000000000061 0000000000000000 -Call Trace: - [] dump_stack+0x4c/0x65 - [] warn_slowpath_common+0x86/0xc0 - [] warn_slowpath_fmt+0x55/0x70 - [] ? debug_lockdep_rcu_enabled+0x1d/0x20 - [] ? prepare_to_wait+0x2d/0x90 - [] ? prepare_to_wait+0x2d/0x90 - [] __might_sleep+0x7d/0x90 - [] __might_fault+0x43/0xa0 - [] copy_from_iter+0x87/0x2a0 - [] __qp_memcpy_to_queue+0x9a/0x1b0 [vmw_vmci] - [] ? qp_memcpy_to_queue+0x20/0x20 [vmw_vmci] - [] qp_memcpy_to_queue_iov+0x17/0x20 [vmw_vmci] - [] qp_enqueue_locked+0xa0/0x140 [vmw_vmci] - [] vmci_qpair_enquev+0x4f/0xd0 [vmw_vmci] - [] vmci_transport_stream_enqueue+0x1b/0x20 -[vmw_vsock_vmci_transport] - [] vsock_stream_sendmsg+0x2c5/0x320 [vsock] - [] ? wake_atomic_t_function+0x70/0x70 - [] sock_sendmsg+0x38/0x50 - [] SYSC_sendto+0x104/0x190 - [] ? vfs_read+0x8a/0x140 - [] SyS_sendto+0xe/0x10 - [] entry_SYSCALL_64_fastpath+0x12/0x76 - -transport->stream_enqueue may call copy_to_user so it should -not be called inside a prepare_to_wait. Narrow the scope of -the prepare_to_wait to avoid the bad call. This also applies -to vsock_stream_recvmsg as well. - -Reported-by: Vinson Lee -Tested-by: Vinson Lee -Signed-off-by: Laura Abbott ---- -v2: fix same issue in recvmsg path as well. ---- - net/vmw_vsock/af_vsock.c | 19 ++++++------------- - 1 file changed, 6 insertions(+), 13 deletions(-) - -diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c -index 7fd1220..bbe65dc 100644 ---- a/net/vmw_vsock/af_vsock.c -+++ b/net/vmw_vsock/af_vsock.c -@@ -1557,8 +1557,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - if (err < 0) - goto out; - -- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); -- - while (total_written < len) { - ssize_t written; - -@@ -1578,7 +1576,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - goto out_wait; - - release_sock(sk); -+ prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); - timeout = schedule_timeout(timeout); -+ finish_wait(sk_sleep(sk), &wait); - lock_sock(sk); - if (signal_pending(current)) { - err = sock_intr_errno(timeout); -@@ -1588,8 +1588,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - goto out_wait; - } - -- prepare_to_wait(sk_sleep(sk), &wait, -- TASK_INTERRUPTIBLE); - } - - /* These checks occur both as part of and after the loop -@@ -1635,7 +1633,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - out_wait: - if (total_written > 0) - err = total_written; -- finish_wait(sk_sleep(sk), &wait); - out: - release_sock(sk); - return err; -@@ -1716,7 +1713,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - if (err < 0) - goto out; - -- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); - - while (1) { - s64 ready = vsock_stream_has_data(vsk); -@@ -1727,7 +1723,7 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - */ - - err = -ENOMEM; -- goto out_wait; -+ goto out; - } else if (ready > 0) { - ssize_t read; - -@@ -1750,7 +1746,7 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - vsk, target, read, - !(flags & MSG_PEEK), &recv_data); - if (err < 0) -- goto out_wait; -+ goto out; - - if (read >= target || flags & MSG_PEEK) - break; -@@ -1773,7 +1769,9 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - break; - - release_sock(sk); -+ prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); - timeout = schedule_timeout(timeout); -+ finish_wait(sk_sleep(sk), &wait); - lock_sock(sk); - - if (signal_pending(current)) { -@@ -1783,9 +1781,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - err = -EAGAIN; - break; - } -- -- prepare_to_wait(sk_sleep(sk), &wait, -- TASK_INTERRUPTIBLE); - } - } - -@@ -1816,8 +1811,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - err = copied; - } - --out_wait: -- finish_wait(sk_sleep(sk), &wait); - out: - release_sock(sk); - return err; --- -2.5.0 - diff --git a/0002-NFSv4-Fix-callback-server-shutdown.patch b/0002-NFSv4-Fix-callback-server-shutdown.patch new file mode 100644 index 000000000..e5745bf01 --- /dev/null +++ b/0002-NFSv4-Fix-callback-server-shutdown.patch @@ -0,0 +1,155 @@ +From ed6473ddc704a2005b9900ca08e236ebb2d8540a Mon Sep 17 00:00:00 2001 +From: Trond Myklebust +Date: Wed, 26 Apr 2017 11:55:27 -0400 +Subject: [PATCH] NFSv4: Fix callback server shutdown + +We want to use kthread_stop() in order to ensure the threads are +shut down before we tear down the nfs_callback_info in nfs_callback_down. + +Tested-and-reviewed-by: Kinglong Mee +Reported-by: Kinglong Mee +Fixes: bb6aeba736ba9 ("NFSv4.x: Switch to using svc_set_num_threads()...") +Signed-off-by: Trond Myklebust +Signed-off-by: J. Bruce Fields +--- + fs/nfs/callback.c | 24 ++++++++++++++++-------- + include/linux/sunrpc/svc.h | 1 + + net/sunrpc/svc.c | 38 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 55 insertions(+), 8 deletions(-) + +diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c +index c5e27eb..73a1f92 100644 +--- a/fs/nfs/callback.c ++++ b/fs/nfs/callback.c +@@ -76,7 +76,10 @@ nfs4_callback_svc(void *vrqstp) + + set_freezable(); + +- while (!kthread_should_stop()) { ++ while (!kthread_freezable_should_stop(NULL)) { ++ ++ if (signal_pending(current)) ++ flush_signals(current); + /* + * Listen for a request on the socket + */ +@@ -85,6 +88,8 @@ nfs4_callback_svc(void *vrqstp) + continue; + svc_process(rqstp); + } ++ svc_exit_thread(rqstp); ++ module_put_and_exit(0); + return 0; + } + +@@ -103,9 +108,10 @@ nfs41_callback_svc(void *vrqstp) + + set_freezable(); + +- while (!kthread_should_stop()) { +- if (try_to_freeze()) +- continue; ++ while (!kthread_freezable_should_stop(NULL)) { ++ ++ if (signal_pending(current)) ++ flush_signals(current); + + prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); + spin_lock_bh(&serv->sv_cb_lock); +@@ -121,11 +127,13 @@ nfs41_callback_svc(void *vrqstp) + error); + } else { + spin_unlock_bh(&serv->sv_cb_lock); +- schedule(); ++ if (!kthread_should_stop()) ++ schedule(); + finish_wait(&serv->sv_cb_waitq, &wq); + } +- flush_signals(current); + } ++ svc_exit_thread(rqstp); ++ module_put_and_exit(0); + return 0; + } + +@@ -221,14 +229,14 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, + static struct svc_serv_ops nfs40_cb_sv_ops = { + .svo_function = nfs4_callback_svc, + .svo_enqueue_xprt = svc_xprt_do_enqueue, +- .svo_setup = svc_set_num_threads, ++ .svo_setup = svc_set_num_threads_sync, + .svo_module = THIS_MODULE, + }; + #if defined(CONFIG_NFS_V4_1) + static struct svc_serv_ops nfs41_cb_sv_ops = { + .svo_function = nfs41_callback_svc, + .svo_enqueue_xprt = svc_xprt_do_enqueue, +- .svo_setup = svc_set_num_threads, ++ .svo_setup = svc_set_num_threads_sync, + .svo_module = THIS_MODULE, + }; + +diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h +index 6ef19cf..9463102 100644 +--- a/include/linux/sunrpc/svc.h ++++ b/include/linux/sunrpc/svc.h +@@ -473,6 +473,7 @@ void svc_pool_map_put(void); + struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, + struct svc_serv_ops *); + int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); ++int svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int); + int svc_pool_stats_open(struct svc_serv *serv, struct file *file); + void svc_destroy(struct svc_serv *); + void svc_shutdown_net(struct svc_serv *, struct net *); +diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c +index 98dc33a..bc0f5a0 100644 +--- a/net/sunrpc/svc.c ++++ b/net/sunrpc/svc.c +@@ -795,6 +795,44 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) + } + EXPORT_SYMBOL_GPL(svc_set_num_threads); + ++/* destroy old threads */ ++static int ++svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ++{ ++ struct task_struct *task; ++ unsigned int state = serv->sv_nrthreads-1; ++ ++ /* destroy old threads */ ++ do { ++ task = choose_victim(serv, pool, &state); ++ if (task == NULL) ++ break; ++ kthread_stop(task); ++ nrservs++; ++ } while (nrservs < 0); ++ return 0; ++} ++ ++int ++svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ++{ ++ if (pool == NULL) { ++ /* The -1 assumes caller has done a svc_get() */ ++ nrservs -= (serv->sv_nrthreads-1); ++ } else { ++ spin_lock_bh(&pool->sp_lock); ++ nrservs -= pool->sp_nrthreads; ++ spin_unlock_bh(&pool->sp_lock); ++ } ++ ++ if (nrservs > 0) ++ return svc_start_kthreads(serv, pool, nrservs); ++ if (nrservs < 0) ++ return svc_stop_kthreads(serv, pool, nrservs); ++ return 0; ++} ++EXPORT_SYMBOL_GPL(svc_set_num_threads_sync); ++ + /* + * Called from a server thread as it's exiting. Caller must hold the "service + * mutex" for the service. +-- +2.9.4 + diff --git a/0002-platform-x86-thinkpad_acpi-add-mapping-for-new-hotke.patch b/0002-platform-x86-thinkpad_acpi-add-mapping-for-new-hotke.patch new file mode 100644 index 000000000..2c9bcbbeb --- /dev/null +++ b/0002-platform-x86-thinkpad_acpi-add-mapping-for-new-hotke.patch @@ -0,0 +1,158 @@ +From 82e71b57b1b4347126b1ffd7b2beed2bc8b795bd Mon Sep 17 00:00:00 2001 +From: Christian Kellner +Date: Tue, 28 Feb 2017 17:10:57 +0100 +Subject: [PATCH 2/2] platform/x86: thinkpad_acpi: add mapping for new hotkeys + +The T470, X270 emits new hkey events in the 0x1311 - 0x1315 range. +According to the user manual they should launch a user selected +favorite application (star icon, 0x1311), snipping tool (0x1312, +currently ignored), enable/disable bluetooth (0x1314) and open they +keyboard settings (0x1315). + +The third nibble (0xf00) is used to differentiate between the original +hotkeys, the adaptive keyboard codes and the new, additional ones. + +Signed-off-by: Christian Kellner +Reviewed-by: Hans de Goede +Acked-by: Henrique de Moraes Holschuh +Signed-off-by: Andy Shevchenko +--- + drivers/platform/x86/thinkpad_acpi.c | 91 +++++++++++++++++++++++++++++++----- + 1 file changed, 79 insertions(+), 12 deletions(-) + +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index e2b962f..7b6cb0c 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -1945,6 +1945,15 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ + TP_ACPI_HOTKEYSCAN_CAMERA_MODE, + TP_ACPI_HOTKEYSCAN_ROTATE_DISPLAY, + ++ /* Lenovo extended keymap, starting at 0x1300 */ ++ TP_ACPI_HOTKEYSCAN_EXTENDED_START, ++ /* first new observed key (star, favorites) is 0x1311 */ ++ TP_ACPI_HOTKEYSCAN_STAR = 69, ++ TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL2, ++ TP_ACPI_HOTKEYSCAN_UNK25, ++ TP_ACPI_HOTKEYSCAN_BLUETOOTH, ++ TP_ACPI_HOTKEYSCAN_KEYBOARD, ++ + /* Hotkey keymap size */ + TPACPI_HOTKEY_MAP_LEN + }; +@@ -3252,6 +3261,15 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) + KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, + KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, + KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ ++ /* No assignment, used for newer Lenovo models */ ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN ++ + }, + + /* Generic keymap for Lenovo ThinkPads */ +@@ -3337,6 +3355,29 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) + KEY_RESERVED, /* Microphone cancellation */ + KEY_RESERVED, /* Camera mode */ + KEY_RESERVED, /* Rotate display, 0x116 */ ++ ++ /* ++ * These are found in 2017 models (e.g. T470s, X270). ++ * The lowest known value is 0x311, which according to ++ * the manual should launch a user defined favorite ++ * application. ++ * ++ * The offset for these is TP_ACPI_HOTKEYSCAN_EXTENDED_START, ++ * corresponding to 0x34. ++ */ ++ ++ /* (assignments unknown, please report if found) */ ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, ++ KEY_UNKNOWN, ++ ++ KEY_FAVORITES, /* Favorite app, 0x311 */ ++ KEY_RESERVED, /* Clipping tool */ ++ KEY_RESERVED, ++ KEY_BLUETOOTH, /* Bluetooth */ ++ KEY_KEYBOARD /* Keyboard, 0x315 */ + }, + }; + +@@ -3747,8 +3788,9 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) + + default: + if (scancode < FIRST_ADAPTIVE_KEY || +- scancode >= FIRST_ADAPTIVE_KEY + TPACPI_HOTKEY_MAP_LEN - +- TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { ++ scancode >= FIRST_ADAPTIVE_KEY + ++ TP_ACPI_HOTKEYSCAN_EXTENDED_START - ++ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { + pr_info("Unhandled adaptive keyboard key: 0x%x\n", + scancode); + return false; +@@ -3779,19 +3821,44 @@ static bool hotkey_notify_hotkey(const u32 hkey, + *send_acpi_ev = true; + *ignore_acpi_ev = false; + +- /* HKEY event 0x1001 is scancode 0x00 */ +- if (scancode > 0 && scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { +- scancode--; +- if (!(hotkey_source_mask & (1 << scancode))) { +- tpacpi_input_send_key_masked(scancode); +- *send_acpi_ev = false; +- } else { +- *ignore_acpi_ev = true; ++ /* ++ * Original events are in the 0x10XX range, the adaptive keyboard ++ * found in 2014 X1 Carbon emits events are of 0x11XX. In 2017 ++ * models, additional keys are emitted through 0x13XX. ++ */ ++ switch ((hkey >> 8) & 0xf) { ++ case 0: ++ if (scancode > 0 && ++ scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { ++ /* HKEY event 0x1001 is scancode 0x00 */ ++ scancode--; ++ if (!(hotkey_source_mask & (1 << scancode))) { ++ tpacpi_input_send_key_masked(scancode); ++ *send_acpi_ev = false; ++ } else { ++ *ignore_acpi_ev = true; ++ } ++ return true; + } +- return true; +- } else { ++ break; ++ ++ case 1: + return adaptive_keyboard_hotkey_notify_hotkey(scancode); ++ ++ case 3: ++ /* Extended keycodes start at 0x300 and our offset into the map ++ * TP_ACPI_HOTKEYSCAN_EXTENDED_START. The calculated scancode ++ * will be positive, but might not be in the correct range. ++ */ ++ scancode -= (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); ++ if (scancode >= TP_ACPI_HOTKEYSCAN_EXTENDED_START && ++ scancode < TPACPI_HOTKEY_MAP_LEN) { ++ tpacpi_input_send_key(scancode); ++ return true; ++ } ++ break; + } ++ + return false; + } + +-- +2.9.4 + diff --git a/2-2-nvme-Quirk-APST-on-Intel-600P-P3100-devices.patch b/2-2-nvme-Quirk-APST-on-Intel-600P-P3100-devices.patch new file mode 100644 index 000000000..088d921a7 --- /dev/null +++ b/2-2-nvme-Quirk-APST-on-Intel-600P-P3100-devices.patch @@ -0,0 +1,33 @@ +From 596bbd8d3752b0a922b7a5a059f47607a36ecc2e Mon Sep 17 00:00:00 2001 +From: Andrew Lutomirski +Date: Wed, 24 May 2017 15:06:31 -0700 +Subject: [PATCH] nvme: Quirk APST on Intel 600P/P3100 devices + +They have known firmware bugs. A fix is apparently in the works -- +once fixed firmware is available, someone from Intel (Hi, Keith!) +can adjust the quirk accordingly. + +Cc: stable@vger.kernel.org # v4.11 +Cc: Kai-Heng Feng +Cc: Mario Limonciello +Signed-off-by: Andy Lutomirski +--- + drivers/nvme/host/pci.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index d8a1707..993d16c 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -2171,6 +2171,8 @@ static const struct pci_device_id nvme_id_table[] = { + { PCI_VDEVICE(INTEL, 0x0a54), + .driver_data = NVME_QUIRK_STRIPE_SIZE | + NVME_QUIRK_DISCARD_ZEROES, }, ++ { PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */ ++ .driver_data = NVME_QUIRK_NO_DEEPEST_PS }, + { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, + { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ +-- +2.7.5 + diff --git a/ACPI-Limit-access-to-custom_method.patch b/ACPI-Limit-access-to-custom_method.patch deleted file mode 100644 index 38236753e..000000000 --- a/ACPI-Limit-access-to-custom_method.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 4b85149b764cd024e3dd2aff9eb22a9e1aadd1fa Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Fri, 9 Mar 2012 08:39:37 -0500 -Subject: [PATCH 04/20] ACPI: Limit access to custom_method - -custom_method effectively allows arbitrary access to system memory, making -it possible for an attacker to circumvent restrictions on module loading. -Disable it if any such restrictions have been enabled. - -Signed-off-by: Matthew Garrett ---- - drivers/acpi/custom_method.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c -index c68e72414a67..4277938af700 100644 ---- a/drivers/acpi/custom_method.c -+++ b/drivers/acpi/custom_method.c -@@ -29,6 +29,9 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, - struct acpi_table_header table; - acpi_status status; - -+ if (secure_modules()) -+ return -EPERM; -+ - if (!(*ppos)) { - /* parse the table header to get the table length */ - if (count <= sizeof(struct acpi_table_header)) --- -2.4.3 - diff --git a/Add-EFI-signature-data-types.patch b/Add-EFI-signature-data-types.patch index 35f170abb..40d14f949 100644 --- a/Add-EFI-signature-data-types.patch +++ b/Add-EFI-signature-data-types.patch @@ -1,4 +1,4 @@ -From 47f6b5c281137394d627e275cb80980492d00d84 Mon Sep 17 00:00:00 2001 +From ba3f737b8521314b62edaa7d4cc4bdc9aeefe394 Mon Sep 17 00:00:00 2001 From: Dave Howells Date: Tue, 23 Oct 2012 09:30:54 -0400 Subject: [PATCH 15/20] Add EFI signature data types @@ -11,29 +11,26 @@ Upstream-status: Fedora mustard for now Signed-off-by: David Howells --- - include/linux/efi.h | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) + include/linux/efi.h | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) diff --git a/include/linux/efi.h b/include/linux/efi.h -index 4dc970e..82d6218 100644 +index 5af91b58afae..190858d62fe3 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h -@@ -599,6 +599,12 @@ void efi_native_runtime_setup(void); - #define EFI_PROPERTIES_TABLE_GUID \ - EFI_GUID( 0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5 ) +@@ -603,6 +603,9 @@ void efi_native_runtime_setup(void); + #define LINUX_EFI_LOADER_ENTRY_GUID EFI_GUID(0x4a67b082, 0x0a4c, 0x41cf, 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f) + #define LINUX_EFI_RANDOM_SEED_TABLE_GUID EFI_GUID(0x1ce1e5bc, 0x7ceb, 0x42f2, 0x81, 0xe5, 0x8a, 0xad, 0xf1, 0x80, 0xf5, 0x7b) -+#define EFI_CERT_SHA256_GUID \ -+ EFI_GUID( 0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28 ) -+ -+#define EFI_CERT_X509_GUID \ -+ EFI_GUID( 0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72 ) ++#define EFI_CERT_SHA256_GUID EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28) ++#define EFI_CERT_X509_GUID EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72) + typedef struct { efi_guid_t guid; u64 table; -@@ -823,6 +829,20 @@ typedef struct { - - #define EFI_INVALID_TABLE_ADDR (~0UL) +@@ -853,6 +856,20 @@ typedef struct { + efi_memory_desc_t entry[0]; + } efi_memory_attributes_table_t; +typedef struct { + efi_guid_t signature_owner; @@ -53,5 +50,5 @@ index 4dc970e..82d6218 100644 * All runtime access to EFI goes through this structure: */ -- -2.5.0 +2.9.3 diff --git a/Add-an-EFI-signature-blob-parser-and-key-loader.patch b/Add-an-EFI-signature-blob-parser-and-key-loader.patch index 06ddd1596..f57abc9f2 100644 --- a/Add-an-EFI-signature-blob-parser-and-key-loader.patch +++ b/Add-an-EFI-signature-blob-parser-and-key-loader.patch @@ -1,4 +1,4 @@ -From c279ba86f93cf6a75d078e2d0e3f59d4ba8a2dd0 Mon Sep 17 00:00:00 2001 +From 822b4b3eb76ca451a416a51f0a7bfedfa5c5ea39 Mon Sep 17 00:00:00 2001 From: Dave Howells Date: Tue, 23 Oct 2012 09:36:28 -0400 Subject: [PATCH 16/20] Add an EFI signature blob parser and key loader. @@ -6,20 +6,21 @@ Subject: [PATCH 16/20] Add an EFI signature blob parser and key loader. X.509 certificates are loaded into the specified keyring as asymmetric type keys. +[labbott@fedoraproject.org: Drop KEY_ALLOC_TRUSTED] Signed-off-by: David Howells --- crypto/asymmetric_keys/Kconfig | 8 +++ crypto/asymmetric_keys/Makefile | 1 + - crypto/asymmetric_keys/efi_parser.c | 109 ++++++++++++++++++++++++++++++++++++ + crypto/asymmetric_keys/efi_parser.c | 108 ++++++++++++++++++++++++++++++++++++ include/linux/efi.h | 4 ++ - 4 files changed, 122 insertions(+) + 4 files changed, 121 insertions(+) create mode 100644 crypto/asymmetric_keys/efi_parser.c diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig -index 4870f28403f5..4a1b50d73b80 100644 +index 331f6baf2df8..5f9002d3192e 100644 --- a/crypto/asymmetric_keys/Kconfig +++ b/crypto/asymmetric_keys/Kconfig -@@ -67,4 +67,12 @@ config SIGNED_PE_FILE_VERIFICATION +@@ -61,4 +61,12 @@ config SIGNED_PE_FILE_VERIFICATION This option provides support for verifying the signature(s) on a signed PE binary. @@ -33,23 +34,23 @@ index 4870f28403f5..4a1b50d73b80 100644 + endif # ASYMMETRIC_KEY_TYPE diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile -index cd1406f9b14a..d9db380bbe53 100644 +index 6516855bec18..c099fe15ed6d 100644 --- a/crypto/asymmetric_keys/Makefile +++ b/crypto/asymmetric_keys/Makefile -@@ -8,6 +8,7 @@ asymmetric_keys-y := asymmetric_type.o signature.o +@@ -10,6 +10,7 @@ asymmetric_keys-y := \ + signature.o obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o - obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa.o +obj-$(CONFIG_EFI_SIGNATURE_LIST_PARSER) += efi_parser.o # # X.509 Certificate handling diff --git a/crypto/asymmetric_keys/efi_parser.c b/crypto/asymmetric_keys/efi_parser.c new file mode 100644 -index 000000000000..424896a0b169 +index 000000000000..636feb18b733 --- /dev/null +++ b/crypto/asymmetric_keys/efi_parser.c -@@ -0,0 +1,109 @@ +@@ -0,0 +1,108 @@ +/* EFI signature/key/certificate list parser + * + * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. @@ -140,8 +141,7 @@ index 000000000000..424896a0b169 + esize - sizeof(*elem), + (KEY_POS_ALL & ~KEY_POS_SETATTR) | + KEY_USR_VIEW, -+ KEY_ALLOC_NOT_IN_QUOTA | -+ KEY_ALLOC_TRUSTED); ++ KEY_ALLOC_NOT_IN_QUOTA); + + if (IS_ERR(key)) + pr_err("Problem loading in-kernel X.509 certificate (%ld)\n", @@ -160,10 +160,10 @@ index 000000000000..424896a0b169 + return 0; +} diff --git a/include/linux/efi.h b/include/linux/efi.h -index fac43c611614..414c3c3d988d 100644 +index 190858d62fe3..668aa1244885 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h -@@ -941,6 +941,10 @@ extern bool efi_poweroff_required(void); +@@ -1025,6 +1025,10 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm, char * __init efi_md_typeattr_format(char *buf, size_t size, const efi_memory_desc_t *md); @@ -175,5 +175,5 @@ index fac43c611614..414c3c3d988d 100644 * efi_range_is_wc - check the WC bit on an address range * @start: starting kvirt address -- -2.4.3 +2.9.3 diff --git a/Add-option-to-automatically-enforce-module-signature.patch b/Add-option-to-automatically-enforce-module-signature.patch deleted file mode 100644 index 015371b8b..000000000 --- a/Add-option-to-automatically-enforce-module-signature.patch +++ /dev/null @@ -1,186 +0,0 @@ -From 37431394b3eeb1ef6d38d0e6b2693210606c2c2c Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Fri, 9 Aug 2013 18:36:30 -0400 -Subject: [PATCH 10/20] Add option to automatically enforce module signatures - when in Secure Boot mode - -UEFI Secure Boot provides a mechanism for ensuring that the firmware will -only load signed bootloaders and kernels. Certain use cases may also -require that all kernel modules also be signed. Add a configuration option -that enforces this automatically when enabled. - -Signed-off-by: Matthew Garrett ---- - Documentation/x86/zero-page.txt | 2 ++ - arch/x86/Kconfig | 10 ++++++++++ - arch/x86/boot/compressed/eboot.c | 36 +++++++++++++++++++++++++++++++++++ - arch/x86/include/uapi/asm/bootparam.h | 3 ++- - arch/x86/kernel/setup.c | 6 ++++++ - include/linux/module.h | 6 ++++++ - kernel/module.c | 7 +++++++ - 7 files changed, 69 insertions(+), 1 deletion(-) - -diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt -index 95a4d34af3fd..b8527c6b7646 100644 ---- a/Documentation/x86/zero-page.txt -+++ b/Documentation/x86/zero-page.txt -@@ -31,6 +31,8 @@ Offset Proto Name Meaning - 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) - 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer - (below) -+1EB/001 ALL kbd_status Numlock is enabled -+1EC/001 ALL secure_boot Secure boot is enabled in the firmware - 1EF/001 ALL sentinel Used to detect broken bootloaders - 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures - 2D0/A00 ALL e820_map E820 memory map table -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig -index cc0d73eac047..14db458f4774 100644 ---- a/arch/x86/Kconfig -+++ b/arch/x86/Kconfig -@@ -1734,6 +1734,16 @@ config EFI_MIXED - - If unsure, say N. - -+config EFI_SECURE_BOOT_SIG_ENFORCE -+ def_bool n -+ prompt "Force module signing when UEFI Secure Boot is enabled" -+ ---help--- -+ UEFI Secure Boot provides a mechanism for ensuring that the -+ firmware will only load signed bootloaders and kernels. Certain -+ use cases may also require that all kernel modules also be signed. -+ Say Y here to automatically enable module signature enforcement -+ when a system boots with UEFI Secure Boot enabled. -+ - config SECCOMP - def_bool y - prompt "Enable seccomp to safely compute untrusted bytecode" -diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c -index ee1b6d346b98..b4de3faa3f29 100644 ---- a/arch/x86/boot/compressed/eboot.c -+++ b/arch/x86/boot/compressed/eboot.c -@@ -12,6 +12,7 @@ - #include - #include - #include -+#include - - #include "../string.h" - #include "eboot.h" -@@ -827,6 +828,37 @@ out: - return status; - } - -+static int get_secure_boot(void) -+{ -+ u8 sb, setup; -+ unsigned long datasize = sizeof(sb); -+ efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID; -+ efi_status_t status; -+ -+ status = efi_early->call((unsigned long)sys_table->runtime->get_variable, -+ L"SecureBoot", &var_guid, NULL, &datasize, &sb); -+ -+ if (status != EFI_SUCCESS) -+ return 0; -+ -+ if (sb == 0) -+ return 0; -+ -+ -+ status = efi_early->call((unsigned long)sys_table->runtime->get_variable, -+ L"SetupMode", &var_guid, NULL, &datasize, -+ &setup); -+ -+ if (status != EFI_SUCCESS) -+ return 0; -+ -+ if (setup == 1) -+ return 0; -+ -+ return 1; -+} -+ -+ - /* - * See if we have Graphics Output Protocol - */ -@@ -1412,6 +1444,10 @@ struct boot_params *efi_main(struct efi_config *c, - else - setup_boot_services32(efi_early); - -+ sanitize_boot_params(boot_params); -+ -+ boot_params->secure_boot = get_secure_boot(); -+ - setup_graphics(boot_params); - - setup_efi_pci(boot_params); -diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h -index 329254373479..b61f8533c0fd 100644 ---- a/arch/x86/include/uapi/asm/bootparam.h -+++ b/arch/x86/include/uapi/asm/bootparam.h -@@ -134,7 +134,8 @@ struct boot_params { - __u8 eddbuf_entries; /* 0x1e9 */ - __u8 edd_mbr_sig_buf_entries; /* 0x1ea */ - __u8 kbd_status; /* 0x1eb */ -- __u8 _pad5[3]; /* 0x1ec */ -+ __u8 secure_boot; /* 0x1ec */ -+ __u8 _pad5[2]; /* 0x1ed */ - /* - * The sentinel is set to a nonzero value (0xff) in header.S. - * -diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c -index baadbf90a7c5..1ac118146e90 100644 ---- a/arch/x86/kernel/setup.c -+++ b/arch/x86/kernel/setup.c -@@ -1135,6 +1135,12 @@ void __init setup_arch(char **cmdline_p) - - io_delay_init(); - -+#ifdef CONFIG_EFI_SECURE_BOOT_SIG_ENFORCE -+ if (boot_params.secure_boot) { -+ enforce_signed_modules(); -+ } -+#endif -+ - /* - * Parse the ACPI tables for possible boot-time SMP configuration. - */ -diff --git a/include/linux/module.h b/include/linux/module.h -index db386349cd01..4b8df91f03cd 100644 ---- a/include/linux/module.h -+++ b/include/linux/module.h -@@ -273,6 +273,12 @@ const struct exception_table_entry *search_exception_tables(unsigned long add); - - struct notifier_block; - -+#ifdef CONFIG_MODULE_SIG -+extern void enforce_signed_modules(void); -+#else -+static inline void enforce_signed_modules(void) {}; -+#endif -+ - #ifdef CONFIG_MODULES - - extern int modules_disabled; /* for sysctl */ -diff --git a/kernel/module.c b/kernel/module.c -index 7f045246e123..2b403ab0ef29 100644 ---- a/kernel/module.c -+++ b/kernel/module.c -@@ -4088,6 +4088,13 @@ void module_layout(struct module *mod, - EXPORT_SYMBOL(module_layout); - #endif - -+#ifdef CONFIG_MODULE_SIG -+void enforce_signed_modules(void) -+{ -+ sig_enforce = true; -+} -+#endif -+ - bool secure_modules(void) - { - #ifdef CONFIG_MODULE_SIG --- -2.4.3 - diff --git a/Add-secure_modules-call.patch b/Add-secure_modules-call.patch deleted file mode 100644 index b6e039ff0..000000000 --- a/Add-secure_modules-call.patch +++ /dev/null @@ -1,63 +0,0 @@ -From a1aaf20cffb1a949c5d6b1198690c7c30cfda4d5 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Fri, 9 Aug 2013 17:58:15 -0400 -Subject: [PATCH 01/20] Add secure_modules() call - -Provide a single call to allow kernel code to determine whether the system -has been configured to either disable module loading entirely or to load -only modules signed with a trusted key. - -Bugzilla: N/A -Upstream-status: Fedora mustard. Replaced by securelevels, but that was nak'd - -Signed-off-by: Matthew Garrett ---- - include/linux/module.h | 6 ++++++ - kernel/module.c | 10 ++++++++++ - 2 files changed, 16 insertions(+) - -diff --git a/include/linux/module.h b/include/linux/module.h -index 3a19c79918e0..db386349cd01 100644 ---- a/include/linux/module.h -+++ b/include/linux/module.h -@@ -635,6 +635,8 @@ static inline bool module_requested_async_probing(struct module *module) - return module && module->async_probe_requested; - } - -+extern bool secure_modules(void); -+ - #else /* !CONFIG_MODULES... */ - - /* Given an address, look for it in the exception tables. */ -@@ -751,6 +753,10 @@ static inline bool module_requested_async_probing(struct module *module) - return false; - } - -+static inline bool secure_modules(void) -+{ -+ return false; -+} - #endif /* CONFIG_MODULES */ - - #ifdef CONFIG_SYSFS -diff --git a/kernel/module.c b/kernel/module.c -index b86b7bf1be38..7f045246e123 100644 ---- a/kernel/module.c -+++ b/kernel/module.c -@@ -4087,3 +4087,13 @@ void module_layout(struct module *mod, - } - EXPORT_SYMBOL(module_layout); - #endif -+ -+bool secure_modules(void) -+{ -+#ifdef CONFIG_MODULE_SIG -+ return (sig_enforce || modules_disabled); -+#else -+ return modules_disabled; -+#endif -+} -+EXPORT_SYMBOL(secure_modules); --- -2.4.3 - diff --git a/Add-sysrq-option-to-disable-secure-boot-mode.patch b/Add-sysrq-option-to-disable-secure-boot-mode.patch deleted file mode 100644 index 4600848cf..000000000 --- a/Add-sysrq-option-to-disable-secure-boot-mode.patch +++ /dev/null @@ -1,246 +0,0 @@ -From 16d2ba5d5bc46e67e6aa7a3d113fbcc18c217388 Mon Sep 17 00:00:00 2001 -From: Kyle McMartin -Date: Fri, 30 Aug 2013 09:28:51 -0400 -Subject: [PATCH 20/20] Add sysrq option to disable secure boot mode - -Bugzilla: N/A -Upstream-status: Fedora mustard ---- - arch/x86/kernel/setup.c | 36 ++++++++++++++++++++++++++++++++++++ - drivers/input/misc/uinput.c | 1 + - drivers/tty/sysrq.c | 19 +++++++++++++------ - include/linux/input.h | 5 +++++ - include/linux/sysrq.h | 8 +++++++- - kernel/debug/kdb/kdb_main.c | 2 +- - kernel/module.c | 2 +- - 7 files changed, 64 insertions(+), 9 deletions(-) - -diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c -index f93826b8522c..41679b1aca83 100644 ---- a/arch/x86/kernel/setup.c -+++ b/arch/x86/kernel/setup.c -@@ -70,6 +70,11 @@ - #include - #include - -+#include -+#include -+#include -+#include -+ - #include